From ae02bbecfcdae29b80eda106b350d97048bc9dca Mon Sep 17 00:00:00 2001
From: Melanie Plageman <melanieplageman@gmail.com>
Date: Fri, 27 Sep 2024 15:51:07 -0400
Subject: [PATCH 1/2] Example use of union in TableScanDescData

For scan type-specific members of the TableScanDescData, we could store
them like this to reduce overhead.

This is just an example since bitmap table scan on master doesn't yet
need the TBMIterator
---
 src/include/access/relscan.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/include/access/relscan.h b/src/include/access/relscan.h
index 114a85dc47..eacdf44d80 100644
--- a/src/include/access/relscan.h
+++ b/src/include/access/relscan.h
@@ -16,6 +16,7 @@
 
 #include "access/htup_details.h"
 #include "access/itup.h"
+#include "nodes/tidbitmap.h"
 #include "port/atomics.h"
 #include "storage/buf.h"
 #include "storage/relfilelocator.h"
@@ -38,8 +39,14 @@ typedef struct TableScanDescData
 	struct ScanKeyData *rs_key; /* array of scan key descriptors */
 
 	/* Range of ItemPointers for table_scan_getnextslot_tidrange() to scan. */
-	ItemPointerData rs_mintid;
-	ItemPointerData rs_maxtid;
+	union {
+		struct {
+			ItemPointerData rs_mintid;
+			ItemPointerData rs_maxtid;
+		};
+
+		TBMIterator *iterator;
+	};
 
 	/*
 	 * Information about type and behaviour of the scan, a bitmask of members
-- 
2.45.2

