Re: Improve CREATE/ALTER PUBLICATION syntax for EXCEPT

From: Peter Smith <smithpb2250(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Improve CREATE/ALTER PUBLICATION syntax for EXCEPT
Date: 2026-07-23 01:01:26
Message-ID: CAHut+PuDJa+kZAB_LYB7eyKwPrX_pHP-S0PL4qxonUFd6qbVeg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Wed, Jul 22, 2026 at 9:51 PM Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>
> On Wed, Jul 22, 2026 at 1:35 PM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
> > So, the suggested synopsis change might seem good today, but in a
> > couple of years IMO we'd probably want to change it back again.
>
> Your point seems reasonable to me. So, how about keeping a reusable
> production, but making it represent the entire EXCEPT table list
> instead of a single list element?
>
> ALL TABLES [ EXCEPT ( except_table_list ) ]
> where except_table_list is:
> TABLE table_object [, [ TABLE ] table_object ] ...
>
> This avoids having list notation in both the EXCEPT clause and the definition
> of except_table_object, which makes the current synopsis a bit hard to read.

Actually, the current synopsis is consistent with other
already-existing double lists like:

publication_object [, ... ]
where publication_object is one of:
TABLE table_and_columns [, ... ]
TABLES IN SCHEMA { schema_name | CURRENT_SCHEMA } [, ... ]

Personally, I don't find those publication_object double lists hard to
read, but perhaps I'm just used to them.

> It also keeps the EXCEPT syntax probably reusable for future command support.
>

Probably reusable how?

e.g. I imagine a future command enhancement where there is the ability
to also exclude entire schemas from FOR ALL TABLES.
Easily done by expanding the existing synopsis like this:

FOR ALL TABLES [ EXCEPT ( { except_table_object | except_schema_object
} [, ... ] ) ]
and except_table_object is:
TABLE table_object [, ... ]
and except_schema_object is:
SCHEMA schema_name [, ... ]

That would allow complete freedom for any complex variation like
FOR ALL TABLES EXCEPT (TABLE t1, SCHEMA s1,s2, TABLE t2,t3, SCHEMA s3);

OTOH, I don't see how you can re-work your `except_table_list` idea to
support that same flexibility, unless you did almost the same thing:

ALL TABLES [ EXCEPT ( { except_table_list | except_schema_list } [, ... ] ) ]
where except_table_list is:
TABLE table_object [, [ TABLE ] table_object ] ...
where except_schema_list is:
SCHEMA schema_name [, [ SCHEMA ] schema_name ] ...

But that circles back to where we are right now with the double-list
notation, and is more wordy than it needs to be.

~~~

Aside:

BTW, in case you are wondering why I did not suggest removing
`except_table_object` to simplify further like below:

FOR ALL TABLES [ EXCEPT ( except_table_or_schema_object [, ... ] ) ]
and except_table_or_schema_object is one of:
TABLE table_object [, ... ]
SCHEMA schema_name [, ... ]

That's because the upcoming FOR TABLES IN SCHEMA s EXCEPT
is going to want to re-use that `except_table_object`

~~~

To summarise.
- The patch-suggested list flattening for `except_table_list` looks
OK, but the status-quo also looks OK to me and is consistent with
other terms
- I think removing these double lists now may need to be reverted
sometime in the future

Anyway, if you still think the new `except_table_list` term with the
flattened list is better, that's fine by me.

======
Kind Regards,
Peter Smith.
Fujitsu Australia

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Fujii Masao 2026-07-23 05:47:19 Re: Improve CREATE/ALTER PUBLICATION syntax for EXCEPT
Previous Message Fujii Masao 2026-07-22 11:51:37 Re: Improve CREATE/ALTER PUBLICATION syntax for EXCEPT