mirror of
https://github.com/postgres/postgres.git
synced 2025-11-01 21:31:19 +03:00
Revert MERGE patch
This reverts commitsd204ef6377,83454e3c2band a few more commits thereafter (complete list at the end) related to MERGE feature. While the feature was fully functional, with sufficient test coverage and necessary documentation, it was felt that some parts of the executor and parse-analyzer can use a different design and it wasn't possible to do that in the available time. So it was decided to revert the patch for PG11 and retry again in the future. Thanks again to all reviewers and bug reporters. List of commits reverted, in reverse chronological order:f1464c5380Improve parse representation for MERGEddb4158579MERGE syntax diagram correction530e69e59bAllow cpluspluscheck to pass by renaming variable01b88b4df5MERGE minor errata3af7b2b0d4MERGE fix variable warning in non-assert buildsa5d86181ecMERGE INSERT allows only one VALUES clause4b2d44031fMERGE post-commit review4923550c20Tab completion for MERGEaa3faa3c7aWITH support in MERGE83454e3c2bNew files for MERGEd204ef6377MERGE SQL Command following SQL:2016 Author: Pavan Deolasee Reviewed-by: Michael Paquier
This commit is contained in:
@@ -207,7 +207,6 @@ _copyModifyTable(const ModifyTable *from)
|
||||
COPY_NODE_FIELD(partitioned_rels);
|
||||
COPY_SCALAR_FIELD(partColsUpdated);
|
||||
COPY_NODE_FIELD(resultRelations);
|
||||
COPY_SCALAR_FIELD(mergeTargetRelation);
|
||||
COPY_SCALAR_FIELD(resultRelIndex);
|
||||
COPY_SCALAR_FIELD(rootResultRelIndex);
|
||||
COPY_NODE_FIELD(plans);
|
||||
@@ -223,8 +222,6 @@ _copyModifyTable(const ModifyTable *from)
|
||||
COPY_NODE_FIELD(onConflictWhere);
|
||||
COPY_SCALAR_FIELD(exclRelRTI);
|
||||
COPY_NODE_FIELD(exclRelTlist);
|
||||
COPY_NODE_FIELD(mergeSourceTargetList);
|
||||
COPY_NODE_FIELD(mergeActionList);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
@@ -2137,20 +2134,6 @@ _copyOnConflictExpr(const OnConflictExpr *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static MergeAction *
|
||||
_copyMergeAction(const MergeAction *from)
|
||||
{
|
||||
MergeAction *newnode = makeNode(MergeAction);
|
||||
|
||||
COPY_SCALAR_FIELD(matched);
|
||||
COPY_SCALAR_FIELD(commandType);
|
||||
COPY_SCALAR_FIELD(override);
|
||||
COPY_NODE_FIELD(qual);
|
||||
COPY_NODE_FIELD(targetList);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyPartitionPruneStepOp
|
||||
*/
|
||||
@@ -3030,9 +3013,6 @@ _copyQuery(const Query *from)
|
||||
COPY_NODE_FIELD(setOperations);
|
||||
COPY_NODE_FIELD(constraintDeps);
|
||||
COPY_NODE_FIELD(withCheckOptions);
|
||||
COPY_SCALAR_FIELD(mergeTarget_relation);
|
||||
COPY_NODE_FIELD(mergeSourceTargetList);
|
||||
COPY_NODE_FIELD(mergeActionList);
|
||||
COPY_LOCATION_FIELD(stmt_location);
|
||||
COPY_LOCATION_FIELD(stmt_len);
|
||||
|
||||
@@ -3096,35 +3076,6 @@ _copyUpdateStmt(const UpdateStmt *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static MergeStmt *
|
||||
_copyMergeStmt(const MergeStmt *from)
|
||||
{
|
||||
MergeStmt *newnode = makeNode(MergeStmt);
|
||||
|
||||
COPY_NODE_FIELD(relation);
|
||||
COPY_NODE_FIELD(source_relation);
|
||||
COPY_NODE_FIELD(join_condition);
|
||||
COPY_NODE_FIELD(mergeWhenClauses);
|
||||
COPY_NODE_FIELD(withClause);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static MergeWhenClause *
|
||||
_copyMergeWhenClause(const MergeWhenClause *from)
|
||||
{
|
||||
MergeWhenClause *newnode = makeNode(MergeWhenClause);
|
||||
|
||||
COPY_SCALAR_FIELD(matched);
|
||||
COPY_SCALAR_FIELD(commandType);
|
||||
COPY_NODE_FIELD(condition);
|
||||
COPY_NODE_FIELD(targetList);
|
||||
COPY_NODE_FIELD(cols);
|
||||
COPY_NODE_FIELD(values);
|
||||
COPY_SCALAR_FIELD(override);
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static SelectStmt *
|
||||
_copySelectStmt(const SelectStmt *from)
|
||||
{
|
||||
@@ -5110,9 +5061,6 @@ copyObjectImpl(const void *from)
|
||||
case T_OnConflictExpr:
|
||||
retval = _copyOnConflictExpr(from);
|
||||
break;
|
||||
case T_MergeAction:
|
||||
retval = _copyMergeAction(from);
|
||||
break;
|
||||
case T_PartitionPruneStepOp:
|
||||
retval = _copyPartitionPruneStepOp(from);
|
||||
break;
|
||||
@@ -5197,12 +5145,6 @@ copyObjectImpl(const void *from)
|
||||
case T_UpdateStmt:
|
||||
retval = _copyUpdateStmt(from);
|
||||
break;
|
||||
case T_MergeStmt:
|
||||
retval = _copyMergeStmt(from);
|
||||
break;
|
||||
case T_MergeWhenClause:
|
||||
retval = _copyMergeWhenClause(from);
|
||||
break;
|
||||
case T_SelectStmt:
|
||||
retval = _copySelectStmt(from);
|
||||
break;
|
||||
|
||||
@@ -812,18 +812,6 @@ _equalOnConflictExpr(const OnConflictExpr *a, const OnConflictExpr *b)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
_equalMergeAction(const MergeAction *a, const MergeAction *b)
|
||||
{
|
||||
COMPARE_SCALAR_FIELD(matched);
|
||||
COMPARE_SCALAR_FIELD(commandType);
|
||||
COMPARE_SCALAR_FIELD(override);
|
||||
COMPARE_NODE_FIELD(qual);
|
||||
COMPARE_NODE_FIELD(targetList);
|
||||
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
* Stuff from relation.h
|
||||
*/
|
||||
@@ -989,8 +977,6 @@ _equalQuery(const Query *a, const Query *b)
|
||||
COMPARE_NODE_FIELD(setOperations);
|
||||
COMPARE_NODE_FIELD(constraintDeps);
|
||||
COMPARE_NODE_FIELD(withCheckOptions);
|
||||
COMPARE_NODE_FIELD(mergeSourceTargetList);
|
||||
COMPARE_NODE_FIELD(mergeActionList);
|
||||
COMPARE_LOCATION_FIELD(stmt_location);
|
||||
COMPARE_LOCATION_FIELD(stmt_len);
|
||||
|
||||
@@ -1046,32 +1032,6 @@ _equalUpdateStmt(const UpdateStmt *a, const UpdateStmt *b)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalMergeStmt(const MergeStmt *a, const MergeStmt *b)
|
||||
{
|
||||
COMPARE_NODE_FIELD(relation);
|
||||
COMPARE_NODE_FIELD(source_relation);
|
||||
COMPARE_NODE_FIELD(join_condition);
|
||||
COMPARE_NODE_FIELD(mergeWhenClauses);
|
||||
COMPARE_NODE_FIELD(withClause);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalMergeWhenClause(const MergeWhenClause *a, const MergeWhenClause *b)
|
||||
{
|
||||
COMPARE_SCALAR_FIELD(matched);
|
||||
COMPARE_SCALAR_FIELD(commandType);
|
||||
COMPARE_NODE_FIELD(condition);
|
||||
COMPARE_NODE_FIELD(targetList);
|
||||
COMPARE_NODE_FIELD(cols);
|
||||
COMPARE_NODE_FIELD(values);
|
||||
COMPARE_SCALAR_FIELD(override);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalSelectStmt(const SelectStmt *a, const SelectStmt *b)
|
||||
{
|
||||
@@ -3197,9 +3157,6 @@ equal(const void *a, const void *b)
|
||||
case T_OnConflictExpr:
|
||||
retval = _equalOnConflictExpr(a, b);
|
||||
break;
|
||||
case T_MergeAction:
|
||||
retval = _equalMergeAction(a, b);
|
||||
break;
|
||||
case T_JoinExpr:
|
||||
retval = _equalJoinExpr(a, b);
|
||||
break;
|
||||
@@ -3265,12 +3222,6 @@ equal(const void *a, const void *b)
|
||||
case T_UpdateStmt:
|
||||
retval = _equalUpdateStmt(a, b);
|
||||
break;
|
||||
case T_MergeStmt:
|
||||
retval = _equalMergeStmt(a, b);
|
||||
break;
|
||||
case T_MergeWhenClause:
|
||||
retval = _equalMergeWhenClause(a, b);
|
||||
break;
|
||||
case T_SelectStmt:
|
||||
retval = _equalSelectStmt(a, b);
|
||||
break;
|
||||
|
||||
@@ -2146,16 +2146,6 @@ expression_tree_walker(Node *node,
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case T_MergeAction:
|
||||
{
|
||||
MergeAction *action = (MergeAction *) node;
|
||||
|
||||
if (walker(action->targetList, context))
|
||||
return true;
|
||||
if (walker(action->qual, context))
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case T_PartitionPruneStepOp:
|
||||
{
|
||||
PartitionPruneStepOp *opstep = (PartitionPruneStepOp *) node;
|
||||
@@ -2276,10 +2266,6 @@ query_tree_walker(Query *query,
|
||||
return true;
|
||||
if (walker((Node *) query->onConflict, context))
|
||||
return true;
|
||||
if (walker((Node *) query->mergeSourceTargetList, context))
|
||||
return true;
|
||||
if (walker((Node *) query->mergeActionList, context))
|
||||
return true;
|
||||
if (walker((Node *) query->returningList, context))
|
||||
return true;
|
||||
if (walker((Node *) query->jointree, context))
|
||||
@@ -2957,18 +2943,6 @@ expression_tree_mutator(Node *node,
|
||||
return (Node *) newnode;
|
||||
}
|
||||
break;
|
||||
case T_MergeAction:
|
||||
{
|
||||
MergeAction *action = (MergeAction *) node;
|
||||
MergeAction *newnode;
|
||||
|
||||
FLATCOPY(newnode, action, MergeAction);
|
||||
MUTATE(newnode->qual, action->qual, Node *);
|
||||
MUTATE(newnode->targetList, action->targetList, List *);
|
||||
|
||||
return (Node *) newnode;
|
||||
}
|
||||
break;
|
||||
case T_PartitionPruneStepOp:
|
||||
{
|
||||
PartitionPruneStepOp *opstep = (PartitionPruneStepOp *) node;
|
||||
@@ -3134,8 +3108,6 @@ query_tree_mutator(Query *query,
|
||||
MUTATE(query->targetList, query->targetList, List *);
|
||||
MUTATE(query->withCheckOptions, query->withCheckOptions, List *);
|
||||
MUTATE(query->onConflict, query->onConflict, OnConflictExpr *);
|
||||
MUTATE(query->mergeSourceTargetList, query->mergeSourceTargetList, List *);
|
||||
MUTATE(query->mergeActionList, query->mergeActionList, List *);
|
||||
MUTATE(query->returningList, query->returningList, List *);
|
||||
MUTATE(query->jointree, query->jointree, FromExpr *);
|
||||
MUTATE(query->setOperations, query->setOperations, Node *);
|
||||
@@ -3277,9 +3249,9 @@ query_or_expression_tree_mutator(Node *node,
|
||||
* boundaries: we descend to everything that's possibly interesting.
|
||||
*
|
||||
* Currently, the node type coverage here extends only to DML statements
|
||||
* (SELECT/INSERT/UPDATE/DELETE/MERGE) and nodes that can appear in them,
|
||||
* because this is used mainly during analysis of CTEs, and only DML
|
||||
* statements can appear in CTEs.
|
||||
* (SELECT/INSERT/UPDATE/DELETE) and nodes that can appear in them, because
|
||||
* this is used mainly during analysis of CTEs, and only DML statements can
|
||||
* appear in CTEs.
|
||||
*/
|
||||
bool
|
||||
raw_expression_tree_walker(Node *node,
|
||||
@@ -3459,36 +3431,6 @@ raw_expression_tree_walker(Node *node,
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case T_MergeStmt:
|
||||
{
|
||||
MergeStmt *stmt = (MergeStmt *) node;
|
||||
|
||||
if (walker(stmt->relation, context))
|
||||
return true;
|
||||
if (walker(stmt->source_relation, context))
|
||||
return true;
|
||||
if (walker(stmt->join_condition, context))
|
||||
return true;
|
||||
if (walker(stmt->mergeWhenClauses, context))
|
||||
return true;
|
||||
if (walker(stmt->withClause, context))
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case T_MergeWhenClause:
|
||||
{
|
||||
MergeWhenClause *mergeWhenClause = (MergeWhenClause *) node;
|
||||
|
||||
if (walker(mergeWhenClause->condition, context))
|
||||
return true;
|
||||
if (walker(mergeWhenClause->targetList, context))
|
||||
return true;
|
||||
if (walker(mergeWhenClause->cols, context))
|
||||
return true;
|
||||
if (walker(mergeWhenClause->values, context))
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case T_SelectStmt:
|
||||
{
|
||||
SelectStmt *stmt = (SelectStmt *) node;
|
||||
|
||||
@@ -375,7 +375,6 @@ _outModifyTable(StringInfo str, const ModifyTable *node)
|
||||
WRITE_NODE_FIELD(partitioned_rels);
|
||||
WRITE_BOOL_FIELD(partColsUpdated);
|
||||
WRITE_NODE_FIELD(resultRelations);
|
||||
WRITE_INT_FIELD(mergeTargetRelation);
|
||||
WRITE_INT_FIELD(resultRelIndex);
|
||||
WRITE_INT_FIELD(rootResultRelIndex);
|
||||
WRITE_NODE_FIELD(plans);
|
||||
@@ -391,22 +390,6 @@ _outModifyTable(StringInfo str, const ModifyTable *node)
|
||||
WRITE_NODE_FIELD(onConflictWhere);
|
||||
WRITE_UINT_FIELD(exclRelRTI);
|
||||
WRITE_NODE_FIELD(exclRelTlist);
|
||||
WRITE_NODE_FIELD(mergeSourceTargetList);
|
||||
WRITE_NODE_FIELD(mergeActionList);
|
||||
}
|
||||
|
||||
static void
|
||||
_outMergeWhenClause(StringInfo str, const MergeWhenClause *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("MERGEWHENCLAUSE");
|
||||
|
||||
WRITE_BOOL_FIELD(matched);
|
||||
WRITE_ENUM_FIELD(commandType, CmdType);
|
||||
WRITE_NODE_FIELD(condition);
|
||||
WRITE_NODE_FIELD(targetList);
|
||||
WRITE_NODE_FIELD(cols);
|
||||
WRITE_NODE_FIELD(values);
|
||||
WRITE_ENUM_FIELD(override, OverridingKind);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1748,17 +1731,6 @@ _outOnConflictExpr(StringInfo str, const OnConflictExpr *node)
|
||||
WRITE_NODE_FIELD(exclRelTlist);
|
||||
}
|
||||
|
||||
static void
|
||||
_outMergeAction(StringInfo str, const MergeAction *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("MERGEACTION");
|
||||
|
||||
WRITE_BOOL_FIELD(matched);
|
||||
WRITE_ENUM_FIELD(commandType, CmdType);
|
||||
WRITE_NODE_FIELD(qual);
|
||||
WRITE_NODE_FIELD(targetList);
|
||||
}
|
||||
|
||||
static void
|
||||
_outPartitionPruneInfo(StringInfo str, const PartitionPruneInfo *node)
|
||||
{
|
||||
@@ -2189,7 +2161,6 @@ _outModifyTablePath(StringInfo str, const ModifyTablePath *node)
|
||||
WRITE_NODE_FIELD(partitioned_rels);
|
||||
WRITE_BOOL_FIELD(partColsUpdated);
|
||||
WRITE_NODE_FIELD(resultRelations);
|
||||
WRITE_INT_FIELD(mergeTargetRelation);
|
||||
WRITE_NODE_FIELD(subpaths);
|
||||
WRITE_NODE_FIELD(subroots);
|
||||
WRITE_NODE_FIELD(withCheckOptionLists);
|
||||
@@ -2197,8 +2168,6 @@ _outModifyTablePath(StringInfo str, const ModifyTablePath *node)
|
||||
WRITE_NODE_FIELD(rowMarks);
|
||||
WRITE_NODE_FIELD(onconflict);
|
||||
WRITE_INT_FIELD(epqParam);
|
||||
WRITE_NODE_FIELD(mergeSourceTargetList);
|
||||
WRITE_NODE_FIELD(mergeActionList);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3012,9 +2981,6 @@ _outQuery(StringInfo str, const Query *node)
|
||||
WRITE_NODE_FIELD(setOperations);
|
||||
WRITE_NODE_FIELD(constraintDeps);
|
||||
/* withCheckOptions intentionally omitted, see comment in parsenodes.h */
|
||||
WRITE_INT_FIELD(mergeTarget_relation);
|
||||
WRITE_NODE_FIELD(mergeSourceTargetList);
|
||||
WRITE_NODE_FIELD(mergeActionList);
|
||||
WRITE_LOCATION_FIELD(stmt_location);
|
||||
WRITE_LOCATION_FIELD(stmt_len);
|
||||
}
|
||||
@@ -3733,9 +3699,6 @@ outNode(StringInfo str, const void *obj)
|
||||
case T_ModifyTable:
|
||||
_outModifyTable(str, obj);
|
||||
break;
|
||||
case T_MergeWhenClause:
|
||||
_outMergeWhenClause(str, obj);
|
||||
break;
|
||||
case T_Append:
|
||||
_outAppend(str, obj);
|
||||
break;
|
||||
@@ -4012,9 +3975,6 @@ outNode(StringInfo str, const void *obj)
|
||||
case T_OnConflictExpr:
|
||||
_outOnConflictExpr(str, obj);
|
||||
break;
|
||||
case T_MergeAction:
|
||||
_outMergeAction(str, obj);
|
||||
break;
|
||||
case T_PartitionPruneStepOp:
|
||||
_outPartitionPruneStepOp(str, obj);
|
||||
break;
|
||||
|
||||
@@ -270,9 +270,6 @@ _readQuery(void)
|
||||
READ_NODE_FIELD(setOperations);
|
||||
READ_NODE_FIELD(constraintDeps);
|
||||
/* withCheckOptions intentionally omitted, see comment in parsenodes.h */
|
||||
READ_INT_FIELD(mergeTarget_relation);
|
||||
READ_NODE_FIELD(mergeSourceTargetList);
|
||||
READ_NODE_FIELD(mergeActionList);
|
||||
READ_LOCATION_FIELD(stmt_location);
|
||||
READ_LOCATION_FIELD(stmt_len);
|
||||
|
||||
@@ -1357,22 +1354,6 @@ _readPartitionPruneStepCombine(void)
|
||||
READ_DONE();
|
||||
}
|
||||
|
||||
/*
|
||||
* _readMergeAction
|
||||
*/
|
||||
static MergeAction *
|
||||
_readMergeAction(void)
|
||||
{
|
||||
READ_LOCALS(MergeAction);
|
||||
|
||||
READ_BOOL_FIELD(matched);
|
||||
READ_ENUM_FIELD(commandType, CmdType);
|
||||
READ_NODE_FIELD(qual);
|
||||
READ_NODE_FIELD(targetList);
|
||||
|
||||
READ_DONE();
|
||||
}
|
||||
|
||||
static PartitionPruneInfo *
|
||||
_readPartitionPruneInfo(void)
|
||||
{
|
||||
@@ -1638,7 +1619,6 @@ _readModifyTable(void)
|
||||
READ_NODE_FIELD(partitioned_rels);
|
||||
READ_BOOL_FIELD(partColsUpdated);
|
||||
READ_NODE_FIELD(resultRelations);
|
||||
READ_INT_FIELD(mergeTargetRelation);
|
||||
READ_INT_FIELD(resultRelIndex);
|
||||
READ_INT_FIELD(rootResultRelIndex);
|
||||
READ_NODE_FIELD(plans);
|
||||
@@ -1654,27 +1634,6 @@ _readModifyTable(void)
|
||||
READ_NODE_FIELD(onConflictWhere);
|
||||
READ_UINT_FIELD(exclRelRTI);
|
||||
READ_NODE_FIELD(exclRelTlist);
|
||||
READ_NODE_FIELD(mergeSourceTargetList);
|
||||
READ_NODE_FIELD(mergeActionList);
|
||||
|
||||
READ_DONE();
|
||||
}
|
||||
|
||||
/*
|
||||
* _readMergeWhenClause
|
||||
*/
|
||||
static MergeWhenClause *
|
||||
_readMergeWhenClause(void)
|
||||
{
|
||||
READ_LOCALS(MergeWhenClause);
|
||||
|
||||
READ_BOOL_FIELD(matched);
|
||||
READ_ENUM_FIELD(commandType, CmdType);
|
||||
READ_NODE_FIELD(condition);
|
||||
READ_NODE_FIELD(targetList);
|
||||
READ_NODE_FIELD(cols);
|
||||
READ_NODE_FIELD(values);
|
||||
READ_ENUM_FIELD(override, OverridingKind);
|
||||
|
||||
READ_DONE();
|
||||
}
|
||||
@@ -2657,8 +2616,6 @@ parseNodeString(void)
|
||||
return_value = _readFromExpr();
|
||||
else if (MATCH("ONCONFLICTEXPR", 14))
|
||||
return_value = _readOnConflictExpr();
|
||||
else if (MATCH("MERGEACTION", 11))
|
||||
return_value = _readMergeAction();
|
||||
else if (MATCH("PARTITIONPRUNESTEPOP", 20))
|
||||
return_value = _readPartitionPruneStepOp();
|
||||
else if (MATCH("PARTITIONPRUNESTEPCOMBINE", 25))
|
||||
@@ -2687,8 +2644,6 @@ parseNodeString(void)
|
||||
return_value = _readProjectSet();
|
||||
else if (MATCH("MODIFYTABLE", 11))
|
||||
return_value = _readModifyTable();
|
||||
else if (MATCH("MERGEWHENCLAUSE", 15))
|
||||
return_value = _readMergeWhenClause();
|
||||
else if (MATCH("APPEND", 6))
|
||||
return_value = _readAppend();
|
||||
else if (MATCH("MERGEAPPEND", 11))
|
||||
|
||||
Reference in New Issue
Block a user