From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make JSON path numeric literals more correct
Date: Mon, 28 Mar 2022 09:20:12 +0000
Message-ID: <E1nYlXn-001jeX-Gx@gemulon.postgresql.org> (raw)
Make JSON path numeric literals more correct
Per ECMAScript standard (ECMA-262, referenced by SQL standard), the
syntax forms
.1
1.
should be allowed for decimal numeric literals, but the existing
implementation rejected them.
Also, by the same standard, reject trailing junk after numeric
literals.
Note that the ECMAScript standard for numeric literals is in respects
like these slightly different from the JSON standard, which might be
the original cause for this discrepancy.
A change is that this kind of syntax is now rejected:
1.type()
This needs to be written as
(1).type()
This is correct; normal JavaScript also does not accept this syntax.
We also need to fix up the jsonpath output function for this case. We
put parentheses around numeric items if they are followed by another
path item.
Reviewed-by: Nikita Glukhov <n.gluhov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/50a828cc-0a00-7791-7883-2ed06dfb2dbb@enterprisedb.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/e26114c817b610424010cfbe91a743f591246ff1
Modified Files
--------------
src/backend/utils/adt/jsonpath.c | 4 +
src/backend/utils/adt/jsonpath_scan.l | 24 ++--
src/test/regress/expected/jsonpath.out | 238 +++++++++++++++++++++------------
src/test/regress/sql/jsonpath.sql | 8 ++
4 files changed, 176 insertions(+), 98 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: peter@eisentraut.org
Subject: Re: pgsql: Make JSON path numeric literals more correct
In-Reply-To: <E1nYlXn-001jeX-Gx@gemulon.postgresql.org>
References: <E1nYlXn-001jeX-Gx@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox