pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Fix json_to_record() bug with nested objects.
4+ messages / 2 participants
[nested] [flat]
* pgsql: Fix json_to_record() bug with nested objects.
@ 2016-03-03 04:31 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2016-03-03 04:31 UTC (permalink / raw)
To: pgsql-committers
Fix json_to_record() bug with nested objects.
A thinko concerning nesting depth caused json_to_record() to produce bogus
output if a field of its input object contained a sub-object with a field
name matching one of the requested output column names. Per bug #13996
from Johann Visagie.
I added a regression test case based on his example, plus parallel tests
for json_to_recordset, jsonb_to_record, jsonb_to_recordset. The latter
three do not exhibit the same bug (which suggests that we may be missing
some opportunities to share code...) but testing seems like a good idea
in any case.
Back-patch to 9.4 where these functions were introduced.
Branch
------
REL9_5_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/429d6846572fe43dc11496adfeaecadf23925e3f
Modified Files
--------------
src/backend/utils/adt/jsonfuncs.c | 2 +-
src/test/regress/expected/json.out | 16 ++++++++++++++++
src/test/regress/expected/jsonb.out | 16 ++++++++++++++++
src/test/regress/sql/json.sql | 7 +++++++
src/test/regress/sql/jsonb.sql | 8 ++++++++
5 files changed, 48 insertions(+), 1 deletion(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix json_to_record() bug with nested objects.
@ 2016-03-03 04:31 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2016-03-03 04:31 UTC (permalink / raw)
To: pgsql-committers
Fix json_to_record() bug with nested objects.
A thinko concerning nesting depth caused json_to_record() to produce bogus
output if a field of its input object contained a sub-object with a field
name matching one of the requested output column names. Per bug #13996
from Johann Visagie.
I added a regression test case based on his example, plus parallel tests
for json_to_recordset, jsonb_to_record, jsonb_to_recordset. The latter
three do not exhibit the same bug (which suggests that we may be missing
some opportunities to share code...) but testing seems like a good idea
in any case.
Back-patch to 9.4 where these functions were introduced.
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/a9d199f6d3b998929cdb8e8aa61e5cd8db9b220f
Modified Files
--------------
src/backend/utils/adt/jsonfuncs.c | 2 +-
src/test/regress/expected/json.out | 16 ++++++++++++++++
src/test/regress/expected/jsonb.out | 16 ++++++++++++++++
src/test/regress/sql/json.sql | 7 +++++++
src/test/regress/sql/jsonb.sql | 8 ++++++++
5 files changed, 48 insertions(+), 1 deletion(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix json_to_record() bug with nested objects.
@ 2016-03-03 04:31 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2016-03-03 04:31 UTC (permalink / raw)
To: pgsql-committers
Fix json_to_record() bug with nested objects.
A thinko concerning nesting depth caused json_to_record() to produce bogus
output if a field of its input object contained a sub-object with a field
name matching one of the requested output column names. Per bug #13996
from Johann Visagie.
I added a regression test case based on his example, plus parallel tests
for json_to_recordset, jsonb_to_record, jsonb_to_recordset. The latter
three do not exhibit the same bug (which suggests that we may be missing
some opportunities to share code...) but testing seems like a good idea
in any case.
Back-patch to 9.4 where these functions were introduced.
Branch
------
REL9_4_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/597e41e45eec8038b8c2c1153d1d050bfafeacbf
Modified Files
--------------
src/backend/utils/adt/jsonfuncs.c | 2 +-
src/test/regress/expected/json.out | 16 ++++++++++++++++
src/test/regress/expected/jsonb.out | 16 ++++++++++++++++
src/test/regress/sql/json.sql | 9 ++++++++-
src/test/regress/sql/jsonb.sql | 8 ++++++++
5 files changed, 49 insertions(+), 2 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pgsql: Fix json_to_record() bug with nested objects.
@ 2016-03-03 13:06 Andrew Dunstan <andrew@dunslane.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Dunstan @ 2016-03-03 13:06 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-committers
On 03/02/2016 11:31 PM, Tom Lane wrote:
> I added a regression test case based on his example, plus parallel tests
> for json_to_recordset, jsonb_to_record, jsonb_to_recordset. The latter
> three do not exhibit the same bug (which suggests that we may be missing
> some opportunities to share code...)
Not really. The jsonb variants don't do any re-parsing at all, so
lex_level simply doesn't come into play, and for json_to_recordset we
want things from lex_level 2, not 1, as the json is supposed to be an
array of objects instead of just an object.
That's not to say that the code can't be improved - It very probably can.
cheers
andrew
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2016-03-03 13:06 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-03-03 04:31 pgsql: Fix json_to_record() bug with nested objects. Tom Lane <tgl@sss.pgh.pa.us>
2016-03-03 13:06 ` Andrew Dunstan <andrew@dunslane.net>
2016-03-03 04:31 pgsql: Fix json_to_record() bug with nested objects. Tom Lane <tgl@sss.pgh.pa.us>
2016-03-03 04:31 pgsql: Fix json_to_record() bug with nested objects. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox