diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-02-07 04:41:04 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-02-07 04:41:04 +0000 |
commit | d8733ce674f62f0e13cfc97d0340b43e1906f458 (patch) | |
tree | fc210768a24a14d07b9bffb9dd629f400bb7cc8f /src/backend/nodes | |
parent | 2bda7a44067f22f73cd7937f6c88efd1bbe97638 (diff) | |
download | postgresql-d8733ce674f62f0e13cfc97d0340b43e1906f458.tar.gz postgresql-d8733ce674f62f0e13cfc97d0340b43e1906f458.zip |
Repair planning bugs caused by my misguided removal of restrictinfo link
fields in JoinPaths --- turns out that we do need that after all :-(.
Also, rearrange planner so that only one RelOptInfo is created for a
particular set of joined base relations, no matter how many different
subsets of relations it can be created from. This saves memory and
processing time compared to the old method of making a bunch of RelOptInfos
and then removing the duplicates. Clean up the jointree iteration logic;
not sure if it's better, but I sure find it more readable and plausible
now, particularly for the case of 'bushy plans'.
Diffstat (limited to 'src/backend/nodes')
-rw-r--r-- | src/backend/nodes/copyfuncs.c | 5 | ||||
-rw-r--r-- | src/backend/nodes/equalfuncs.c | 4 | ||||
-rw-r--r-- | src/backend/nodes/freefuncs.c | 8 | ||||
-rw-r--r-- | src/backend/nodes/outfuncs.c | 54 | ||||
-rw-r--r-- | src/backend/nodes/readfuncs.c | 63 |
5 files changed, 48 insertions, 86 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index cb447b63717..c5c9cb0782e 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.103 2000/01/27 18:11:27 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.104 2000/02/07 04:40:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -977,7 +977,7 @@ _copyRelOptInfo(RelOptInfo *from) newnode->pages = from->pages; newnode->tuples = from->tuples; - Node_Copy(from, newnode, restrictinfo); + Node_Copy(from, newnode, baserestrictinfo); Node_Copy(from, newnode, joininfo); Node_Copy(from, newnode, innerjoin); @@ -1137,6 +1137,7 @@ CopyJoinPathFields(JoinPath *from, JoinPath *newnode) { Node_Copy(from, newnode, outerjoinpath); Node_Copy(from, newnode, innerjoinpath); + Node_Copy(from, newnode, joinrestrictinfo); } /* ---------------- diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index 90344ae6698..5888f49515e 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.58 2000/01/31 01:21:39 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.59 2000/02/07 04:40:57 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -374,6 +374,8 @@ _equalJoinPath(JoinPath *a, JoinPath *b) return false; if (!equal(a->innerjoinpath, b->innerjoinpath)) return false; + if (!equal(a->joinrestrictinfo, b->joinrestrictinfo)) + return false; return true; } diff --git a/src/backend/nodes/freefuncs.c b/src/backend/nodes/freefuncs.c index fc5c3506d8c..ab308fe3101 100644 --- a/src/backend/nodes/freefuncs.c +++ b/src/backend/nodes/freefuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.33 2000/01/27 18:11:28 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.34 2000/02/07 04:40:57 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -735,7 +735,7 @@ _freeRelOptInfo(RelOptInfo *node) */ freeObject(node->cheapestpath); - freeObject(node->restrictinfo); + freeObject(node->baserestrictinfo); freeObject(node->joininfo); freeObject(node->innerjoin); @@ -853,6 +853,10 @@ FreeJoinPathFields(JoinPath *node) { freeObject(node->outerjoinpath); freeObject(node->innerjoinpath); + /* XXX probably wrong, since ordinarily a JoinPath would share its + * restrictinfo list with other paths made for the same join? + */ + freeObject(node->joinrestrictinfo); } /* ---------------- diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 4475fa382bb..8923510e1b4 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.105 2000/01/27 18:11:28 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.106 2000/02/07 04:40:57 tgl Exp $ * * NOTES * Every (plan) node in POSTGRES has an associated "out" routine which @@ -915,10 +915,10 @@ _outRelOptInfo(StringInfo str, RelOptInfo *node) */ appendStringInfo(str, - " :cheapestpath @ 0x%x :pruneable %s :restrictinfo ", + " :cheapestpath @ 0x%x :pruneable %s :baserestrictinfo ", (int) node->cheapestpath, node->pruneable ? "true" : "false"); - _outNode(str, node->restrictinfo); + _outNode(str, node->baserestrictinfo); appendStringInfo(str, " :joininfo "); _outNode(str, node->joininfo); @@ -1035,16 +1035,12 @@ _outNestPath(StringInfo str, NestPath *node) node->path.pathtype, node->path.path_cost); _outNode(str, node->path.pathkeys); - - /* - * Not sure if these are nodes; they're declared as "struct path *". - * For now, i'll just print the addresses. - */ - - appendStringInfo(str, - " :outerjoinpath @ 0x%x :innerjoinpath @ 0x%x ", - (int) node->outerjoinpath, - (int) node->innerjoinpath); + appendStringInfo(str, " :outerjoinpath "); + _outNode(str, node->outerjoinpath); + appendStringInfo(str, " :innerjoinpath "); + _outNode(str, node->innerjoinpath); + appendStringInfo(str, " :joinrestrictinfo "); + _outNode(str, node->joinrestrictinfo); } /* @@ -1058,16 +1054,12 @@ _outMergePath(StringInfo str, MergePath *node) node->jpath.path.pathtype, node->jpath.path.path_cost); _outNode(str, node->jpath.path.pathkeys); - - /* - * Not sure if these are nodes; they're declared as "struct path *". - * For now, i'll just print the addresses. - */ - - appendStringInfo(str, - " :outerjoinpath @ 0x%x :innerjoinpath @ 0x%x ", - (int) node->jpath.outerjoinpath, - (int) node->jpath.innerjoinpath); + appendStringInfo(str, " :outerjoinpath "); + _outNode(str, node->jpath.outerjoinpath); + appendStringInfo(str, " :innerjoinpath "); + _outNode(str, node->jpath.innerjoinpath); + appendStringInfo(str, " :joinrestrictinfo "); + _outNode(str, node->jpath.joinrestrictinfo); appendStringInfo(str, " :path_mergeclauses "); _outNode(str, node->path_mergeclauses); @@ -1090,16 +1082,12 @@ _outHashPath(StringInfo str, HashPath *node) node->jpath.path.pathtype, node->jpath.path.path_cost); _outNode(str, node->jpath.path.pathkeys); - - /* - * Not sure if these are nodes; they're declared as "struct path *". - * For now, i'll just print the addresses. - */ - - appendStringInfo(str, - " :outerjoinpath @ 0x%x :innerjoinpath @ 0x%x ", - (int) node->jpath.outerjoinpath, - (int) node->jpath.innerjoinpath); + appendStringInfo(str, " :outerjoinpath "); + _outNode(str, node->jpath.outerjoinpath); + appendStringInfo(str, " :innerjoinpath "); + _outNode(str, node->jpath.innerjoinpath); + appendStringInfo(str, " :joinrestrictinfo "); + _outNode(str, node->jpath.joinrestrictinfo); appendStringInfo(str, " :path_hashclauses "); _outNode(str, node->path_hashclauses); diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index 9dccbf50170..38db7def0b1 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.81 2000/01/27 18:11:28 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.82 2000/02/07 04:40:57 tgl Exp $ * * NOTES * Most of the read functions for plan nodes are tested. (In fact, they @@ -1288,8 +1288,8 @@ _readRelOptInfo() sscanf(token, "%x", (unsigned int *) &local_node->cheapestpath); - token = lsptok(NULL, &length); /* get :restrictinfo */ - local_node->restrictinfo = nodeRead(true); /* now read it */ + token = lsptok(NULL, &length); /* get :baserestrictinfo */ + local_node->baserestrictinfo = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :joininfo */ local_node->joininfo = nodeRead(true); /* now read it */ @@ -1518,25 +1518,14 @@ _readNestPath() token = lsptok(NULL, &length); /* get :pathkeys */ local_node->path.pathkeys = nodeRead(true); /* now read it */ - /* - * Not sure if these are nodes; they're declared as "struct path *". - * For now, i'll just print the addresses. - * - * GJK: Since I am parsing this stuff, I'll just ignore the addresses, - * and initialize these pointers to NULL. - */ - token = lsptok(NULL, &length); /* get :outerjoinpath */ - token = lsptok(NULL, &length); /* get @ */ - token = lsptok(NULL, &length); /* now read it */ - - local_node->outerjoinpath = NULL; + local_node->outerjoinpath = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :innerjoinpath */ - token = lsptok(NULL, &length); /* get @ */ - token = lsptok(NULL, &length); /* now read it */ + local_node->innerjoinpath = nodeRead(true); /* now read it */ - local_node->innerjoinpath = NULL; + token = lsptok(NULL, &length); /* get :joinrestrictinfo */ + local_node->joinrestrictinfo = nodeRead(true); /* now read it */ return local_node; } @@ -1569,25 +1558,14 @@ _readMergePath() token = lsptok(NULL, &length); /* get :pathkeys */ local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */ - /* - * Not sure if these are nodes; they're declared as "struct path *". - * For now, i'll just print the addresses. - * - * GJK: Since I am parsing this stuff, I'll just ignore the addresses, - * and initialize these pointers to NULL. - */ - token = lsptok(NULL, &length); /* get :outerjoinpath */ - token = lsptok(NULL, &length); /* get @ */ - token = lsptok(NULL, &length); /* now read it */ - - local_node->jpath.outerjoinpath = NULL; + local_node->jpath.outerjoinpath = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :innerjoinpath */ - token = lsptok(NULL, &length); /* get @ */ - token = lsptok(NULL, &length); /* now read it */ + local_node->jpath.innerjoinpath = nodeRead(true); /* now read it */ - local_node->jpath.innerjoinpath = NULL; + token = lsptok(NULL, &length); /* get :joinrestrictinfo */ + local_node->jpath.joinrestrictinfo = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :path_mergeclauses */ local_node->path_mergeclauses = nodeRead(true); /* now read it */ @@ -1629,25 +1607,14 @@ _readHashPath() token = lsptok(NULL, &length); /* get :pathkeys */ local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */ - /* - * Not sure if these are nodes; they're declared as "struct path *". - * For now, i'll just print the addresses. - * - * GJK: Since I am parsing this stuff, I'll just ignore the addresses, - * and initialize these pointers to NULL. - */ - token = lsptok(NULL, &length); /* get :outerjoinpath */ - token = lsptok(NULL, &length); /* get @ */ - token = lsptok(NULL, &length); /* now read it */ - - local_node->jpath.outerjoinpath = NULL; + local_node->jpath.outerjoinpath = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :innerjoinpath */ - token = lsptok(NULL, &length); /* get @ */ - token = lsptok(NULL, &length); /* now read it */ + local_node->jpath.innerjoinpath = nodeRead(true); /* now read it */ - local_node->jpath.innerjoinpath = NULL; + token = lsptok(NULL, &length); /* get :joinrestrictinfo */ + local_node->jpath.joinrestrictinfo = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :path_hashclauses */ local_node->path_hashclauses = nodeRead(true); /* now read it */ |