mirror of
https://github.com/postgres/postgres.git
synced 2026-04-24 07:40:59 -04:00
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
108 lines
2 KiB
C
108 lines
2 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* deparse_utility.h
|
|
*
|
|
* Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/tcop/deparse_utility.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef DEPARSE_UTILITY_H
|
|
#define DEPARSE_UTILITY_H
|
|
|
|
#include "access/attnum.h"
|
|
#include "catalog/objectaddress.h"
|
|
#include "nodes/nodes.h"
|
|
#include "utils/aclchk_internal.h"
|
|
|
|
|
|
/*
|
|
* Support for keeping track of collected commands.
|
|
*/
|
|
typedef enum CollectedCommandType
|
|
{
|
|
SCT_Simple,
|
|
SCT_AlterTable,
|
|
SCT_Grant,
|
|
SCT_AlterOpFamily,
|
|
SCT_AlterDefaultPrivileges,
|
|
SCT_CreateOpClass,
|
|
SCT_AlterTSConfig
|
|
} CollectedCommandType;
|
|
|
|
/*
|
|
* For ALTER TABLE commands, we keep a list of the subcommands therein.
|
|
*/
|
|
typedef struct CollectedATSubcmd
|
|
{
|
|
ObjectAddress address; /* affected column, constraint, index, ... */
|
|
Node *parsetree;
|
|
} CollectedATSubcmd;
|
|
|
|
typedef struct CollectedCommand
|
|
{
|
|
CollectedCommandType type;
|
|
|
|
bool in_extension;
|
|
Node *parsetree;
|
|
|
|
union
|
|
{
|
|
/* most commands */
|
|
struct
|
|
{
|
|
ObjectAddress address;
|
|
ObjectAddress secondaryObject;
|
|
} simple;
|
|
|
|
/* ALTER TABLE, and internal uses thereof */
|
|
struct
|
|
{
|
|
Oid objectId;
|
|
Oid classId;
|
|
List *subcmds;
|
|
} alterTable;
|
|
|
|
/* GRANT / REVOKE */
|
|
struct
|
|
{
|
|
InternalGrant *istmt;
|
|
} grant;
|
|
|
|
/* ALTER OPERATOR FAMILY */
|
|
struct
|
|
{
|
|
ObjectAddress address;
|
|
List *operators;
|
|
List *procedures;
|
|
} opfam;
|
|
|
|
/* CREATE OPERATOR CLASS */
|
|
struct
|
|
{
|
|
ObjectAddress address;
|
|
List *operators;
|
|
List *procedures;
|
|
} createopc;
|
|
|
|
/* ALTER TEXT SEARCH CONFIGURATION ADD/ALTER/DROP MAPPING */
|
|
struct
|
|
{
|
|
ObjectAddress address;
|
|
Oid *dictIds;
|
|
int ndicts;
|
|
} atscfg;
|
|
|
|
/* ALTER DEFAULT PRIVILEGES */
|
|
struct
|
|
{
|
|
ObjectType objtype;
|
|
} defprivs;
|
|
} d;
|
|
|
|
struct CollectedCommand *parent; /* when nested */
|
|
} CollectedCommand;
|
|
|
|
#endif /* DEPARSE_UTILITY_H */
|