Re: PATCH: recursive json_populate_record()

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PATCH: recursive json_populate_record()
Date: 2016-12-13 01:07:46
Message-ID: CAB7nPqR_su1w5yC2KMSuH=XmmY8JHL+aDz-sJzc3Ln-juOAgtQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 13, 2016 at 9:38 AM, Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru> wrote:
> It also fixes the following errors/inconsistencies caused by lost quoting of
> string json values:
>
> [master]=# select * from json_to_record('{"js": "a"}') as rec(js json);
> ERROR: invalid input syntax for type json
> DETAIL: Token "a" is invalid.
> CONTEXT: JSON data, line 1: a

The docs mention that this is based on a best effort now. It may be
interesting to improve that.

> [master]=# select * from json_to_record('{"js": "true"}') as rec(js json);
> js
> ------
> true
>
> [patched]=# select * from json_to_record('{"js": "a"}') as rec(js json);
> js
> -----
> "a"

That's indeed valid JSON.

> [patched]=# select * from json_to_record('{"js": "true"}') as rec(js json);
> js
> --------
> "true"

And so is that.

> The second patch adds assignment of correct ndims to array fields of RECORD
> function result types.
> Without this patch, attndims in tuple descriptors of RECORD types is always
> 0 and the corresponding assertion fails in the next test:
>
> [patched]=# select json_to_record('{"a": [1, 2, 3]}') as rec(a int[]);
>
>
> Should I submit these patches to commitfest?

It seems to me that it would be a good idea to add them.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-12-13 01:08:01 Re: pgsql: Add support for temporary replication slots
Previous Message Craig Ringer 2016-12-13 01:05:12 Re: exposing wait events for non-backends (was: Tracking wait event for latches)