Re: Extending amcheck to check toast size and compression

From: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
To: Greg Stark <stark(at)mit(dot)edu>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Aleksander Alekseev <aleksander(at)timescale(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Extending amcheck to check toast size and compression
Date: 2021-10-20 19:06:01
Message-ID: 8C8A33DF-EEA5-45F7-91A7-5E0EA79208CC@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Oct 20, 2021, at 11:42 AM, Greg Stark <stark(at)mit(dot)edu> wrote:
>
>
>
> On Wed., Oct. 20, 2021, 12:41 Mark Dilger, <mark(dot)dilger(at)enterprisedb(dot)com> wrote:
>
> I used a switch statement to trigger a compiler warning in such an event.
>
> Catching better compiler diagnostics is an excellent reason to choose this structure. I guess all I could ask is that the comment saying no default branch say this is the motivation.

Ok. How about:

diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 774a70f63d..9500f43bc9 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -30,7 +30,11 @@ PG_FUNCTION_INFO_V1(verify_heapam);
/* The number of columns in tuples returned by verify_heapam */
#define HEAPCHECK_RELATION_COLS 4

-/* The largest valid toast va_rawsize */
+/*
+ * The largest valid toast va_rawsize. This is the same as the MaxAllocSize
+ * constant from memutils.h, and is the largest size that can fit in a varlena
+ * va_header's 30-bit size field.
+ */
#define VARLENA_SIZE_LIMIT 0x3FFFFFFF

/*
@@ -1452,7 +1456,11 @@ check_tuple_attribute(HeapCheckContext *ctx)
case TOAST_INVALID_COMPRESSION_ID:
break;

- /* Intentionally no default here */
+ /*
+ * Intentionally no default here. We want the compiler to warn if
+ * new compression methods are added to the ToastCompressionId enum
+ * but not handled in our switch.
+ */
}
if (!valid)
report_corruption(ctx,


Mark Dilger
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2021-10-20 19:06:41 Re: Split xlog.c
Previous Message John Naylor 2021-10-20 19:01:13 Re: [RFC] speed up count(*)