0002-Convert-macros-to-static-inline-functions-clog.c.patch
application/octet-stream
Filename: 0002-Convert-macros-to-static-inline-functions-clog.c.patch
Type: application/octet-stream
Part: 1
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0002
Subject: Convert macros to static inline functions (clog.c)
| File | + | − |
|---|---|---|
| src/backend/access/transam/clog.c | 23 | 5 |
From 4a11ee36b552cbc7c13f039f4ed439b0efe2c1a7 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <orlovmg@gmail.com>
Date: Fri, 27 Feb 2026 14:47:03 +0300
Subject: [PATCH 2/3] Convert macros to static inline functions (clog.c)
This commit refactors the code as a step to FullTransactionId in clog.
---
src/backend/access/transam/clog.c | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index b5c38bbb16..3de650a18d 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -84,16 +84,34 @@ TransactionIdToPage(TransactionId xid)
return xid / (int64) CLOG_XACTS_PER_PAGE;
}
-#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
-#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
-#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
+static inline int
+TransactionIdToPgIndex(TransactionId xid)
+{
+ return xid % (TransactionId) CLOG_XACTS_PER_PAGE;
+}
+
+static inline int
+TransactionIdToByte(TransactionId xid)
+{
+ return TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE;
+}
+
+static inline int
+TransactionIdToBIndex(TransactionId xid)
+{
+ return xid % (TransactionId) CLOG_XACTS_PER_BYTE;
+}
/* We store the latest async LSN for each group of transactions */
#define CLOG_XACTS_PER_LSN_GROUP 32 /* keep this a power of 2 */
#define CLOG_LSNS_PER_PAGE (CLOG_XACTS_PER_PAGE / CLOG_XACTS_PER_LSN_GROUP)
-#define GetLSNIndex(slotno, xid) ((slotno) * CLOG_LSNS_PER_PAGE + \
- ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE) / CLOG_XACTS_PER_LSN_GROUP)
+static inline int
+GetLSNIndex(int slotno, TransactionId xid)
+{
+ return slotno * CLOG_LSNS_PER_PAGE +
+ TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_LSN_GROUP;
+}
/*
* The number of subtransactions below which we consider to apply clog group
--
2.43.0