postgresql/contrib/amcheck
Alexander Korotkov 0b5c161248 amcheck: Don't load the right sibling page into BtreeCheckState
5ae2087202 implemented a cross-page unique constraint check by loading
the right sibling to the BtreeCheckState.target variable.  This is wrong,
because bt_target_page_check() shouldn't change the target page.  Also,
BtreeCheckState.target shouldn't be changed alone without
BtreeCheckState.targetblock.

However, the above didn't cause any visible bugs for the following reasons.
1. We do a cross-page unique constraint check only for leaf index pages.
2. The only way target page get accessed after a cross-page unique constraint
   check is loading of the lowkey.
3. The only place lowkey is used is bt_child_highkey_check(), and that applies
   only to non-leafs.

The reasons above don't diminish the fact that changing BtreeCheckState.target
for a cross-page unique constraint check is wrong.  This commit changes this
check to temporarily store the right sibling to the local variable.

Reported-by: Peter Geoghegan
Discussion: https://postgr.es/m/CAH2-Wzk%2B2116uOXdOViA27SHcr31WKPgmjsxXLBs_aTxAeThzg%40mail.gmail.com
Author: Pavel Borisov
2024-05-23 02:12:45 +03:00
..
expected Fix typos and duplicate words 2024-04-18 21:28:07 +02:00
sql Fix typos and duplicate words 2024-04-18 21:28:07 +02:00
t Fix buildfarm failures from 2af07e2f74. 2024-03-04 19:42:16 -08:00
.gitignore
Makefile amcheck: Distinguish interrupted page deletion from corruption. 2023-10-30 14:46:05 -07:00
amcheck--1.0--1.1.sql Add amcheck verification of heap relations belonging to btree indexes. 2018-03-31 19:52:01 -07:00
amcheck--1.0.sql
amcheck--1.1--1.2.sql Allow amcheck to re-find tuples using new search. 2019-03-20 10:41:36 -07:00
amcheck--1.2--1.3.sql Extend amcheck to check heap pages. 2020-10-22 08:44:18 -04:00
amcheck--1.3--1.4.sql Teach contrib/amcheck to check the unique constraint violation 2023-10-28 00:21:23 +03:00
amcheck.control Teach contrib/amcheck to check the unique constraint violation 2023-10-28 00:21:23 +03:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00
verify_heapam.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
verify_nbtree.c amcheck: Don't load the right sibling page into BtreeCheckState 2024-05-23 02:12:45 +03:00