From: Alexander Korotkov Date: Sat, 13 Jun 2026 23:49:05 +0000 (+0300) Subject: amcheck: Use correct varlena size accessor in bt_normalize_tuple() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4284476c0f67e9b3c4be36203193ca8ce8f21d40;p=thirdparty%2Fpostgresql.git amcheck: Use correct varlena size accessor in bt_normalize_tuple() bt_normalize_tuple() uses VARSIZE() to get the size of varlena, even though it's not yet known, that it has a 4-byte header. Fix this by replacing a accessor with a universal VARSIZE_ANY(). Backpatch to all supported versions. Reported-by: Andres Freund Discussion: https://postgr.es/m/7ckc7oka4bvafkf5bwlqs6ygrhlsbhz25ppozfch7zbuxcx3rf%40e4pr4oqenalc Author: Andrey Borodin Reviewed-by: Alexander Korotkov Backpatch-through: 14 --- diff --git a/contrib/amcheck/verify_nbtree.c b/contrib/amcheck/verify_nbtree.c index 073d259fd88..5a2ee7b91d8 100644 --- a/contrib/amcheck/verify_nbtree.c +++ b/contrib/amcheck/verify_nbtree.c @@ -2674,7 +2674,7 @@ bt_normalize_tuple(BtreeCheckState *state, IndexTuple itup) ItemPointerGetOffsetNumber(&(itup->t_tid)), RelationGetRelationName(state->rel)))); else if (!VARATT_IS_COMPRESSED(DatumGetPointer(normalized[i])) && - VARSIZE(DatumGetPointer(normalized[i])) > TOAST_INDEX_TARGET && + VARSIZE_ANY(DatumGetPointer(normalized[i])) > TOAST_INDEX_TARGET && (att->attstorage == TYPSTORAGE_EXTENDED || att->attstorage == TYPSTORAGE_MAIN)) {