diff options
author | Robert Haas <rhaas@postgresql.org> | 2022-06-22 13:11:49 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2022-06-22 13:11:49 -0400 |
commit | e243de03fb4583dd4a9f0afb41493727d7946c02 (patch) | |
tree | df9210bae2d7ac6746952a14701fe91505252cb9 | |
parent | 9f0b953457012a41321ab62cffa6aeabcb6e99b2 (diff) | |
download | postgresql-e243de03fb4583dd4a9f0afb41493727d7946c02.tar.gz postgresql-e243de03fb4583dd4a9f0afb41493727d7946c02.zip |
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
-rw-r--r-- | contrib/amcheck/verify_heapam.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c index c875f3e5a2a..e488f5e234b 100644 --- a/contrib/amcheck/verify_heapam.c +++ b/contrib/amcheck/verify_heapam.c @@ -1385,19 +1385,11 @@ check_tuple_attribute(HeapCheckContext *ctx) toast_pointer.va_rawsize, VARLENA_SIZE_LIMIT)); - if (VARATT_IS_COMPRESSED(&toast_pointer)) + if (VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer)) { ToastCompressionId cmid; bool valid = false; - /* Compression should never expand the attribute */ - if (VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer) > toast_pointer.va_rawsize - VARHDRSZ) - report_corruption(ctx, - psprintf("toast value %u external size %u exceeds maximum expected for rawsize %d", - toast_pointer.va_valueid, - VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer), - toast_pointer.va_rawsize)); - /* Compressed attributes should have a valid compression method */ cmid = TOAST_COMPRESS_METHOD(&toast_pointer); switch (cmid) |