Skip to content

Commit b54aad8

Browse files
committed
Document lack of validation when attaching foreign partitions.
Ashutosh Bapat, revised a bit by me. Discussion: http://postgr.es/m/CAFjFpRdLaCa-1wJase0=YWG5o3cJnbuUt_vrqm2TDBKM_vQ_oA@mail.gmail.com
1 parent 054637d commit b54aad8

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

doc/src/sgml/ref/alter_table.sgml

+19-12
Original file line numberDiff line numberDiff line change
@@ -743,18 +743,25 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
743743
</para>
744744

745745
<para>
746-
A full table scan is performed on the table being attached to check that
747-
no existing row in the table violates the partition constraint. It is
748-
possible to avoid this scan by adding a valid <literal>CHECK</literal>
749-
constraint to the table that would allow only the rows satisfying the
750-
desired partition constraint before running this command. It will be
751-
determined using such a constraint that the table need not be scanned
752-
to validate the partition constraint. This does not work, however, if
753-
any of the partition keys is an expression and the partition does not
754-
accept <literal>NULL</literal> values. If attaching a list partition
755-
that will not accept <literal>NULL</literal> values, also add
756-
<literal>NOT NULL</literal> constraint to the partition key column,
757-
unless it's an expression.
746+
If the new partition is a regular table, a full table scan is performed
747+
to check that no existing row in the table violates the partition
748+
constraint. It is possible to avoid this scan by adding a valid
749+
<literal>CHECK</literal> constraint to the table that would allow only
750+
the rows satisfying the desired partition constraint before running this
751+
command. It will be determined using such a constraint that the table
752+
need not be scanned to validate the partition constraint. This does not
753+
work, however, if any of the partition keys is an expression and the
754+
partition does not accept <literal>NULL</literal> values. If attaching
755+
a list partition that will not accept <literal>NULL</literal> values,
756+
also add <literal>NOT NULL</literal> constraint to the partition key
757+
column, unless it's an expression.
758+
</para>
759+
760+
<para>
761+
If the new partition is a foreign table, nothing is done to verify
762+
that all the rows in the foreign table obey the partition constraint.
763+
(See the discussion in <xref linkend="SQL-CREATEFOREIGNTABLE"> about
764+
constraints on the foreign table.)
758765
</para>
759766
</listitem>
760767
</varlistentry>

0 commit comments

Comments
 (0)