From 293c1e8c1a398bdea10a1e9d769e08177a0b75dd Mon Sep 17 00:00:00 2001
From: Mark Dilger <mark.dilger@enterprisedb.com>
Date: Mon, 29 Mar 2021 14:37:20 -0700
Subject: [PATCH v13 3/4] Renaming report_corruption as report_main_corruption

In preparation for checking toast as a separate pass from checking
the main heap, renaming report_corruption so that the name
report_toast_corruption can be added in the next commit and fit in
nicely with this name.

This patch can probably be left out if the committer believes it
creates more git churn than it is worth.
---
 contrib/amcheck/verify_heapam.c | 486 ++++++++++++++++----------------
 1 file changed, 243 insertions(+), 243 deletions(-)

diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 59b13180d9..c5bde63ea7 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -142,7 +142,7 @@ static bool check_tuple_attribute(HeapCheckContext *ctx);
 static bool check_tuple_header(HeapCheckContext *ctx);
 static bool check_tuple_visibility(HeapCheckContext *ctx);
 
-static void report_corruption(HeapCheckContext *ctx, char *msg);
+static void report_main_corruption(HeapCheckContext *ctx, char *msg);
 static TupleDesc verify_heapam_tupdesc(void);
 static FullTransactionId FullTransactionIdFromXidAndCtx(TransactionId xid,
 														const HeapCheckContext *ctx);
@@ -407,25 +407,25 @@ verify_heapam(PG_FUNCTION_ARGS)
 
 				if (rdoffnum < FirstOffsetNumber)
 				{
-					report_corruption(&ctx,
-									  psprintf("line pointer redirection to item at offset %u precedes minimum offset %u",
-											   (unsigned) rdoffnum,
-											   (unsigned) FirstOffsetNumber));
+					report_main_corruption(&ctx,
+										   psprintf("line pointer redirection to item at offset %u precedes minimum offset %u",
+													(unsigned) rdoffnum,
+													(unsigned) FirstOffsetNumber));
 					continue;
 				}
 				if (rdoffnum > maxoff)
 				{
-					report_corruption(&ctx,
-									  psprintf("line pointer redirection to item at offset %u exceeds maximum offset %u",
-											   (unsigned) rdoffnum,
-											   (unsigned) maxoff));
+					report_main_corruption(&ctx,
+										   psprintf("line pointer redirection to item at offset %u exceeds maximum offset %u",
+													(unsigned) rdoffnum,
+													(unsigned) maxoff));
 					continue;
 				}
 				rditem = PageGetItemId(ctx.page, rdoffnum);
 				if (!ItemIdIsUsed(rditem))
-					report_corruption(&ctx,
-									  psprintf("line pointer redirection to unused item at offset %u",
-											   (unsigned) rdoffnum));
+					report_main_corruption(&ctx,
+										   psprintf("line pointer redirection to unused item at offset %u",
+													(unsigned) rdoffnum));
 				continue;
 			}
 
@@ -435,26 +435,26 @@ verify_heapam(PG_FUNCTION_ARGS)
 
 			if (ctx.lp_off != MAXALIGN(ctx.lp_off))
 			{
-				report_corruption(&ctx,
-								  psprintf("line pointer to page offset %u is not maximally aligned",
-										   ctx.lp_off));
+				report_main_corruption(&ctx,
+									   psprintf("line pointer to page offset %u is not maximally aligned",
+												ctx.lp_off));
 				continue;
 			}
 			if (ctx.lp_len < MAXALIGN(SizeofHeapTupleHeader))
 			{
-				report_corruption(&ctx,
-								  psprintf("line pointer length %u is less than the minimum tuple header size %u",
-										   ctx.lp_len,
-										   (unsigned) MAXALIGN(SizeofHeapTupleHeader)));
+				report_main_corruption(&ctx,
+									   psprintf("line pointer length %u is less than the minimum tuple header size %u",
+												ctx.lp_len,
+												(unsigned) MAXALIGN(SizeofHeapTupleHeader)));
 				continue;
 			}
 			if (ctx.lp_off + ctx.lp_len > BLCKSZ)
 			{
-				report_corruption(&ctx,
-								  psprintf("line pointer to page offset %u with length %u ends beyond maximum page offset %u",
-										   ctx.lp_off,
-										   ctx.lp_len,
-										   (unsigned) BLCKSZ));
+				report_main_corruption(&ctx,
+									   psprintf("line pointer to page offset %u with length %u ends beyond maximum page offset %u",
+												ctx.lp_off,
+												ctx.lp_len,
+												(unsigned) BLCKSZ));
 				continue;
 			}
 
