From 543c4bccd37da82a12b44b09ffa730935217fa5f Mon Sep 17 00:00:00 2001
From: Shveta Malik <shveta.malik@gmail.com>
Date: Tue, 13 Oct 2026 09:17:43 +0530
Subject: [PATCH] Datestyle fix.

---
 src/backend/replication/logical/conflict.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/backend/replication/logical/conflict.c b/src/backend/replication/logical/conflict.c
index 782a4e16a11..1db457b4aa3 100644
--- a/src/backend/replication/logical/conflict.c
+++ b/src/backend/replication/logical/conflict.c
@@ -31,6 +31,7 @@
 #include "storage/lmgr.h"
 #include "utils/array.h"
 #include "utils/builtins.h"
+#include "utils/guc.h"
 #include "utils/json.h"
 #include "utils/lsyscache.h"
 #include "utils/pg_lsn.h"
@@ -1029,6 +1030,7 @@ build_index_key_json(Relation localrel, Oid indexid,
 	StringInfoData result;
 	int			indnkeyatts;
 	Datum		datum;
+	int			save_nestlevel;
 
 	Assert(slot != NULL);
 	Assert(CheckRelationOidLockedByMe(indexid, RowExclusiveLock, true));
@@ -1037,6 +1039,9 @@ build_index_key_json(Relation localrel, Oid indexid,
 
 	indexDesc = index_open(indexid, NoLock);
 
+	save_nestlevel = NewGUCNestLevel();
+	SetConfigOption("datestyle", "ISO", PGC_USERSET, PGC_S_SESSION);
+
 	/*
 	 * Build the JSON object here rather than handing the values to
 	 * row_to_json(), and render each of them with its type's output function.
@@ -1146,6 +1151,7 @@ build_index_key_json(Relation localrel, Oid indexid,
 
 	appendStringInfoChar(&result, '}');
 
+	AtEOXact_GUC(true, save_nestlevel);
 	index_close(indexDesc, NoLock);
 
 	datum = PointerGetDatum(cstring_to_text_with_len(result.data, result.len));
-- 
2.34.1

