| From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Cc: | james(dot)moore(at)g5labs(dot)ai |
| Subject: | BUG #19958: jsonpath: a word directly followed by a /* comment */ is silently dropped, so strict becomes lax |
| Date: | 2026-11-30 17:32:28 |
| Message-ID: | 19958-5e9019814c971751@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 19958
Logged by: James Moore
Email address: james(dot)moore(at)g5labs(dot)ai
PostgreSQL version: 19.0
Operating system: Debian 13 (official postgres image), x86_64
Description:
In a jsonpath, an unquoted word that is immediately followed by a C-style
comment is discarded by the scanner. For the mode keyword this silently
turns a strict path into a lax one, so a query that should raise an error
returns an empty result instead.
Reproduced on 17.11, 18.7 and 19.0:
SELECT 'strict/**/$.a'::jsonpath;
-- returns: $."a" expected: strict $."a"
SELECT jsonb_path_query('{"b":1}', 'strict/**/$.a');
-- returns 0 rows
-- expected: ERROR: JSON object does not contain key "a"
-- (which is what 'strict $.a' gives)
SELECT 'abc/**/1'::jsonpath;
-- returns: 1 expected: a syntax error, as for 'abc 1'
Cause, as far as we can tell: in src/backend/utils/adt/jsonpath_scan.l the
<xnq>\/\* rule (around line 132) switches to the comment state without
first returning the pending unquoted word, so the word is lost.
Impact: strict mode is how a caller asks for structural errors. Adding a
comment after the keyword makes those errors disappear without any message.
Found by comparing PostgreSQL's results against a formal model of SQL/JSON
path semantics.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | PG Bug reporting form | 2026-11-30 17:32:58 | BUG #19959: tsquery = ignores weights and prefix flags, so queries that match different documents compare equal |
| Previous Message | Sami Imseih | 2026-11-30 17:18:22 | Re: Anti-wraparound autovacuum stops for good after no slot available for new autovacuum worker process |