From 1884867f41a67fcf856d61f94efba5f0c108ac92 Mon Sep 17 00:00:00 2001
From: reshke <reshke@double.cloud>
Date: Wed, 18 Feb 2026 07:51:34 +0000
Subject: [PATCH v1] Modernize error message for malformed B-Tree tuple posting
 list

---
 src/backend/access/nbtree/nbtdedup.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/backend/access/nbtree/nbtdedup.c b/src/backend/access/nbtree/nbtdedup.c
index 95be0b17939..b77d24510c0 100644
--- a/src/backend/access/nbtree/nbtdedup.c
+++ b/src/backend/access/nbtree/nbtdedup.c
@@ -1038,8 +1038,11 @@ _bt_swap_posting(IndexTuple newitem, IndexTuple oposting, int postingoff)
 	 * Perform a basic sanity check to catch this case now.
 	 */
 	if (!(postingoff > 0 && postingoff < nhtids))
-		elog(ERROR, "posting list tuple with %d items cannot be split at offset %d",
-			 nhtids, postingoff);
+		ereport(ERROR,
+				errcode(ERRCODE_INDEX_CORRUPTED),
+				errmsg("posting list tuple with %d items cannot be split at offset %d",
+					   nhtids, postingoff),
+				errhint("Please REINDEX it."));
 
 	/*
 	 * Move item pointers in posting list to make a gap for the new item's
-- 
2.43.0

