Re: [HACKERS] BUG #10728: json_to_recordset with nested json objects NULLs columns

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, matti(dot)hameister(at)technologygroup(dot)de, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] BUG #10728: json_to_recordset with nested json objects NULLs columns
Date: 2014-06-24 12:31:45
Message-ID: CAHyXU0x60k9Ue_HM_FhBCvssh=NXUyFT69Kqov0sOWc4ee-AsA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Mon, Jun 23, 2014 at 8:43 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> * 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.

Not quite following your logic here. 9.3 gave an error for an
internally nested array:

postgres=# create type foo as(a int, b int[]);
postgres=# select * from json_populate_recordset(null::foo, '[{"a": 1,
"b": [1,2,3]},{"a": 1, "b": [1,2,3]}]');
ERROR: cannot call json_populate_recordset on a nested object

With your proposal this would still fail? TBH, I'd rather this
function fail as above than implement a behavior we couldn't take back
later.

merlin

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrew Dunstan 2014-06-24 14:08:15 Re: [HACKERS] BUG #10728: json_to_recordset with nested json objects NULLs columns
Previous Message 德哥 2014-06-24 11:43:40 Re: BUG #10734: PostgreSQL 9.3.4 shutdown forever in zfsonlinux 0.6.3-1 filesystem

Browse pgsql-hackers by date

  From Date Subject
Next Message David Brownlee 2014-06-24 12:43:32 Re: PostgreSQL for VAX on NetBSD/OpenBSD
Previous Message Robert Haas 2014-06-24 12:17:21 Re: pgaudit - an auditing extension for PostgreSQL