From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "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 15:54:33 |
Message-ID: | 20136.1540396473@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
"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.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Sergei Kornilov | 2018-10-24 16:27:42 | Re: JSON validation behavior |
Previous Message | Sandeep Thakkar | 2018-10-24 15:43:35 | Re: Problem with EDB 11.0 Windows x64 distributions |