Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e8d78d3

Browse files
committed
ExecAgg() failed to finish running out set-returning functions in the last
aggregated tuple of a run. Per report from Laurenz Albe. This is a new bug in 8.4, but only because prior versions rejected SRFs in an Agg plan node altogether.
1 parent 5126826 commit e8d78d3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/backend/executor/nodeAgg.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
* Portions Copyright (c) 1994, Regents of the University of California
6262
*
6363
* IDENTIFICATION
64-
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.166 2009/04/02 20:59:10 momjian Exp $
64+
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.167 2009/06/17 16:05:34 tgl Exp $
6565
*
6666
*-------------------------------------------------------------------------
6767
*/
@@ -811,9 +811,6 @@ lookup_hash_entry(AggState *aggstate, TupleTableSlot *inputslot)
811811
TupleTableSlot *
812812
ExecAgg(AggState *node)
813813
{
814-
if (node->agg_done)
815-
return NULL;
816-
817814
/*
818815
* Check to see if we're still projecting out tuples from a previous agg
819816
* tuple (because there is a function-returning-set in the projection
@@ -831,6 +828,15 @@ ExecAgg(AggState *node)
831828
node->ss.ps.ps_TupFromTlist = false;
832829
}
833830

831+
/*
832+
* Exit if nothing left to do. (We must do the ps_TupFromTlist check
833+
* first, because in some cases agg_done gets set before we emit the
834+
* final aggregate tuple, and we have to finish running SRFs for it.)
835+
*/
836+
if (node->agg_done)
837+
return NULL;
838+
839+
/* Dispatch based on strategy */
834840
if (((Agg *) node->ss.ps.plan)->aggstrategy == AGG_HASHED)
835841
{
836842
if (!node->table_filled)

0 commit comments

Comments
 (0)