tlist_matches_tupdesc() needs to defend itself against dropped columns.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 25 Sep 2003 19:41:49 +0000 (19:41 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 25 Sep 2003 19:41:49 +0000 (19:41 +0000)
src/backend/executor/execScan.c

index a0a043e3bb3d4610cb023a141df7c2a1c0845e08..ec2caf3354f437be776a7d2cb2b8d00a13dbb8a5 100644 (file)
@@ -196,9 +196,7 @@ tlist_matches_tupdesc(List *tlist, Index varno, TupleDesc tupdesc)
 
        for (attrno = 1; attrno <= numattrs; attrno++)
        {
-#ifdef USE_ASSERT_CHECKING             /* only used in Assert() */
                Form_pg_attribute att_tup = tupdesc->attrs[attrno - 1];
-#endif
                Var                *var;
 
                if (tlist == NIL)
@@ -207,11 +205,13 @@ tlist_matches_tupdesc(List *tlist, Index varno, TupleDesc tupdesc)
                if (!var || !IsA(var, Var))
                        return false;           /* tlist item not a Var */
                Assert(var->varno == varno);
+               Assert(var->varlevelsup == 0);
                if (var->varattno != attrno)
                        return false;           /* out of order */
+               if (att_tup->attisdropped)
+                       return false;           /* table contains dropped columns */
                Assert(var->vartype == att_tup->atttypid);
                Assert(var->vartypmod == att_tup->atttypmod);
-               Assert(var->varlevelsup == 0);
 
                tlist = lnext(tlist);
        }