Skip to content

Commit c254d8d

Browse files
amcheck: Sanitize metapage's allequalimage field.
This will be helpful if it ever proves necessary to revoke an opclass's support for deduplication. Backpatch: 13-, where nbtree deduplication was introduced.
1 parent d5e9652 commit c254d8d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

contrib/amcheck/verify_nbtree.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,20 @@ bt_index_check_internal(Oid indrelid, bool parentcheck, bool heapallindexed,
305305
errmsg("index \"%s\" lacks a main relation fork",
306306
RelationGetRelationName(indrel))));
307307

308-
/* Check index, possibly against table it is an index on */
308+
/* Extract metadata from metapage, and sanitize it in passing */
309309
_bt_metaversion(indrel, &heapkeyspace, &allequalimage);
310+
if (allequalimage && !heapkeyspace)
311+
ereport(ERROR,
312+
(errcode(ERRCODE_INDEX_CORRUPTED),
313+
errmsg("index \"%s\" metapage has equalimage field set on unsupported nbtree version",
314+
RelationGetRelationName(indrel))));
315+
if (allequalimage && !_bt_allequalimage(indrel, false))
316+
ereport(ERROR,
317+
(errcode(ERRCODE_INDEX_CORRUPTED),
318+
errmsg("index \"%s\" metapage incorrectly indicates that deduplication is safe",
319+
RelationGetRelationName(indrel))));
320+
321+
/* Check index, possibly against table it is an index on */
310322
bt_check_every_level(indrel, heaprel, heapkeyspace, parentcheck,
311323
heapallindexed, rootdescend);
312324
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy