pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Dunstan <andrew@dunslane.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
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 20:34:08 -0400
Message-ID: <53A8C780.2070701@dunslane.net> (raw)
In-Reply-To: <17766.1403566448@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>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>


On 06/23/2014 07:34 PM, Tom Lane wrote:
> Andrew Dunstan <andrew@dunslane.net> 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



view thread (18+ messages)  latest in thread

Message-ID: <53A8C780.2070701@dunslane.net>
Permalink:  ../53A8C780.2070701@dunslane.net/
Also on:    postgresql.org/message-id/53A8C780.2070701@dunslane.net

 · 

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-bugs@postgresql.org
  Cc: andrew@dunslane.net, tgl@sss.pgh.pa.us, 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: <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>

* 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