pgsql: Fix gistkillitems for GiST root page

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix gistkillitems for GiST root page
Date: 2026-07-07 18:21:40
Message-ID: E1whAQO-00025u-0n@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix gistkillitems for GiST root page

GiST index killitems feature misbehaves for single-page GiST index,
i.e. one that has only a root page. This is caused by the GiST scan's
curBlkno variable not being initialized for the first-to-scan page,
which is the root page. Fix this by moving the initializing of
curBlkno into gistScanPage(), where we also set the related curPageLSN
variable.

Commit 377b7ab145 actually added a regression test for this already,
but it merely noted that it's not working and memorized the result
where the items were not killed. Now they are, as the test shows.

This has been broken all along, but since it's just a very minor
performance issue on tiny tables, I didn't bother backpatching it.

Author: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Reviewed-by: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Reviewed-by: Soumya S Murali <soumyamurali(dot)work(at)gmail(dot)com>
Discussion: https://postgr.es/m/CALdSSPgZWX_D8%2BFx4YQqRN5eW5iSx_rJdqQhCfdWTvqKXVfJ4w%40mail.gmail.com
Discussion: https://postgr.es/m/lxzj26ga6ippdeunz6kuncectr5gfuugmm2ry22qu6hcx6oid6@lzx3sjsqhmt6

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9c9ddf109bd8d73660ff3fef317f95bc1d7d6cc5

Modified Files
--------------
src/backend/access/gist/gistget.c | 11 +++++------
src/test/modules/index/expected/killtuples.out | 2 +-
src/test/modules/index/specs/killtuples.spec | 3 ++-
3 files changed, 8 insertions(+), 8 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-07-07 19:40:07 pgsql: Cleanup comments/docs around the new shmem request callbacks
Previous Message Heikki Linnakangas 2026-07-07 17:08:46 pgsql: Rename register_unlink_segment() to register_unlink_tombstone()