Re: [plpython] Add missing volatile qualifier.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [plpython] Add missing volatile qualifier.
Дата
Msg-id 1088178.1711987027@sss.pgh.pa.us
обсуждение исходный текст
Ответ на [MASSMAIL][plpython] Add missing volatile qualifier.  (Xing Guo <higuoxing@gmail.com>)
Ответы Re: [plpython] Add missing volatile qualifier.  (Nathan Bossart <nathandbossart@gmail.com>)
Список pgsql-hackers
Xing Guo <higuoxing@gmail.com> writes:
> I'm playing a toy static analysis checker with PostgreSQL and found a
> variable is missing volatile qualifier.

Good catch!  It looks like the consequences of a failure would be
pretty minimal --- AFAICS, no worse than a possible failure to remove
a refcount on Py_None --- but that's still a bug.

I don't care for your proposed fix though.  I think the real problem
here is schizophrenia about when to set up pltargs, and we could
fix it more nicely as attached.  (Perhaps the Asserts are overkill
though.)

            regards, tom lane

diff --git a/src/pl/plpython/plpy_exec.c b/src/pl/plpython/plpy_exec.c
index e06fde1dd9..3145c69699 100644
--- a/src/pl/plpython/plpy_exec.c
+++ b/src/pl/plpython/plpy_exec.c
@@ -689,7 +689,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
                *pltrelid,
                *plttablename,
                *plttableschema,
-               *pltargs = NULL,
+               *pltargs,
                *pytnew,
                *pytold,
                *pltdata;
@@ -713,6 +713,11 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
             return NULL;
         }
     }
+    else
+    {
+        Py_INCREF(Py_None);
+        pltargs = Py_None;
+    }

     PG_TRY();
     {
@@ -856,7 +861,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
             PyObject   *pltarg;

             /* pltargs should have been allocated before the PG_TRY block. */
-            Assert(pltargs);
+            Assert(pltargs && pltargs != Py_None);

             for (i = 0; i < tdata->tg_trigger->tgnargs; i++)
             {
@@ -870,8 +875,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
         }
         else
         {
-            Py_INCREF(Py_None);
-            pltargs = Py_None;
+            Assert(pltargs == Py_None);
         }
         PyDict_SetItemString(pltdata, "args", pltargs);
         Py_DECREF(pltargs);

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Nathan Bossart
Дата:
Сообщение: Re: Popcount optimization using AVX512
Следующее
От: "Tristan Partin"
Дата:
Сообщение: Re: psql not responding to SIGINT upon db reconnection