Monthly Summary: Schema-Qualified Names in Publication Error Messages (May 2026)
Overview
This thread reached completion in May 2026, progressing from API design refinement through final commit and backpatch, with a minor post-commit quoting issue identified but accepted as pre-existing behavior.
Problem Statement
The function check_publication_add_relation() in pg_publication.c emitted error messages with only unqualified relation names (e.g., ERROR: "orders" is a system table), creating ambiguity in multi-schema databases — particularly problematic for logical replication setups referencing many relations across schemas.
Key Design Decisions
Two-Helper Architecture (Finalized)
The final committed design uses two helpers:
-
get_qualified_objnameinlsyscache.c— Oid-based, generalized for any namespace-qualified object (not just relations). Named generically after Shveta surveyed other call sites (getObjectIdentityParts(),generate_function_name(), etc.) that follow the same pattern. -
RelationGetQualifiedRelationNameinrel.h/relcache.c— A thin Relation-based wrapper following theRelationGet*naming family. Placed with relcache APIs rather thanlsyscache.cbecause the input is aRelationdescriptor, not anOid, following PostgreSQL's "input-type-dictates-module" convention.
Both use quote_qualified_identifier() at their core for proper double-quoting.
Two-Patch Split Strategy (Executed)
- HEAD (v20 target): Full generalized-helper refactor with all publication error messages schema-qualified.
- PG18 backpatch: Only the
EXCEPT-clause messages (introduced in PG18 byfd366065e06a), with therelnamelocal variable preserved to minimize diff and insulate against future changes.
The rationale: changing long-standing error message text in stable branches breaks log-analysis tooling that matches on message shape, but freshly-introduced messages haven't calcified yet.
Backpatch Committed
Vignesh submitted the backpatch variant, accepting Euler's argument for keeping the local variable (since alignment with the already-committed HEAD patch was no longer a constraint). Amit Kapila pushed the backpatch after minor adjustments.
Post-Commit Issue: Nested Quoting
Peter Smith identified a quoting anomaly where errmsg() templates wrap %s in hardcoded double quotes, but quote_qualified_identifier() also quotes components, producing:
ERROR: cannot specify relation "public."my table"" in the publication EXCEPT clause
Vignesh demonstrated this is pre-existing behavior (same pattern in REFRESH MATERIALIZED VIEW CONCURRENTLY) and the issue was accepted as status quo with no follow-up patch proposed.
Thread Status
Closed. Both HEAD and backpatch commits are done. The nested-quoting concern is acknowledged but deferred as a broader pre-existing PostgreSQL design tension.