On 21.03.2019 16:58, Alexander Korotkov wrote:
On Tue, Mar 19, 2019 at 8:10 PM Alexander Korotkov
<[email protected]> wrote:
Attaches patches improving jsonpath parser. First one introduces
cosmetic changes, while second gets rid of backtracking. I'm also
planning to add high-level comment for both grammar and lexer.
Parsing of integers now is wrong: neither JSON specification, nor our json[b]
allow leading zeros in integers and floats starting with a dot.
=# SELECT json '.1';
ERROR: invalid input syntax for type json
LINE 1: SELECT jsonb '.1'; ^
DETAIL: Token "." is invalid.
CONTEXT: JSON data, line 1: ....
=# SELECT json '00';
ERROR: invalid input syntax for type json
LINE 1: SELECT jsonb '00'; ^
DETAIL: Token "00" is invalid.
CONTEXT: JSON data, line 1: 00
=# SELECT json '00.1';
ERROR: invalid input syntax for type json
LINE 1: SELECT jsonb '00.1'; ^
DETAIL: Token "00" is invalid.
CONTEXT: JSON data, line 1: 00...
In JavaScript integers with leading zero are treated as octal numbers,
but leading dot is a allowed:
v8 > 0123
83
v8 > 000.1
Uncaught SyntaxError: Unexpected number
v8> .1
0.1
Attached patch 0003 fixes this issue.
--
Nikita Glukhov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company