public inbox for [email protected]
help / color / mirror / Atom feed[PATCH v16 01/10] Document historic behavior of links to directories..
3+ messages / 3 participants
[nested] [flat]
* [PATCH v16 01/10] Document historic behavior of links to directories..
@ 2020-03-16 19:12 Justin Pryzby <[email protected]>
0 siblings, 0 replies; 3+ messages in thread
From: Justin Pryzby @ 2020-03-16 19:12 UTC (permalink / raw)
Backpatch to 9.5: pg_stat_file
---
doc/src/sgml/func.sgml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 96ea57eedd..9b885102da 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -25486,7 +25486,8 @@ SELECT convert_from(pg_read_binary_file('file_in_utf8.txt'), 'UTF8');
size, last accessed time stamp, last modified time stamp,
last file status change time stamp (Unix platforms only),
file creation time stamp (Windows only), and a <type>boolean</type>
- indicating if it is a directory. Typical usages include:
+ indicating if it is a directory (or a symbolic link to a directory).
+ Typical usages include:
<programlisting>
SELECT * FROM pg_stat_file('filename');
SELECT (pg_stat_file('filename')).modification;
--
2.17.0
--2FkSFaIQeDFoAt0B
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v16-0002-pg_stat_file-and-pg_ls_dir_-to-use-lstat.patch"
^ permalink raw reply [nested|flat] 3+ messages in thread
* [PATCH] Remove redundant Assert() calls in report_namespace_conflict()
@ 2026-01-16 14:24 =?ISO-8859-1?B?emVuZ21hbg==?= <[email protected]>
0 siblings, 1 reply; 3+ messages in thread
From: =?ISO-8859-1?B?emVuZ21hbg==?= @ 2026-01-16 14:24 UTC (permalink / raw)
To: =?ISO-8859-1?B?cGdzcWwtaGFja2Vycw==?= <[email protected]>
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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [PATCH] Remove redundant Assert() calls in report_namespace_conflict()
@ 2026-01-16 21:57 Kirill Reshke <[email protected]>
parent: =?ISO-8859-1?B?emVuZ21hbg==?= <[email protected]>
0 siblings, 0 replies; 3+ messages in thread
From: Kirill Reshke @ 2026-01-16 21:57 UTC (permalink / raw)
To: zengman <[email protected]>; +Cc: pgsql-hackers <[email protected]>
On Fri, 16 Jan 2026, 19:25 zengman, <[email protected]> wrote:
> 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
Hi!
Yes, this patch looks valid
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-01-16 21:57 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-03-16 19:12 [PATCH v16 01/10] Document historic behavior of links to directories.. Justin Pryzby <[email protected]>
2026-01-16 14:24 [PATCH] Remove redundant Assert() calls in report_namespace_conflict() =?ISO-8859-1?B?emVuZ21hbg==?= <[email protected]>
2026-01-16 21:57 ` Re: [PATCH] Remove redundant Assert() calls in report_namespace_conflict() Kirill Reshke <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox