v1-0001-Replace-invalid-Assert-with-ereport-ERROR.patch

text/plain

Filename: v1-0001-Replace-invalid-Assert-with-ereport-ERROR.patch
Type: text/plain
Part: 1
Message: Re: Assert when executing query on partitioned table
From 50fe893680665226982ffa67bbde6c2cf6017260 Mon Sep 17 00:00:00 2001
From: Koval Dmitry <d.koval@postgrespro.ru>
Date: Fri, 19 Dec 2025 01:51:07 +0300
Subject: [PATCH v1] Replace invalid Assert with ereport(ERROR, ...)

At the time Assert was added, the UPDATE of INSERT ON CONFLICT operation
was not supported for partitioned tables. However, support has been
added, so need to replace Assert with ereport(ERROR, ...).
---
 src/backend/executor/nodeModifyTable.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index d131abcd67..f51ffbfc1e 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2810,13 +2810,10 @@ ExecOnConflictUpdate(ModifyTableContext *context,
 						(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
 						 errmsg("could not serialize access due to concurrent update")));
 
-			/*
-			 * As long as we don't support an UPDATE of INSERT ON CONFLICT for
-			 * a partitioned table we shouldn't reach to a case where tuple to
-			 * be lock is moved to another partition due to concurrent update
-			 * of the partition key.
-			 */
-			Assert(!ItemPointerIndicatesMovedPartitions(&tmfd.ctid));
+			if (ItemPointerIndicatesMovedPartitions(&tmfd.ctid))
+				ereport(ERROR,
+						errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
+						errmsg("tuple to be updated was already moved to another partition due to concurrent update"));
 
 			/*
 			 * Tell caller to try again from the very start.
-- 
2.43.0