summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2018-04-06 09:38:59 +0100
committerSimon Riggs <simon@2ndQuadrant.com>2018-04-06 09:38:59 +0100
commitf1464c53804fa7280a7942f6ac08038440f73b11 (patch)
tree92667694010e18a435bd7d409b341d935a1ee90b /src/include
parent3b0b4f31f73a5f45f8e122d826211c13cd2412f7 (diff)
Improve parse representation for MERGE
Separation of parser data structures from executor, as requested by Tom Lane. Further improvements possible. While there, implement error for multiple VALUES clauses via parser to allow line number of error, as requested by Andres Freund. Author: Pavan Deolasee Discussion: https://www.postgresql.org/message-id/CABOikdPpqjectFchg0FyTOpsGXyPoqwgC==OLKWuxgBOsrDDZw@mail.gmail.com
Diffstat (limited to 'src/include')
-rw-r--r--src/include/nodes/nodes.h3
-rw-r--r--src/include/nodes/parsenodes.h27
2 files changed, 23 insertions, 7 deletions
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index fce48026b6d..b1e3d53f78f 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -269,6 +269,7 @@ typedef enum NodeTag
T_RollupData,
T_GroupingSetData,
T_StatisticExtInfo,
+ T_MergeAction,
/*
* TAGS FOR MEMORY NODES (memnodes.h)
@@ -310,7 +311,6 @@ typedef enum NodeTag
T_DeleteStmt,
T_UpdateStmt,
T_MergeStmt,
- T_MergeAction,
T_SelectStmt,
T_AlterTableStmt,
T_AlterTableCmd,
@@ -475,6 +475,7 @@ typedef enum NodeTag
T_PartitionRangeDatum,
T_PartitionCmd,
T_VacuumRelation,
+ T_MergeWhenClause,
/*
* TAGS FOR REPLICATION GRAMMAR PARSE NODES (replnodes.h)
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 699fa77bc70..06abb70e947 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -1518,19 +1518,34 @@ typedef struct MergeStmt
RangeVar *relation; /* target relation to merge into */
Node *source_relation; /* source relation */
Node *join_condition; /* join condition between source and target */
- List *mergeActionList; /* list of MergeAction(s) */
+ List *mergeWhenClauses; /* list of MergeWhenClause(es) */
WithClause *withClause; /* WITH clause */
} MergeStmt;
-typedef struct MergeAction
+typedef struct MergeWhenClause
{
NodeTag type;
bool matched; /* true=MATCHED, false=NOT MATCHED */
- Node *condition; /* WHEN AND conditions (raw parser) */
- Node *qual; /* transformed WHEN AND conditions */
CmdType commandType; /* INSERT/UPDATE/DELETE/DO NOTHING */
- Node *stmt; /* T_UpdateStmt etc */
- List *targetList; /* the target list (of ResTarget) */
+ Node *condition; /* WHEN AND conditions (raw parser) */
+ List *targetList; /* INSERT/UPDATE targetlist */
+ /* the following members are only useful for INSERT action */
+ List *cols; /* optional: names of the target columns */
+ List *values; /* VALUES to INSERT, or NULL */
+ OverridingKind override; /* OVERRIDING clause */
+} MergeWhenClause;
+
+/*
+ * WHEN [NOT] MATCHED THEN action info
+ */
+typedef struct MergeAction
+{
+ NodeTag type;
+ bool matched; /* true=MATCHED, false=NOT MATCHED */
+ OverridingKind override; /* OVERRIDING clause */
+ Node *qual; /* transformed WHEN AND conditions */
+ CmdType commandType; /* INSERT/UPDATE/DELETE/DO NOTHING */
+ List *targetList; /* the target list (of ResTarget) */
} MergeAction;
/* ----------------------