0001-Simplify-hash_xlog_split_allocate_page.patch.nocfbot

text/plain

Filename: 0001-Simplify-hash_xlog_split_allocate_page.patch.nocfbot
Type: text/plain
Part: 0
Message: Re: Remove useless casting to the same type
From 01d999144692ce3af845882bbe32754f260281fb Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Fri, 28 Nov 2025 09:05:48 +0100
Subject: [PATCH] Simplify hash_xlog_split_allocate_page()

---
 src/backend/access/hash/hash_xlog.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/src/backend/access/hash/hash_xlog.c b/src/backend/access/hash/hash_xlog.c
index 2a0145f3c9b..fa6b80d3a83 100644
--- a/src/backend/access/hash/hash_xlog.c
+++ b/src/backend/access/hash/hash_xlog.c
@@ -314,8 +314,6 @@ hash_xlog_split_allocate_page(XLogReaderState *record)
 	Buffer		oldbuf;
 	Buffer		newbuf;
 	Buffer		metabuf;
-	Size		datalen PG_USED_FOR_ASSERTS_ONLY;
-	char	   *data;
 	XLogRedoAction action;
 
 	/*
@@ -375,6 +373,8 @@ hash_xlog_split_allocate_page(XLogReaderState *record)
 	{
 		Page		page;
 		HashMetaPage metap;
+		Size		datalen;
+		char	   *data;
 
 		page = BufferGetPage(metabuf);
 		metap = HashPageGetMeta(page);
@@ -384,31 +384,23 @@ hash_xlog_split_allocate_page(XLogReaderState *record)
 
 		if (xlrec->flags & XLH_SPLIT_META_UPDATE_MASKS)
 		{
-			uint32		lowmask;
-			uint32	   *highmask;
-
-			/* extract low and high masks. */
-			memcpy(&lowmask, data, sizeof(uint32));
-			highmask = (uint32 *) ((char *) data + sizeof(uint32));
+			uint32	   *mask_data = (uint32 *) data;
+			uint32		lowmask = mask_data[0];
+			uint32		highmask = mask_data[1];
 
 			/* update metapage */
 			metap->hashm_lowmask = lowmask;
-			metap->hashm_highmask = *highmask;
-
-			data += sizeof(uint32) * 2;
+			metap->hashm_highmask = highmask;
 		}
 
 		if (xlrec->flags & XLH_SPLIT_META_UPDATE_SPLITPOINT)
 		{
-			uint32		ovflpoint;
-			uint32	   *ovflpages;
-
-			/* extract information of overflow pages. */
-			memcpy(&ovflpoint, data, sizeof(uint32));
-			ovflpages = (uint32 *) ((char *) data + sizeof(uint32));
+			uint32	   *ovfl_data = (uint32 *) data;
+			uint32		ovflpoint = ovfl_data[0];
+			uint32		ovflpages = ovfl_data[1];
 
 			/* update metapage */
-			metap->hashm_spares[ovflpoint] = *ovflpages;
+			metap->hashm_spares[ovflpoint] = ovflpages;
 			metap->hashm_ovflpoint = ovflpoint;
 		}
 
-- 
2.52.0