aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/readfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1999-08-21 03:49:17 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1999-08-21 03:49:17 +0000
commitdb436adf761bd5cb7990745ceba2959ac4bfca7c (patch)
tree8878ce970fd9b3ac480f3c5ef953fbc85827e685 /src/backend/nodes/readfuncs.c
parent5588c559e6e21fae6ba1f162616f4fb4f680fb31 (diff)
downloadpostgresql-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/readfuncs.c')
-rw-r--r--src/backend/nodes/readfuncs.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c
index 98385dd96f6..588528daa1d 100644
--- a/src/backend/nodes/readfuncs.c
+++ b/src/backend/nodes/readfuncs.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.72 1999/08/16 02:17:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.73 1999/08/21 03:48:58 tgl Exp $
*
* NOTES
* Most of the read functions for plan nodes are tested. (In fact, they
@@ -184,12 +184,13 @@ _readSortClause()
local_node = makeNode(SortClause);
- token = lsptok(NULL, &length); /* skip the :resdom */
- local_node->resdom = nodeRead(true);
+ token = lsptok(NULL, &length); /* skip :tleSortGroupRef */
+ token = lsptok(NULL, &length); /* get tleSortGroupRef */
+ local_node->tleSortGroupRef = strtoul(token, NULL, 10);
- token = lsptok(NULL, &length); /* skip :opoid */
- token = lsptok(NULL, &length); /* get opoid */
- local_node->opoid = strtoul(token, NULL, 10);
+ token = lsptok(NULL, &length); /* skip :sortop */
+ token = lsptok(NULL, &length); /* get sortop */
+ local_node->sortop = strtoul(token, NULL, 10);
return local_node;
}
@@ -207,13 +208,13 @@ _readGroupClause()
local_node = makeNode(GroupClause);
- token = lsptok(NULL, &length); /* skip :grpOpoid */
- token = lsptok(NULL, &length); /* get grpOpoid */
- local_node->grpOpoid = strtoul(token, NULL, 10);
+ token = lsptok(NULL, &length); /* skip :tleSortGroupRef */
+ token = lsptok(NULL, &length); /* get tleSortGroupRef */
+ local_node->tleSortGroupRef = strtoul(token, NULL, 10);
- token = lsptok(NULL, &length); /* skip :tleGroupref */
- token = lsptok(NULL, &length); /* get tleGroupref */
- local_node->tleGroupref = strtoul(token, NULL, 10);
+ token = lsptok(NULL, &length); /* skip :sortop */
+ token = lsptok(NULL, &length); /* get sortop */
+ local_node->sortop = strtoul(token, NULL, 10);
return local_node;
}
@@ -600,15 +601,10 @@ static Agg *
_readAgg()
{
Agg *local_node;
- char *token;
- int length;
local_node = makeNode(Agg);
_getPlan((Plan *) local_node);
- token = lsptok(NULL, &length); /* eat :agg */
- local_node->aggs = nodeRead(true); /* now read it */
-
return local_node;
}
@@ -712,9 +708,9 @@ _readResdom()
token = lsptok(NULL, &length); /* get reskeyop */
local_node->reskeyop = (Oid) atol(token);
- token = lsptok(NULL, &length); /* eat :resgroupref */
- token = lsptok(NULL, &length); /* get resgroupref */
- local_node->resgroupref = strtoul(token, NULL, 10);
+ token = lsptok(NULL, &length); /* eat :ressortgroupref */
+ token = lsptok(NULL, &length); /* get ressortgroupref */
+ local_node->ressortgroupref = strtoul(token, NULL, 10);
token = lsptok(NULL, &length); /* eat :resjunk */
token = lsptok(NULL, &length); /* get resjunk */
@@ -1163,10 +1159,6 @@ _readAggref()
token = lsptok(NULL, &length); /* eat :target */
local_node->target = nodeRead(true); /* now read it */
- token = lsptok(NULL, &length); /* eat :aggno */
- token = lsptok(NULL, &length); /* get aggno */
- local_node->aggno = atoi(token);
-
token = lsptok(NULL, &length); /* eat :usenulls */
token = lsptok(NULL, &length); /* get usenulls */
local_node->usenulls = (token[0] == 't') ? true : false;