Hi,

On Thu, Jan 29, 2026 at 06:45:12PM +0100, Álvaro Herrera wrote:
> On 2025-Nov-17, Bertrand Drouvot wrote:
> 
> > On Mon, Nov 17, 2025 at 01:12:24PM +0000, Bertrand Drouvot wrote:
> > > The script has been updated and the patch too (finding a new replacement 
> > > in
> > > gist.c).
> > 
> > Finally, adding GistNSN to the game (as a typedef XLogRecPtr) gives the 
> > attached.
> 
> I've pushed this.

Thanks!

I just looked at the cocci script used for that and realized (with more 
Coccinelle
practice) that it could be simplified. It's done in [1], and lead to a few more
cases discovered and fixed in the attached. I think that, with the attached, we
cover them all.

[1]: 
https://github.com/bdrouvot/coccinelle_on_pg/blob/main/replace_literal_0_assignement_with_InvalidXLogRecPtr.cocci

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
>From 8e2cb3e2d72553daa6381010ba70da3b1252994f Mon Sep 17 00:00:00 2001
From: Bertrand Drouvot <[email protected]>
Date: Fri, 30 Jan 2026 07:50:36 +0000
Subject: [PATCH v1] Fix other cases of literal 0 instead of InvalidXLogRecPtr
 assignment

Those ones were missed in ec317440716.

Author: Bertrand Drouvot <[email protected]>
Discussion: https://postgr.es/m/[email protected]
---
 src/backend/access/transam/xact.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
 100.0% src/backend/access/transam/

diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index eba4f063168..7e3dc3f9386 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1573,7 +1573,7 @@ RecordTransactionCommit(void)
 	XactLastCommitEnd = XactLastRecEnd;
 
 	/* Reset XactLastRecEnd until the next transaction writes something */
-	XactLastRecEnd = 0;
+	XactLastRecEnd = InvalidXLogRecPtr;
 cleanup:
 	/* Clean up local data */
 	if (rels)
@@ -1787,7 +1787,7 @@ RecordTransactionAbort(bool isSubXact)
 	{
 		/* Reset XactLastRecEnd until the next transaction writes something */
 		if (!isSubXact)
-			XactLastRecEnd = 0;
+			XactLastRecEnd = InvalidXLogRecPtr;
 		return InvalidTransactionId;
 	}
 
@@ -1879,7 +1879,7 @@ RecordTransactionAbort(bool isSubXact)
 
 	/* Reset XactLastRecEnd until the next transaction writes something */
 	if (!isSubXact)
-		XactLastRecEnd = 0;
+		XactLastRecEnd = InvalidXLogRecPtr;
 
 	/* And clean up local data */
 	if (rels)
@@ -2701,7 +2701,7 @@ PrepareTransaction(void)
 	 */
 
 	/* Reset XactLastRecEnd until the next transaction writes something */
-	XactLastRecEnd = 0;
+	XactLastRecEnd = InvalidXLogRecPtr;
 
 	/*
 	 * Transfer our locks to a dummy PGPROC.  This has to be done before
-- 
2.34.1

Reply via email to