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

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

I wrote:
> * 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.

Here's a draft patch that gets rid of the use_json_as_text flag argument
altogether for all the functions newly added in 9.4. The pre-existing
json_populate_record(set) functions still have such an argument, but
it's ignored and undocumented (not that it was well documented before).
The behavior is as if the flag had been specified as true, which AFAICS
is the only useful case.

This does not do anything about the question of possibly printing
JSON arrays in SQL array syntax when the target record field is of
array type. While I think that's definitely do-able, it would require
some significant rewriting of the code, which is probably not something
to be doing at this point for 9.4. I think it's something we can add
as a new feature in 9.5 or later, because it changes the behavior only
in cases that are currently guaranteed-to-fail, so there's not really
any backwards compatibility problem IMO.

BTW, depending on how hard we want to work, one could imagine also
printing JSON objects in SQL record format if the target type is record
rather than JSON, and then making this happen recursively for nested
arrays/composites. Again, any attempt to do that today would fail with
a syntax error from record_in, so there's no backwards compatibility
problem.

regards, tom lane

Attachment Content-Type Size
no-use-json-as-text-flag.patch text/x-patch 69.2 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message 王学敏 2014-06-27 06:41:20 Re: pg import text data to not null table comma error but semicolon right
Previous Message v-seishi 2014-06-26 19:41:44 BUG #10770: PostgreSQL Global Development Group PostgreSQL user interface compatibility with DPI scaling in Wind

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-06-26 22:40:11 Re: Spinlocks and compiler/memory barriers
Previous Message Thomas Munro 2014-06-26 22:03:24 Re: Cluster name in ps output