aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2018-10-06 19:17:46 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2018-10-06 19:17:46 -0300
commita2a5159ed678f0e4a0efa7e8aabbd4c03eb36843 (patch)
tree905a786eb1a0d3bde6a1808a6727a2a297bfe10f /src/include
parent3c9dd963cec6d4c314bccf74256acc893108a4be (diff)
downloadpostgresql-a2a5159ed678f0e4a0efa7e8aabbd4c03eb36843.tar.gz
postgresql-a2a5159ed678f0e4a0efa7e8aabbd4c03eb36843.zip
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
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/index.h3
-rw-r--r--src/include/tcop/deparse_utility.h3
2 files changed, 5 insertions, 1 deletions
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index a29174b6905..f982489168e 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -40,7 +40,8 @@ typedef enum
extern void index_check_primary_key(Relation heapRel,
IndexInfo *indexInfo,
- bool is_alter_table);
+ bool is_alter_table,
+ IndexStmt *stmt);
extern Oid index_create(Relation heapRelation,
const char *indexRelationName,
diff --git a/src/include/tcop/deparse_utility.h b/src/include/tcop/deparse_utility.h
index d276eeb2287..8dd7bd61983 100644
--- a/src/include/tcop/deparse_utility.h
+++ b/src/include/tcop/deparse_utility.h
@@ -44,6 +44,7 @@ typedef struct CollectedATSubcmd
typedef struct CollectedCommand
{
CollectedCommandType type;
+
bool in_extension;
Node *parsetree;
@@ -100,6 +101,8 @@ typedef struct CollectedCommand
GrantObjectType objtype;
} defprivs;
} d;
+
+ struct CollectedCommand *parent; /* when nested */
} CollectedCommand;
#endif /* DEPARSE_UTILITY_H */