]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
doc: Clarify INCLUDING COMMENTS behavior in CREATE TABLE LIKE.
authorFujii Masao <fujii@postgresql.org>
Thu, 26 Feb 2026 00:01:52 +0000 (09:01 +0900)
committerFujii Masao <fujii@postgresql.org>
Thu, 26 Feb 2026 00:02:30 +0000 (09:02 +0900)
The documentation for the INCLUDING COMMENTS option of the LIKE clause
in CREATE TABLE was inaccurate and incomplete. It stated that comments for
copied columns, constraints, and indexes are copied, but regarding comments
on constraints in reality only comments on CHECK and NOT NULL constraints
are copied; comments on other constraints (such as primary keys) are not.
In addition, comments on extended statistics are copied, but this was not
documented.

The CREATE FOREIGN TABLE documentation had a similar omission: comments
on extended statistics are also copied, but this was not mentioned.

This commit updates the documentation to clarify the actual behavior.
The CREATE TABLE reference now specifies that comments on copied columns,
CHECK constraints, NOT NULL constraints, indexes, and extended statistics are
copied. The CREATE FOREIGN TABLE reference now notes that comments on
extended statistics are copied as well.

Backpatch to all supported versions. Documentation updates related to
CREATE FOREIGN TABLE LIKE and NOT NULL constraint comment copying are
not applied to v17 and earlier, since those features were introduced in v18.

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwHSOSGcaYDvHF8EYCUCfGPjbRwGFsJ23cx5KbJ1X6JouQ@mail.gmail.com
Backpatch-through: 14

doc/src/sgml/ref/create_foreign_table.sgml
doc/src/sgml/ref/create_table.sgml

index 009fa46532bbe2202f9ec954dc6594e59837561b..adc775b90c5bb53e77355b595db12e17445e83ba 100644 (file)
@@ -232,9 +232,9 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         <term><literal>INCLUDING COMMENTS</literal></term>
         <listitem>
          <para>
-          Comments for the copied columns and constraints will be
-          copied.  The default behavior is to exclude comments, resulting in
-          the copied columns and constraints in the new table having no
+          Comments for the copied columns, constraints, and extended statistics
+          will be copied.  The default behavior is to exclude comments,
+          resulting in the corresponding objects in the new table having no
           comments.
          </para>
         </listitem>
index 927d541781451a5d07df79dd800a0b5c3f00505b..a033efce4de89da44edf131547f60b765f1659ad 100644 (file)
@@ -672,9 +672,10 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         <term><literal>INCLUDING COMMENTS</literal></term>
         <listitem>
          <para>
-          Comments for the copied columns, constraints, and indexes will be
+          Comments for the copied columns, check constraints,
+          not-null constraints, indexes, and extended statistics will be
           copied.  The default behavior is to exclude comments, resulting in
-          the copied columns and constraints in the new table having no
+          the corresponding objects in the new table having no
           comments.
          </para>
         </listitem>