| From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | GIN jsonpath scans miss rows when methods follow a predicate |
| Date: | 2026-10-14 01:16:11 |
| Message-ID: | CAHGQGwG757QfokcU1ysE7ZgmedPp3_ivKJ7+qCR2NQhocj0W2g@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
Codex reported me an issue where GIN scans can miss matching rows when
methods are applied to a jsonpath predicate's result. For example:
------------------------------------------
CREATE TEMP TABLE t AS SELECT '2'::jsonb AS j;
-- Returns one row.
SELECT * FROM t WHERE j @@ '($ == 1).size().boolean()';
CREATE INDEX ON t USING gin (j);
SET enable_seqscan = off;
-- Returns no rows, but should return one.
SELECT * FROM t WHERE j @@ '($ == 1).size().boolean()';
RESET enable_seqscan;
------------------------------------------
In the default lax mode, "($ == 1).size().boolean()" evaluates to true.
But, extract_jsp_bool_expr() ignores the following methods and
incorrectly extracts an index condition from "$ == 1", causing the issue.
The attached patch fixes this by skipping index condition extraction for
predicates with following items.
Regards,
--
Fujii Masao
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-GIN-jsonpath-quals-for-predicates-with-follow.patch | application/octet-stream | 4.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-10-14 01:18:57 | Re: Memory leak in statext_ndistinct_build() during ANALYZE |
| Previous Message | Henson Choi | 2026-10-14 01:10:42 | [DEPARSE] Operators on ROW() constructors read back as row comparisons |