]> granicus.if.org Git - postgresql/commit
Fix wrong validation of top-parent pointer during page deletion in Btree.
authorTeodor Sigaev <teodor@sigaev.ru>
Mon, 23 Apr 2018 12:55:10 +0000 (15:55 +0300)
committerTeodor Sigaev <teodor@sigaev.ru>
Mon, 23 Apr 2018 12:55:10 +0000 (15:55 +0300)
commit6db4b49986be3fe59a1f6ba6fabf9852864efc3e
tree7df7a5e74e34121c679ca92fa87ecf50eda88f78
parent6a7b2ce2bdb9ab5fd23c98ace4bb2d811231706a
Fix wrong validation of top-parent pointer during page deletion in Btree.

After introducing usage of t_tid of inner or page high key for storing
number of attributes of tuple, validation of tuple's ItemPointer with
ItemPointerIsValid becomes incorrect, it's need to validate only blocknumber of
ItemPointer. Missing this causes a incorrect page deletion, fix that. Test is
added.

BTW, current contrib/amcheck doesn't fail on index corrupted by this way.

Also introduce BTreeTupleGetTopParent/BTreeTupleSetTopParent macroses to improve
code readability and to avoid possible confusion with page high key: high key
is used to store top-parent link for branch to remove.

Bug found by Michael Paquier, but bug doesn't exist in previous versions because
t_tid was set to P_HIKEY.

Author: Teodor Sigaev
Reviewer: Peter Geoghegan
Discussion: https://www.postgresql.org/message-id/flat/20180419052436.GA16000%40paquier.xyz
src/backend/access/nbtree/nbtpage.c
src/backend/access/nbtree/nbtxlog.c
src/include/access/nbtree.h
src/test/regress/expected/create_index.out
src/test/regress/expected/sanity_check.out
src/test/regress/sql/create_index.sql