Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4a5ee2a

Browse files
committed
Move main error message text in plperl into errmsg from errdetail,
and move the context information into errcontext instead of errmsg. This makes them better conform to our guidelines. Also remove a few errcode declarations that were providing the default value ERRCODE_INTERNAL_ERROR.
1 parent 1acc06a commit 4a5ee2a

File tree

2 files changed

+22
-48
lines changed

2 files changed

+22
-48
lines changed

src/pl/plperl/expected/plperl_init.out

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ SHOW plperl.on_plperl_init;
99
(1 row)
1010

1111
DO $$ warn 42 $$ language plperl;
12-
ERROR: while executing plperl.on_plperl_init
13-
DETAIL: 'eval "string"' trapped by operation mask at line 2.
14-
CONTEXT: PL/Perl anonymous code block
12+
ERROR: 'eval "string"' trapped by operation mask at line 2.
13+
CONTEXT: While executing plperl.on_plperl_init.
14+
PL/Perl anonymous code block

src/pl/plperl/plperl.c

+19-45
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**********************************************************************
22
* plperl.c - perl as a procedural language for PostgreSQL
33
*
4-
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.166 2010/02/14 18:42:18 rhaas Exp $
4+
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.167 2010/02/15 22:23:25 alvherre Exp $
55
*
66
**********************************************************************/
77

@@ -413,13 +413,9 @@ select_perl_context(bool trusted)
413413

414414
eval_pv("PostgreSQL::InServer::SPI::bootstrap()", FALSE);
415415
if (SvTRUE(ERRSV))
416-
{
417416
ereport(ERROR,
418-
(errcode(ERRCODE_INTERNAL_ERROR),
419-
errmsg("%s", strip_trailing_ws(SvPV_nolen(ERRSV))),
420-
errdetail("While executing PostgreSQL::InServer::SPI::bootstrap")));
421-
}
422-
417+
(errmsg("%s", strip_trailing_ws(SvPV_nolen(ERRSV))),
418+
errdetail("While executing PostgreSQL::InServer::SPI::bootstrap.")));
423419
}
424420

425421
/*
@@ -553,15 +549,13 @@ plperl_init_interp(void)
553549
if (perl_parse(plperl, plperl_init_shared_libs,
554550
nargs, embedding, NULL) != 0)
555551
ereport(ERROR,
556-
(errcode(ERRCODE_INTERNAL_ERROR),
557-
errmsg("while parsing perl initialization"),
558-
errdetail("%s", strip_trailing_ws(SvPV_nolen(ERRSV))) ));
552+
(errmsg("%s", strip_trailing_ws(SvPV_nolen(ERRSV))),
553+
errcontext("While parsing perl initialization.")));
559554

560555
if (perl_run(plperl) != 0)
561556
ereport(ERROR,
562-
(errcode(ERRCODE_INTERNAL_ERROR),
563-
errmsg("while running perl initialization"),
564-
errdetail("%s", strip_trailing_ws(SvPV_nolen(ERRSV))) ));
557+
(errmsg("%s", strip_trailing_ws(SvPV_nolen(ERRSV))),
558+
errcontext("While running perl initialization.")));
565559

566560
#ifdef WIN32
567561

@@ -691,24 +685,17 @@ plperl_trusted_init(void)
691685
/* not safe, so disallow all trusted funcs */
692686
eval_pv(PLC_SAFE_BAD, FALSE);
693687
if (SvTRUE(ERRSV))
694-
{
695688
ereport(ERROR,
696-
(errcode(ERRCODE_INTERNAL_ERROR),
697-
errmsg("while executing PLC_SAFE_BAD"),
698-
errdetail("%s", strip_trailing_ws(SvPV_nolen(ERRSV))) ));
699-
}
700-
689+
(errmsg("%s", strip_trailing_ws(SvPV_nolen(ERRSV))),
690+
errcontext("While executing PLC_SAFE_BAD.")));
701691
}
702692
else
703693
{
704694
eval_pv(PLC_SAFE_OK, FALSE);
705695
if (SvTRUE(ERRSV))
706-
{
707696
ereport(ERROR,
708-
(errcode(ERRCODE_INTERNAL_ERROR),
709-
errmsg("while executing PLC_SAFE_OK"),
710-
errdetail("%s", strip_trailing_ws(SvPV_nolen(ERRSV))) ));
711-
}
697+
(errmsg("%s", strip_trailing_ws(SvPV_nolen(ERRSV))),
698+
errcontext("While executing PLC_SAFE_OK.")));
712699

713700
if (GetDatabaseEncoding() == PG_UTF8)
714701
{
@@ -719,12 +706,9 @@ plperl_trusted_init(void)
719706
*/
720707
eval_pv("my $a=chr(0x100); return $a =~ /\\xa9/i", FALSE);
721708
if (SvTRUE(ERRSV))
722-
{
723709
ereport(ERROR,
724-
(errcode(ERRCODE_INTERNAL_ERROR),
725-
errmsg("while executing utf8fix"),
726-
errdetail("%s", strip_trailing_ws(SvPV_nolen(ERRSV))) ));
727-
}
710+
(errmsg("%s", strip_trailing_ws(SvPV_nolen(ERRSV))),
711+
errcontext("While executing utf8fix.")));
728712
}
729713

730714
/* switch to the safe require opcode */
@@ -742,12 +726,9 @@ plperl_trusted_init(void)
742726
SPAGAIN;
743727

744728
if (SvTRUE(ERRSV))
745-
{
746729
ereport(ERROR,
747-
(errcode(ERRCODE_INTERNAL_ERROR),
748-
errmsg("while executing plperl.on_plperl_init"),
749-
errdetail("%s", strip_trailing_ws(SvPV_nolen(ERRSV))) ));
750-
}
730+
(errmsg("%s", strip_trailing_ws(SvPV_nolen(ERRSV))),
731+
errcontext("While executing plperl.on_plperl_init.")));
751732
}
752733

753734
}
@@ -761,12 +742,9 @@ plperl_untrusted_init(void)
761742
{
762743
eval_pv(plperl_on_plperlu_init, FALSE);
763744
if (SvTRUE(ERRSV))
764-
{
765745
ereport(ERROR,
766-
(errcode(ERRCODE_INTERNAL_ERROR),
767-
errmsg("while executing plperl.on_plperlu_init"),
768-
errdetail("%s", strip_trailing_ws(SvPV_nolen(ERRSV))) ));
769-
}
746+
(errmsg("%s", strip_trailing_ws(SvPV_nolen(ERRSV))),
747+
errcontext("While executing plperl.on_plperlu_init.")));
770748
}
771749
}
772750

@@ -1299,18 +1277,14 @@ plperl_create_sub(plperl_proc_desc *prodesc, char *s, Oid fn_oid)
12991277
LEAVE;
13001278

13011279
if (SvTRUE(ERRSV))
1302-
{
13031280
ereport(ERROR,
13041281
(errcode(ERRCODE_SYNTAX_ERROR),
13051282
errmsg("%s", strip_trailing_ws(SvPV_nolen(ERRSV)))));
1306-
}
13071283

13081284
if (!subref)
1309-
{
13101285
ereport(ERROR,
1311-
(errcode(ERRCODE_INTERNAL_ERROR),
1312-
errmsg("didn't get a GLOB from compiling %s via %s", prodesc->proname, compile_sub)));
1313-
}
1286+
(errmsg("didn't get a GLOB from compiling %s via %s",
1287+
prodesc->proname, compile_sub)));
13141288

13151289
prodesc->reference = newSVsv(subref);
13161290

0 commit comments

Comments
 (0)