]> granicus.if.org Git - postgresql/commit
Fix handling of nested JSON objects in json_populate_recordset and friends.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 25 Jun 2014 04:22:43 +0000 (21:22 -0700)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 25 Jun 2014 04:22:43 +0000 (21:22 -0700)
commita331512dec25807c4c93e3d537ac7734ee901641
tree2600514d3ae5e04988b4f7bf8301af8dbc985ba5
parentdd5369047fc3400f4b5d1d61d85b040a8eef8d1b
Fix handling of nested JSON objects in json_populate_recordset and friends.

populate_recordset_object_start() improperly created a new hash table
(overwriting the link to the existing one) if called at nest levels
greater than one.  This resulted in previous fields not appearing in
the final output, as reported by Matti Hameister in bug #10728.
In 9.4 the problem also affects json_to_recordset.

This perhaps missed detection earlier because the default behavior is to
throw an error for nested objects: you have to pass use_json_as_text = true
to see the problem.

In addition, fix query-lifespan leakage of the hashtable created by
json_populate_record().  This is pretty much the same problem recently
fixed in dblink: creating an intended-to-be-temporary context underneath
the executor's per-tuple context isn't enough to make it go away at the
end of the tuple cycle, because MemoryContextReset is not
MemoryContextResetAndDeleteChildren.

Michael Paquier and Tom Lane
src/backend/utils/adt/jsonfuncs.c
src/test/regress/expected/json.out
src/test/regress/expected/json_1.out
src/test/regress/sql/json.sql