Skip to content

Commit be09bc9

Browse files
committed
Modify nodeAgg.c so that no rows are returned for a GROUP BY
with no input rows, per pghackers discussions around 7/22/99. Clean up a bunch of ugly coding while at it; remove redundant re-lookup of aggregate info at start of each new GROUP. Arrange to pfree intermediate values when they are pass-by-ref types, so that aggregates on pass-by-ref types no longer eat memory. This takes care of a couple of TODO items...
1 parent 40f6524 commit be09bc9

File tree

4 files changed

+452
-416
lines changed

4 files changed

+452
-416
lines changed

src/backend/executor/execQual.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.61 1999/09/26 02:28:15 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.62 1999/09/26 21:21:09 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -209,8 +209,8 @@ ExecEvalArrayRef(ArrayRef *arrayRef,
209209
static Datum
210210
ExecEvalAggref(Aggref *aggref, ExprContext *econtext, bool *isNull)
211211
{
212-
*isNull = econtext->ecxt_nulls[aggref->aggno];
213-
return econtext->ecxt_values[aggref->aggno];
212+
*isNull = econtext->ecxt_aggnulls[aggref->aggno];
213+
return econtext->ecxt_aggvalues[aggref->aggno];
214214
}
215215

216216
/* ----------------------------------------------------------------
@@ -244,7 +244,6 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull)
244244
AttrNumber attnum;
245245
HeapTuple heapTuple;
246246
TupleDesc tuple_type;
247-
Buffer buffer;
248247
bool byval;
249248
int16 len;
250249

@@ -272,22 +271,21 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull)
272271
*/
273272
heapTuple = slot->val;
274273
tuple_type = slot->ttc_tupleDescriptor;
275-
buffer = slot->ttc_buffer;
276274

277275
attnum = variable->varattno;
278276

279277
/* (See prolog for explanation of this Assert) */
280278
Assert(attnum <= 0 ||
281279
(attnum - 1 <= tuple_type->natts - 1 &&
282280
tuple_type->attrs[attnum - 1] != NULL &&
283-
variable->vartype == tuple_type->attrs[attnum - 1]->atttypid))
281+
variable->vartype == tuple_type->attrs[attnum - 1]->atttypid));
284282

285283
/*
286284
* If the attribute number is invalid, then we are supposed to return
287285
* the entire tuple, we give back a whole slot so that callers know
288286
* what the tuple looks like.
289287
*/
290-
if (attnum == InvalidAttrNumber)
288+
if (attnum == InvalidAttrNumber)
291289
{
292290
TupleTableSlot *tempSlot;
293291
TupleDesc td;
@@ -301,7 +299,7 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull)
301299
tempSlot->ttc_whichplan = -1;
302300

303301
tup = heap_copytuple(heapTuple);
304-
td = CreateTupleDescCopy(slot->ttc_tupleDescriptor);
302+
td = CreateTupleDescCopy(tuple_type);
305303

306304
ExecSetSlotDescriptor(tempSlot, td);
307305

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy