diff options
| author | Amit Kapila <akapila@postgresql.org> | 2025-10-09 03:48:54 +0000 |
|---|---|---|
| committer | Amit Kapila <akapila@postgresql.org> | 2025-10-09 03:48:54 +0000 |
| commit | 96b37849734673e7c82fb86c4f0a46a28f500ac8 (patch) | |
| tree | bd12627fe6ff240f26d7ff2db36e29a9c3e751e4 /doc/src/sgml/ref | |
| parent | ef5e60a9d352a97791af632e0d26a572bc88e921 (diff) | |
Add "ALL SEQUENCES" support to publications.
This patch adds support for the ALL SEQUENCES clause in publications,
enabling synchronization/replication of all sequences that is useful for
upgrades.
Publications can now include all sequences via FOR ALL SEQUENCES.
psql enhancements:
\d shows publications for a given sequence.
\dRp indicates if a publication includes all sequences.
ALL SEQUENCES can be combined with ALL TABLES, but not with other options
like TABLE or TABLES IN SCHEMA. We can extend support for more granular
clauses in future.
The view pg_publication_sequences provides information about the mapping
between publications and sequences.
This patch enables publishing of sequences; subscriber-side support will
be added in upcoming patches.
Author: vignesh C <vignesh21@gmail.com>
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/CAA4eK1LC+KJiAkSrpE_NwvNdidw9F2os7GERUeSxSKv71gXysQ@mail.gmail.com
Diffstat (limited to 'doc/src/sgml/ref')
| -rw-r--r-- | doc/src/sgml/ref/alter_publication.sgml | 6 | ||||
| -rw-r--r-- | doc/src/sgml/ref/create_publication.sgml | 74 |
2 files changed, 59 insertions, 21 deletions
diff --git a/doc/src/sgml/ref/alter_publication.sgml b/doc/src/sgml/ref/alter_publication.sgml index d5ea383e8bc..c36e754f887 100644 --- a/doc/src/sgml/ref/alter_publication.sgml +++ b/doc/src/sgml/ref/alter_publication.sgml @@ -82,8 +82,9 @@ ALTER PUBLICATION <replaceable class="parameter">name</replaceable> RENAME TO <r new owning role, and that role must have <literal>CREATE</literal> privilege on the database. Also, the new owner of a - <link linkend="sql-createpublication-params-for-all-tables"><literal>FOR ALL TABLES</literal></link> - or <link linkend="sql-createpublication-params-for-tables-in-schema"><literal>FOR TABLES IN SCHEMA</literal></link> + <link linkend="sql-createpublication-params-for-tables-in-schema"><literal>FOR TABLES IN SCHEMA</literal></link> + or <link linkend="sql-createpublication-params-for-all-tables"><literal>FOR ALL TABLES</literal></link> + or <link linkend="sql-createpublication-params-for-all-sequences"><literal>FOR ALL SEQUENCES</literal></link> publication must be a superuser. However, a superuser can change the ownership of a publication regardless of these restrictions. </para> @@ -153,6 +154,7 @@ ALTER PUBLICATION <replaceable class="parameter">name</replaceable> RENAME TO <r <para> This clause alters publication parameters originally set by <xref linkend="sql-createpublication"/>. See there for more information. + This clause is not applicable to sequences. </para> <caution> <para> diff --git a/doc/src/sgml/ref/create_publication.sgml b/doc/src/sgml/ref/create_publication.sgml index 802630f2df1..66a70e5c5b5 100644 --- a/doc/src/sgml/ref/create_publication.sgml +++ b/doc/src/sgml/ref/create_publication.sgml @@ -22,14 +22,18 @@ PostgreSQL documentation <refsynopsisdiv> <synopsis> CREATE PUBLICATION <replaceable class="parameter">name</replaceable> - [ FOR ALL TABLES - | FOR <replaceable class="parameter">publication_object</replaceable> [, ... ] ] + [ FOR { <replaceable class="parameter">publication_object</replaceable> [, ... ] | <replaceable class="parameter">all_publication_object</replaceable> [, ... ] } ] [ WITH ( <replaceable class="parameter">publication_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ] <phrase>where <replaceable class="parameter">publication_object</replaceable> is one of:</phrase> TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ] [ ( <replaceable class="parameter">column_name</replaceable> [, ... ] ) ] [ WHERE ( <replaceable class="parameter">expression</replaceable> ) ] [, ... ] TABLES IN SCHEMA { <replaceable class="parameter">schema_name</replaceable> | CURRENT_SCHEMA } [, ... ] + +<phrase>where <replaceable class="parameter">all_publication_object</replaceable> is one of:</phrase> + + ALL TABLES + ALL SEQUENCES </synopsis> </refsynopsisdiv> @@ -120,16 +124,6 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable> </listitem> </varlistentry> - <varlistentry id="sql-createpublication-params-for-all-tables"> - <term><literal>FOR ALL TABLES</literal></term> - <listitem> - <para> - Marks the publication as one that replicates changes for all tables in - the database, including tables created in the future. - </para> - </listitem> - </varlistentry> - <varlistentry id="sql-createpublication-params-for-tables-in-schema"> <term><literal>FOR TABLES IN SCHEMA</literal></term> <listitem> @@ -161,11 +155,37 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable> </listitem> </varlistentry> + <varlistentry id="sql-createpublication-params-for-all-tables"> + <term><literal>FOR ALL TABLES</literal></term> + <listitem> + <para> + Marks the publication as one that replicates changes for all tables in + the database, including tables created in the future. + </para> + </listitem> + </varlistentry> + + <varlistentry id="sql-createpublication-params-for-all-sequences"> + <term><literal>FOR ALL SEQUENCES</literal></term> + <listitem> + <para> + Marks the publication as one that synchronizes changes for all sequences + in the database, including sequences created in the future. + </para> + + <para> + Only persistent sequences are included in the publication. Temporary + sequences and unlogged sequences are excluded from the publication. + </para> + </listitem> + </varlistentry> + <varlistentry id="sql-createpublication-params-with"> <term><literal>WITH ( <replaceable class="parameter">publication_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] )</literal></term> <listitem> <para> - This clause specifies optional parameters for a publication. The + This clause specifies optional parameters for a publication when + publishing tables. This clause is not applicable to sequences. The following parameters are supported: <variablelist> @@ -279,10 +299,10 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable> <title>Notes</title> <para> - If <literal>FOR TABLE</literal>, <literal>FOR ALL TABLES</literal> or - <literal>FOR TABLES IN SCHEMA</literal> are not specified, then the - publication starts out with an empty set of tables. That is useful if - tables or schemas are to be added later. + If <literal>FOR TABLE</literal>, <literal>FOR TABLES IN SCHEMA</literal>, + <literal>FOR ALL TABLES</literal> or <literal>FOR ALL SEQUENCES</literal> + are not specified, then the publication starts out with an empty set of + tables. That is useful if tables or schemas are to be added later. </para> <para> @@ -298,8 +318,9 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable> <para> To add a table to a publication, the invoking user must have ownership - rights on the table. The <command>FOR ALL TABLES</command> and - <command>FOR TABLES IN SCHEMA</command> clauses require the invoking + rights on the table. The <literal>FOR TABLES IN SCHEMA</literal>, + <literal>FOR ALL TABLES</literal> and + <literal>FOR ALL SEQUENCES</literal> clauses require the invoking user to be a superuser. </para> @@ -449,6 +470,21 @@ CREATE PUBLICATION sales_publication FOR TABLES IN SCHEMA marketing, sales; <programlisting> CREATE PUBLICATION users_filtered FOR TABLE users (user_id, firstname); </programlisting></para> + + <para> + Create a publication that publishes all sequences for synchronization: +<programlisting> +CREATE PUBLICATION all_sequences FOR ALL SEQUENCES; +</programlisting> + </para> + + <para> + Create a publication that publishes all changes in all tables, and + all sequences for synchronization: +<programlisting> +CREATE PUBLICATION all_tables_sequences FOR ALL TABLES, ALL SEQUENCES; +</programlisting> + </para> </refsect1> <refsect1> |
