Re: Support EXCEPT for TABLES IN SCHEMA publications - Mailing list pgsql-hackers

From Nisha Moond
Subject Re: Support EXCEPT for TABLES IN SCHEMA publications
Date
Msg-id CABdArM5fFNZ024+LUTZzph5wZmbkz3A2rZVuxx4LvHiU16CssQ@mail.gmail.com
Whole thread
In response to Re: Support EXCEPT for TABLES IN SCHEMA publications  (vignesh C <vignesh21@gmail.com>)
List pgsql-hackers
On Wed, Apr 15, 2026 at 11:18 AM vignesh C <vignesh21@gmail.com> wrote:
>
> On Tue, 14 Apr 2026 at 12:00, Nisha Moond <nisha.moond412@gmail.com> wrote:
> >
>
> Few comments for the second patch:

Thanks for the review.

> 1) This patch adds support only for:
>   ALTER PUBLICATION pub ADD TABLES IN SCHEMA s EXCEPT (s.t1, s.t2);
>
> But documentation mentions for both add and set:
> @@ -31,7 +31,7 @@ ALTER PUBLICATION <replaceable
> class="parameter">name</replaceable> RENAME TO <r
>  <phrase>where <replaceable
> class="parameter">publication_object</replaceable> is one of:</phrase>
>
>      TABLE <replaceable
> class="parameter">table_and_columns</replaceable> [, ... ]
> -    TABLES IN SCHEMA { <replaceable
> class="parameter">schema_name</replaceable> | CURRENT_SCHEMA } [, ...
> ]
> +    TABLES IN SCHEMA { <replaceable
> class="parameter">schema_name</replaceable> | CURRENT_SCHEMA } [
> EXCEPT ( <replaceable
> class="parameter">except_table_object</replaceable> [, ... ] ) ] [,
> ... ]
>

Fixed the doc descriptions where SET was mentioned in patch-002.
But for the synopsis, I feel it will be unnecessary to first separate
the ADD and SET publication objects like "publication_add_object" and
"publication_set_object" in patch-002 and then remove them in
patch-003. Please let me know if you think otherwise.

> 2) Tab completion missing for:
> alter publication pub1 add TABLES IN SCHEMA sch1
>

Done.

> 3) Currently Set tables in schema sch1 also works partially with the
> second patch without adding the except tables:
> postgres=# alter publication pub1 set tables in schema sch1 except (sch1.t1);
> ALTER PUBLICATION
> postgres=# \dRp+ pub1
>                                                       Publication pub1
>   Owner  | All tables | All sequences | Inserts | Updates | Deletes |
> Truncates | Generated columns | Via root | Description
>
---------+------------+---------------+---------+---------+---------+-----------+-------------------+----------+-------------
>  vignesh | f          | f             | t       | t       | t       |
> t         | none              | f        |
> Tables from schemas:
>     "sch1"
>
> Should there be a check here to throw an error:
> +static void
> +AlterPublicationExceptTables(AlterPublicationStmt *stmt,
> +                                                        HeapTuple
> tup, List *exceptrelations,
> +                                                        List *schemaidlist)
> +{
> +       Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup);
> +       Oid                     pubid = pubform->oid;
> +
> +       /*
> +        * Nothing to do if no EXCEPT entries.
> +        */
> +       if (!exceptrelations)
> +               return;
> +
>

Fixed

> 4) Can this check be done at parser itself, it can be done in
> preprocess_pubobj_list parser function to detect the error early:
> +               foreach(lc, exceptrelations)
> +               {
> +                       PublicationTable *t = (PublicationTable *) lfirst(lc);
> +
> +                       if (t->relation->schemaname == NULL)
> +                               ereport(ERROR,
> +
> errcode(ERRCODE_INVALID_PARAMETER_VALUE),
> +                                               errmsg("table \"%s\"
> in EXCEPT clause must be schema-qualified",
> +
> t->relation->relname));
> +               }
>

Fixed.

All above comments are addressed in v2 attached above.

[1]
--
Thanks,
Nisha



pgsql-hackers by date:

Previous
From: Nisha Moond
Date:
Subject: Re: Support EXCEPT for TABLES IN SCHEMA publications
Next
From: Tom Lane
Date:
Subject: Re: Add errdetail() with PID and UID about source of termination signal