Commit c7f5c58e authored by Peter Eisentraut's avatar Peter Eisentraut

PL/Python: Fix remaining scan-build warnings

Apparently, scan-build thinks that proc->is_setof can change during
PLy_exec_function().  To make it clearer, save the value in a local
variable.

Also add an assertion to clear another warning.
Reviewed-by: default avatarJohn Naylor <jcnaylor@gmail.com>
parent cdddd5d4
...@@ -57,6 +57,7 @@ static void PLy_abort_open_subtransactions(int save_subxact_level); ...@@ -57,6 +57,7 @@ static void PLy_abort_open_subtransactions(int save_subxact_level);
Datum Datum
PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc) PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc)
{ {
bool is_setof = proc->is_setof;
Datum rv; Datum rv;
PyObject *volatile plargs = NULL; PyObject *volatile plargs = NULL;
PyObject *volatile plrv = NULL; PyObject *volatile plrv = NULL;
...@@ -73,7 +74,7 @@ PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc) ...@@ -73,7 +74,7 @@ PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc)
PG_TRY(); PG_TRY();
{ {
if (proc->is_setof) if (is_setof)
{ {
/* First Call setup */ /* First Call setup */
if (SRF_IS_FIRSTCALL()) if (SRF_IS_FIRSTCALL())
...@@ -93,6 +94,7 @@ PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc) ...@@ -93,6 +94,7 @@ PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc)
funcctx = SRF_PERCALL_SETUP(); funcctx = SRF_PERCALL_SETUP();
Assert(funcctx != NULL); Assert(funcctx != NULL);
srfstate = (PLySRFState *) funcctx->user_fctx; srfstate = (PLySRFState *) funcctx->user_fctx;
Assert(srfstate != NULL);
} }
if (srfstate == NULL || srfstate->iter == NULL) if (srfstate == NULL || srfstate->iter == NULL)
...@@ -125,7 +127,7 @@ PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc) ...@@ -125,7 +127,7 @@ PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc)
* We stay in the SPI context while doing this, because PyIter_Next() * We stay in the SPI context while doing this, because PyIter_Next()
* calls back into Python code which might contain SPI calls. * calls back into Python code which might contain SPI calls.
*/ */
if (proc->is_setof) if (is_setof)
{ {
if (srfstate->iter == NULL) if (srfstate->iter == NULL)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment