aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-10-19 17:31:20 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-10-19 17:31:20 +0000
commit32fcfcdbd66368c51c5561329d2a003eaff1fd64 (patch)
tree1ef12dc3fdd56e8e4c45b66312a51068f158b9a5
parentb33a73226487ac1ea045c6e52b4a22d1451d0895 (diff)
downloadpostgresql-32fcfcdbd66368c51c5561329d2a003eaff1fd64.tar.gz
postgresql-32fcfcdbd66368c51c5561329d2a003eaff1fd64.zip
Fix oversight in recent changes to enable the 'physical tlist'
optimization for subquery and function scan nodes: we can't just do it unconditionally, we still have to check whether there is any need for a whole-row Var. I had been thinking that these node types couldn't have any system columns, which is true, but that loop is also checking for attno zero, ie, whole-row Var. Fix comment to not be so misleading. Per test case from Richard Huxton.
-rw-r--r--src/backend/optimizer/plan/createplan.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index f0dd6548711..fc093fdf180 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.201 2005/10/15 02:49:20 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.202 2005/10/19 17:31:20 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -308,17 +308,13 @@ use_physical_tlist(RelOptInfo *rel)
int i;
/*
- * OK for subquery and function scans; otherwise, can't do it for anything
- * except real relations.
+ * We can do this for real relation scans, subquery scans, and function
+ * scans (but not for, eg, joins).
*/
- if (rel->rtekind != RTE_RELATION)
- {
- if (rel->rtekind == RTE_SUBQUERY)
- return true;
- if (rel->rtekind == RTE_FUNCTION)
- return true;
+ if (rel->rtekind != RTE_RELATION &&
+ rel->rtekind != RTE_SUBQUERY &&
+ rel->rtekind != RTE_FUNCTION)
return false;
- }
/*
* Can't do it with inheritance cases either (mainly because Append
@@ -328,15 +324,16 @@ use_physical_tlist(RelOptInfo *rel)
return false;
/*
- * Can't do it if any system columns are requested, either. (This could
- * possibly be fixed but would take some fragile assumptions in setrefs.c,
- * I think.)
+ * Can't do it if any system columns or whole-row Vars are requested,
+ * either. (This could possibly be fixed but would take some fragile
+ * assumptions in setrefs.c, I think.)
*/
for (i = rel->min_attr; i <= 0; i++)
{
if (!bms_is_empty(rel->attr_needed[i - rel->min_attr]))
return false;
}
+
return true;
}