@@ -517,7 +517,7 @@ sanity_check_relation(Relation rel)
  * The msg argument is pfree'd by this function.
  */
 static void
-report_corruption(HeapCheckContext *ctx, char *msg)
+report_main_corruption(HeapCheckContext *ctx, char *msg)
 {
 	Datum		values[HEAPCHECK_RELATION_COLS];
 	bool		nulls[HEAPCHECK_RELATION_COLS];
@@ -599,17 +599,17 @@ check_tuple_header(HeapCheckContext *ctx)
 
 	if (ctx->tuphdr->t_hoff > ctx->lp_len)
 	{
-		report_corruption(ctx,
-						  psprintf("data begins at offset %u beyond the tuple length %u",
-								   ctx->tuphdr->t_hoff, ctx->lp_len));
+		report_main_corruption(ctx,
+							   psprintf("data begins at offset %u beyond the tuple length %u",
+										ctx->tuphdr->t_hoff, ctx->lp_len));
 		header_garbled = true;
 	}
 
 	if ((ctx->tuphdr->t_infomask & HEAP_XMAX_COMMITTED) &&
 		(ctx->tuphdr->t_infomask & HEAP_XMAX_IS_MULTI))
 	{
-		report_corruption(ctx,
-						  pstrdup("multixact should not be marked committed"));
+		report_main_corruption(ctx,
+							   pstrdup("multixact should not be marked committed"));
 
 		/*
 		 * This condition is clearly wrong, but we do not consider the header
@@ -626,21 +626,21 @@ check_tuple_header(HeapCheckContext *ctx)
 	if (ctx->tuphdr->t_hoff != expected_hoff)
 	{
 		if ((infomask & HEAP_HASNULL) && ctx->natts == 1)
-			report_corruption(ctx,
-							  psprintf("tuple data should begin at byte %u, but actually begins at byte %u (1 attribute, has nulls)",
-									   expected_hoff, ctx->tuphdr->t_hoff));
+			report_main_corruption(ctx,
+								   psprintf("tuple data should begin at byte %u, but actually begins at byte %u (1 attribute, has nulls)",
+											expected_hoff, ctx->tuphdr->t_hoff));
 		else if ((infomask & HEAP_HASNULL))
-			report_corruption(ctx,
-							  psprintf("tuple data should begin at byte %u, but actually begins at byte %u (%u attributes, has nulls)",
-									   expected_hoff, ctx->tuphdr->t_hoff, ctx->natts));
+			report_main_corruption(ctx,
+								   psprintf("tuple data should begin at byte %u, but actually begins at byte %u (%u attributes, has nulls)",
+											expected_hoff, ctx->tuphdr->t_hoff, ctx->natts));
 		else if (ctx->natts == 1)
-			report_corruption(ctx,
-							  psprintf("tuple data should begin at byte %u, but actually begins at byte %u (1 attribute, no nulls)",
-									   expected_hoff, ctx->tuphdr->t_hoff));
+			report_main_corruption(ctx,
+								   psprintf("tuple data should begin at byte %u, but actually begins at byte %u (1 attribute, no nulls)",
+											expected_hoff, ctx->tuphdr->t_hoff));
 		else
-			report_corruption(ctx,
-							  psprintf("tuple data should begin at byte %u, but actually begins at byte %u (%u attributes, no nulls)",
-									   expected_hoff, ctx->tuphdr->t_hoff, ctx->natts));
+			report_main_corruption(ctx,
+								   psprintf("tuple data should begin at byte %u, but actually begins at byte %u (%u attributes, no nulls)",
+											expected_hoff, ctx->tuphdr->t_hoff, ctx->natts));
 		header_garbled = true;
 	}
 
@@ -702,25 +702,25 @@ check_tuple_visibility(HeapCheckContext *ctx)
 		case XID_BOUNDS_OK:
 			break;
 		case XID_IN_FUTURE:
-			report_corruption(ctx,
-							  psprintf("xmin %u equals or exceeds next valid transaction ID %u:%u",
-									   xmin,
-									   EpochFromFullTransactionId(ctx->next_fxid),
-									   XidFromFullTransactionId(ctx->next_fxid)));
+			report_main_corruption(ctx,
+								   psprintf("xmin %u equals or exceeds next valid transaction ID %u:%u",
+											xmin,
+											EpochFromFullTransactionId(ctx->next_fxid),
+											XidFromFullTransactionId(ctx->next_fxid)));
 			return false;		/* corrupt */
 		case XID_PRECEDES_CLUSTERMIN:
-			report_corruption(ctx,
-							  psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
-									   xmin,
-									   EpochFromFullTransactionId(ctx->oldest_fxid),
-									   XidFromFullTransactionId(ctx->oldest_fxid)));
+			report_main_corruption(ctx,
+								   psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
+											xmin,
+											EpochFromFullTransactionId(ctx->oldest_fxid),
+											XidFromFullTransactionId(ctx->oldest_fxid)));
 			return false;		/* corrupt */
 		case XID_PRECEDES_RELMIN:
