When enqueueing after-row triggers for updates of a table with a foreign
authorNeil Conway <neilc@samurai.com>
Mon, 30 May 2005 07:20:59 +0000 (07:20 +0000)
committerNeil Conway <neilc@samurai.com>
Mon, 30 May 2005 07:20:59 +0000 (07:20 +0000)
commit529a091c927466f31a03569f5e7d0b133f7622e6
treef6de82ad4675a48c3da5e393e2b0f7c7806b3215
parentbbed73c63719eca316260d6bfb01ef75abd543e1
When enqueueing after-row triggers for updates of a table with a foreign
key, compare the new and old row versions. If the foreign key column has
not changed, we needn't enqueue the trigger, since the update cannot
violate the foreign key. This optimization was previously applied in the
RI trigger function, but it is more efficient to avoid firing the trigger
altogether. Per recent discussion on pgsql-hackers.

Also add a regression test for some unintuitive foreign key behavior, and
refactor some code that deals with the OIDs of the various RI trigger
functions.
src/backend/commands/tablecmds.c
src/backend/commands/trigger.c
src/backend/utils/adt/ri_triggers.c
src/include/commands/trigger.h
src/test/regress/expected/foreign_key.out
src/test/regress/sql/foreign_key.sql