From: | Sergei Kornilov <sk(at)zsrv(dot)org> |
---|---|
To: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | JSON validation behavior |
Date: | 2018-10-24 14:24:01 |
Message-ID: | 6996811540391041@sas1-890ba5c2334a.qloud-c.yandex.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi
We have some json regression tests in src/test/regress/expected/json_encoding_1.out with \u0000 symbol
select json '{ "a": "null \u0000 escape" }' as not_unescaped;
not_unescaped
--------------------------------
{ "a": "null \u0000 escape" }
(1 row)
select json '{ "a": "null \u0000 escape" }' ->> 'a' as fails;
ERROR: unsupported Unicode escape sequence
DETAIL: \u0000 cannot be converted to text.
CONTEXT: JSON data, line 1: { "a":...
Well, requested text type can not have \u0000 byte. But seems strange: we test json type with this value but raise same error for -> operator:
melkij=> select json '{ "a": "null \u0000 escape"}' -> 'a' as fails;
ERROR: unsupported Unicode escape sequence
DETAIL: \u0000 cannot be converted to text.
CONTEXT: JSON data, line 1: { "a":...
Result was requested in json datatype, like 'SELECT '"\u0000"'::json;' from tests before.
Similar error with access by different key:
melkij=> select json '{ "a": "null \u0000 escape", "b":1 }' ->>'b' as fails;
ERROR: unsupported Unicode escape sequence
DETAIL: \u0000 cannot be converted to text.
CONTEXT: JSON data, line 1: { "a":...
We allow write such json to table, we allow read whole json, but we can not use native operators. Is this behavior expected?
regards, Sergei
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-10-24 14:27:19 | Re: Estimating number of distinct values. |
Previous Message | David Fetter | 2018-10-24 14:21:56 | Re: Log timestamps at higher resolution |