mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Update docs & tests to reflect that unassigned OLD/NEW are now NULL.
For a long time, plpgsql has allowed trigger functions to parse references to OLD and NEW even if the current trigger event type didn't assign a value to one or the other variable; but actually executing such a reference would fail. The v11 changes to use "expanded records" for DTYPE_REC variables changed the behavior so that the unassigned variable now reads as a null composite value. While this behavioral change was more or less unintentional, it seems that leaving it like this is better than adding code and complexity to be bug-compatible with the old way. The change doesn't break any code that worked before, and it eliminates a gotcha that often required extra code to work around. Hence, update the docs to say that these variables are "null" not "unassigned" when not relevant to the event type. And add a regression test covering the behavior, so that we'll notice if we ever break it again. Per report from Kristjan Tammekivi. Discussion: https://postgr.es/m/CAABK7uL-uC9ZxKBXzo_68pKt7cECfNRv+c35CXZpjq6jCAzYYA@mail.gmail.com
This commit is contained in:
@ -3857,7 +3857,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
|
||||
<para>
|
||||
Data type <type>RECORD</type>; variable holding the new
|
||||
database row for <command>INSERT</command>/<command>UPDATE</command> operations in row-level
|
||||
triggers. This variable is unassigned in statement-level triggers
|
||||
triggers. This variable is null in statement-level triggers
|
||||
and for <command>DELETE</command> operations.
|
||||
</para>
|
||||
</listitem>
|
||||
@ -3869,7 +3869,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
|
||||
<para>
|
||||
Data type <type>RECORD</type>; variable holding the old
|
||||
database row for <command>UPDATE</command>/<command>DELETE</command> operations in row-level
|
||||
triggers. This variable is unassigned in statement-level triggers
|
||||
triggers. This variable is null in statement-level triggers
|
||||
and for <command>INSERT</command> operations.
|
||||
</para>
|
||||
</listitem>
|
||||
|
@ -1033,6 +1033,23 @@ Branch: REL9_3_STABLE [84261eb10] 2018-10-19 17:02:26 -0400
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<!--
|
||||
2018-02-13 [4b93f5799] Make plpgsql use its DTYPE_REC code paths for composite-
|
||||
-->
|
||||
|
||||
<para>
|
||||
In PL/pgSQL trigger functions, the <varname>OLD</varname>
|
||||
and <varname>NEW</varname> variables now read as NULL when not
|
||||
assigned (Tom Lane)
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Previously, references to these variables could be parsed but not
|
||||
executed.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
</itemizedlist>
|
||||
|
||||
</sect2>
|
||||
@ -2574,7 +2591,6 @@ same commits as above
|
||||
<listitem>
|
||||
<!--
|
||||
2018-02-13 [4b93f5799] Make plpgsql use its DTYPE_REC code paths for composite-
|
||||
|
||||
-->
|
||||
|
||||
<para>
|
||||
|
Reference in New Issue
Block a user