mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Change Agg and Group nodes so that Vars contained in their targetlists
and quals have varno OUTER, rather than zero, to indicate a reference to an output of their lefttree subplan. This is consistent with the way that every other upper-level node type does it, and allows some simplifications in setrefs.c and EXPLAIN.
This commit is contained in:
@ -61,7 +61,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.150 2007/02/02 00:07:03 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.151 2007/02/22 23:44:24 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -420,7 +420,7 @@ advance_transition_function(AggState *aggstate,
|
||||
|
||||
/*
|
||||
* Advance all the aggregates for one input tuple. The input tuple
|
||||
* has been stored in tmpcontext->ecxt_scantuple, so that it is accessible
|
||||
* has been stored in tmpcontext->ecxt_outertuple, so that it is accessible
|
||||
* to ExecEvalExpr. pergroup is the array of per-group structs to use
|
||||
* (this might be in a hashtable entry).
|
||||
*
|
||||
@ -643,8 +643,8 @@ find_unaggregated_cols_walker(Node *node, Bitmapset **colnos)
|
||||
{
|
||||
Var *var = (Var *) node;
|
||||
|
||||
/* setrefs.c should have set the varno to 0 */
|
||||
Assert(var->varno == 0);
|
||||
/* setrefs.c should have set the varno to OUTER */
|
||||
Assert(var->varno == OUTER);
|
||||
Assert(var->varlevelsup == 0);
|
||||
*colnos = bms_add_member(*colnos, var->varattno);
|
||||
return false;
|
||||
@ -905,7 +905,7 @@ agg_retrieve_direct(AggState *aggstate)
|
||||
aggstate->grp_firstTuple = NULL; /* don't keep two pointers */
|
||||
|
||||
/* set up for first advance_aggregates call */
|
||||
tmpcontext->ecxt_scantuple = firstSlot;
|
||||
tmpcontext->ecxt_outertuple = firstSlot;
|
||||
|
||||
/*
|
||||
* Process each outer-plan tuple, and then fetch the next one,
|
||||
@ -926,7 +926,7 @@ agg_retrieve_direct(AggState *aggstate)
|
||||
break;
|
||||
}
|
||||
/* set up for next advance_aggregates call */
|
||||
tmpcontext->ecxt_scantuple = outerslot;
|
||||
tmpcontext->ecxt_outertuple = outerslot;
|
||||
|
||||
/*
|
||||
* If we are grouping, check whether we've crossed a group
|
||||
@ -973,7 +973,7 @@ agg_retrieve_direct(AggState *aggstate)
|
||||
* 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;
|
||||
econtext->ecxt_outertuple = firstSlot;
|
||||
|
||||
/*
|
||||
* Check the qual (HAVING clause); if the group does not match, ignore
|
||||
@ -1022,7 +1022,7 @@ agg_fill_hash_table(AggState *aggstate)
|
||||
if (TupIsNull(outerslot))
|
||||
break;
|
||||
/* set up for advance_aggregates call */
|
||||
tmpcontext->ecxt_scantuple = outerslot;
|
||||
tmpcontext->ecxt_outertuple = outerslot;
|
||||
|
||||
/* Find or build hashtable entry for this tuple's group */
|
||||
entry = lookup_hash_entry(aggstate, outerslot);
|
||||
@ -1116,7 +1116,7 @@ agg_retrieve_hash_table(AggState *aggstate)
|
||||
* Use the representative input tuple for any references to
|
||||
* non-aggregated input columns in the qual and tlist.
|
||||
*/
|
||||
econtext->ecxt_scantuple = firstSlot;
|
||||
econtext->ecxt_outertuple = firstSlot;
|
||||
|
||||
/*
|
||||
* Check the qual (HAVING clause); if the group does not match, ignore
|
||||
|
@ -15,7 +15,7 @@
|
||||
* locate group boundaries.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeGroup.c,v 1.68 2007/02/02 00:07:03 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeGroup.c,v 1.69 2007/02/22 23:44:24 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -72,9 +72,14 @@ ExecGroup(GroupState *node)
|
||||
node->grp_done = TRUE;
|
||||
return NULL;
|
||||
}
|
||||
/* Copy tuple, set up as input for qual test and projection */
|
||||
/* Copy tuple into firsttupleslot */
|
||||
ExecCopySlot(firsttupleslot, outerslot);
|
||||
econtext->ecxt_scantuple = firsttupleslot;
|
||||
|
||||
/*
|
||||
* Set it up as input for qual test and projection. The expressions
|
||||
* will access the input tuple as varno OUTER.
|
||||
*/
|
||||
econtext->ecxt_outertuple = firsttupleslot;
|
||||
|
||||
/*
|
||||
* Check the qual (HAVING clause); if the group does not match, ignore
|
||||
@ -126,7 +131,7 @@ ExecGroup(GroupState *node)
|
||||
*/
|
||||
/* Copy tuple, set up as input for qual test and projection */
|
||||
ExecCopySlot(firsttupleslot, outerslot);
|
||||
econtext->ecxt_scantuple = firsttupleslot;
|
||||
econtext->ecxt_outertuple = firsttupleslot;
|
||||
|
||||
/*
|
||||
* Check the qual (HAVING clause); if the group does not match, ignore
|
||||
|
@ -38,7 +38,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeResult.c,v 1.39 2007/02/16 03:49:04 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeResult.c,v 1.40 2007/02/22 23:44:25 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -132,13 +132,11 @@ ExecResult(ResultState *node)
|
||||
if (TupIsNull(outerTupleSlot))
|
||||
return NULL;
|
||||
|
||||
node->ps.ps_OuterTupleSlot = outerTupleSlot;
|
||||
|
||||
/*
|
||||
* XXX gross hack. use outer tuple as scan tuple for projection
|
||||
* prepare to compute projection expressions, which will expect
|
||||
* to access the input tuples as varno OUTER.
|
||||
*/
|
||||
econtext->ecxt_outertuple = outerTupleSlot;
|
||||
econtext->ecxt_scantuple = outerTupleSlot;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user