Fix GIN index search for root strings in strict jsonpath queries. A jsonb_ops index scan for 'strict $ == "a scalar"' missed a matching root string. Root scalars are stored in single-element arrays, so gin_extract_jsonb() indexes strings with JGINFLAG_KEY. In strict mode, jsonb_ops__extract_nodes() instead searches for JGINFLAG_STR at the root. Leave gin_extract_jsonb() alone (else we'd force people to reindex) and make jsonb_ops__extract_nodes() search for JGINFLAG_KEY instead.
Author: Rui Zhao <[email protected]> Reviewed-by: shihao zhong <[email protected]> Reviewed-by: Tom Lane <[email protected]> Discussion: https://postgr.es/m/CAHWVJhHH0k3PxWmS==v1p_ponomuasm6ljuv487fwnoqd0j...@mail.gmail.com Backpatch-through: 14 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0cf2c7e38fa1ed81224e028014fef9ee666abcc4 Modified Files -------------- src/backend/utils/adt/jsonb_gin.c | 5 +++-- src/test/regress/expected/jsonb.out | 27 +++++++++++++++++++++++++++ src/test/regress/sql/jsonb.sql | 8 ++++++++ 3 files changed, 38 insertions(+), 2 deletions(-)
