Fix GiST contained-by scans of multiranges

GiST stores a multirange leaf key as its union range.  When both the
indexed value and the query have gaps, the indexed multirange can be
contained by the query even though its union range is not.  The current
leaf check can therefore discard a matching row before heap recheck.

Implement a special test function for this case.  Union range of query
multirange must contain the leaf key union range.

Back-patch to all supported branches.

Reported-by: Peter Geoghegan <[email protected]>
Discussion: 
https://postgr.es/m/CAH2-Wzm1GpQ9qixP=Xs2TYdfnLM88OZ=yufhnuajs_w7u90...@mail.gmail.com
Author: Andrey Borodin <[email protected]>

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1cb5a9dc27d7355688ed12e835d5ed2a86b11102

Modified Files
--------------
src/backend/utils/adt/rangetypes_gist.c       | 55 ++++++++++++++++++++++++++-
src/test/regress/expected/multirangetypes.out | 12 ++++++
src/test/regress/sql/multirangetypes.sql      |  2 +
3 files changed, 67 insertions(+), 2 deletions(-)

Reply via email to