pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Fix json_to_record() bug with nested objects.
Date: Thu, 03 Mar 2016 04:31:59 +0000
Message-ID: <E1abKvf-0007oW-Jd@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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


view thread (4+ messages)  latest in thread

Message-ID: <E1abKvf-0007oW-Jd@gemulon.postgresql.org>
Permalink:  ../E1abKvf-0007oW-Jd@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1abKvf-0007oW-Jd@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix json_to_record() bug with nested objects.
  In-Reply-To: <E1abKvf-0007oW-Jd@gemulon.postgresql.org>
  References: <E1abKvf-0007oW-Jd@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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