Commit a0692181 authored by Tom Lane's avatar Tom Lane

In jsonb_plpython.c, suppress warning message from gcc 10.

Very recent gcc complains that PLyObject_ToJsonbValue could return
a pointer to a local variable.  I think it's wrong; but the coding
is fragile enough, and the savings of one palloc() minimal enough,
that it seems better to just do a palloc() all the time.  (My other
idea of tweaking the if-condition doesn't suppress the warning.)

Back-patch to v11 where this code was introduced.

Discussion: https://postgr.es/m/21547.1580170366@sss.pgh.pa.us
parent 74618e77
...@@ -410,7 +410,6 @@ PLyNumber_ToJsonbValue(PyObject *obj, JsonbValue *jbvNum) ...@@ -410,7 +410,6 @@ PLyNumber_ToJsonbValue(PyObject *obj, JsonbValue *jbvNum)
static JsonbValue * static JsonbValue *
PLyObject_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state, bool is_elem) PLyObject_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state, bool is_elem)
{ {
JsonbValue buf;
JsonbValue *out; JsonbValue *out;
if (!(PyString_Check(obj) || PyUnicode_Check(obj))) if (!(PyString_Check(obj) || PyUnicode_Check(obj)))
...@@ -421,11 +420,7 @@ PLyObject_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state, bool is_ele ...@@ -421,11 +420,7 @@ PLyObject_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state, bool is_ele
return PLyMapping_ToJsonbValue(obj, jsonb_state); return PLyMapping_ToJsonbValue(obj, jsonb_state);
} }
/* Allocate JsonbValue in heap only if it is raw scalar value. */ out = palloc(sizeof(JsonbValue));
if (*jsonb_state)
out = &buf;
else
out = palloc(sizeof(JsonbValue));
if (obj == Py_None) if (obj == Py_None)
out->type = jbvNull; out->type = jbvNull;
......
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