| From: | Baji Shaik <baji(dot)pgdev(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
| Subject: | [PATCH] Improve CREATE PUBLICATION error detail for a standalone table/schema name |
| Date: | 2026-10-22 23:32:57 |
| Message-ID: | CA+fm-RNBP0BxrPjVyoHEy8iPHjaAd5K8RKQGayKv0qmL3UgBXQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
If we write any of these, all reasonable guesses at syntax that
doesn't actually exist:
CREATE PUBLICATION p FOR SEQUENCE s1;
CREATE PUBLICATION p FOR SCHEMA myschema;
we get this error:
ERROR: invalid publication object list
DETAIL: One of TABLE or TABLES IN SCHEMA must be specified
before a standalone table or schema name.
The detail is correct but generic. It doesn't say which name
triggered it, so when the FOR list has more than one word, there's
nothing pointing at what to fix.
The attached patch adds the name to the message, when the parser has
one, and a hint listing the valid publication object kinds:
ERROR: invalid publication object list
DETAIL: One of TABLE or TABLES IN SCHEMA must be specified before
standalone table or schema name "sequence".
HINT: Valid publication objects are TABLE, TABLES IN SCHEMA, ALL
TABLES, and ALL SEQUENCES.
It says "sequence" and not "s1" because SEQUENCE is the word that's
actually in the wrong position: it's the first word in the FOR list,
and that's the one missing a TABLE/TABLES IN SCHEMA prefix. s1 is a
second, separate object in the same list.
The message doesn't guess *why* the word is there. It doesn't say
anything about the SEQUENCE or SCHEMA keywords specifically. A table
or schema genuinely named "sequence" hits this same code path and
gets the same message, and it's just as correct for that case:
CREATE TABLE sequence (a int);
CREATE PUBLICATION p FOR sequence;
ERROR: invalid publication object list
DETAIL: One of TABLE or TABLES IN SCHEMA must be specified before
standalone table or schema name "sequence".
HINT: Valid publication objects are TABLE, TABLES IN SCHEMA, ALL
TABLES, and ALL SEQUENCES.
so there's no risk of the message being wrong depending on which case
the user is actually in.
Let me know your feedback.
Thanks,
Baji Shaik
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Improve-CREATE-PUBLICATION-error-for-standalone-table-schema-name.patch | application/octet-stream | 6.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Amit Langote | 2026-10-22 23:06:58 | Re: PG19: two RI fast-path issues found while testing the batching revert |