Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitef59fa0

Browse files
committed
Ensure the previous Perl interpreter selection is restored upon exit from
plperl_call_handler, in both the normal and error-exit paths. Per reportfrom Alexey Klyukin.
1 parentfb5d058 commitef59fa0

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

‎src/pl/plperl/plperl.c

Lines changed: 10 additions & 13 deletions
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.152 2009/09/28 17:31:12 adunstan Exp $
4+
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.153 2009/10/31 18:11:59 tgl Exp $
55
*
66
**********************************************************************/
77

@@ -150,8 +150,8 @@ void_PG_init(void);
150150
staticvoidplperl_init_interp(void);
151151

152152
staticDatumplperl_func_handler(PG_FUNCTION_ARGS);
153-
154153
staticDatumplperl_trigger_handler(PG_FUNCTION_ARGS);
154+
155155
staticplperl_proc_desc*compile_plperl_function(Oidfn_oid,boolis_trigger);
156156

157157
staticSV*plperl_hash_from_tuple(HeapTupletuple,TupleDesctupdesc);
@@ -380,11 +380,13 @@ check_interp(bool trusted)
380380
}
381381
}
382382

383-
383+
/*
384+
* Restore previous interpreter selection, if two are active
385+
*/
384386
staticvoid
385387
restore_context(boolold_context)
386388
{
387-
if (trusted_context!=old_context)
389+
if (interp_state==INTERP_BOTH&&trusted_context!=old_context)
388390
{
389391
if (old_context)
390392
PERL_SET_CONTEXT(plperl_trusted_interp);
@@ -870,9 +872,9 @@ Datum
870872
plperl_call_handler(PG_FUNCTION_ARGS)
871873
{
872874
Datumretval;
873-
plperl_call_data*save_call_data;
875+
plperl_call_data*save_call_data=current_call_data;
876+
boololdcontext=trusted_context;
874877

875-
save_call_data=current_call_data;
876878
PG_TRY();
877879
{
878880
if (CALLED_AS_TRIGGER(fcinfo))
@@ -883,11 +885,13 @@ plperl_call_handler(PG_FUNCTION_ARGS)
883885
PG_CATCH();
884886
{
885887
current_call_data=save_call_data;
888+
restore_context(oldcontext);
886889
PG_RE_THROW();
887890
}
888891
PG_END_TRY();
889892

890893
current_call_data=save_call_data;
894+
restore_context(oldcontext);
891895
returnretval;
892896
}
893897

@@ -1226,7 +1230,6 @@ plperl_func_handler(PG_FUNCTION_ARGS)
12261230
Datumretval;
12271231
ReturnSetInfo*rsi;
12281232
SV*array_ret=NULL;
1229-
boololdcontext=trusted_context;
12301233
ErrorContextCallbackpl_error_context;
12311234

12321235
/*
@@ -1376,9 +1379,6 @@ plperl_func_handler(PG_FUNCTION_ARGS)
13761379
if (array_ret==NULL)
13771380
SvREFCNT_dec(perlret);
13781381

1379-
current_call_data=NULL;
1380-
restore_context(oldcontext);
1381-
13821382
returnretval;
13831383
}
13841384

@@ -1391,7 +1391,6 @@ plperl_trigger_handler(PG_FUNCTION_ARGS)
13911391
Datumretval;
13921392
SV*svTD;
13931393
HV*hvTD;
1394-
boololdcontext=trusted_context;
13951394
ErrorContextCallbackpl_error_context;
13961395

13971396
/*
@@ -1491,8 +1490,6 @@ plperl_trigger_handler(PG_FUNCTION_ARGS)
14911490
if (perlret)
14921491
SvREFCNT_dec(perlret);
14931492

1494-
current_call_data=NULL;
1495-
restore_context(oldcontext);
14961493
returnretval;
14971494
}
14981495

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp