pgsql: amcheck: Add gin_index_check() to verify GIN index

From: Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: amcheck: Add gin_index_check() to verify GIN index
Date: 2025-03-29 14:44:54
Message-ID: E1tyXQc-001bH4-1z@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

amcheck: Add gin_index_check() to verify GIN index

Adds a new function, validating two kinds of invariants on a GIN index:

- parent-child consistency: Paths in a GIN graph have to contain
consistent keys. Tuples on parent pages consistently include tuples
from child pages; parent tuples do not require any adjustments.

- balanced-tree / graph: Each internal page has at least one downlink,
and can reference either only leaf pages or only internal pages.

The GIN verification is based on work by Grigory Kryachko, reworked by
Heikki Linnakangas and with various improvements by Andrey Borodin.
Investigation and fixes for multiple bugs by Kirill Reshke.

Author: Grigory Kryachko <GSKryachko(at)gmail(dot)com>
Author: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Author: Andrey Borodin <amborodin(at)acm(dot)org>
Reviewed-By: José Villanova <jose(dot)arthur(at)gmail(dot)com>
Reviewed-By: Aleksander Alekseev <aleksander(at)timescale(dot)com>
Reviewed-By: Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>
Reviewed-By: Andres Freund <andres(at)anarazel(dot)de>
Reviewed-By: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Reviewed-By: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Reviewed-By: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
Reviewed-By: Peter Geoghegan <pg(at)bowt(dot)ie>
Discussion: https://postgr.es/m/45AC9B0A-2B45-40EE-B08F-BDCF5739D1E1%40yandex-team.ru

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/14ffaece0fb53fed8ddbc46d2b353e1c4834863a

Modified Files
--------------
contrib/amcheck/Makefile | 6 +-
contrib/amcheck/amcheck--1.4--1.5.sql | 14 +
contrib/amcheck/amcheck.control | 2 +-
contrib/amcheck/expected/check_gin.out | 64 +++
contrib/amcheck/meson.build | 3 +
contrib/amcheck/sql/check_gin.sql | 40 ++
contrib/amcheck/verify_gin.c | 798 +++++++++++++++++++++++++++++++++
doc/src/sgml/amcheck.sgml | 20 +
src/tools/pgindent/typedefs.list | 2 +
9 files changed, 946 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2025-03-29 14:49:31 pgsql: Fix "‘static’ is not at beginning of declaration" warning
Previous Message Peter Eisentraut 2025-03-29 14:31:17 pgsql: pgbench: Make set_random_seed() 64-bit everywhere.