diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 1999-08-21 03:49:17 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 1999-08-21 03:49:17 +0000 |
commit | db436adf761bd5cb7990745ceba2959ac4bfca7c (patch) | |
tree | 8878ce970fd9b3ac480f3c5ef953fbc85827e685 /src/backend/nodes/equalfuncs.c | |
parent | 5588c559e6e21fae6ba1f162616f4fb4f680fb31 (diff) | |
download | postgresql-db436adf761bd5cb7990745ceba2959ac4bfca7c.tar.gz postgresql-db436adf761bd5cb7990745ceba2959ac4bfca7c.zip |
Major revision of sort-node handling: push knowledge of query
sort order down into planner, instead of handling it only at the very top
level of the planner. This fixes many things. An explicit sort is now
avoided if there is a cheaper alternative (typically an indexscan) not
only for ORDER BY, but also for the internal sort of GROUP BY. It works
even when there is no other reason (such as a WHERE condition) to consider
the indexscan. It works for indexes on functions. It works for indexes
on functions, backwards. It's just so cool...
CAUTION: I have changed the representation of SortClause nodes, therefore
THIS UPDATE BREAKS STORED RULES. You will need to initdb.
Diffstat (limited to 'src/backend/nodes/equalfuncs.c')
-rw-r--r-- | src/backend/nodes/equalfuncs.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index 1c53fe6aede..d8538a45066 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.47 1999/08/16 02:17:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.48 1999/08/21 03:48:57 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -34,14 +34,23 @@ _equalResdom(Resdom *a, Resdom *b) return false; if (a->restypmod != b->restypmod) return false; - if (strcmp(a->resname, b->resname) != 0) + if (a->resname && b->resname) + { + if (strcmp(a->resname, b->resname) != 0) + return false; + } + else + { + /* must both be null to be equal */ + if (a->resname != b->resname) + return false; + } + if (a->ressortgroupref != b->ressortgroupref) return false; if (a->reskey != b->reskey) return false; if (a->reskeyop != b->reskeyop) return false; - if (a->resgroupref != b->resgroupref) - return false; /* we ignore resjunk flag ... is this correct? */ return true; @@ -208,10 +217,9 @@ _equalAggref(Aggref *a, Aggref *b) return false; if (!equal(a->target, b->target)) return false; - if (a->aggno != b->aggno) - return false; if (a->usenulls != b->usenulls) return false; + /* ignore aggno, which is only a private field for the executor */ return true; } @@ -503,6 +511,14 @@ _equalQuery(Query *a, Query *b) return false; if (a->hasSubLinks != b->hasSubLinks) return false; + if (!equal(a->rtable, b->rtable)) + return false; + if (!equal(a->targetList, b->targetList)) + return false; + if (!equal(a->qual, b->qual)) + return false; + if (!equal(a->rowMark, b->rowMark)) + return false; if (a->uniqueFlag && b->uniqueFlag) { if (strcmp(a->uniqueFlag, b->uniqueFlag) != 0) @@ -515,14 +531,6 @@ _equalQuery(Query *a, Query *b) } if (!equal(a->sortClause, b->sortClause)) return false; - if (!equal(a->rtable, b->rtable)) - return false; - if (!equal(a->targetList, b->targetList)) - return false; - if (!equal(a->qual, b->qual)) - return false; - if (!equal(a->rowMark, b->rowMark)) - return false; if (!equal(a->groupClause, b->groupClause)) return false; if (!equal(a->havingQual, b->havingQual)) @@ -537,9 +545,9 @@ _equalQuery(Query *a, Query *b) return false; /* - * We do not check the internal-to-the-planner fields base_rel_list - * and join_rel_list. They might not be set yet, and in any case they - * should be derivable from the other fields. + * We do not check the internal-to-the-planner fields: base_rel_list, + * join_rel_list, query_pathkeys. They might not be set yet, and + * in any case they should be derivable from the other fields. */ return true; } |