Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3a06a79

Browse files
committed
Copy-edit docs for logical replication column lists
There was a excessive structure, leading to somewhat disorganized presentation of the information. Remove a few tags and reorder paragraphs to make the text flow more easily. Also, reword some of it to be more concise. The bit about column list combination is not modified, other than to remove an uninteresting (and IMO confusing and wrong) paragraph; I intend to deal with it differently afterwards. Backpatch to 15. Discussion: https://postgr.es/m/20220913121138.yn7ekkfysxzhkm2u@alvherre.pgsql
1 parent 918de37 commit 3a06a79

File tree

2 files changed

+47
-82
lines changed

2 files changed

+47
-82
lines changed

doc/src/sgml/logical-replication.sgml

+46-81
Original file line numberDiff line numberDiff line change
@@ -1093,89 +1093,60 @@ test_sub=# SELECT * FROM child ORDER BY a;
10931093
<title>Column Lists</title>
10941094

10951095
<para>
1096-
By default, all columns of a published table will be replicated to the
1097-
appropriate subscribers. The subscriber table must have at least all the
1098-
columns of the published table. However, if a
1099-
<firstterm>column list</firstterm> is specified then only the columns named
1100-
in the list will be replicated. This means the subscriber-side table only
1101-
needs to have those columns named by the column list. A user might choose to
1102-
use column lists for behavioral, security or performance reasons.
1096+
Each publication can optionally specify which columns of each table are
1097+
replicated to subscribers. The table on the subscriber side must have at
1098+
least all the columns that are published. If no column list is specified,
1099+
then all columns in the publisher are replicated.
1100+
See <xref linkend="sql-createpublication"/> for details on the syntax.
11031101
</para>
11041102

1105-
<sect2 id="logical-replication-col-list-rules">
1106-
<title>Column List Rules</title>
1107-
1108-
<para>
1109-
A column list is specified per table following the table name, and enclosed
1110-
by parentheses. See <xref linkend="sql-createpublication"/> for details.
1111-
</para>
1112-
1113-
<para>
1114-
When specifying a column list, the order of columns is not important. If no
1115-
column list is specified, all columns of the table are replicated through
1116-
this publication, including any columns added later. This means a column
1117-
list which names all columns is not quite the same as having no column list
1118-
at all. For example, if additional columns are added to the table then only
1119-
those named columns mentioned in the column list will continue to be
1120-
replicated.
1121-
</para>
1122-
1123-
<para>
1124-
Column lists have no effect for <literal>TRUNCATE</literal> command.
1125-
</para>
1126-
1127-
</sect2>
1128-
1129-
<sect2 id="logical-replication-col-list-restrictions">
1130-
<title>Column List Restrictions</title>
1131-
1132-
<para>
1133-
A column list can contain only simple column references.
1134-
</para>
1135-
1136-
<para>
1137-
If a publication publishes <command>UPDATE</command> or
1138-
<command>DELETE</command> operations, any column list must include the
1139-
table's replica identity columns (see
1140-
<xref linkend="sql-altertable-replica-identity"/>).
1141-
If a publication publishes only <command>INSERT</command> operations, then
1142-
the column list is arbitrary and may omit some replica identity columns.
1143-
</para>
1144-
1145-
</sect2>
1146-
1147-
<sect2 id="logical-replication-col-list-partitioned">
1148-
<title>Partitioned Tables</title>
1103+
<para>
1104+
The choice of columns can be based on behavioral or performance reasons.
1105+
However, do not rely on this feature for security: a malicious subscriber
1106+
is able to obtain data from columns that are not specifically
1107+
published. If security is a consideration, protections can be applied
1108+
at the publisher side.
1109+
</para>
11491110

1150-
<para>
1151-
For partitioned tables, the publication parameter
1152-
<literal>publish_via_partition_root</literal> determines which column list
1153-
is used. If <literal>publish_via_partition_root</literal> is
1154-
<literal>true</literal>, the root partitioned table's column list is used.
1155-
Otherwise, if <literal>publish_via_partition_root</literal> is
1156-
<literal>false</literal> (default), each partition's column list is used.
1157-
</para>
1111+
<para>
1112+
If no column list is specified, any columns added later are automatically
1113+
replicated. This means that having a column list which names all columns
1114+
is not the same as having no column list at all.
1115+
</para>
11581116

1159-
</sect2>
1117+
<para>
1118+
A column list can contain only simple column references. The order
1119+
of columns in the list is not preserved.
1120+
</para>
11601121

1161-
<sect2 id="logical-replication-col-list-initial-data-sync">
1162-
<title>Initial Data Synchronization</title>
1122+
<para>
1123+
For partitioned tables, the publication parameter
1124+
<literal>publish_via_partition_root</literal> determines which column list
1125+
is used. If <literal>publish_via_partition_root</literal> is
1126+
<literal>true</literal>, the root partitioned table's column list is used.
1127+
Otherwise, if <literal>publish_via_partition_root</literal> is
1128+
<literal>false</literal> (the default), each partition's column list is used.
1129+
</para>
11631130

1164-
<para>
1165-
If the subscription requires copying pre-existing table data and a
1166-
publication specifies a column list, only data from those columns will be
1167-
copied.
1168-
</para>
1131+
<para>
1132+
If a publication publishes <command>UPDATE</command> or
1133+
<command>DELETE</command> operations, any column list must include the
1134+
table's replica identity columns (see
1135+
<xref linkend="sql-altertable-replica-identity"/>).
1136+
If a publication publishes only <command>INSERT</command> operations, then
1137+
the column list may omit replica identity columns.
1138+
</para>
11691139

1170-
<note>
1171-
<para>
1172-
If the subscriber is in a release prior to 15, copy pre-existing data
1173-
doesn't use column lists even if they are defined in the publication.
1174-
This is because old releases can only copy the entire table data.
1175-
</para>
1176-
</note>
1140+
<para>
1141+
Column lists have no effect for the <literal>TRUNCATE</literal> command.
1142+
</para>
11771143

1178-
</sect2>
1144+
<para>
1145+
During initial data synchronization, only the published columns are
1146+
copied. However, if the subscriber is from a release prior to 15, then
1147+
all the columns in the table are copied during initial data synchronization,
1148+
ignoring any column lists.
1149+
</para>
11791150

11801151
<sect2 id="logical-replication-col-list-combining">
11811152
<title>Combining Multiple Column Lists</title>
@@ -1193,12 +1164,6 @@ test_sub=# SELECT * FROM child ORDER BY a;
11931164
<literal>ALTER SUBSCRIPTION ... DROP PUBLICATION</literal> and then add it
11941165
back after adjusting the column list.
11951166
</para>
1196-
<para>
1197-
Background: The main purpose of the column list feature is to allow
1198-
statically different table shapes on publisher and subscriber, or hide
1199-
sensitive column data. In both cases, it doesn't seem to make sense to
1200-
combine column lists.
1201-
</para>
12021167
</warning>
12031168

12041169
</sect2>

doc/src/sgml/ref/create_publication.sgml

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
9494
effect on <literal>TRUNCATE</literal> commands. See
9595
<xref linkend="logical-replication-col-lists"/> for details about column
9696
lists.
97-
</para>
97+
</para>
9898

9999
<para>
100100
Only persistent base tables and partitioned tables can be part of a

0 commit comments

Comments
 (0)