From 59fd249a300d4dbf0b0388ea943e666ad6ab2f95 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 21 Jun 2006 18:39:42 +0000 Subject: [PATCH] Remove ancient kluge that kept nodeAgg.c from crashing on UPDATEs involving aggregates. We just disallowed that, and AFAICS there should be no other cases where direct (non-aggregated) references to input columns are allowed in a query with aggregation and no GROUP BY. --- src/backend/executor/nodeAgg.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index a242d53968..dfb9938715 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -61,7 +61,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.139 2006/04/04 19:35:34 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.140 2006/06/21 18:39:42 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -831,32 +831,12 @@ agg_retrieve_direct(AggState *aggstate) &aggvalues[aggno], &aggnulls[aggno]); } - /* - * If we have no first tuple (ie, the outerPlan didn't return - * anything), create a dummy all-nulls input tuple for use by - * ExecQual/ExecProject. 99.44% of the time this is a waste of cycles, - * because ordinarily the projected output tuple's targetlist cannot - * contain any direct (non-aggregated) references to input columns, so - * the dummy tuple will not be referenced. However there are special - * cases where this isn't so --- in particular an UPDATE involving an - * aggregate will have a targetlist reference to ctid. We need to - * return a null for ctid in that situation, not coredump. - * - * The values returned for the aggregates will be the initial values - * of the transition functions. - */ - if (TupIsNull(firstSlot)) - { - /* Should only happen in non-grouped mode */ - Assert(node->aggstrategy == AGG_PLAIN); - Assert(aggstate->agg_done); - - ExecStoreAllNullTuple(firstSlot); - } - /* * Use the representative input tuple for any references to - * non-aggregated input columns in the qual and tlist. + * non-aggregated input columns in the qual and tlist. (If we are + * not grouping, and there are no input rows at all, we will come + * here with an empty firstSlot ... but if not grouping, there can't + * be any references to non-aggregated input columns, so no problem.) */ econtext->ecxt_scantuple = firstSlot;