Skip to content

Commit 420f9ac

Browse files
committed
Correct comment and some documentation about REPLICA_IDENTITY_INDEX
catalog/pg_class.h was stating that REPLICA_IDENTITY_INDEX with a dropped index is equivalent to REPLICA_IDENTITY_DEFAULT. The code tells a different story, as it is equivalent to REPLICA_IDENTITY_NOTHING. The behavior exists since the introduction of replica identities, and fe7fd4e even added tests for this case but I somewhat forgot to fix this comment. While on it, this commit reorganizes the documentation about replica identities on the ALTER TABLE page, and a note is added about the case of dropped indexes with REPLICA_IDENTITY_INDEX. Author: Michael Paquier, Wei Wang Reviewed-by: Euler Taveira Discussion: https://postgr.es/m/OS3PR01MB6275464AD0A681A0793F56879E759@OS3PR01MB6275.jpnprd01.prod.outlook.com Backpatch-through: 10
1 parent 8a22a40 commit 420f9ac

File tree

2 files changed

+44
-9
lines changed

2 files changed

+44
-9
lines changed

doc/src/sgml/ref/alter_table.sgml

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -851,16 +851,51 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
851851
<para>
852852
This form changes the information which is written to the write-ahead log
853853
to identify rows which are updated or deleted. This option has no effect
854-
except when logical replication is in use. <literal>DEFAULT</literal>
855-
(the default for non-system tables) records the
856-
old values of the columns of the primary key, if any. <literal>USING INDEX</literal>
857-
records the old values of the columns covered by the named index, which
858-
must be unique, not partial, not deferrable, and include only columns marked
859-
<literal>NOT NULL</literal>. <literal>FULL</literal> records the old values of all columns
860-
in the row. <literal>NOTHING</literal> records no information about the old row.
861-
(This is the default for system tables.)
854+
except when logical replication is in use.
862855
In all cases, no old values are logged unless at least one of the columns
863856
that would be logged differs between the old and new versions of the row.
857+
<variablelist>
858+
<varlistentry>
859+
<term><literal>DEFAULT</literal></term>
860+
<listitem>
861+
<para>
862+
Records the old values of the columns of the primary key, if any.
863+
This is the default for non-system tables.
864+
</para>
865+
</listitem>
866+
</varlistentry>
867+
868+
<varlistentry>
869+
<term><literal>USING INDEX <replaceable class="parameter">index_name</replaceable></literal></term>
870+
<listitem>
871+
<para>
872+
Records the old values of the columns covered by the named index,
873+
that must be unique, not partial, not deferrable, and include only
874+
columns marked <literal>NOT NULL</literal>. If this index is
875+
dropped, the behavior is the same as <literal>NOTHING</literal>.
876+
</para>
877+
</listitem>
878+
</varlistentry>
879+
880+
<varlistentry>
881+
<term><literal>FULL</literal></term>
882+
<listitem>
883+
<para>
884+
Records the old values of all columns in the row.
885+
</para>
886+
</listitem>
887+
</varlistentry>
888+
889+
<varlistentry>
890+
<term><literal>NOTHING</literal></term>
891+
<listitem>
892+
<para>
893+
Records no information about the old row. This is the default for
894+
system tables.
895+
</para>
896+
</listitem>
897+
</varlistentry>
898+
</variablelist>
864899
</para>
865900
</listitem>
866901
</varlistentry>

src/include/catalog/pg_class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ DECLARE_INDEX(pg_class_tblspc_relfilenode_index, 3455, on pg_class using btree(r
185185
/*
186186
* an explicitly chosen candidate key's columns are used as replica identity.
187187
* Note this will still be set if the index has been dropped; in that case it
188-
* has the same meaning as 'd'.
188+
* has the same meaning as 'n'.
189189
*/
190190
#define REPLICA_IDENTITY_INDEX 'i'
191191

0 commit comments

Comments
 (0)