From a8ff4aba915a2f99a51883405589b3160264e622 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Wed, 26 Jul 2023 16:26:33 +0300
Subject: [PATCH v3 2/2] Replace ReorderBufferTupleBufData() macro with a
 function

This adds a bit more type sefety without any likely impact to the performance.

Aleksander Alekseev, reviewed by TODO FIXME
Discussion: https://postgr.es/m/CAD21AoCvnuxiXXfRecp7g9+CeC35POQfhuQeJFr7_9u_Q5jc_Q@mail.gmail.com
---
 src/backend/replication/logical/reorderbuffer.c | 10 ++++++++++
 src/include/replication/reorderbuffer.h         |  4 ----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 47913184e1..70796ad4f3 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -462,6 +462,16 @@ ReorderBufferReturnTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
 	pfree(txn);
 }
 
+/*
+ * Pointer to the data stored in a TupleBuf.
+ * Implemented as an inlined function for type safety.
+ */
+inline static HeapTupleHeader
+ReorderBufferTupleBufData(ReorderBufferTupleBuf* p)
+{
+	return (HeapTupleHeader) MAXALIGN(((char *) p) + sizeof(ReorderBufferTupleBuf));
+}
+
 /*
  * Get a fresh ReorderBufferChange.
  */
diff --git a/src/include/replication/reorderbuffer.h b/src/include/replication/reorderbuffer.h
index baa3442a35..c97c18109a 100644
--- a/src/include/replication/reorderbuffer.h
+++ b/src/include/replication/reorderbuffer.h
@@ -37,10 +37,6 @@ typedef struct ReorderBufferTupleBuf
 	/* actual tuple data follows */
 } ReorderBufferTupleBuf;
 
-/* pointer to the data stored in a TupleBuf */
-#define ReorderBufferTupleBufData(p) \
-	((HeapTupleHeader) MAXALIGN(((char *) p) + sizeof(ReorderBufferTupleBuf)))
-
 /*
  * Types of the change passed to a 'change' callback.
  *
-- 
2.41.0

