• Alvaro Herrera's avatar
    Fix event triggers for partitioned tables · ad08006b
    Alvaro Herrera authored
    Index DDL cascading on partitioned tables introduced a way for ALTER
    TABLE to be called reentrantly.  This caused an an important deficiency
    in event trigger support to be exposed: on exiting the reentrant call,
    the alter table state object was clobbered, causing a crash when the
    outer alter table tries to finalize its processing.  Fix the crash by
    creating a stack of event trigger state objects.  There are still ways
    to cause things to misbehave (and probably other crashers) with more
    elaborate tricks, but at least it now doesn't crash in the obvious
    scenario.
    
    Backpatch to 9.5, where DDL deparsing of event triggers was introduced.
    
    Reported-by: Marco Slot
    Authors: Michaël Paquier, Álvaro Herrera
    Discussion: https://postgr.es/m/CANNhMLCpi+HQ7M36uPfGbJZEQLyTy7XvX=5EFkpR-b1bo0uJew@mail.gmail.com
    ad08006b
event_trigger.c 64.8 KB