]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Remove bogus restriction from BEFORE UPDATE triggers
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Thu, 28 Jan 2021 19:56:07 +0000 (16:56 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Thu, 28 Jan 2021 19:56:07 +0000 (16:56 -0300)
commit16f69062e599eccda8aea52301009e63fa96bef4
treef2a7aa479881db9a3e893a497783a3d4837ca4ef
parent7f1921cb922879796f7946273db304922a439a58
Remove bogus restriction from BEFORE UPDATE triggers

In trying to protect the user from inconsistent behavior, commit
487e9861d0cf "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
doc/src/sgml/ddl.sgml
src/backend/commands/trigger.c
src/test/regress/expected/triggers.out
src/test/regress/sql/triggers.sql