-			report_corruption(ctx,
-							  psprintf("xmin %u precedes relation freeze threshold %u:%u",
-									   xmin,
-									   EpochFromFullTransactionId(ctx->relfrozenfxid),
-									   XidFromFullTransactionId(ctx->relfrozenfxid)));
+			report_main_corruption(ctx,
+								   psprintf("xmin %u precedes relation freeze threshold %u:%u",
+											xmin,
+											EpochFromFullTransactionId(ctx->relfrozenfxid),
+											XidFromFullTransactionId(ctx->relfrozenfxid)));
 			return false;		/* corrupt */
 	}
 
@@ -744,29 +744,29 @@ check_tuple_visibility(HeapCheckContext *ctx)
 			switch (get_xid_status(xvac, ctx, &xvac_status))
 			{
 				case XID_INVALID:
-					report_corruption(ctx,
-									  pstrdup("old-style VACUUM FULL transaction ID for moved off tuple is invalid"));
+					report_main_corruption(ctx,
+										   pstrdup("old-style VACUUM FULL transaction ID for moved off tuple is invalid"));
 					return false;	/* corrupt */
 				case XID_IN_FUTURE:
-					report_corruption(ctx,
-									  psprintf("old-style VACUUM FULL transaction ID %u for moved off tuple equals or exceeds next valid transaction ID %u:%u",
-											   xvac,
-											   EpochFromFullTransactionId(ctx->next_fxid),
-											   XidFromFullTransactionId(ctx->next_fxid)));
+					report_main_corruption(ctx,
+										   psprintf("old-style VACUUM FULL transaction ID %u for moved off tuple equals or exceeds next valid transaction ID %u:%u",
+													xvac,
+													EpochFromFullTransactionId(ctx->next_fxid),
+													XidFromFullTransactionId(ctx->next_fxid)));
 					return false;	/* corrupt */
 				case XID_PRECEDES_RELMIN:
-					report_corruption(ctx,
-									  psprintf("old-style VACUUM FULL transaction ID %u for moved off tuple precedes relation freeze threshold %u:%u",
-											   xvac,
-											   EpochFromFullTransactionId(ctx->relfrozenfxid),
-											   XidFromFullTransactionId(ctx->relfrozenfxid)));
+					report_main_corruption(ctx,
+										   psprintf("old-style VACUUM FULL transaction ID %u for moved off tuple precedes relation freeze threshold %u:%u",
+													xvac,
+													EpochFromFullTransactionId(ctx->relfrozenfxid),
+													XidFromFullTransactionId(ctx->relfrozenfxid)));
 					return false;	/* corrupt */
 				case XID_PRECEDES_CLUSTERMIN:
-					report_corruption(ctx,
-									  psprintf("old-style VACUUM FULL transaction ID %u for moved off tuple precedes oldest valid transaction ID %u:%u",
-											   xvac,
-											   EpochFromFullTransactionId(ctx->oldest_fxid),
-											   XidFromFullTransactionId(ctx->oldest_fxid)));
+					report_main_corruption(ctx,
+										   psprintf("old-style VACUUM FULL transaction ID %u for moved off tuple precedes oldest valid transaction ID %u:%u",
+													xvac,
+													EpochFromFullTransactionId(ctx->oldest_fxid),
+													XidFromFullTransactionId(ctx->oldest_fxid)));
 					return false;	/* corrupt */
 				case XID_BOUNDS_OK:
 					break;
@@ -775,14 +775,14 @@ check_tuple_visibility(HeapCheckContext *ctx)
 			switch (xvac_status)
 			{
 				case XID_IS_CURRENT_XID:
-					report_corruption(ctx,
-									  psprintf("old-style VACUUM FULL transaction ID %u for moved off tuple matches our current transaction ID",
-											   xvac));
+					report_main_corruption(ctx,
+										   psprintf("old-style VACUUM FULL transaction ID %u for moved off tuple matches our current transaction ID",
+													xvac));
 					return false;	/* corrupt */
 				case XID_IN_PROGRESS:
-					report_corruption(ctx,
-									  psprintf("old-style VACUUM FULL transaction ID %u for moved off tuple appears to be in progress",
-											   xvac));
+					report_main_corruption(ctx,
+										   psprintf("old-style VACUUM FULL transaction ID %u for moved off tuple appears to be in progress",
+													xvac));
 					return false;	/* corrupt */
 
 				case XID_COMMITTED:
@@ -810,29 +810,29 @@ check_tuple_visibility(HeapCheckContext *ctx)
 			switch (get_xid_status(xvac, ctx, &xvac_status))
 			{
 				case XID_INVALID:
-					report_corruption(ctx,
-									  pstrdup("old-style VACUUM FULL transaction ID for moved in tuple is invalid"));
+					report_main_corruption(ctx,
+										   pstrdup("old-style VACUUM FULL transaction ID for moved in tuple is invalid"));
 					return false;	/* corrupt */
 				case XID_IN_FUTURE:
-					report_corruption(ctx,
-									  psprintf("old-style VACUUM FULL transaction ID %u for moved in tuple equals or exceeds next valid transaction ID %u:%u",
-											   xvac,
-											   EpochFromFullTransactionId(ctx->next_fxid),
-											   XidFromFullTransactionId(ctx->next_fxid)));
+					report_main_corruption(ctx,
+										   psprintf("old-style VACUUM FULL transaction ID %u for moved in tuple equals or exceeds next valid transaction ID %u:%u",
+													xvac,
+													EpochFromFullTransactionId(ctx->next_fxid),
+													XidFromFullTransactionId(ctx->next_fxid)));
 					return false;	/* corrupt */
 				case XID_PRECEDES_RELMIN:
-					report_corruption(ctx,
-									  psprintf("old-style VACUUM FULL transaction ID %u for moved in tuple precedes relation freeze threshold %u:%u",
-											   xvac,
-											   EpochFromFullTransactionId(ctx->relfrozenfxid),
-											   XidFromFullTransactionId(ctx->relfrozenfxid)));
+					report_main_corruption(ctx,
+										   psprintf("old-style VACUUM FULL transaction ID %u for moved in tuple precedes relation freeze threshold %u:%u",
+													xvac,
+													EpochFromFullTransactionId(ctx->relfrozenfxid),
+													XidFromFullTransactionId(ctx->relfrozenfxid)));
 					return false;	/* corrupt */
 				case XID_PRECEDES_CLUSTERMIN:
-					report_corruption(ctx,
-									  psprintf("old-style VACUUM FULL transaction ID %u for moved in tuple precedes oldest valid transaction ID %u:%u",
-											   xvac,
-											   EpochFromFullTransactionId(ctx->oldest_fxid),
-											   XidFromFullTransactionId(ctx->oldest_fxid)));
+					report_main_corruption(ctx,
+										   psprintf("old-style VACUUM FULL transaction ID %u for moved in tuple precedes oldest valid transaction ID %u:%u",
+													xvac,
+													EpochFromFullTransactionId(ctx->oldest_fxid),
+													XidFromFullTransactionId(ctx->oldest_fxid)));
 					return false;	/* corrupt */
 				case XID_BOUNDS_OK:
 					break;
@@ -841,14 +841,14 @@ check_tuple_visibility(HeapCheckContext *ctx)
 			switch (xvac_status)
 			{
 				case XID_IS_CURRENT_XID:
-					report_corruption(ctx,
-									  psprintf("old-style VACUUM FULL transaction ID %u for moved in tuple matches our current transaction ID",
-											   xvac));
+					report_main_corruption(ctx,
+										   psprintf("old-style VACUUM FULL transaction ID %u for moved in tuple matches our current transaction ID",
+													xvac));
 					return false;	/* corrupt */
 				case XID_IN_PROGRESS:
-					report_corruption(ctx,
-									  psprintf("old-style VACUUM FULL transaction ID %u for moved in tuple appears to be in progress",
-											   xvac));
+					report_main_corruption(ctx,
+										   psprintf("old-style VACUUM FULL transaction ID %u for moved in tuple appears to be in progress",
+													xvac));
 					return false;	/* corrupt */
 
 				case XID_COMMITTED:
@@ -904,24 +904,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
 		switch (check_mxid_valid_in_rel(xmax, ctx))
 		{
 			case XID_INVALID:
-				report_corruption(ctx,
-								  pstrdup("multitransaction ID is invalid"));
+				report_main_corruption(ctx,
+									   pstrdup("multitransaction ID is invalid"));
 				return false;	/* corrupt */
 			case XID_PRECEDES_RELMIN:
-				report_corruption(ctx,
-								  psprintf("multitransaction ID %u precedes relation minimum multitransaction ID threshold %u",
-										   xmax, ctx->relminmxid));
+				report_main_corruption(ctx,
+									   psprintf("multitransaction ID %u precedes relation minimum multitransaction ID threshold %u",
+												xmax, ctx->relminmxid));
 				return false;	/* corrupt */
 			case XID_PRECEDES_CLUSTERMIN:
-				report_corruption(ctx,
-								  psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
-										   xmax, ctx->oldest_mxact));
+				report_main_corruption(ctx,
+									   psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
+												xmax, ctx->oldest_mxact));
 				return false;	/* corrupt */
 			case XID_IN_FUTURE:
-				report_corruption(ctx,
-								  psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
-										   xmax,
-										   ctx->next_mxact));
+				report_main_corruption(ctx,
+									   psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
+												xmax,
+												ctx->next_mxact));
 				return false;	/* corrupt */
 			case XID_BOUNDS_OK:
 				break;
@@ -962,29 +962,29 @@ check_tuple_visibility(HeapCheckContext *ctx)
 		{
 				/* not LOCKED_ONLY, so it has to have an xmax */
 			case XID_INVALID:
-				report_corruption(ctx,
-								  pstrdup("update xid is invalid"));
+				report_main_corruption(ctx,
+									   pstrdup("update xid is invalid"));
 				return false;	/* corrupt */
 			case XID_IN_FUTURE:
-				report_corruption(ctx,
-								  psprintf("update xid %u equals or exceeds next valid transaction ID %u:%u",
-										   xmax,
-										   EpochFromFullTransactionId(ctx->next_fxid),
-										   XidFromFullTransactionId(ctx->next_fxid)));
+				report_main_corruption(ctx,
+									   psprintf("update xid %u equals or exceeds next valid transaction ID %u:%u",
+												xmax,
+												EpochFromFullTransactionId(ctx->next_fxid),
+												XidFromFullTransactionId(ctx->next_fxid)));
 				return false;	/* corrupt */
 			case XID_PRECEDES_RELMIN:
-				report_corruption(ctx,
-								  psprintf("update xid %u precedes relation freeze threshold %u:%u",
-										   xmax,
-										   EpochFromFullTransactionId(ctx->relfrozenfxid),
-										   XidFromFullTransactionId(ctx->relfrozenfxid)));
+				report_main_corruption(ctx,
+									   psprintf("update xid %u precedes relation freeze threshold %u:%u",
+												xmax,
+												EpochFromFullTransactionId(ctx->relfrozenfxid),
+												XidFromFullTransactionId(ctx->relfrozenfxid)));
 				return false;	/* corrupt */
 			case XID_PRECEDES_CLUSTERMIN:
-				report_corruption(ctx,
-								  psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
-										   xmax,
-										   EpochFromFullTransactionId(ctx->oldest_fxid),
-										   XidFromFullTransactionId(ctx->oldest_fxid)));
+				report_main_corruption(ctx,
+									   psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
+												xmax,
+												EpochFromFullTransactionId(ctx->oldest_fxid),
+												XidFromFullTransactionId(ctx->oldest_fxid)));
 				return false;	/* corrupt */
 			case XID_BOUNDS_OK:
 				break;
@@ -1029,25 +1029,25 @@ check_tuple_visibility(HeapCheckContext *ctx)
 	switch (get_xid_status(xmax, ctx, &xmax_status))
 	{
 		case XID_IN_FUTURE:
-			report_corruption(ctx,
-							  psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
-									   xmax,
-									   EpochFromFullTransactionId(ctx->next_fxid),
-									   XidFromFullTransactionId(ctx->next_fxid)));
+			report_main_corruption(ctx,
+								   psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
+											xmax,
+											EpochFromFullTransactionId(ctx->next_fxid),
+											XidFromFullTransactionId(ctx->next_fxid)));
 			return false;		/* corrupt */
 		case XID_PRECEDES_RELMIN:
-			report_corruption(ctx,
-							  psprintf("xmax %u precedes relation freeze threshold %u:%u",
-									   xmax,
-									   EpochFromFullTransactionId(ctx->relfrozenfxid),
-									   XidFromFullTransactionId(ctx->relfrozenfxid)));
+			report_main_corruption(ctx,
+								   psprintf("xmax %u precedes relation freeze threshold %u:%u",
+											xmax,
+											EpochFromFullTransactionId(ctx->relfrozenfxid),
+											XidFromFullTransactionId(ctx->relfrozenfxid)));
 			return false;		/* corrupt */
 		case XID_PRECEDES_CLUSTERMIN:
-			report_corruption(ctx,
-							  psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
-									   xmax,
-									   EpochFromFullTransactionId(ctx->oldest_fxid),
-									   XidFromFullTransactionId(ctx->oldest_fxid)));
+			report_main_corruption(ctx,
+								   psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
+											xmax,
+											EpochFromFullTransactionId(ctx->oldest_fxid),
+											XidFromFullTransactionId(ctx->oldest_fxid)));
 			return false;		/* corrupt */
 		case XID_BOUNDS_OK:
 		case XID_INVALID:
@@ -1114,16 +1114,16 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContext *ctx)
 										 ctx->toast_rel->rd_att, &isnull));
 	if (isnull)
 	{
-		report_corruption(ctx,
-						  pstrdup("toast chunk sequence number is null"));
+		report_main_corruption(ctx,
+							   pstrdup("toast chunk sequence number is null"));
 		return;
 	}
 	chunk = DatumGetPointer(fastgetattr(toasttup, 3,
 										ctx->toast_rel->rd_att, &isnull));
 	if (isnull)
 	{
-		report_corruption(ctx,
-						  pstrdup("toast chunk data is null"));
+		report_main_corruption(ctx,
+							   pstrdup("toast chunk data is null"));
 		return;
 	}
 	if (!VARATT_IS_EXTENDED(chunk))
@@ -1140,9 +1140,9 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContext *ctx)
 		/* should never happen */
 		uint32		header = ((varattrib_4b *) chunk)->va_4byte.va_header;
 
-		report_corruption(ctx,
-						  psprintf("corrupt extended toast chunk has invalid varlena header: %0x (sequence number %d)",
-								   header, curchunk));
+		report_main_corruption(ctx,
+							   psprintf("corrupt extended toast chunk has invalid varlena header: %0x (sequence number %d)",
+										header, curchunk));
 		return;
 	}
 
@@ -1151,16 +1151,16 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContext *ctx)
 	 */
 	if (curchunk != ctx->chunkno)
 	{
-		report_corruption(ctx,
-						  psprintf("toast chunk sequence number %u does not match the expected sequence number %u",
-								   curchunk, ctx->chunkno));
+		report_main_corruption(ctx,
+							   psprintf("toast chunk sequence number %u does not match the expected sequence number %u",
+										curchunk, ctx->chunkno));
 		return;
 	}
 	if (curchunk > ctx->endchunk)
 	{
-		report_corruption(ctx,
-						  psprintf("toast chunk sequence number %u exceeds the end chunk sequence number %u",
-								   curchunk, ctx->endchunk));
+		report_main_corruption(ctx,
+							   psprintf("toast chunk sequence number %u exceeds the end chunk sequence number %u",
+										curchunk, ctx->endchunk));
 		return;
 	}
 
@@ -1168,9 +1168,9 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContext *ctx)
 		: ctx->attrsize - ((ctx->totalchunks - 1) * TOAST_MAX_CHUNK_SIZE);
 	if (chunksize != expected_size)
 	{
-		report_corruption(ctx,
-						  psprintf("toast chunk size %u differs from the expected size %u",
-								   chunksize, expected_size));
+		report_main_corruption(ctx,
+							   psprintf("toast chunk size %u differs from the expected size %u",
+										chunksize, expected_size));
 		return;
 	}
 }
@@ -1217,12 +1217,12 @@ check_tuple_attribute(HeapCheckContext *ctx)
 
 	if (ctx->tuphdr->t_hoff + ctx->offset > ctx->lp_len)
 	{
-		report_corruption(ctx,
-						  psprintf("attribute %u with length %u starts at offset %u beyond total tuple length %u",
-								   ctx->attnum,
-								   thisatt->attlen,
-								   ctx->tuphdr->t_hoff + ctx->offset,
-								   ctx->lp_len));
+		report_main_corruption(ctx,
+							   psprintf("attribute %u with length %u starts at offset %u beyond total tuple length %u",
+										ctx->attnum,
+										thisatt->attlen,
+										ctx->tuphdr->t_hoff + ctx->offset,
+										ctx->lp_len));
 		return false;
 	}
 
@@ -1238,12 +1238,12 @@ check_tuple_attribute(HeapCheckContext *ctx)
 											tp + ctx->offset);
 		if (ctx->tuphdr->t_hoff + ctx->offset > ctx->lp_len)
 		{
-			report_corruption(ctx,
-							  psprintf("attribute %u with length %u ends at offset %u beyond total tuple length %u",
-									   ctx->attnum,
-									   thisatt->attlen,
-									   ctx->tuphdr->t_hoff + ctx->offset,
-									   ctx->lp_len));
+			report_main_corruption(ctx,
+								   psprintf("attribute %u with length %u ends at offset %u beyond total tuple length %u",
+											ctx->attnum,
+											thisatt->attlen,
+											ctx->tuphdr->t_hoff + ctx->offset,
+											ctx->lp_len));
 			return false;
 		}
 		return true;
@@ -1271,10 +1271,10 @@ check_tuple_attribute(HeapCheckContext *ctx)
 
 		if (va_tag != VARTAG_ONDISK)
 		{
-			report_corruption(ctx,
-							  psprintf("toasted attribute %u has unexpected TOAST tag %u",
-									   ctx->attnum,
-									   va_tag));
+			report_main_corruption(ctx,
+								   psprintf("toasted attribute %u has unexpected TOAST tag %u",
+											ctx->attnum,
+											va_tag));
 			/* We can't know where the next attribute begins */
 			return false;
 		}
@@ -1286,12 +1286,12 @@ check_tuple_attribute(HeapCheckContext *ctx)
 
 	if (ctx->tuphdr->t_hoff + ctx->offset > ctx->lp_len)
 	{
-		report_corruption(ctx,
-						  psprintf("attribute %u with length %u ends at offset %u beyond total tuple length %u",
-								   ctx->attnum,
-								   thisatt->attlen,
-								   ctx->tuphdr->t_hoff + ctx->offset,
-								   ctx->lp_len));
+		report_main_corruption(ctx,
+							   psprintf("attribute %u with length %u ends at offset %u beyond total tuple length %u",
+										ctx->attnum,
+										thisatt->attlen,
+										ctx->tuphdr->t_hoff + ctx->offset,
+										ctx->lp_len));
 
 		return false;
 	}
@@ -1318,18 +1318,18 @@ check_tuple_attribute(HeapCheckContext *ctx)
 	/* The tuple header better claim to contain toasted values */
 	if (!(infomask & HEAP_HASEXTERNAL))
 	{
-		report_corruption(ctx,
-						  psprintf("attribute %u is external but tuple header flag HEAP_HASEXTERNAL not set",
-								   ctx->attnum));
+		report_main_corruption(ctx,
+							   psprintf("attribute %u is external but tuple header flag HEAP_HASEXTERNAL not set",
+										ctx->attnum));
 		return true;
 	}
 
 	/* The relation better have a toast table */
 	if (!ctx->rel->rd_rel->reltoastrelid)
 	{
-		report_corruption(ctx,
-						  psprintf("attribute %u is external but relation has no toast relation",
-								   ctx->attnum));
+		report_main_corruption(ctx,
+							   psprintf("attribute %u is external but relation has no toast relation",
+										ctx->attnum));
 		return true;
 	}
 
@@ -1374,13 +1374,13 @@ check_tuple_attribute(HeapCheckContext *ctx)
 		ctx->chunkno++;
 	}
 	if (!found_toasttup)
-		report_corruption(ctx,
-						  psprintf("toasted value for attribute %u missing from toast table",
-								   ctx->attnum));
+		report_main_corruption(ctx,
+							   psprintf("toasted value for attribute %u missing from toast table",
+										ctx->attnum));
 	else if (ctx->chunkno != (ctx->endchunk + 1))
-		report_corruption(ctx,
-						  psprintf("final toast chunk number %u differs from expected value %u",
-								   ctx->chunkno, (ctx->endchunk + 1)));
+		report_main_corruption(ctx,
+							   psprintf("final toast chunk number %u differs from expected value %u",
+										ctx->chunkno, (ctx->endchunk + 1)));
 	systable_endscan_ordered(toastscan);
 
 	return true;
@@ -1406,27 +1406,27 @@ check_tuple(HeapCheckContext *ctx)
 		case XID_BOUNDS_OK:
 			break;
 		case XID_IN_FUTURE:
-			report_corruption(ctx,
-							  psprintf("xmin %u equals or exceeds next valid transaction ID %u:%u",
-									   xmin,
-									   EpochFromFullTransactionId(ctx->next_fxid),
-									   XidFromFullTransactionId(ctx->next_fxid)));
+			report_main_corruption(ctx,
+								   psprintf("xmin %u equals or exceeds next valid transaction ID %u:%u",
+											xmin,
+											EpochFromFullTransactionId(ctx->next_fxid),
+											XidFromFullTransactionId(ctx->next_fxid)));
 			fatal = true;
 			break;
 		case XID_PRECEDES_CLUSTERMIN:
-			report_corruption(ctx,
-							  psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
-									   xmin,
-									   EpochFromFullTransactionId(ctx->oldest_fxid),
-									   XidFromFullTransactionId(ctx->oldest_fxid)));
+			report_main_corruption(ctx,
+								   psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
+											xmin,
+											EpochFromFullTransactionId(ctx->oldest_fxid),
+											XidFromFullTransactionId(ctx->oldest_fxid)));
 			fatal = true;
 			break;
 		case XID_PRECEDES_RELMIN:
-			report_corruption(ctx,
-							  psprintf("xmin %u precedes relation freeze threshold %u:%u",
-									   xmin,
-									   EpochFromFullTransactionId(ctx->relfrozenfxid),
-									   XidFromFullTransactionId(ctx->relfrozenfxid)));
+			report_main_corruption(ctx,
+								   psprintf("xmin %u precedes relation freeze threshold %u:%u",
+											xmin,
+											EpochFromFullTransactionId(ctx->relfrozenfxid),
+											XidFromFullTransactionId(ctx->relfrozenfxid)));
 			fatal = true;
 			break;
 	}
@@ -1439,27 +1439,27 @@ check_tuple(HeapCheckContext *ctx)
 		switch (check_mxid_valid_in_rel(xmax, ctx))
 		{
 			case XID_INVALID:
-				report_corruption(ctx,
-								  pstrdup("multitransaction ID is invalid"));
+				report_main_corruption(ctx,
+									   pstrdup("multitransaction ID is invalid"));
 				fatal = true;
 				break;
 			case XID_PRECEDES_RELMIN:
-				report_corruption(ctx,
-								  psprintf("multitransaction ID %u precedes relation minimum multitransaction ID threshold %u",
-										   xmax, ctx->relminmxid));
+				report_main_corruption(ctx,
+									   psprintf("multitransaction ID %u precedes relation minimum multitransaction ID threshold %u",
+												xmax, ctx->relminmxid));
 				fatal = true;
 				break;
 			case XID_PRECEDES_CLUSTERMIN:
-				report_corruption(ctx,
-								  psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
-										   xmax, ctx->oldest_mxact));
+				report_main_corruption(ctx,
+									   psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
+												xmax, ctx->oldest_mxact));
 				fatal = true;
 				break;
 			case XID_IN_FUTURE:
-				report_corruption(ctx,
-								  psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
-										   xmax,
-										   ctx->next_mxact));
+				report_main_corruption(ctx,
+									   psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
+												xmax,
+												ctx->next_mxact));
 				fatal = true;
 				break;
 			case XID_BOUNDS_OK:
@@ -1478,27 +1478,27 @@ check_tuple(HeapCheckContext *ctx)
 			case XID_BOUNDS_OK:
 				break;
 			case XID_IN_FUTURE:
-				report_corruption(ctx,
-								  psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
-										   xmax,
-										   EpochFromFullTransactionId(ctx->next_fxid),
-										   XidFromFullTransactionId(ctx->next_fxid)));
+				report_main_corruption(ctx,
+									   psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
+												xmax,
+												EpochFromFullTransactionId(ctx->next_fxid),
+												XidFromFullTransactionId(ctx->next_fxid)));
 				fatal = true;
 				break;
 			case XID_PRECEDES_CLUSTERMIN:
-				report_corruption(ctx,
-								  psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
-										   xmax,
-										   EpochFromFullTransactionId(ctx->oldest_fxid),
-										   XidFromFullTransactionId(ctx->oldest_fxid)));
+				report_main_corruption(ctx,
+									   psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
+												xmax,
+												EpochFromFullTransactionId(ctx->oldest_fxid),
+												XidFromFullTransactionId(ctx->oldest_fxid)));
 				fatal = true;
 				break;
 			case XID_PRECEDES_RELMIN:
-				report_corruption(ctx,
-								  psprintf("xmax %u precedes relation freeze threshold %u:%u",
-										   xmax,
-										   EpochFromFullTransactionId(ctx->relfrozenfxid),
-										   XidFromFullTransactionId(ctx->relfrozenfxid)));
+				report_main_corruption(ctx,
+									   psprintf("xmax %u precedes relation freeze threshold %u:%u",
+												xmax,
+												EpochFromFullTransactionId(ctx->relfrozenfxid),
+												XidFromFullTransactionId(ctx->relfrozenfxid)));
 				fatal = true;
 		}
 	}
@@ -1533,10 +1533,10 @@ check_tuple(HeapCheckContext *ctx)
 	 */
 	if (RelationGetDescr(ctx->rel)->natts < ctx->natts)
 	{
-		report_corruption(ctx,
-						  psprintf("number of attributes %u exceeds maximum expected for table %u",
-								   ctx->natts,
-								   RelationGetDescr(ctx->rel)->natts));
+		report_main_corruption(ctx,
+							   psprintf("number of attributes %u exceeds maximum expected for table %u",
+										ctx->natts,
+										RelationGetDescr(ctx->rel)->natts));
 		return;
 	}
 
-- 
2.21.1 (Apple Git-122.3)

