| From: | Peter Smith <smithpb2250(at)gmail(dot)com> |
|---|---|
| To: | vignesh C <vignesh21(at)gmail(dot)com> |
| Cc: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Euler Taveira <euler(at)eulerto(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, "shveta(dot)malik(at)gmail(dot)com" <shveta(dot)malik(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Include schema-qualified names in publication error messages (generalised to all of LR). |
| Date: | 2026-10-07 08:10:13 |
| Message-ID: | CAHut+PsQ-77Mw5Ujj293kgo1GGZwfUhx90K1XgqePAHQet+tMw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi hackers,
Here is my more generic solution.
It generalises the EXCEPT-clause fix (a49b9cfd) and Vignesh's v8 for
check_publication_add_relation() to the rest of the logical
replication code.
~
The same pattern -- wrap a relation's namespace+name lookup before
putting it in a message -- is currently done ad hoc across LR code, in
three different ways:
1. Bare RelationGetRelationName()/get_rel_name(). Ambiguous whenever
the same name exists in more than one schema, which is routine with
per-schema publications.
2. Manual get_namespace_name()+get_rel_name() concatenation.
3. get_qualified_objname(), which quotes via
quote_qualified_identifier() and so double-quotes when put into a
message that already supplies its own quotes. Not hypothetical -- this
is what 926627bf902 ("Don't quote the relation name twice in EXCEPT
clause errors") had to fix.
That's more than a dozen call sites across pg_publication.c,
pg_subscription.c, publicationcmds.c, subscriptioncmds.c,
execReplication.c, conflict.c, relation.c, sequencesync.c,
tablesync.c, worker.c, pgoutput.c, and others.
~
PSA 0001 and 0002.
0001 adds three helpers to relcache.c -- MsgQualifiedRelName(),
...ByRel(), ...ByRelId() -- returning an unquoted "schema.relation"
string for %s substitution. Per the error style guide, a function that
already quotes its own output should not be wrapped in more quotes
[1], so these deliberately don't quote. All LR call sites that build a
qualified name for a message are converted to use them, including
index names, which weren't qualified anywhere before this.
0002 removes get_qualified_objname() once 0001 leaves it with a single
remaining caller, inlining it into generate_qualified_relation_name()
in ruleutils.c.
~
Open question: for a temporary table, should the schema be displayed
as "pg_temp" or "pg_temp_N"? The attached keeps "pg_temp_N", which is
the current status quo. Anyway, after 0001 this is a one-line change
in MsgQualifiedRelNameByRel()/...ByRelId() if the consensus is
otherwise.
~
More details can be found in the patch commit messages.
This is not a competing patch to Vignesh's v8 -- it's the same fix
carried through to everywhere else it already applies. The alternative
is fixing check_publication_add_relation() now and having this same
discussion again next time it turns up somewhere else in LR, which it
has, repeatedly.
======
[1] https://www.postgresql.org/docs/current/error-style-guide.html#ERROR-STYLE-GUIDE-QUOTES
Kind Regards,
Peter Smith.
Fujitsu Australia
| Attachment | Content-Type | Size |
|---|---|---|
| v20261007-0001-Add-helpers-for-schema-qualified-relation-.patch | application/octet-stream | 90.6 KB |
| v20261007-0002-Remove-function-get_qualified_objname.patch | application/octet-stream | 3.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Haruna Miwa | 2026-10-07 08:17:33 | Re: [PATCH] psql: avoid CREATE command completion after GRANT/REVOKE CREATE |
| Previous Message | Fujii Masao | 2026-10-07 07:43:46 | Re: [PATCH] psql: avoid CREATE command completion after GRANT/REVOKE CREATE |