mirror of
https://github.com/postgres/postgres.git
synced 2025-12-22 17:42:17 +03:00
Add decoding of sequences to built-in replication
This commit adds support for decoding of sequences to the built-in
replication (the infrastructure was added by commit 0da92dc530).
The syntax and behavior mostly mimics handling of tables, i.e. a
publication may be defined as FOR ALL SEQUENCES (replicating all
sequences in a database), FOR ALL SEQUENCES IN SCHEMA (replicating
all sequences in a particular schema) or individual sequences.
To publish sequence modifications, the publication has to include
'sequence' action. The protocol is extended with a new message,
describing sequence increments.
A new system view pg_publication_sequences lists all the sequences
added to a publication, both directly and indirectly. Various psql
commands (\d and \dRp) are improved to also display publications
including a given sequence, or sequences included in a publication.
Author: Tomas Vondra, Cary Huang
Reviewed-by: Peter Eisentraut, Amit Kapila, Hannu Krosing, Andres
Freund, Petr Jelinek
Discussion: https://postgr.es/m/d045f3c2-6cfb-06d3-5540-e63c320df8bc@enterprisedb.com
Discussion: https://postgr.es/m/1710ed7e13b.cd7177461430746.3372264562543607781@highgo.ca
This commit is contained in:
@@ -31,7 +31,9 @@ ALTER PUBLICATION <replaceable class="parameter">name</replaceable> RENAME TO <r
|
||||
<phrase>where <replaceable class="parameter">publication_object</replaceable> is one of:</phrase>
|
||||
|
||||
TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ] [ WHERE ( <replaceable class="parameter">expression</replaceable> ) ] [, ... ]
|
||||
SEQUENCE <replaceable class="parameter">sequence_name</replaceable> [, ... ]
|
||||
ALL TABLES IN SCHEMA { <replaceable class="parameter">schema_name</replaceable> | CURRENT_SCHEMA } [, ... ]
|
||||
ALL SEQUENCES IN SCHEMA { <replaceable class="parameter">schema_name</replaceable> | CURRENT_SCHEMA } [, ... ]
|
||||
</synopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
@@ -44,13 +46,13 @@ ALTER PUBLICATION <replaceable class="parameter">name</replaceable> RENAME TO <r
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The first three variants change which tables/schemas are part of the
|
||||
publication. The <literal>SET</literal> clause will replace the list of
|
||||
tables/schemas in the publication with the specified list; the existing
|
||||
tables/schemas that were present in the publication will be removed. The
|
||||
<literal>ADD</literal> and <literal>DROP</literal> clauses will add and
|
||||
remove one or more tables/schemas from the publication. Note that adding
|
||||
tables/schemas to a publication that is already subscribed to will require an
|
||||
The first three variants change which objects (tables, sequences or schemas)
|
||||
are part of the publication. The <literal>SET</literal> clause will replace
|
||||
the list of objects in the publication with the specified list; the existing
|
||||
objects that were present in the publication will be removed.
|
||||
The <literal>ADD</literal> and <literal>DROP</literal> clauses will add and
|
||||
remove one or more objects from the publication. Note that adding objects
|
||||
to a publication that is already subscribed to will require an
|
||||
<literal>ALTER SUBSCRIPTION ... REFRESH PUBLICATION</literal> action on the
|
||||
subscribing side in order to become effective. Note also that the combination
|
||||
of <literal>DROP</literal> with a <literal>WHERE</literal> clause is not
|
||||
@@ -122,6 +124,15 @@ ALTER PUBLICATION <replaceable class="parameter">name</replaceable> RENAME TO <r
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable class="parameter">sequence_name</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Name of an existing sequence.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable class="parameter">schema_name</replaceable></term>
|
||||
<listitem>
|
||||
|
||||
@@ -148,8 +148,8 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
|
||||
<listitem>
|
||||
<para>
|
||||
Fetch missing table information from publisher. This will start
|
||||
replication of tables that were added to the subscribed-to publications
|
||||
since <command>CREATE SUBSCRIPTION</command> or
|
||||
replication of tables and sequences that were added to the subscribed-to
|
||||
publications since <command>CREATE SUBSCRIPTION</command> or
|
||||
the last invocation of <command>REFRESH PUBLICATION</command>.
|
||||
</para>
|
||||
|
||||
@@ -167,8 +167,8 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
|
||||
The default is <literal>true</literal>.
|
||||
</para>
|
||||
<para>
|
||||
Previously subscribed tables are not copied, even if a table's row
|
||||
filter <literal>WHERE</literal> clause has since been modified.
|
||||
Previously subscribed tables and sequences are not copied, even if a
|
||||
table's row filter <literal>WHERE</literal> clause has since been modified.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -22,14 +22,21 @@ PostgreSQL documentation
|
||||
<refsynopsisdiv>
|
||||
<synopsis>
|
||||
CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
|
||||
[ FOR ALL TABLES
|
||||
[ FOR ALL <replaceable class="parameter">object_type</replaceable> [, ...]
|
||||
| FOR <replaceable class="parameter">publication_object</replaceable> [, ... ] ]
|
||||
[ WITH ( <replaceable class="parameter">publication_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ]
|
||||
|
||||
<phrase>where <replaceable class="parameter">object type</replaceable> is one of:</phrase>
|
||||
|
||||
TABLES
|
||||
SEQUENCES
|
||||
|
||||
<phrase>where <replaceable class="parameter">publication_object</replaceable> is one of:</phrase>
|
||||
|
||||
TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ] [ WHERE ( <replaceable class="parameter">expression</replaceable> ) ] [, ... ]
|
||||
SEQUENCE <replaceable class="parameter">sequence_name</replaceable> [ * ] [, ... ]
|
||||
ALL TABLES IN SCHEMA { <replaceable class="parameter">schema_name</replaceable> | CURRENT_SCHEMA } [, ... ]
|
||||
ALL SEQUENCES IN SCHEMA { <replaceable class="parameter">schema_name</replaceable> | CURRENT_SCHEMA } [, ... ]
|
||||
</synopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
@@ -108,26 +115,42 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>FOR ALL TABLES</literal></term>
|
||||
<term><literal>FOR SEQUENCE</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Marks the publication as one that replicates changes for all tables in
|
||||
the database, including tables created in the future.
|
||||
Specifies a list of sequences to add to the publication.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Specifying a sequence that is part of a schema specified by <literal>FOR
|
||||
ALL SEQUENCES IN SCHEMA</literal> is not supported.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>FOR ALL TABLES</literal></term>
|
||||
<term><literal>FOR ALL SEQUENCES</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Marks the publication as one that replicates changes for all tables/sequences in
|
||||
the database, including tables/sequences created in the future.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>FOR ALL TABLES IN SCHEMA</literal></term>
|
||||
<term><literal>FOR ALL SEQUENCES IN SCHEMA</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Marks the publication as one that replicates changes for all tables in
|
||||
the specified list of schemas, including tables created in the future.
|
||||
Marks the publication as one that replicates changes for all sequences/tables in
|
||||
the specified list of schemas, including sequences/tables created in the future.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Specifying a schema along with a table which belongs to the specified
|
||||
schema using <literal>FOR TABLE</literal> is not supported.
|
||||
Specifying a schema along with a sequence/table which belongs to the specified
|
||||
schema using <literal>FOR SEQUENCE</literal>/<literal>FOR TABLE</literal> is not supported.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@@ -202,10 +225,9 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
|
||||
<title>Notes</title>
|
||||
|
||||
<para>
|
||||
If <literal>FOR TABLE</literal>, <literal>FOR ALL TABLES</literal> or
|
||||
<literal>FOR ALL 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 SEQUENCE</literal>, etc. is
|
||||
not specified, then the publication starts out with an empty set of tables
|
||||
and sequences. That is useful if objects are to be added later.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@@ -220,10 +242,9 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
|
||||
</para>
|
||||
|
||||
<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 ALL TABLES IN SCHEMA</command> clauses require the invoking
|
||||
user to be a superuser.
|
||||
To add a table or a sequence to a publication, the invoking user must
|
||||
have ownership rights on the object. The <command>FOR ALL ...</command>
|
||||
clauses require the invoking user to be a superuser.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
|
||||
Reference in New Issue
Block a user