]> granicus.if.org Git - postgresql/commit
Fix event triggers for partitioned tables
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Sat, 6 Oct 2018 22:17:46 +0000 (19:17 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Sat, 6 Oct 2018 22:17:46 +0000 (19:17 -0300)
commitad08006ba03797fed431af87de6e66c6c0985b7a
treeb17cf68d3e51944f13fd0012728e6e1b992e1793
parent29ef2b310da9892fda075ff9ee12da7f92d5da6e
Fix event triggers for partitioned tables

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
src/backend/catalog/index.c
src/backend/commands/event_trigger.c
src/backend/commands/indexcmds.c
src/backend/commands/tablecmds.c
src/backend/commands/view.c
src/include/catalog/index.h
src/include/tcop/deparse_utility.h
src/test/modules/test_ddl_deparse/expected/alter_table.out
src/test/modules/test_ddl_deparse/sql/alter_table.sql
src/test/regress/expected/event_trigger.out
src/test/regress/sql/event_trigger.sql