Re: bug in json_to_record with arrays

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Josh Berkus <josh(at)agliodbs(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: bug in json_to_record with arrays
Date: 2014-11-26 21:34:50
Message-ID: 5476477A.7080208@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 11/26/2014 03:48 PM, Tom Lane wrote:

> Arguably,
> populate_record_worker should be smart enough to convert somehow, but
> it isn't today. Looks to me like it wouldn't succeed for the comparable
> case of converting a sub-object to a Postgres composite type, either.
> I'm satisfied with regarding those cases as missing features to be
> added later.

Right. Before commit a749a23d7af4dba9b3468076ec561d2cbf69af09 it didn't
try by default to treat the value as text, but instead errored out if
the value was an array or object, with an appropriate message. Now we
always try to treat it as text and pass that to the array or composite
input functions, who now get the responsibility of telling us what's wrong.

It might be possible to process such values recursively, but it would be
far from trivial.

>
> As far as your request for a better error message is concerned, I'm a
> bit inclined to lay the blame on array_in rather than the JSON code.
> Wouldn't it be better if it said
>
> ERROR: invalid input syntax for array: "["potter","chef","programmer"]"
> DETAIL: Dimension value is missing.
>
> which is comparable to what you'd get out of most other input functions
> that were feeling indigestion?
>
>

+1

cheers

andrew

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Maxim Boguk 2014-11-26 21:36:23 Re: BUG #12071: Stat collector went crasy (50MB/s constant writes)
Previous Message Maxim Boguk 2014-11-26 21:19:32 Re: BUG #12071: Stat collector went crasy (50MB/s constant writes)