Re: JSON validation behavior

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: JSON validation behavior
Дата
Msg-id 20136.1540396473@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: JSON validation behavior  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: JSON validation behavior
Re: JSON validation behavior
Список pgsql-hackers
"David G. Johnston" <david.g.johnston@gmail.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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Sandeep Thakkar
Дата:
Сообщение: Re: Problem with EDB 11.0 Windows x64 distributions
Следующее
От: Sergei Kornilov
Дата:
Сообщение: Re: JSON validation behavior