summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/prep/prepkeyset.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-09-29 18:21:41 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-09-29 18:21:41 +0000
commit3a94e789f5c9537d804210be3cb26f7fb08e3b9e (patch)
treef1eac12405e3c0ded881d7dd7e59cec35b30c335 /src/backend/optimizer/prep/prepkeyset.c
parent6f64c2e54a0b14154a335249f4dca91a39c61c50 (diff)
Subselects in FROM clause, per ISO syntax: FROM (SELECT ...) [AS] alias.
(Don't forget that an alias is required.) Views reimplemented as expanding to subselect-in-FROM. Grouping, aggregates, DISTINCT in views actually work now (he says optimistically). No UNION support in subselects/views yet, but I have some ideas about that. Rule-related permissions checking moved out of rewriter and into executor. INITDB REQUIRED!
Diffstat (limited to 'src/backend/optimizer/prep/prepkeyset.c')
-rw-r--r--src/backend/optimizer/prep/prepkeyset.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/backend/optimizer/prep/prepkeyset.c b/src/backend/optimizer/prep/prepkeyset.c
index a28e329e537..60166289a59 100644
--- a/src/backend/optimizer/prep/prepkeyset.c
+++ b/src/backend/optimizer/prep/prepkeyset.c
@@ -85,19 +85,14 @@ transformKeySetQuery(Query *origNode)
/*************************/
/* Qualify where clause */
/*************************/
- if (!inspectOrNode((Expr *) origNode->qual) || TotalExpr < 9)
+ if (!inspectOrNode((Expr *) origNode->jointree->quals) || TotalExpr < 9)
return;
/* Copy essential elements into a union node */
- while (((Expr *) origNode->qual)->opType == OR_EXPR)
+ while (((Expr *) origNode->jointree->quals)->opType == OR_EXPR)
{
Query *unionNode = makeNode(Query);
-
- /* Pull up Expr = */
- unionNode->qual = lsecond(((Expr *) origNode->qual)->args);
-
- /* Pull up balance of tree */
- origNode->qual = lfirst(((Expr *) origNode->qual)->args);
+ List *qualargs = ((Expr *) origNode->jointree->quals)->args;
unionNode->commandType = origNode->commandType;
unionNode->resultRelation = origNode->resultRelation;
@@ -107,9 +102,16 @@ transformKeySetQuery(Query *origNode)
Node_Copy(origNode, unionNode, distinctClause);
Node_Copy(origNode, unionNode, sortClause);
Node_Copy(origNode, unionNode, rtable);
+ origNode->jointree->quals = NULL; /* avoid unnecessary copying */
Node_Copy(origNode, unionNode, jointree);
Node_Copy(origNode, unionNode, targetList);
+ /* Pull up Expr = */
+ unionNode->jointree->quals = lsecond(qualargs);
+
+ /* Pull up balance of tree */
+ origNode->jointree->quals = lfirst(qualargs);
+
origNode->unionClause = lappend(origNode->unionClause, unionNode);
}
return;