minor error message enhancement in refuseDupeIndexAttach
hi.
minor error message enhancement
in refuseDupeIndexAttach, we can change from
errdetail("Another index is already attached for partition \"%s\"."...)
to
errdetail("Another index \"%s\" is already attached for partition \"%s\".")
So we can easily understand which index is already attached for
partition \"%s\".
Attachments:
v1-0001-minor-error-message-enhancement.patchtext/x-patch; charset=US-ASCII; name=v1-0001-minor-error-message-enhancement.patchDownload
From 1b9f592756eab51049307862aa6f954e551743ac Mon Sep 17 00:00:00 2001
From: jian he <jian.universality@gmail.com>
Date: Tue, 15 Apr 2025 15:50:08 +0800
Subject: [PATCH v1 1/1] minor error message enhancement
in refuseDupeIndexAttach change it
from
errdetail("Another index is already attached for partition \"%s\"."...)
to
errdetail("Another index \"%s\" is already attached for partition \"%s\".")
So we can easily understand which index is already attached for partition \"%s\".
discussion: https://postgr.es/m/
---
src/backend/commands/tablecmds.c | 3 ++-
src/test/regress/expected/indexing.out | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index b3ed69457fc..c113f7e022f 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -21674,7 +21674,8 @@ refuseDupeIndexAttach(Relation parentIdx, Relation partIdx, Relation partitionTb
errmsg("cannot attach index \"%s\" as a partition of index \"%s\"",
RelationGetRelationName(partIdx),
RelationGetRelationName(parentIdx)),
- errdetail("Another index is already attached for partition \"%s\".",
+ errdetail("Another index \"%s\" is already attached for partition \"%s\".",
+ get_rel_name(existingIdx),
RelationGetRelationName(partitionTbl))));
}
diff --git a/src/test/regress/expected/indexing.out b/src/test/regress/expected/indexing.out
index bcf1db11d73..4d29fb85293 100644
--- a/src/test/regress/expected/indexing.out
+++ b/src/test/regress/expected/indexing.out
@@ -248,7 +248,7 @@ alter index idxpart_a_b_idx attach partition idxpart1_a_b_idx; -- quiet
create index idxpart1_2_a_b on idxpart1 (a, b);
alter index idxpart_a_b_idx attach partition idxpart1_2_a_b;
ERROR: cannot attach index "idxpart1_2_a_b" as a partition of index "idxpart_a_b_idx"
-DETAIL: Another index is already attached for partition "idxpart1".
+DETAIL: Another index "idxpart1_a_b_idx" is already attached for partition "idxpart1".
drop table idxpart;
-- make sure everything's gone
select indexrelid::regclass, indrelid::regclass
--
2.34.1
On 15 Apr 2025, at 10:52, jian he <jian.universality@gmail.com> wrote:
in refuseDupeIndexAttach, we can change from
errdetail("Another index is already attached for partition \"%s\"."...)
to
errdetail("Another index \"%s\" is already attached for partition \"%s\".")
So we can easily understand which index is already attached for
partition \"%s\".
That seems like it could be handy. As this relates to chaning old and existing
behavior, and we are in feature freeze, I suggest registering this in the
commitfest app.
--
Daniel Gustafsson
On 15.04.25 11:02, Daniel Gustafsson wrote:
On 15 Apr 2025, at 10:52, jian he <jian.universality@gmail.com> wrote:
in refuseDupeIndexAttach, we can change from
errdetail("Another index is already attached for partition \"%s\"."...)
to
errdetail("Another index \"%s\" is already attached for partition \"%s\".")
So we can easily understand which index is already attached for
partition \"%s\".That seems like it could be handy. As this relates to chaning old and existing
behavior, and we are in feature freeze, I suggest registering this in the
commitfest app.
committed