Commit 31a697bf authored by Bruce Momjian's avatar Bruce Momjian

Yohoo UNIONS of VIEWS.

parent 8f125413
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.27 1998/01/04 04:31:02 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.28 1998/01/09 05:48:10 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1520,6 +1520,16 @@ _copyQuery(Query *from) ...@@ -1520,6 +1520,16 @@ _copyQuery(Query *from)
int i; int i;
newnode->commandType = from->commandType; newnode->commandType = from->commandType;
if (from->utilityStmt && nodeTag(from->utilityStmt) == T_NotifyStmt)
{
NotifyStmt *from_notify = (NotifyStmt *) from->utilityStmt;
NotifyStmt *n = makeNode(NotifyStmt);
int length = strlen(from_notify->relname);
n->relname = palloc(length + 1);
strcpy(n->relname, from_notify->relname);
newnode->utilityStmt = (Node *) n;
}
newnode->resultRelation = from->resultRelation; newnode->resultRelation = from->resultRelation;
/* probably should dup this string instead of just pointing */ /* probably should dup this string instead of just pointing */
/* to the old one --djm */ /* to the old one --djm */
...@@ -1532,17 +1542,8 @@ _copyQuery(Query *from) ...@@ -1532,17 +1542,8 @@ _copyQuery(Query *from)
newnode->into = (char *) 0; newnode->into = (char *) 0;
} }
newnode->isPortal = from->isPortal; newnode->isPortal = from->isPortal;
Node_Copy(from, newnode, rtable); newnode->isBinary = from->isBinary;
if (from->utilityStmt && nodeTag(from->utilityStmt) == T_NotifyStmt) newnode->unionall = from->unionall;
{
NotifyStmt *from_notify = (NotifyStmt *) from->utilityStmt;
NotifyStmt *n = makeNode(NotifyStmt);
int length = strlen(from_notify->relname);
n->relname = palloc(length + 1);
strcpy(n->relname, from_notify->relname);
newnode->utilityStmt = (Node *) n;
}
if (from->uniqueFlag) if (from->uniqueFlag)
{ {
newnode->uniqueFlag = (char *) palloc(strlen(from->uniqueFlag) + 1); newnode->uniqueFlag = (char *) palloc(strlen(from->uniqueFlag) + 1);
...@@ -1551,6 +1552,7 @@ _copyQuery(Query *from) ...@@ -1551,6 +1552,7 @@ _copyQuery(Query *from)
else else
newnode->uniqueFlag = NULL; newnode->uniqueFlag = NULL;
Node_Copy(from, newnode, sortClause); Node_Copy(from, newnode, sortClause);
Node_Copy(from, newnode, rtable);
Node_Copy(from, newnode, targetList); Node_Copy(from, newnode, targetList);
Node_Copy(from, newnode, qual); Node_Copy(from, newnode, qual);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.9 1998/01/07 21:04:37 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.10 1998/01/09 05:48:17 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -598,8 +598,12 @@ RewriteQuery(Query *parsetree, bool *instead_flag, List **qual_products) ...@@ -598,8 +598,12 @@ RewriteQuery(Query *parsetree, bool *instead_flag, List **qual_products)
*/ */
Query *other; Query *other;
other = copyObject(parsetree); /* ApplyRetrieveRule changes the /*
* range table */ * ApplyRetrieveRule changes the range table
* XXX Unions are copied again.
*/
other = copyObject(parsetree);
return return
ProcessRetrieveQuery(other, parsetree->rtable, ProcessRetrieveQuery(other, parsetree->rtable,
instead_flag, FALSE); instead_flag, FALSE);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.59 1998/01/07 21:06:00 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.60 1998/01/09 05:48:22 momjian Exp $
* *
* NOTES * NOTES
* this is the "main" module of the postgres backend and * this is the "main" module of the postgres backend and
...@@ -439,6 +439,8 @@ pg_parse_and_plan(char *query_string, /* string to execute */ ...@@ -439,6 +439,8 @@ pg_parse_and_plan(char *query_string, /* string to execute */
* rewrites */ * rewrites */
for (i = 0; i < querytree_list->len; i++) for (i = 0; i < querytree_list->len; i++)
{ {
List *union_result, *union_list, *rewritten_list;
querytree = querytree_list->qtrees[i]; querytree = querytree_list->qtrees[i];
...@@ -465,6 +467,19 @@ pg_parse_and_plan(char *query_string, /* string to execute */ ...@@ -465,6 +467,19 @@ pg_parse_and_plan(char *query_string, /* string to execute */
/* rewrite queries (retrieve, append, delete, replace) */ /* rewrite queries (retrieve, append, delete, replace) */
rewritten = QueryRewrite(querytree); rewritten = QueryRewrite(querytree);
/*
* Rewrite the UNIONS.
*/
foreach(rewritten_list, rewritten)
{
Query *qry = (Query *)lfirst(rewritten_list);
union_result = NIL;
foreach(union_list, qry->unionClause)
union_result = nconc(union_result, QueryRewrite((Query *)lfirst(union_list)));
qry->unionClause = union_result;
}
if (rewritten != NULL) if (rewritten != NULL)
{ {
int len, int len,
...@@ -1372,7 +1387,7 @@ PostgresMain(int argc, char *argv[]) ...@@ -1372,7 +1387,7 @@ PostgresMain(int argc, char *argv[])
if (IsUnderPostmaster == false) if (IsUnderPostmaster == false)
{ {
puts("\nPOSTGRES backend interactive interface"); puts("\nPOSTGRES backend interactive interface");
puts("$Revision: 1.59 $ $Date: 1998/01/07 21:06:00 $"); puts("$Revision: 1.60 $ $Date: 1998/01/09 05:48:22 $");
} }
/* ---------------- /* ----------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment