Re: Skipping schema changes in publication

From: Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: vignesh C <vignesh21(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, YeXiu <1518981153(at)qq(dot)com>, Ian Lawrence Barwick <barwick(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Skipping schema changes in publication
Date: 2026-03-02 13:21:21
Message-ID: CANhcyEWg8F2J4vbo7yvsY-vf4rAKodVTj6bq5Afdnt8KRGRvPQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 2 Mar 2026 at 16:18, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Sun, Mar 1, 2026 at 8:41 AM vignesh C <vignesh21(at)gmail(dot)com> wrote:
> >
> > The attached v53 version patch has the changes for the same.
> >
>
> Few comments on 0001:
> ===================
> 1.
> + appendStringInfoString(&pubnames, quote_literal_cstr(pubname));
> + }
> +
> + ereport(ERROR,
> + errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> + errmsg_plural("cannot attach table \"%s\" as partition because it is
> referenced in publication \"%s\" EXCEPT clause",
> + "cannot attach table \"%s\" as partition because it is referenced
> in publications \"%s\" EXCEPT clause",
>
> Because of the quoting before the error message, the publication names
> in the error message will be displayed in single quotes which are
> inside double quotes.
> See below examples:
> ERROR: cannot attach table "testpub_root" as partition because it is
> referenced in publication "'testpub8'" EXCEPT clause
> ERROR: cannot attach table "testpub_root" as partition because it is
> referenced in publications "'testpub8', 'testpub10'" EXCEPT clause
>
> Do you this type of quoting single/multiple object names in error
> messages at other places? What is the rationale behind this?
>
> The other place where I see such names is following but it also
> doesn't use the pattern followed above:
> A.
> postgres=# create subscription sub1 connection 'dbname=postgres'
> publication pub9, pub10, pub11;
> WARNING: publications "pub9", "pub10", "pub11" do not exist on the publisher
> postgres=# create subscription sub2 connection 'dbname=postgres'
> publication pub12;
> WARNING: publication "pub12" does not exist on the publisher
>
> B.
> logical replication target relation "public.t10" is missing replicated
> columns: "c2", "c3". For this See logicalrep_get_attrs_str and
> following error_message
> ereport(ERROR,
> errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> errmsg_plural("logical replication target relation \"%s.%s\" is
> missing replicated column: %s",
> "logical replication target relation \"%s.%s\" is missing replicated
> columns: %s",
>
> I think we should follow what is done in logicalrep_get_attrs_str for
> message construction and translation.
>
I agree. Made the changes for the same.

> 2.
> * pub_all_obj_type is one of:
> *
> - * TABLES
> + * TABLES [EXCEPT [TABLE] ( table [, ...] )]
>
> Though the table is no longer optional, the above syntax reference
> still shows it as optional.
>
> 3.
> + List *ancestor_exceptpuboids = GetRelationExcludedPublications(ancestor);;
>
> One spurious semicolon at the end of above statement
>
> 4.
> @@ -5838,16 +5841,22 @@ RelationBuildPublicationDesc(Relation
> relation, PublicationDesc *pubdesc)
> foreach(lc, ancestors)
> {
> Oid ancestor = lfirst_oid(lc);
> + List *ancestor_puboids = GetRelationIncludedPublications(ancestor);
> + List *ancestor_exceptpuboids = GetRelationExcludedPublications(ancestor);;
>
> - puboids = list_concat_unique_oid(puboids,
> - GetRelationPublications(ancestor));
> + puboids = list_concat_unique_oid(puboids, ancestor_puboids);
> schemaid = get_rel_namespace(ancestor);
> puboids = list_concat_unique_oid(puboids,
> GetSchemaPublications(schemaid));
> + exceptpuboids = list_concat_unique_oid(exceptpuboids,
> + ancestor_exceptpuboids);
> }
>
> Why do we need to get the exceptpuboids for all ancestors instead of
> just the top-one as we are doing in get_rel_sync_entry()?
>
I agree we should only check the root partitioned table here. Modified the code

I have also addressed the other comments.
I have addressed the comments shared by Shveta in [1].
Attached the updated v54 patch.

[1]: https://www.postgresql.org/message-id/CAJpy0uCr15=dxg+bmGeJUoNfKOHU2xZd2Wa6hg=YNTnQzz2fcA@mail.gmail.com

Thanks,
Shlok Kyal

Attachment Content-Type Size
v54-0001-Skip-publishing-the-tables-specified-in-EXCEPT-T.patch application/octet-stream 75.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Geier 2026-03-02 13:47:05 Re: Use correct collation in pg_trgm
Previous Message Tomas Vondra 2026-03-02 13:18:31 Re: index prefetching