aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execScan.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-01-22 02:23:21 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-01-22 02:23:21 +0000
commita376a4673ae9c331700f19f1bae999e3eadfaf10 (patch)
treeb2600f41af8e95543b479eec09053a0c8301db7a /src/backend/executor/execScan.c
parentbb9f66351ab3fed583d93200dc68dd60f8615d30 (diff)
downloadpostgresql-a376a4673ae9c331700f19f1bae999e3eadfaf10.tar.gz
postgresql-a376a4673ae9c331700f19f1bae999e3eadfaf10.zip
Fix oversight in optimization that avoids an unnecessary projection step
when scanning a table that we need all the columns from. In case of SELECT INTO, we have to check that the hasoids flag matches the desired output type, too. Per report from Mike Mascari.
Diffstat (limited to 'src/backend/executor/execScan.c')
-rw-r--r--src/backend/executor/execScan.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/backend/executor/execScan.c b/src/backend/executor/execScan.c
index 39b879310ea..2508a9f2b1b 100644
--- a/src/backend/executor/execScan.c
+++ b/src/backend/executor/execScan.c
@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/execScan.c,v 1.29 2003/11/29 19:51:48 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/execScan.c,v 1.30 2004/01/22 02:23:21 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -23,7 +23,7 @@
#include "utils/memutils.h"
-static bool tlist_matches_tupdesc(List *tlist, Index varno, TupleDesc tupdesc);
+static bool tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc);
/* ----------------------------------------------------------------
@@ -180,7 +180,8 @@ ExecAssignScanProjectionInfo(ScanState *node)
{
Scan *scan = (Scan *) node->ps.plan;
- if (tlist_matches_tupdesc(scan->plan.targetlist,
+ if (tlist_matches_tupdesc(&node->ps,
+ scan->plan.targetlist,
scan->scanrelid,
node->ss_ScanTupleSlot->ttc_tupleDescriptor))
node->ps.ps_ProjInfo = NULL;
@@ -189,11 +190,13 @@ ExecAssignScanProjectionInfo(ScanState *node)
}
static bool
-tlist_matches_tupdesc(List *tlist, Index varno, TupleDesc tupdesc)
+tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc)
{
int numattrs = tupdesc->natts;
int attrno;
+ bool hasoid;
+ /* Check the tlist attributes */
for (attrno = 1; attrno <= numattrs; attrno++)
{
Form_pg_attribute att_tup = tupdesc->attrs[attrno - 1];
@@ -219,5 +222,13 @@ tlist_matches_tupdesc(List *tlist, Index varno, TupleDesc tupdesc)
if (tlist)
return false; /* tlist too long */
+ /*
+ * If the plan context requires a particular hasoid setting, then
+ * that has to match, too.
+ */
+ if (ExecContextForcesOids(ps, &hasoid) &&
+ hasoid != tupdesc->tdhasoid)
+ return false;
+
return true;
}