Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7292fd8

Browse files
committed
Suppress compiler warnings from commit ee895a6.
For obscure reasons, some buildfarm members are now generating complaints about plpgsql_call_handler's "retval" variable possibly being used uninitialized. It seems no less safe than it was before that commit, but these complaints are (mostly?) new. I trust that initializing the variable where it's declared will be enough to shut that up. I also notice that some compilers are warning about setjmp clobber of the same variable, which is maybe a bit more defensible. Mark it volatile to silence that. Also, rearrange the logic to give procedure_resowner a single point of initialization, in hopes of silencing some setjmp-clobber warnings about that. (Marking it volatile would serve too, but its sibling variables are depending on single assignment, so let's stick with that method.) Discussion: https://postgr.es/m/[email protected]
1 parent f76a850 commit 7292fd8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/pl/plpgsql/src/pl_handler.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ plpgsql_call_handler(PG_FUNCTION_ARGS)
224224
bool nonatomic;
225225
PLpgSQL_function *func;
226226
PLpgSQL_execstate *save_cur_estate;
227-
ResourceOwner procedure_resowner = NULL;
228-
Datum retval;
227+
ResourceOwner procedure_resowner;
228+
volatile Datum retval = (Datum) 0;
229229
int rc;
230230

231231
nonatomic = fcinfo->context &&
@@ -254,9 +254,9 @@ plpgsql_call_handler(PG_FUNCTION_ARGS)
254254
* Therefore, be very wary of adding any code between here and the PG_TRY
255255
* block.
256256
*/
257-
if (nonatomic && func->requires_procedure_resowner)
258-
procedure_resowner =
259-
ResourceOwnerCreate(NULL, "PL/pgSQL procedure resources");
257+
procedure_resowner =
258+
(nonatomic && func->requires_procedure_resowner) ?
259+
ResourceOwnerCreate(NULL, "PL/pgSQL procedure resources") : NULL;
260260

261261
PG_TRY();
262262
{
@@ -271,7 +271,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS)
271271
{
272272
plpgsql_exec_event_trigger(func,
273273
(EventTriggerData *) fcinfo->context);
274-
retval = (Datum) 0;
274+
/* there's no return value in this case */
275275
}
276276
else
277277
retval = plpgsql_exec_function(func, fcinfo,

0 commit comments

Comments
 (0)