1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Remove bogus restriction from BEFORE UPDATE triggers

In trying to protect the user from inconsistent behavior, commit
487e9861d0 "Enable BEFORE row-level triggers for partitioned tables"
tried to prevent BEFORE UPDATE FOR EACH ROW triggers from moving the row
from one partition to another.  However, it turns out that the
restriction is wrong in two ways: first, it fails spuriously, preventing
valid situations from working, as in bug #16794; and second, they don't
protect from any misbehavior, because tuple routing would cope anyway.

Fix by removing that restriction.

We keep the same restriction on BEFORE INSERT FOR EACH ROW triggers,
though.  It is valid and useful there.  In the future we could remove it
by having tuple reroute work for inserts as it does for updates.

Backpatch to 13.

Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
Reported-by: Phillip Menke <pg@pmenke.de>
Discussion: https://postgr.es/m/16794-350a655580fbb9ae@postgresql.org
This commit is contained in:
Alvaro Herrera
2021-01-28 16:56:07 -03:00
parent 7f1921cb92
commit 16f69062e5
4 changed files with 77 additions and 22 deletions

View File

@ -4026,8 +4026,8 @@ ALTER INDEX measurement_city_id_logdate_key
<listitem>
<para>
<literal>BEFORE ROW</literal> triggers cannot change which partition
is the final destination for a new row.
<literal>BEFORE ROW</literal> triggers on <literal>INSERT</literal>
cannot change which partition is the final destination for a new row.
</para>
</listitem>