Avoid trying to fetch metapage of an SPGist partitioned index.
commit0977bd64e294bba50efc354479ebe3925cffa0ef
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 21 Dec 2023 17:43:36 +0000 (21 12:43 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 21 Dec 2023 17:43:36 +0000 (21 12:43 -0500)
treef7397131dad82dc1c296befd04786f78a3fc33e4
parent7f07384dc2697abb405e47a7447c6edf7e07d5f9
Avoid trying to fetch metapage of an SPGist partitioned index.

This is necessary when spgcanreturn() is invoked on a partitioned
index, and the failure might be reachable in other scenarios as
well.  The rest of what spgGetCache() does is perfectly sensible
for a partitioned index, so we should allow it to go through.

I think the main takeaway from this is that we lack sufficient test
coverage for non-btree partitioned indexes.  Therefore, I added
simple test cases for brin and gin as well as spgist (hash and
gist AMs were covered already in indexing.sql).

Per bug #18256 from Alexander Lakhin.  Although the known test case
only fails since v16 (3c569049b), I've got no faith at all that there
aren't other ways to reach this problem; so back-patch to all
supported branches.

Discussion: https://postgr.es/m/18256-0b0e1b6e4a620f1b@postgresql.org
src/backend/access/spgist/spgutils.c
src/test/regress/expected/indexing.out
src/test/regress/sql/indexing.sql