]> granicus.if.org Git - postgresql/commitdiff
Relax an Assert() that has been found to be too strict in some situations
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 24 Jan 2007 01:26:08 +0000 (01:26 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 24 Jan 2007 01:26:08 +0000 (01:26 +0000)
involving unions of types having typmods.  Variants of the failure are known
to occur in 8.1 and up; not sure if it's possible in 8.0 and 7.4, but since
the code exists that far back, I'll just patch 'em all.  Per report from
Brian Hurt.

src/backend/executor/execScan.c

index b24994c8ded8a4f2cfcd83d65dac2b576492b260..ba0f3c655163c96694e6f73565b5606191b1533a 100644 (file)
@@ -12,7 +12,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.28.2.1 2004/01/22 02:23:35 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.28.2.2 2007/01/24 01:26:08 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -213,8 +213,18 @@ tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc
                        return false;           /* out of order */
                if (att_tup->attisdropped)
                        return false;           /* table contains dropped columns */
+               /*
+                * Note: usually the Var's type should match the tupdesc exactly,
+                * but in situations involving unions of columns that have different
+                * typmods, the Var may have come from above the union and hence have
+                * typmod -1.  This is a legitimate situation since the Var still
+                * describes the column, just not as exactly as the tupdesc does.
+                * We could change the planner to prevent it, but it'd then insert
+                * projection steps just to convert from specific typmod to typmod -1,
+                * which is pretty silly.
+                */
                Assert(var->vartype == att_tup->atttypid);
-               Assert(var->vartypmod == att_tup->atttypmod);
+               Assert(var->vartypmod == att_tup->atttypmod || var->vartypmod == -1);
 
                tlist = lnext(tlist);
        }