From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: matti.hameister@technologygroup.de
Cc: pgsql-bugs@postgresql.org
Cc: pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] BUG #10728: json_to_recordset with nested json objects NULLs columns
Date: Mon, 23 Jun 2014 18:43:31 -0700
Message-ID: <20561.1403574211@sss.pgh.pa.us> (raw)
In-Reply-To: <53A8C780.2070701@dunslane.net>
References: <20140622153409.2618.90346@wrigleys.postgresql.org>
<CAB7nPqQ2hLVt3o-d8-5=h5MEfPr1sS9jT4CK0GpQXew8PeY=yw@mail.gmail.com>
<CAB7nPqS0b=1DEKPWTQgzB0L3iV-ZQxTdffnqpc2Qp8_F1U2-6A@mail.gmail.com>
<CAB7nPqTP1m5H=kNsm6mmv-5f7A99O7AP2X6E9ubb4ShZWq-COQ@mail.gmail.com>
<16858.1403538180@sss.pgh.pa.us>
<53A8877F.7060208@dunslane.net>
<17766.1403566448@sss.pgh.pa.us>
<53A8C780.2070701@dunslane.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Andrew Dunstan <andrew@dunslane.net> writes:
> On 06/23/2014 07:34 PM, Tom Lane wrote:
>> I'm not following your comment about 9.3. The json[b]_to_record[set]
>> functions are new in 9.4, which is what makes me feel it's not too
>> late to redefine their behavior. But changing behavior of stuff that
>> was in 9.3 seems a lot more debatable.
> This problem is also manifest in json_populate_recordset, which also
> uses the function in question, and is in 9.3:
Ah, I see the problem.
Here is a first cut suggestion:
* Get rid of the use_json_as_text flag argument for the new functions.
In json_populate_record(set), ignore its value and deprecate using it.
(The fact that it already had a default makes that easier.) The
behavior should always be as below.
* For nested json objects, we'll spit those out in json textual format,
which means they'll successfully convert to either text or json/jsonb.
Compared to the old behavior of json_populate_recordset, this just means
that we don't throw an error anymore regardless of the flag value,
which seems ok (though maybe not something to backpatch into 9.3).
* Nested json arrays are a bit more problematic. What I'd ideally like
is to spit them out in a form that would be successfully parsable as a SQL
array of the appropriate element type. Unfortunately, I think that that
ship has sailed because json_populate_recordset failed to do that in 9.3.
What we should probably do is define this the same as the nested object
case, ie, we spit it out in *json* array format, meaning you can insert it
into a text or json/jsonb field of the result record. Maybe sometime in
the future we can add a json-array-to-SQL-array converter function, but
these functions won't do that.
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-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, andrew@dunslane.net, michael.paquier@gmail.com, matti.hameister@technologygroup.de, pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] BUG #10728: json_to_recordset with nested json objects NULLs columns
In-Reply-To: <20561.1403574211@sss.pgh.pa.us>
References: <20140622153409.2618.90346@wrigleys.postgresql.org> <CAB7nPqQ2hLVt3o-d8-5=h5MEfPr1sS9jT4CK0GpQXew8PeY=yw@mail.gmail.com> <CAB7nPqS0b=1DEKPWTQgzB0L3iV-ZQxTdffnqpc2Qp8_F1U2-6A@mail.gmail.com> <CAB7nPqTP1m5H=kNsm6mmv-5f7A99O7AP2X6E9ubb4ShZWq-COQ@mail.gmail.com> <16858.1403538180@sss.pgh.pa.us> <53A8877F.7060208@dunslane.net> <17766.1403566448@sss.pgh.pa.us> <53A8C780.2070701@dunslane.net> <20561.1403574211@sss.pgh.pa.us>
* 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