Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WzEgq-0004Aw-85 for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Jun 2014 00:34:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WzEgp-0004ZM-I8 for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Jun 2014 00:34:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1WzEgn-0004Z9-HT; Tue, 24 Jun 2014 00:34:21 +0000 Received: from relay6-d.mail.gandi.net ([2001:4b98:c:538::198]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1WzEgj-0008UC-HP; Tue, 24 Jun 2014 00:34:19 +0000 Received: from mfilter28-d.gandi.net (mfilter28-d.gandi.net [217.70.178.159]) by relay6-d.mail.gandi.net (Postfix) with ESMTP id B54DAFB87F; Tue, 24 Jun 2014 02:34:15 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter28-d.gandi.net Received: from relay6-d.mail.gandi.net ([217.70.183.198]) by mfilter28-d.gandi.net (mfilter28-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id DDT8AD0+kDX4; Tue, 24 Jun 2014 02:34:14 +0200 (CEST) X-Originating-IP: 98.27.58.255 Received: from [192.168.10.146] (cpe-098-027-058-255.nc.res.rr.com [98.27.58.255]) (Authenticated sender: adsend@dunslane.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id B3934FB87D; Tue, 24 Jun 2014 02:34:12 +0200 (CEST) Message-ID: <53A8C780.2070701@dunslane.net> Date: Mon, 23 Jun 2014 20:34:08 -0400 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Tom Lane CC: Michael Paquier , matti.hameister@technologygroup.de, pgsql-bugs@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: [HACKERS] BUG #10728: json_to_recordset with nested json objects NULLs columns References: <20140622153409.2618.90346@wrigleys.postgresql.org> <16858.1403538180@sss.pgh.pa.us> <53A8877F.7060208@dunslane.net> <17766.1403566448@sss.pgh.pa.us> In-Reply-To: <17766.1403566448@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 06/23/2014 07:34 PM, Tom Lane wrote: > Andrew Dunstan writes: >> On 06/23/2014 11:43 AM, Tom Lane wrote: >>> However, it seems to me that these functions (json[b]_to_record[set]) are >>> handling the nested-json-objects case in a fairly brain-dead fashion to >>> start with. I would like to propose that we should think about getting >>> rid of the use_json_as_text flag arguments altogether. What purpose do >>> they serve? If we're going to the trouble of parsing the nested JSON >>> objects anyway, why don't we just reconstruct from that data? >> Looks like we have some problems in this whole area, not just the new >> function, so we need to fix 9.3 also :-( >> IIRC, originally, the intention was to disallow nested json objects, but >> the use_json_as_text was put in as a possibly less drastic possibility. >> If we get rid of it our only recourse is to error out if we encounter >> nested json. I was probably remiss in not considering the likelihood of >> a json target field. >> I currently don't have lots of time to devote to this, sadly, but >> Michael's patch looks like a good minimal fix. > I can spend some time on it over the next couple of days. I take it you > don't have a problem with the concept of doing recursive processing, > as long as it doesn't add much complication? > > 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: andrew=# create type yyy as (a int, b json, c int, d int); CREATE TYPE andrew=# select * from json_populate_recordset(null::yyy, '[ {"a":2,"c":3,"b":{"z":4}, "d":6} ] ',true) x; a | b | c | d ---+---------+---+--- | {"z":4} | | 6 (1 row) I don't have any problem with recursive processing, but I'm not sure I understand how it will work. If you post a patch I will be able to look it over, though. cheers andrew > -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs