I've updated the patch to make verify_compact_attribute a no-op.

The extension sets USE_ASSERT_CHECKING, which is why the macro approach
doesn't work (it won't take that path).

Also, it looks like it fails when creating the extension / loading the
shared library (on Ubuntu), not when linking (as I misstated earlier).
From 90aab02fd882b0fd7fb8df96c80022bf64a720c5 Mon Sep 17 00:00:00 2001
From: Andrew Kane <andrew@ankane.org>
Date: Fri, 10 Jan 2025 15:41:42 -0800
Subject: [PATCH v2] Restore support for USE_ASSERT_CHECKING in extensions only

---
 src/backend/access/common/tupdesc.c | 5 ++---
 src/include/access/tupdesc.h        | 2 --
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index cc94074219..2e4666c469 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -118,7 +118,6 @@ populate_compact_attribute(TupleDesc tupdesc, int attnum)
 	populate_compact_attribute_internal(src, dst);
 }
 
-#ifdef USE_ASSERT_CHECKING
 /*
  * verify_compact_attribute
  *		In Assert enabled builds, we verify that the CompactAttribute is
@@ -132,6 +131,7 @@ populate_compact_attribute(TupleDesc tupdesc, int attnum)
 void
 verify_compact_attribute(TupleDesc tupdesc, int attnum)
 {
+#ifdef USE_ASSERT_CHECKING
 	CompactAttribute *cattr = &tupdesc->compact_attrs[attnum];
 	Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum);
 	CompactAttribute tmp;
@@ -150,9 +150,8 @@ verify_compact_attribute(TupleDesc tupdesc, int attnum)
 
 	/* Check the freshly populated CompactAttribute matches the TupleDesc's */
 	Assert(memcmp(&tmp, cattr, sizeof(CompactAttribute)) == 0);
-}
 #endif
-
+}
 
 /*
  * CreateTemplateTupleDesc
diff --git a/src/include/access/tupdesc.h b/src/include/access/tupdesc.h
index aee871b0e8..504ce22250 100644
--- a/src/include/access/tupdesc.h
+++ b/src/include/access/tupdesc.h
@@ -158,9 +158,7 @@ TupleDescAttr(TupleDesc tupdesc, int i)
 
 #undef TupleDescAttrAddress
 
-#ifdef USE_ASSERT_CHECKING
 extern void verify_compact_attribute(TupleDesc, int attnum);
-#endif
 
 /*
  * Accessor for the i'th CompactAttribute element of tupdesc.
-- 
2.45.0

Reply via email to