Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit965b2cc

Browse files
author
Amit Kapila
committed
Doc: Improve the Replica Identity information.
This commit improves the Replica Identity information and clarifies itsrelated restrictions.Reported-by: James ColemanAuthor: Peter SmithCo-authored-by: Robert TreatReviewed-by: Laurenz Albe, Amit KapilaDiscussion:https://postgr.es/m/CAAaqYe_=7qFSqW7qavvhVy58mmzk1uSQ0RReRiUHyKO5znvr7g@mail.gmail.com
1 parent32a18cc commit965b2cc

File tree

2 files changed

+55
-30
lines changed

2 files changed

+55
-30
lines changed

‎doc/src/sgml/logical-replication.sgml

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -124,35 +124,6 @@
124124
<command>TRUNCATE</command>. See <xref linkend="logical-replication-row-filter"/>).
125125
</para>
126126

127-
<para>
128-
A published table must have a <firstterm>replica identity</firstterm> configured in
129-
order to be able to replicate <command>UPDATE</command>
130-
and <command>DELETE</command> operations, so that appropriate rows to
131-
update or delete can be identified on the subscriber side. By default,
132-
this is the primary key, if there is one. Another unique index (with
133-
certain additional requirements) can also be set to be the replica
134-
identity. If the table does not have any suitable key, then it can be set
135-
to replica identity <literal>FULL</literal>, which means the entire row becomes
136-
the key. When replica identity <literal>FULL</literal> is specified,
137-
indexes can be used on the subscriber side for searching the rows. Candidate
138-
indexes must be btree or hash, non-partial, and the leftmost index field must
139-
be a column (not an expression) that references the published table column.
140-
These restrictions on the non-unique index properties adhere to some of the
141-
restrictions that are enforced for primary keys. If there are no such
142-
suitable indexes, the search on the subscriber side can be very inefficient,
143-
therefore replica identity <literal>FULL</literal> should only be used as a
144-
fallback if no other solution is possible. If a replica identity other
145-
than <literal>FULL</literal> is set on the publisher side, a replica identity
146-
comprising the same or fewer columns must also be set on the subscriber
147-
side. See <xref linkend="sql-altertable-replica-identity"/> for details on
148-
how to set the replica identity. If a table without a replica identity is
149-
added to a publication that replicates <command>UPDATE</command>
150-
or <command>DELETE</command> operations then
151-
subsequent <command>UPDATE</command> or <command>DELETE</command>
152-
operations will cause an error on the publisher. <command>INSERT</command>
153-
operations can proceed regardless of any replica identity.
154-
</para>
155-
156127
<para>
157128
Every publication can have multiple subscribers.
158129
</para>
@@ -169,6 +140,59 @@
169140
transactional, so the table will start or stop replicating at the correct
170141
snapshot once the transaction has committed.
171142
</para>
143+
144+
<sect2 id="logical-replication-publication-replica-identity">
145+
<title>Replica Identity</title>
146+
147+
<para>
148+
A published table must have a <firstterm>replica identity</firstterm>
149+
configured in order to be able to replicate <command>UPDATE</command>
150+
and <command>DELETE</command> operations, so that appropriate rows to
151+
update or delete can be identified on the subscriber side.
152+
</para>
153+
154+
<para>
155+
By default, this is the primary key, if there is one. Another unique index
156+
(with certain additional requirements) can also be set to be the replica
157+
identity. If the table does not have any suitable key, then it can be set
158+
to replica identity <literal>FULL</literal>, which means the entire row
159+
becomes the key. When replica identity <literal>FULL</literal> is
160+
specified, indexes can be used on the subscriber side for searching the
161+
rows. Candidate indexes must be btree or hash, non-partial, and the
162+
leftmost index field must be a column (not an expression) that references
163+
the published table column. These restrictions on the non-unique index
164+
properties adhere to some of the restrictions that are enforced for
165+
primary keys. If there are no such suitable indexes, the search on the
166+
subscriber side can be very inefficient, therefore replica identity
167+
<literal>FULL</literal> should only be used as a fallback if no other
168+
solution is possible.
169+
</para>
170+
171+
<para>
172+
If a replica identity other than <literal>FULL</literal> is set on the
173+
publisher side, a replica identity comprising the same or fewer columns
174+
must also be set on the subscriber side.
175+
</para>
176+
177+
<para>
178+
Tables with a replica identity defined as <literal>NOTHING</literal>,
179+
<literal>DEFAULT</literal> without a primary key, or <literal>USING
180+
INDEX</literal> with a dropped index, cannot support
181+
<command>UPDATE</command> or <command>DELETE</command> operations when
182+
included in a publication replicating these actions. Attempting such
183+
operations will result in an error on the publisher.
184+
</para>
185+
186+
<para>
187+
<command>INSERT</command> operations can proceed regardless of any replica identity.
188+
</para>
189+
190+
<para>
191+
See <link linkend="sql-altertable-replica-identity"><literal>ALTER TABLE...REPLICA IDENTITY</literal></link>
192+
for details on how to set the replica identity.
193+
</para>
194+
</sect2>
195+
172196
</sect1>
173197

174198
<sect1 id="logical-replication-subscription">

‎doc/src/sgml/ref/alter_table.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,8 +927,9 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
927927
<term><literal>DEFAULT</literal></term>
928928
<listitem>
929929
<para>
930-
Records the old values of the columns of the primary key, if any.
930+
Records the old values of the columns of the primary key.
931931
This is the default for non-system tables.
932+
When there is no primary key, the behavior is the same as <literal>NOTHING</literal>.
932933
</para>
933934
</listitem>
934935
</varlistentry>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp