From a60e3cb4911911fff968eadb4e0f318c2edd1dbb Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Thu, 12 Mar 2026 14:40:25 +0200 Subject: [PATCH 3/4] XXX: a few more places that maybe need clearing? I spotted these by doing 'pahole bin/postgres', and searching for "xl_*" structs that have padding in them. Then I searched where they're initialized. --- src/backend/access/hash/hashinsert.c | 2 ++ src/backend/access/heap/heapam.c | 6 ++++++ src/backend/access/heap/rewriteheap.c | 2 ++ src/backend/access/transam/twophase.c | 2 ++ src/backend/commands/tablecmds.c | 2 ++ src/backend/replication/logical/message.c | 2 ++ 6 files changed, 16 insertions(+) diff --git a/src/backend/access/hash/hashinsert.c b/src/backend/access/hash/hashinsert.c index 0cefbacc96e..45e613ceddb 100644 --- a/src/backend/access/hash/hashinsert.c +++ b/src/backend/access/hash/hashinsert.c @@ -426,6 +426,8 @@ _hash_vacuum_one_page(Relation rel, Relation hrel, Buffer metabuf, Buffer buf) xl_hash_vacuum_one_page xlrec; XLogRecPtr recptr; + /* XXX: clear padding? */ + xlrec.isCatalogRel = RelationIsAccessibleInLogicalDecoding(hrel); xlrec.snapshotConflictHorizon = snapshotConflictHorizon; xlrec.ntuples = ndeletable; diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index b11dba81aef..54943be6126 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -2616,6 +2616,12 @@ heap_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples, xlrec = (xl_heap_multi_insert *) scratchptr; scratchptr += SizeOfHeapMultiInsert; + /* + * XXX: need to clear padding in xl_heap_multi_insert? The scratch + * area was zeroed at the top of the function, but we're reusing + * it for multiple records. + */ + /* * Allocate offsets array. Unless we're reinitializing the page, * in that case the tuples are stored in order starting at diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index 6b19ac3030d..b6d784572ec 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -842,6 +842,8 @@ logical_heap_rewrite_flush_mappings(RewriteState state) else dboid = MyDatabaseId; + /* XXX: clear padding? */ + xlrec.num_mappings = num_mappings; xlrec.mapped_rel = RelationGetRelid(state->rs_old_rel); xlrec.mapped_xid = src->xid; diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index 55b9f38927d..c22ab93965e 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -1076,6 +1076,8 @@ StartPrepare(GlobalTransaction gxact) records.total_len = 0; + /* XXX: Clear padding? */ + /* Create header */ hdr.magic = TWOPHASE_MAGIC; hdr.total_len = 0; /* EndPrepare will fill this in */ diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index a7c32679b22..1bf59f77ae1 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -2325,6 +2325,8 @@ ExecuteTruncateGuts(List *explicit_rels, foreach(cell, relids_logged) logrelids[i++] = lfirst_oid(cell); + /* XXX: clear padding? */ + xlrec.dbId = MyDatabaseId; xlrec.nrelids = list_length(relids_logged); xlrec.flags = 0; diff --git a/src/backend/replication/logical/message.c b/src/backend/replication/logical/message.c index 06825d66e7f..40d032a4ffc 100644 --- a/src/backend/replication/logical/message.c +++ b/src/backend/replication/logical/message.c @@ -55,6 +55,8 @@ LogLogicalMessage(const char *prefix, const char *message, size_t size, GetCurrentTransactionId(); } + /* XXX: clear padding? */ + xlrec.dbId = MyDatabaseId; xlrec.transactional = transactional; /* trailing zero is critical; see logicalmsg_desc */ -- 2.47.3