OSDN Git Service

Forbid ALTER TABLE and CLUSTER when there are pending AFTER-trigger events
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 2 Jan 2008 23:34:42 +0000 (23:34 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 2 Jan 2008 23:34:42 +0000 (23:34 +0000)
commit20e862155f1000804f9e2ae20b7fbb9a55623951
treeaa73bd2379ab9fa89abc9e3ba73e723934fc8b06
parent69528aefbbf2c1bfb68b488fafd08bea390eb3f5
Forbid ALTER TABLE and CLUSTER when there are pending AFTER-trigger events
in the current backend for the target table.  These operations move tuples
around and would thus invalidate the TIDs stored in the trigger event records.
(We need not worry about events in other backends, since acquiring exclusive
lock should be enough to ensure there aren't any.)  It might be sufficient
to forbid only the table-rewriting variants of ALTER TABLE, but in the absence
of any compelling use-case, let's just be safe and simple.  Per follow-on
investigation of bug #3847, though this is not actually the same problem
reported therein.

Possibly this should be back-patched, but since the case has never been
reported from the field, I didn't bother.
src/backend/commands/cluster.c
src/backend/commands/tablecmds.c
src/backend/commands/trigger.c
src/include/commands/trigger.h