amcheck: Add gin_index_check() to verify GIN index
authorTomas Vondra <[email protected]>
Sat, 29 Mar 2025 14:43:55 +0000 (15:43 +0100)
committerTomas Vondra <[email protected]>
Sat, 29 Mar 2025 14:44:29 +0000 (15:44 +0100)
commit14ffaece0fb53fed8ddbc46d2b353e1c4834863a
tree0b49b3431f1d0980631bc15ca31981448d76f5d2
parent53a2a1564ae450a46a7c565756ab536b84150e36
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 <[email protected]>
Author: Heikki Linnakangas <[email protected]>
Author: Andrey Borodin <[email protected]>
Reviewed-By: José Villanova <[email protected]>
Reviewed-By: Aleksander Alekseev <[email protected]>
Reviewed-By: Nikolay Samokhvalov <[email protected]>
Reviewed-By: Andres Freund <[email protected]>
Reviewed-By: Tomas Vondra <[email protected]>
Reviewed-By: Kirill Reshke <[email protected]>
Reviewed-By: Mark Dilger <[email protected]>
Reviewed-By: Peter Geoghegan <[email protected]>
Discussion: https://postgr.es/m/45AC9B0A-2B45-40EE-B08F-BDCF5739D1E1%40yandex-team.ru
contrib/amcheck/Makefile
contrib/amcheck/amcheck--1.4--1.5.sql [new file with mode: 0644]
contrib/amcheck/amcheck.control
contrib/amcheck/expected/check_gin.out [new file with mode: 0644]
contrib/amcheck/meson.build
contrib/amcheck/sql/check_gin.sql [new file with mode: 0644]
contrib/amcheck/verify_gin.c [new file with mode: 0644]
doc/src/sgml/amcheck.sgml
src/tools/pgindent/typedefs.list