aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/copyfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-11-06 00:00:45 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-11-06 00:00:45 +0000
commitf6dba10e623fa575c8446f854aa63c97d4fedea3 (patch)
tree2c5eb86c8e2961c90b524b49f25e3c25efa6eee2 /src/backend/nodes/copyfuncs.c
parenta8c18b980e1e00fe08ac02562f81e3e64d4e9fd4 (diff)
downloadpostgresql-f6dba10e623fa575c8446f854aa63c97d4fedea3.tar.gz
postgresql-f6dba10e623fa575c8446f854aa63c97d4fedea3.zip
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.
Diffstat (limited to 'src/backend/nodes/copyfuncs.c')
-rw-r--r--src/backend/nodes/copyfuncs.c41
1 files changed, 38 insertions, 3 deletions
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;
}
@@ -1281,6 +1290,29 @@ _copyAppendPath(AppendPath *from)
}
/* ----------------
+ * _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
*
* This function copies the fields of the JoinPath node. It is used by
@@ -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;