OSDN Git Service

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)
commitadfeef55cbcc5dc72a772777f88c1be05a70dfee
treeb7d0a756c03241faa60c0ea416d68040741be4d0
parentf99b75b0a0ee642a87a10726ba8f6831c1c95cc7
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