Thread: pgsql: Forbid ALTER TABLE and CLUSTER when there are pending

pgsql: Forbid ALTER TABLE and CLUSTER when there are pending

From
tgl@postgresql.org (Tom Lane)
Date:
Log Message:
-----------
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.

Modified Files:
--------------
    pgsql/src/backend/commands:
        cluster.c (r1.166 -> r1.167)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/cluster.c?r1=1.166&r2=1.167)
        tablecmds.c (r1.238 -> r1.239)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/tablecmds.c?r1=1.238&r2=1.239)
        trigger.c (r1.226 -> r1.227)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/trigger.c?r1=1.226&r2=1.227)
    pgsql/src/include/commands:
        trigger.h (r1.65 -> r1.66)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/commands/trigger.h?r1=1.65&r2=1.66)