]> granicus.if.org Git - postgresql/commit
Fix crash in json{b}_populate_recordset() and json{b}_to_recordset().
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 13 Jul 2018 18:16:47 +0000 (14:16 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 13 Jul 2018 18:16:55 +0000 (14:16 -0400)
commit9a5e8ed283e583782b3f40e6ededcb005d5c0333
treea85ab6c5e2dd13369fb5d1dc382fc35f0c85f773
parent2af39c39df94096ecc593f5a162947e1e994cab3
Fix crash in json{b}_populate_recordset() and json{b}_to_recordset().

As of commit 37a795a60, populate_recordset_worker() tried to pass back
(as rsi.setDesc) a tupdesc that it also had cached in its fn_extra.
But the core executor would free the passed-back tupdesc, risking a
crash if the function were called again in the same query.  The safest
and least invasive way to fix that is to make an extra tupdesc copy
to pass back.

While at it, I failed to resist the temptation to get rid of unnecessary
get_fn_expr_argtype() calls here and in populate_record_worker().

Per report from Dmitry Dolgov; thanks to Michael Paquier and
Andrew Gierth for investigation and discussion.

Discussion: https://postgr.es/m/CA+q6zcWzN9ztCfR47ZwgTr1KLnuO6BAY6FurxXhovP4hxr+yOQ@mail.gmail.com
src/backend/utils/adt/jsonfuncs.c
src/test/regress/expected/json.out
src/test/regress/expected/jsonb.out
src/test/regress/sql/json.sql
src/test/regress/sql/jsonb.sql