1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-13 18:28:01 +03:00

Add the notion of REPLICA IDENTITY for a table.

Pending patches for logical replication will use this to determine
which columns of a tuple ought to be considered as its candidate key.

Andres Freund, with minor, mostly cosmetic adjustments by me
This commit is contained in:
Robert Haas
2013-11-08 12:30:43 -05:00
parent b97ee66cc1
commit 07cacba983
23 changed files with 902 additions and 49 deletions

View File

@@ -1862,6 +1862,19 @@
relations other than some materialized views)</entry>
</row>
<row>
<entry><structfield>relreplident</structfield></entry>
<entry><type>char</type></entry>
<entry></entry>
<entry>
Columns used to form <quote>replica identity</> for rows:
<literal>d</> = default (primary key, if any),
<literal>n</> = nothing,
<literal>f</> = all columns
<literal>i</> = index with indisreplident set, or default
</entry>
</row>
<row>
<entry><structfield>relfrozenxid</structfield></entry>
<entry><type>xid</type></entry>
@@ -3657,6 +3670,17 @@
</entry>
</row>
<row>
<entry><structfield>indisreplident</structfield></entry>
<entry><type>bool</type></entry>
<entry></entry>
<entry>
If true this index has been chosen as <quote>replica identity</>
using <command>ALTER TABLE ... REPLICA IDENTITY USING INDEX
...</>
</entry>
</row>
<row>
<entry><structfield>indkey</structfield></entry>
<entry><type>int2vector</type></entry>

View File

@@ -69,6 +69,7 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
NOT OF
OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>
SET TABLESPACE <replaceable class="PARAMETER">new_tablespace</replaceable>
REPLICA IDENTITY {DEFAULT | USING INDEX <replaceable class="PARAMETER">index_name</replaceable> | FULL | NOTHING}
<phrase>and <replaceable class="PARAMETER">table_constraint_using_index</replaceable> is:</phrase>
@@ -579,6 +580,24 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>REPLICA IDENTITY</literal></term>
<listitem>
<para>
This form changes the information which is written to the write-ahead log
to identify rows which are updated or deleted. This option has no effect
except when logical replication is in use. <literal>DEFAULT</> records the
old values of the columns of the primary key, if any. <literal>USING INDEX</>
records the old values of the columns covered by the named index, which
must be unique, not partial, not deferrable, and include only columns marked
<literal>NOT NULL</>. <literal>FULL</> records the old values of all columns
in the row. <literal>NOTHING</> records no information about the old row.
In all cases, no old values are logged unless at least one of the columns
that would be logged differs between the old and new versions of the row.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>RENAME</literal></term>
<listitem>