On Wed, Mar 11, 2026 at 11:24 PM Masahiko Sawada <[email protected]> wrote: > > > > > 2. Parentheses around the exclusion list > > > > Parentheses are required to clearly separate the excluded objects from > > other elements in the publication definition, especially when mixed > > with inclusion clauses. For example, consider a future case like: > > > > CREATE PUBLICATION pub > > FOR TABLES IN SCHEMA s1 > > EXCEPT TABLE (t1, t2), TABLE t3; > > > > Here it is clear that t1 and t2 are excluded, while t3 is explicitly > > included. Without parentheses, a statement like: > > > > CREATE PUBLICATION pub > > FOR TABLES IN SCHEMA s1 > > EXCEPT TABLE t1, t2, TABLE t3; > > > > would be harder to interpret and potentially ambiguous. > > > > So although the syntax differs slightly from the existing inclusion > > list (e.g., TABLE a, b), requiring both the TABLE keyword and > > parentheses after EXCEPT helps keep the grammar unambiguous and makes > > the syntax easier to extend in the future. > > I'm still unsure that the syntax like TABLE (t1, t2) for the exclusion > list is syntactically correct. The syntax of TABLE (...) is already > used in a quite different way as follows (borrowed an example from > stats_import.sql): > > CREATE FUNCTION stats_import.pg_statistic_get_difference(a text, b text) > RETURNS TABLE (relname text, stats stats_import.pg_statistic_flat_t) >
Both are different usage and not clear if they are comparable. > > Wouldn't it be more appropriate to use a plural form or the IN > keyword, such as EXCEPT TABLES (t1, t2) or EXCEPT TABLES IN (t1, t2)? > We can consider it. Let's try to compare it with following existing publication syntax: CREATE PUBLICATION production_publication FOR TABLE users, departments, TABLES IN SCHEMA production; CREATE PUBLICATION alltables FOR ALL TABLES; Here we used singular form when a user could specify one or more objects and plural when all objects of schema or database are considered. As per this, the except syntax falls in the singular category which is in favor of current syntax. -- With Regards, Amit Kapila.
