aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/subselect.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-01-09 03:48:51 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-01-09 03:48:51 +0000
commit07c741e61c8cb1fd945907a225d15467a08aca70 (patch)
tree68ab78fd412905df40da36058e4f35ec31858c6f /src/backend/optimizer/plan/subselect.c
parent4cb0950cfe4055ca54d08b9639ee4e462cb009a3 (diff)
downloadpostgresql-07c741e61c8cb1fd945907a225d15467a08aca70.tar.gz
postgresql-07c741e61c8cb1fd945907a225d15467a08aca70.zip
Fix oversight in planning of GROUP queries: when an expression is used
as both a GROUP BY item and an output expression, the top-level Group node should just copy up the evaluated expression value from its input, rather than re-evaluating the expression. Aside from any performance benefit this might offer, this avoids a crash when there is a sub-SELECT in said expression.
Diffstat (limited to 'src/backend/optimizer/plan/subselect.c')
-rw-r--r--src/backend/optimizer/plan/subselect.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c
index 4ebabc1e875..61dd2baa7fd 100644
--- a/src/backend/optimizer/plan/subselect.c
+++ b/src/backend/optimizer/plan/subselect.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.46 2000/11/21 00:17:59 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.47 2001/01/09 03:48:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -125,6 +125,7 @@ make_subplan(SubLink *slink)
{
SubPlan *node = makeNode(SubPlan);
Query *subquery = (Query *) (slink->subselect);
+ Oid result_type = exprType((Node *) slink);
double tuple_fraction;
Plan *plan;
List *lst;
@@ -368,7 +369,7 @@ make_subplan(SubLink *slink)
/*
* Make expression of SUBPLAN type
*/
- expr->typeOid = BOOLOID;/* bogus, but we don't really care */
+ expr->typeOid = result_type;
expr->opType = SUBPLAN_EXPR;
expr->oper = (Node *) node;