Re: JSON validation behavior

From: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Sergei Kornilov <sk(at)zsrv(dot)org>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: JSON validation behavior
Date: 2018-10-24 20:49:57
Message-ID: caee7b8e-1f9a-f6ae-c85f-cb0c02d03405@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10/24/2018 11:54 AM, Tom Lane wrote:
> "David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
>> The following does seem buggy though:
>> select json '{ "a": "null \u0000 escape"}' -> 'a' as fails;
> Perhaps, but AFAICS it's entirely accidental that any variant of this
> doesn't fail. Although this manages not to fail:
>
> regression=# select json '{ "a": "null \u0000 escape"}' ;
> json
> ------------------------------
> { "a": "null \u0000 escape"}
> (1 row)
>
> this does:
>
> regression=# select jsonb '{ "a": "null \u0000 escape"}' ;
> ERROR: unsupported Unicode escape sequence
>
> The error message is actually being thrown in the JSON parser, and it
> only doesn't get thrown if the parser knows that it's just error-checking
> the data and not producing any converted output (cf the
> "if (lex->strval != NULL)" block starting at json.c:832). It actually
> seems to me that this behavior is a bug, in that there are a bunch of
> error checks there (not only this one) that are skipped in the allegedly
> "error checking only" path.
>
> But anyway, making it work as suggested here would take a substantial
> amount of refactoring, and it would not (I think) work anyway for jsonb,
> so it doesn't quite seem worth a lot of work. I could get behind fixing
> it to always throw the error, but that's not what Sergei was hoping for.
>
>

I think we might be able to do something that doesn't have too high an
impact. I'll take a look.

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2018-10-24 21:00:08 Re: pgbench - add pseudo-random permutation function
Previous Message Fabien COELHO 2018-10-24 20:43:02 Re: pgbench - add pseudo-random permutation function