mirror of
https://github.com/postgres/postgres.git
synced 2025-11-04 20:11:56 +03:00
Fix INSERT OVERRIDING USER VALUE behavior
The original implementation disallowed using OVERRIDING USER VALUE on identity columns defined as GENERATED ALWAYS, which is not per standard. So allow that now. Expand documentation and tests around this. Author: Dean Rasheed <dean.a.rasheed@gmail.com> Reviewed-by: Peter Eisentraut <peter.eisentraut@2ndquadrant.com> Reviewed-by: Vik Fearing <vik@postgresfriends.org> Discussion: https://www.postgresql.org/message-id/flat/CAEZATCVrh2ufCwmzzM%3Dk_OfuLhTTPBJCdFkimst2kry4oHepuQ%40mail.gmail.com
This commit is contained in:
@@ -842,15 +842,27 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
|
||||
|
||||
<para>
|
||||
The clauses <literal>ALWAYS</literal> and <literal>BY DEFAULT</literal>
|
||||
determine how the sequence value is given precedence over a
|
||||
user-specified value in an <command>INSERT</command> statement.
|
||||
If <literal>ALWAYS</literal> is specified, a user-specified value is
|
||||
only accepted if the <command>INSERT</command> statement
|
||||
specifies <literal>OVERRIDING SYSTEM VALUE</literal>. If <literal>BY
|
||||
DEFAULT</literal> is specified, then the user-specified value takes
|
||||
precedence. See <xref linkend="sql-insert"/> for details. (In
|
||||
the <command>COPY</command> command, user-specified values are always
|
||||
used regardless of this setting.)
|
||||
determine how explicitly user-specified values are handled in
|
||||
<command>INSERT</command> and <command>UPDATE</command> commands.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
In an <command>INSERT</command> command, if <literal>ALWAYS</literal> is
|
||||
selected, a user-specified value is only accepted if the
|
||||
<command>INSERT</command> statement specifies <literal>OVERRIDING SYSTEM
|
||||
VALUE</literal>. If <literal>BY DEFAULT</literal> is selected, then the
|
||||
user-specified value takes precedence. See <xref linkend="sql-insert"/>
|
||||
for details. (In the <command>COPY</command> command, user-specified
|
||||
values are always used regardless of this setting.)
|
||||
</para>
|
||||
|
||||
<para>
|
||||
In an <command>UPDATE</command> command, if <literal>ALWAYS</literal> is
|
||||
selected, any update of the column to any value other than
|
||||
<literal>DEFAULT</literal> will be rejected. If <literal>BY
|
||||
DEFAULT</literal> is selected, the column can be updated normally.
|
||||
(There is no <literal>OVERRIDING</literal> clause for the
|
||||
<command>UPDATE</command> command.)
|
||||
</para>
|
||||
|
||||
<para>
|
||||
|
||||
Reference in New Issue
Block a user