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
v1-0001-Fix-GIN-jsonpath-quals-for-predicates-with-follow.patch
Description: Binary data
