mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Allow ALTER TABLE ONLY on partitioned tables
There is no need to forbid ALTER TABLE ONLY on partitioned tables, when no partitions exist yet. This can be handy for users who are building up their partitioned table independently and will create actual partitions later. In addition, this is how pg_dump likes to operate in certain instances. Author: Amit Langote, with some error message word-smithing by me
This commit is contained in:
@ -2944,17 +2944,23 @@ VALUES ('Albany', NULL, NULL, 'NY');
|
||||
Both <literal>CHECK</literal> and <literal>NOT NULL</literal>
|
||||
constraints of a partitioned table are always inherited by all its
|
||||
partitions. <literal>CHECK</literal> constraints that are marked
|
||||
<literal>NO INHERIT</literal> are not allowed.
|
||||
<literal>NO INHERIT</literal> are not allowed to be created on
|
||||
partitioned tables.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
The <literal>ONLY</literal> notation used to exclude child tables
|
||||
will cause an error for partitioned tables in the case of
|
||||
schema-modifying commands such as most <literal>ALTER TABLE</literal>
|
||||
commands. For example, dropping a column from only the parent does
|
||||
not make sense for partitioned tables.
|
||||
Using <literal>ONLY</literal> to add or drop a constraint on only the
|
||||
partitioned table is supported when there are no partitions. Once
|
||||
partitions exist, using <literal>ONLY</literal> will result in an error
|
||||
as adding or dropping constraints on only the partitioned table, when
|
||||
partitions exist, is not supported. Instead, constraints can be added
|
||||
or dropped, when they are not present in the parent table, directly on
|
||||
the partitions. As a partitioned table does not have any data
|
||||
directly, attempts to use <command>TRUNCATE</command>
|
||||
<literal>ONLY</literal> on a partitioned table will always return an
|
||||
error.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
|
Reference in New Issue
Block a user