From: | vignesh C <vignesh21(at)gmail(dot)com> |
---|---|
To: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Cc: | shveta malik <shveta(dot)malik(at)gmail(dot)com>, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Euler Taveira <euler(at)eulerto(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, "Jonathan S(dot) Katz" <jkatz(at)postgresql(dot)org> |
Subject: | Re: Logical Replication of sequences |
Date: | 2025-10-07 11:21:48 |
Message-ID: | CALDaNm3NJBiXpQ3uY8=XhSPd6jBn2rTJS6wJZSFo6m2pzW5hqw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, 7 Oct 2025 at 12:09, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Tue, Oct 7, 2025 at 10:53 AM shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
> >
> > 2)
> > postgres=# create publication pub1 for all sequences WITH(publish='insert');
> > ERROR: publication parameters are not supported for publications
> > defined as FOR ALL SEQUENCES
> >
> > postgres=# alter publication pub1 add table tab1;
> > ERROR: Tables or sequences cannot be added to or dropped from
> > publication defined FOR ALL TABLES, ALL SEQUENCES, or both
> >
> > a) First msg has 'as', while second does not. Shall we make both the
> > same? I think we can get rid of 'as'.
> > b) Shouldn't the error msg start with lower case (second one)?
> >
>
> The (b) is related to following change:
>
> + if (tables && (pubform->puballtables || pubform->puballsequences))
> ereport(ERROR,
> - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> - errmsg("publication \"%s\" is defined as FOR ALL TABLES",
> - NameStr(pubform->pubname)),
> - errdetail("Tables cannot be added to or dropped from FOR ALL
> TABLES publications.")));
> + errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> + errmsg("Tables or sequences cannot be added to or dropped
> from publication defined FOR ALL TABLES, ALL SEQUENCES, or both"));
> }
>
> I see a bigger problem where we made errdetail as errmsg. Here, we are
> trying to combine the message FOR ALL TABLES and FOR ALL SEQUENCES
> which caused this change/confusion. It is better to keep them separate
> to avoid confusion. The similar problem exists for following message:
> - if (schemaidlist && pubform->puballtables)
> + if (schemaidlist && (pubform->puballtables || pubform->puballsequences))
> ereport(ERROR,
> - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> - errmsg("publication \"%s\" is defined as FOR ALL TABLES",
> - NameStr(pubform->pubname)),
> - errdetail("Schemas cannot be added to or dropped from FOR ALL TABLES
> publications.")));
> + errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> + errmsg("Schemas cannot be added to or dropped from publication
> defined FOR ALL TABLES, ALL SEQUENCES, or both"));
Modified to keep it as separate error messages.
> If we fix both of these then we don't need to do anything for point (a).
Agreed
> Few other comments:
> =================
> 1. Is there a reason not to change just the footers part in
> describeOneTableDetails()?
I tried the approach to keep it as a footer and it simplifies the code
further. Update the patch accordingly.
> 2. I think we can move create_publication.sgml and
> pg_publication_sequences related changes to 0001 from doc patch.
Modified
> 3. Atop is_publishable_class(), we mention it has all the checks as
> check_publication_add_relation but the sequence check is different. Is
> it because check_publication_add_relation() is not called FOR ALL
> SEQUENCES? If so, I have modified a few comments in the attached
> related to that.
Updated
> 4.
> @@ -878,13 +885,35 @@ CreatePublication(ParseState *pstate,
> CreatePublicationStmt *stmt)
> &publish_via_partition_root_given,
> &publish_via_partition_root,
> &publish_generated_columns_given,
> - &publish_generated_columns);
> + &publish_generated_columns,
> + def_pub_action);
> +
> + if (stmt->for_all_sequences &&
> + (publish_given || publish_via_partition_root_given ||
> + publish_generated_columns_given))
> + {
> + /*
> + * WITH clause parameters are not applicable when creating a FOR ALL
> + * SEQUENCES publication. If the publication includes tables as well,
> + * issue a notice.
> + */
> + if (!stmt->for_all_tables)
> + ereport(ERROR,
> + errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> + errmsg("publication parameters are not supported for publications
> defined as FOR ALL SEQUENCES"));
> +
> + ereport(NOTICE,
> + errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> + errmsg("publication parameters are not applicable to sequence
> synchronization and will be ignored"));
> + }
>
> This change looks a bit ad hoc to me. I think it would be better to
> handle this inside parse_publication_options(). The function can take
> the third parameter as for_all_sequences and then use that to give
> error when any options are present.
Modified
Thanks for the comments, the attached patch has the changes for the same.
Regards,
Vignesh
Attachment | Content-Type | Size |
---|---|---|
v20251007-0001-Introduce-ALL-SEQUENCES-support-for-Postgr.patch | application/octet-stream | 126.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Dilip Kumar | 2025-10-07 11:25:49 | Re: Logical Replication of sequences |
Previous Message | Ashutosh Bapat | 2025-10-07 11:19:26 | Re: Improve pg_sync_replication_slots() to wait for primary to advance |