1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-06 07:49:08 +03:00

Implement syntax for transition tables in AFTER triggers.

This is infrastructure for the complete SQL standard feature.  No
support is included at this point for execution nodes or PLs.  The
intent is to add that soon.

As this patch leaves things, standard syntax can create tuplestores
to contain old and/or new versions of rows affected by a statement.
References to these tuplestores are in the TriggerData structure.
C triggers can access the tuplestores directly, so they are usable,
but they cannot yet be referenced within a SQL statement.
This commit is contained in:
Kevin Grittner
2016-11-04 10:49:50 -05:00
parent 69d590fffb
commit 8c48375e5f
16 changed files with 580 additions and 43 deletions

View File

@@ -1204,6 +1204,21 @@ typedef struct CommonTableExpr
((Query *) (cte)->ctequery)->targetList : \
((Query *) (cte)->ctequery)->returningList)
/*
* TriggerTransition -
* representation of transition row or table naming clause
*
* Only transition tables are initially supported in the syntax, and only for
* AFTER triggers, but other permutations are accepted by the parser so we can
* give a meaningful message from C code.
*/
typedef struct TriggerTransition
{
NodeTag type;
char *name;
bool isNew;
bool isTable;
} TriggerTransition;
/*****************************************************************************
* Optimizable Statements
@@ -2105,6 +2120,8 @@ typedef struct CreateTrigStmt
List *columns; /* column names, or NIL for all columns */
Node *whenClause; /* qual expression, or NULL if none */
bool isconstraint; /* This is a constraint trigger */
/* explicitly named transition data */
List *transitionRels; /* TriggerTransition nodes, or NIL if none */
/* The remaining fields are only used for constraint triggers */
bool deferrable; /* [NOT] DEFERRABLE */
bool initdeferred; /* INITIALLY {DEFERRED|IMMEDIATE} */