From f6dba10e623fa575c8446f854aa63c97d4fedea3 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 6 Nov 2002 00:00:45 +0000 Subject: First phase of implementing hash-based grouping/aggregation. An AGG plan node now does its own grouping of the input rows, and has no need for a preceding GROUP node in the plan pipeline. This allows elimination of the misnamed tuplePerGroup option for GROUP, and actually saves more code in nodeGroup.c than it costs in nodeAgg.c, as well as being presumably faster. Restructure the API of query_planner so that we do not commit to using a sorted or unsorted plan in query_planner; instead grouping_planner makes the decision. (Right now it isn't any smarter than query_planner was, but that will change as soon as it has the option to select a hash- based aggregation step.) Despite all the hackery, no initdb needed since only in-memory node types changed. --- src/backend/nodes/readfuncs.c | 56 ++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 14 deletions(-) (limited to 'src/backend/nodes/readfuncs.c') diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index 33e28413439..568bf8ee1e4 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.135 2002/10/14 22:14:34 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.136 2002/11/06 00:00:44 tgl Exp $ * * NOTES * Most of the read functions for plan nodes are tested. (In fact, they @@ -696,17 +696,6 @@ _readSort(void) return local_node; } -static Agg * -_readAgg(void) -{ - Agg *local_node; - - local_node = makeNode(Agg); - _getPlan((Plan *) local_node); - - return local_node; -} - /* ---------------- * _readHash * @@ -1880,6 +1869,45 @@ _readAppendPath(void) return local_node; } +/* ---------------- + * _readResultPath + * + * ResultPath is a subclass of Path. + * ---------------- + */ +static ResultPath * +_readResultPath(void) +{ + ResultPath *local_node; + char *token; + int length; + + local_node = makeNode(ResultPath); + + token = pg_strtok(&length); /* get :pathtype */ + token = pg_strtok(&length); /* now read it */ + local_node->path.pathtype = atoi(token); + + token = pg_strtok(&length); /* get :startup_cost */ + token = pg_strtok(&length); /* now read it */ + local_node->path.startup_cost = (Cost) atof(token); + + token = pg_strtok(&length); /* get :total_cost */ + token = pg_strtok(&length); /* now read it */ + local_node->path.total_cost = (Cost) atof(token); + + token = pg_strtok(&length); /* get :pathkeys */ + local_node->path.pathkeys = nodeRead(true); /* now read it */ + + token = pg_strtok(&length); /* get :subpath */ + local_node->subpath = nodeRead(true); /* now read it */ + + token = pg_strtok(&length); /* get :constantqual */ + local_node->constantqual = nodeRead(true); /* now read it */ + + return local_node; +} + /* ---------------- * _readNestPath * @@ -2196,8 +2224,6 @@ parsePlanString(void) return_value = _readFromExpr(); else if (length == 8 && strncmp(token, "JOINEXPR", length) == 0) return_value = _readJoinExpr(); - else if (length == 3 && strncmp(token, "AGG", length) == 0) - return_value = _readAgg(); else if (length == 4 && strncmp(token, "HASH", length) == 0) return_value = _readHash(); else if (length == 6 && strncmp(token, "RESDOM", length) == 0) @@ -2240,6 +2266,8 @@ parsePlanString(void) return_value = _readTidPath(); else if (length == 10 && strncmp(token, "APPENDPATH", length) == 0) return_value = _readAppendPath(); + else if (length == 10 && strncmp(token, "RESULTPATH", length) == 0) + return_value = _readResultPath(); else if (length == 8 && strncmp(token, "NESTPATH", length) == 0) return_value = _readNestPath(); else if (length == 9 && strncmp(token, "MERGEPATH", length) == 0) -- cgit v1.2.3