aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_clause.c
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2018-04-12 11:22:56 +0100
committerSimon Riggs <simon@2ndQuadrant.com>2018-04-12 11:22:56 +0100
commit08ea7a2291db21a618d19d612c8060cda68f1892 (patch)
tree4d10675439742c7206e089bd21e793332562ae83 /src/backend/parser/parse_clause.c
parentc9c875a28fa6cbc38c227fb9e656dd7be948166f (diff)
downloadpostgresql-08ea7a2291db21a618d19d612c8060cda68f1892.tar.gz
postgresql-08ea7a2291db21a618d19d612c8060cda68f1892.zip
Revert MERGE patch
This reverts commits d204ef63776b8a00ca220adec23979091564e465, 83454e3c2b28141c0db01c7d2027e01040df5249 and 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: f1464c5380 Improve parse representation for MERGE ddb4158579 MERGE syntax diagram correction 530e69e59b Allow cpluspluscheck to pass by renaming variable 01b88b4df5 MERGE minor errata 3af7b2b0d4 MERGE fix variable warning in non-assert builds a5d86181ec MERGE INSERT allows only one VALUES clause 4b2d44031f MERGE post-commit review 4923550c20 Tab completion for MERGE aa3faa3c7a WITH support in MERGE 83454e3c2b New files for MERGE d204ef6377 MERGE SQL Command following SQL:2016 Author: Pavan Deolasee Reviewed-by: Michael Paquier
Diffstat (limited to 'src/backend/parser/parse_clause.c')
-rw-r--r--src/backend/parser/parse_clause.c57
1 files changed, 11 insertions, 46 deletions
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index c73d06b3917..e1478805c26 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -76,6 +76,9 @@ static RangeTblEntry *transformRangeTableFunc(ParseState *pstate,
RangeTableFunc *t);
static TableSampleClause *transformRangeTableSample(ParseState *pstate,
RangeTableSample *rts);
+static Node *transformFromClauseItem(ParseState *pstate, Node *n,
+ RangeTblEntry **top_rte, int *top_rti,
+ List **namespace);
static Node *buildMergedJoinVar(ParseState *pstate, JoinType jointype,
Var *l_colvar, Var *r_colvar);
static ParseNamespaceItem *makeNamespaceItem(RangeTblEntry *rte,
@@ -136,7 +139,6 @@ transformFromClause(ParseState *pstate, List *frmList)
n = transformFromClauseItem(pstate, n,
&rte,
&rtindex,
- NULL, NULL,
&namespace);
checkNameSpaceConflicts(pstate, pstate->p_namespace, namespace);
@@ -1094,21 +1096,14 @@ getRTEForSpecialRelationTypes(ParseState *pstate, RangeVar *rv)
*
* *top_rti: receives the rangetable index of top_rte. (Ditto.)
*
- * *right_rte: receives the RTE corresponding to the right side of the
- * jointree. Only MERGE really needs to know about this and only MERGE passes a
- * non-NULL pointer.
- *
- * *right_rti: receives the rangetable index of the right_rte.
- *
* *namespace: receives a List of ParseNamespaceItems for the RTEs exposed
* as table/column names by this item. (The lateral_only flags in these items
* are indeterminate and should be explicitly set by the caller before use.)
*/
-Node *
+static Node *
transformFromClauseItem(ParseState *pstate, Node *n,
RangeTblEntry **top_rte, int *top_rti,
- RangeTblEntry **right_rte, int *right_rti,
- List **fnamespace)
+ List **namespace)
{
if (IsA(n, RangeVar))
{
@@ -1130,7 +1125,7 @@ transformFromClauseItem(ParseState *pstate, Node *n,
Assert(rte == rt_fetch(rtindex, pstate->p_rtable));
*top_rte = rte;
*top_rti = rtindex;
- *fnamespace = list_make1(makeDefaultNSItem(rte));
+ *namespace = list_make1(makeDefaultNSItem(rte));
rtr = makeNode(RangeTblRef);
rtr->rtindex = rtindex;
return (Node *) rtr;
@@ -1148,7 +1143,7 @@ transformFromClauseItem(ParseState *pstate, Node *n,
Assert(rte == rt_fetch(rtindex, pstate->p_rtable));
*top_rte = rte;
*top_rti = rtindex;
- *fnamespace = list_make1(makeDefaultNSItem(rte));
+ *namespace = list_make1(makeDefaultNSItem(rte));
rtr = makeNode(RangeTblRef);
rtr->rtindex = rtindex;
return (Node *) rtr;
@@ -1166,7 +1161,7 @@ transformFromClauseItem(ParseState *pstate, Node *n,
Assert(rte == rt_fetch(rtindex, pstate->p_rtable));
*top_rte = rte;
*top_rti = rtindex;
- *fnamespace = list_make1(makeDefaultNSItem(rte));
+ *namespace = list_make1(makeDefaultNSItem(rte));
rtr = makeNode(RangeTblRef);
rtr->rtindex = rtindex;
return (Node *) rtr;
@@ -1184,7 +1179,7 @@ transformFromClauseItem(ParseState *pstate, Node *n,
Assert(rte == rt_fetch(rtindex, pstate->p_rtable));
*top_rte = rte;
*top_rti = rtindex;
- *fnamespace = list_make1(makeDefaultNSItem(rte));
+ *namespace = list_make1(makeDefaultNSItem(rte));
rtr = makeNode(RangeTblRef);
rtr->rtindex = rtindex;
return (Node *) rtr;
@@ -1199,7 +1194,7 @@ transformFromClauseItem(ParseState *pstate, Node *n,
/* Recursively transform the contained relation */
rel = transformFromClauseItem(pstate, rts->relation,
- top_rte, top_rti, NULL, NULL, fnamespace);
+ top_rte, top_rti, namespace);
/* Currently, grammar could only return a RangeVar as contained rel */
rtr = castNode(RangeTblRef, rel);
rte = rt_fetch(rtr->rtindex, pstate->p_rtable);
@@ -1227,7 +1222,6 @@ transformFromClauseItem(ParseState *pstate, Node *n,
List *l_namespace,
*r_namespace,
*my_namespace,
- *save_namespace,
*l_colnames,
*r_colnames,
*res_colnames,
@@ -1246,7 +1240,6 @@ transformFromClauseItem(ParseState *pstate, Node *n,
j->larg = transformFromClauseItem(pstate, j->larg,
&l_rte,
&l_rtindex,
- NULL, NULL,
&l_namespace);
/*
@@ -1270,34 +1263,12 @@ transformFromClauseItem(ParseState *pstate, Node *n,
sv_namespace_length = list_length(pstate->p_namespace);
pstate->p_namespace = list_concat(pstate->p_namespace, l_namespace);
- /*
- * If we are running MERGE, don't make the other RTEs visible while
- * parsing the source relation. It mustn't see them.
- *
- * Currently, only MERGE passes non-NULL value for right_rte, so we
- * can safely deduce if we're running MERGE or not by just looking at
- * the right_rte. If that ever changes, we should look at other means
- * to find that.
- */
- if (right_rte)
- {
- save_namespace = pstate->p_namespace;
- pstate->p_namespace = NIL;
- }
-
/* And now we can process the RHS */
j->rarg = transformFromClauseItem(pstate, j->rarg,
&r_rte,
&r_rtindex,
- NULL, NULL,
&r_namespace);
- /*
- * And now restore the namespace again so that join-quals can see it.
- */
- if (right_rte)
- pstate->p_namespace = save_namespace;
-
/* Remove the left-side RTEs from the namespace list again */
pstate->p_namespace = list_truncate(pstate->p_namespace,
sv_namespace_length);
@@ -1324,12 +1295,6 @@ transformFromClauseItem(ParseState *pstate, Node *n,
expandRTE(r_rte, r_rtindex, 0, -1, false,
&r_colnames, &r_colvars);
- if (right_rte)
- *right_rte = r_rte;
-
- if (right_rti)
- *right_rti = r_rtindex;
-
/*
* Natural join does not explicitly specify columns; must generate
* columns to join. Need to run through the list of columns from each
@@ -1558,7 +1523,7 @@ transformFromClauseItem(ParseState *pstate, Node *n,
* The join RTE itself is always made visible for unqualified column
* names. It's visible as a relation name only if it has an alias.
*/
- *fnamespace = lappend(my_namespace,
+ *namespace = lappend(my_namespace,
makeNamespaceItem(rte,
(j->alias != NULL),
true,