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/copyfuncs.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'src/backend/nodes/copyfuncs.c') diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 5fff2f762ab..0438e0ce609 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.214 2002/10/14 22:14:34 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.215 2002/11/06 00:00:43 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -497,10 +497,10 @@ _copyGroup(Group *from) CopyPlanFields((Plan *) from, (Plan *) newnode); - newnode->tuplePerGroup = from->tuplePerGroup; newnode->numCols = from->numCols; newnode->grpColIdx = palloc(from->numCols * sizeof(AttrNumber)); - memcpy(newnode->grpColIdx, from->grpColIdx, from->numCols * sizeof(AttrNumber)); + memcpy(newnode->grpColIdx, from->grpColIdx, + from->numCols * sizeof(AttrNumber)); return newnode; } @@ -516,6 +516,15 @@ _copyAgg(Agg *from) CopyPlanFields((Plan *) from, (Plan *) newnode); + newnode->aggstrategy = from->aggstrategy; + newnode->numCols = from->numCols; + if (from->numCols > 0) + { + newnode->grpColIdx = palloc(from->numCols * sizeof(AttrNumber)); + memcpy(newnode->grpColIdx, from->grpColIdx, + from->numCols * sizeof(AttrNumber)); + } + return newnode; } @@ -1280,6 +1289,29 @@ _copyAppendPath(AppendPath *from) return newnode; } +/* ---------------- + * _copyResultPath + * ---------------- + */ +static ResultPath * +_copyResultPath(ResultPath *from) +{ + ResultPath *newnode = makeNode(ResultPath); + + /* + * copy the node superclass fields + */ + CopyPathFields((Path *) from, (Path *) newnode); + + /* + * copy remainder of node + */ + Node_Copy(from, newnode, subpath); + Node_Copy(from, newnode, constantqual); + + return newnode; +} + /* ---------------- * CopyJoinPathFields * @@ -2878,6 +2910,9 @@ copyObject(void *from) case T_AppendPath: retval = _copyAppendPath(from); break; + case T_ResultPath: + retval = _copyResultPath(from); + break; case T_NestPath: retval = _copyNestPath(from); break; -- cgit v1.2.3