Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e243de0

Browse files
committed
amcheck: Fix incorrect use of VARATT_IS_COMPRESSED.
The macro is being applied to a TOAST pointer, not a varlena header. Therefore the use of VARATT_IS_COMPRESSED() is wrong. We can check VARATT_EXTERNAL_IS_COMPRESSED(), but then we don't need the length check that follows. Report and fix by Kyotaro Horiguchi. Discussion: http://postgr.es/m/20220517.162719.1671558681467343711.horikyota.ntt@gmail.com
1 parent 9f0b953 commit e243de0

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

contrib/amcheck/verify_heapam.c

+1-9
Original file line numberDiff line numberDiff line change
@@ -1385,19 +1385,11 @@ check_tuple_attribute(HeapCheckContext *ctx)
13851385
toast_pointer.va_rawsize,
13861386
VARLENA_SIZE_LIMIT));
13871387

1388-
if (VARATT_IS_COMPRESSED(&toast_pointer))
1388+
if (VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer))
13891389
{
13901390
ToastCompressionId cmid;
13911391
bool valid = false;
13921392

1393-
/* Compression should never expand the attribute */
1394-
if (VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer) > toast_pointer.va_rawsize - VARHDRSZ)
1395-
report_corruption(ctx,
1396-
psprintf("toast value %u external size %u exceeds maximum expected for rawsize %d",
1397-
toast_pointer.va_valueid,
1398-
VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer),
1399-
toast_pointer.va_rawsize));
1400-
14011393
/* Compressed attributes should have a valid compression method */
14021394
cmid = TOAST_COMPRESS_METHOD(&toast_pointer);
14031395
switch (cmid)

0 commit comments

Comments
 (0)