1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-15 19:21:59 +03:00

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!
This commit is contained in:
Tom Lane
2000-09-29 18:21:41 +00:00
parent 6f64c2e54a
commit 3a94e789f5
77 changed files with 3176 additions and 2661 deletions

View File

@ -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;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.52 2000/09/12 21:06:57 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.53 2000/09/29 18:21:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -411,7 +411,7 @@ find_all_inheritors(Oid parentrel)
* there can't be any cycles in the inheritance graph anyway.)
*/
currentchildren = set_differencei(currentchildren, examined_relids);
unexamined_relids = LispUnioni(unexamined_relids, currentchildren);
unexamined_relids = set_unioni(unexamined_relids, currentchildren);
}
return examined_relids;