]> granicus.if.org Git - postgresql/commitdiff
PL/Python: Fix remaining scan-build warnings
authorPeter Eisentraut <peter_e@gmx.net>
Wed, 23 Aug 2017 00:05:49 +0000 (20:05 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Wed, 29 Nov 2017 14:56:49 +0000 (09:56 -0500)
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: John Naylor <jcnaylor@gmail.com>
src/pl/plpython/plpy_exec.c

index 9d2341a4a3b4c166c4717872f1dd73ab58fd5330..fe217c6a2c10c48cd30b42319a395ae7beb7441e 100644 (file)
@@ -57,6 +57,7 @@ static void PLy_abort_open_subtransactions(int save_subxact_level);
 Datum
 PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc)
 {
+       bool            is_setof = proc->is_setof;
        Datum           rv;
        PyObject   *volatile plargs = NULL;
        PyObject   *volatile plrv = NULL;
@@ -73,7 +74,7 @@ PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc)
 
        PG_TRY();
        {
-               if (proc->is_setof)
+               if (is_setof)
                {
                        /* First Call setup */
                        if (SRF_IS_FIRSTCALL())
@@ -93,6 +94,7 @@ PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc)
                        funcctx = SRF_PERCALL_SETUP();
                        Assert(funcctx != NULL);
                        srfstate = (PLySRFState *) funcctx->user_fctx;
+                       Assert(srfstate != NULL);
                }
 
                if (srfstate == NULL || srfstate->iter == NULL)
@@ -125,7 +127,7 @@ PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc)
                 * We stay in the SPI context while doing this, because PyIter_Next()
                 * calls back into Python code which might contain SPI calls.
                 */
-               if (proc->is_setof)
+               if (is_setof)
                {
                        if (srfstate->iter == NULL)
                        {