aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-05-11 15:03:52 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-05-11 15:03:52 +0000
commit8f2e53bc1063f6c43d09356ecb6095be0cd907ea (patch)
treeb227976bd91d2efae2e91136400d6bf9b20e0a72 /src
parenta4e775a263317a23607eb1a6ea8205a185385a4b (diff)
downloadpostgresql-8f2e53bc1063f6c43d09356ecb6095be0cd907ea.tar.gz
postgresql-8f2e53bc1063f6c43d09356ecb6095be0cd907ea.zip
Disable the recently-added use_physical_tlist optimization in cases
where the table contains dropped columns. If the columns are dropped, then their types may be gone as well, which causes ExecTypeFromTL() to fail if the dropped columns appear in a plan node's tlist. This could be worked around but I don't think the optimization is valuable enough to be worth the trouble.
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/plan/createplan.c8
-rw-r--r--src/backend/optimizer/util/plancat.c20
2 files changed, 24 insertions, 4 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index b491065f03d..3445400988a 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.139 2003/05/06 00:20:32 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.140 2003/05/11 15:03:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -296,6 +296,12 @@ use_physical_tlist(RelOptInfo *rel)
if (rel->reloptkind != RELOPT_BASEREL)
return false;
/*
+ * Can't do it if relation contains dropped columns. This is detected
+ * in plancat.c, see notes there.
+ */
+ if (rel->varlist == NIL)
+ 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.)
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 029ddae189c..943e5752faa 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.79 2003/02/09 06:56:27 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.80 2003/05/11 15:03:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -62,8 +62,15 @@ get_relation_info(Oid relationObjectId, RelOptInfo *rel)
relation = heap_open(relationObjectId, AccessShareLock);
/*
- * Make list of physical Vars. Note we do NOT ignore dropped columns;
- * the intent is to model the physical tuples of the relation.
+ * Make list of physical Vars. But if there are any dropped columns,
+ * punt and set varlist to NIL. (XXX Ideally we would like to include
+ * dropped columns so that the varlist models the physical tuples
+ * of the relation. However this creates problems for ExecTypeFromTL,
+ * which may be asked to build a tupdesc for a tlist that includes vars
+ * of no-longer-existent types. In theory we could dig out the required
+ * info from the pg_attribute entries of the relation, but that data is
+ * not readily available to ExecTypeFromTL. For now, punt and don't
+ * apply the physical-tlist optimization when there are dropped cols.)
*/
numattrs = RelationGetNumberOfAttributes(relation);
@@ -71,6 +78,13 @@ get_relation_info(Oid relationObjectId, RelOptInfo *rel)
{
Form_pg_attribute att_tup = relation->rd_att->attrs[attrno - 1];
+ if (att_tup->attisdropped)
+ {
+ /* found a dropped col, so punt */
+ varlist = NIL;
+ break;
+ }
+
varlist = lappend(varlist,
makeVar(varno,
attrno,