public inbox for [email protected]
help / color / mirror / Atom feedFrom: =?ISO-8859-1?B?emVuZ21hbg==?= <[email protected]>
To: =?ISO-8859-1?B?cGdzcWwtaGFja2Vycw==?= <[email protected]>
Subject: [PATCH] Remove redundant Assert() calls in report_namespace_conflict()
Date: Fri, 16 Jan 2026 22:24:56 +0800
Message-ID: <[email protected]> (raw)
Hi all,
I noticed that report_namespace_conflict() has Assert(OidIsValid(nspOid)) at the function entry, and the same assertion is repeated in each switch case. These duplicate assertions are redundant since the check at the top already covers all cases.
Attached patch removes the 6 redundant assertions to make the code a bit cleaner.
```
static void
report_namespace_conflict(Oid classId, const char *name, Oid nspOid)
{
char *msgfmt;
Assert(OidIsValid(nspOid));
switch (classId)
{
case ConversionRelationId:
Assert(OidIsValid(nspOid));
msgfmt = gettext_noop("conversion \"%s\" already exists in schema \"%s\"");
break;
case StatisticExtRelationId:
Assert(OidIsValid(nspOid));
msgfmt = gettext_noop("statistics object \"%s\" already exists in schema \"%s\"");
break;
case TSParserRelationId:
Assert(OidIsValid(nspOid));
msgfmt = gettext_noop("text search parser \"%s\" already exists in schema \"%s\"");
break;
case TSDictionaryRelationId:
Assert(OidIsValid(nspOid));
msgfmt = gettext_noop("text search dictionary \"%s\" already exists in schema \"%s\"");
break;
case TSTemplateRelationId:
Assert(OidIsValid(nspOid));
msgfmt = gettext_noop("text search template \"%s\" already exists in schema \"%s\"");
break;
case TSConfigRelationId:
Assert(OidIsValid(nspOid));
msgfmt = gettext_noop("text search configuration \"%s\" already exists in schema \"%s\"");
break;
default:
elog(ERROR, "unsupported object class: %u", classId);
break;
}
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg(msgfmt, name, get_namespace_name(nspOid))));
}
```
--
Regards,
Man Zeng
www.openhalo.org
Attachments:
[application/octet-stream] 0001-Remove-unnecessary-Oid-validity-assertions-in-report.patch (1.6K, ../[email protected]/2-0001-Remove-unnecessary-Oid-validity-assertions-in-report.patch)
download | inline diff:
From e630f9031c59a152937411ac3af89648462f63c5 Mon Sep 17 00:00:00 2001
From: Man Zeng <[email protected]>
Date: Fri, 16 Jan 2026 21:43:17 +0800
Subject: [PATCH] Remove unnecessary Oid validity assertions in
report_namespace_conflict()
---
src/backend/commands/alter.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index f7b2389b019..08957104c70 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -117,27 +117,21 @@ report_namespace_conflict(Oid classId, const char *name, Oid nspOid)
switch (classId)
{
case ConversionRelationId:
- Assert(OidIsValid(nspOid));
msgfmt = gettext_noop("conversion \"%s\" already exists in schema \"%s\"");
break;
case StatisticExtRelationId:
- Assert(OidIsValid(nspOid));
msgfmt = gettext_noop("statistics object \"%s\" already exists in schema \"%s\"");
break;
case TSParserRelationId:
- Assert(OidIsValid(nspOid));
msgfmt = gettext_noop("text search parser \"%s\" already exists in schema \"%s\"");
break;
case TSDictionaryRelationId:
- Assert(OidIsValid(nspOid));
msgfmt = gettext_noop("text search dictionary \"%s\" already exists in schema \"%s\"");
break;
case TSTemplateRelationId:
- Assert(OidIsValid(nspOid));
msgfmt = gettext_noop("text search template \"%s\" already exists in schema \"%s\"");
break;
case TSConfigRelationId:
- Assert(OidIsValid(nspOid));
msgfmt = gettext_noop("text search configuration \"%s\" already exists in schema \"%s\"");
break;
default:
--
2.45.2
view thread (3+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: [PATCH] Remove redundant Assert() calls in report_namespace_conflict()
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox