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
v20261007-0001-Add-helpers-for-schema-qualified-relation-.patch
Description: Binary data
v20261007-0002-Remove-function-get_qualified_objname.patch
Description: Binary data
