]> granicus.if.org Git - postgresql/commitdiff
postgres_fdw: Promote an Assert() to elog().
authorRobert Haas <rhaas@postgresql.org>
Tue, 14 Jun 2016 12:55:50 +0000 (08:55 -0400)
committerRobert Haas <rhaas@postgresql.org>
Tue, 14 Jun 2016 13:00:12 +0000 (09:00 -0400)
Andreas Seltenreich reports that it is possible for a PlaceHolderVar
to creep into this tlist, and I fear that even after that's fixed we
might have other, similar bugs in this area either now or in the
future.  There's a lot of action-at-a-distance here, because the
validity of this assertion depends on core planner behavior; so, let's
use elog() to make sure we catch this even in non-assert builds,
rather than just crashing.

contrib/postgres_fdw/deparse.c

index 7d2512cf04d6d5a648b33e9f551be5254fb5d4c9..f38da5d0dca0d400bc3dc01b1f57a37e6aae0484 100644 (file)
@@ -1112,8 +1112,10 @@ deparseExplicitTargetList(List *tlist, List **retrieved_attrs,
                /* Extract expression if TargetEntry node */
                Assert(IsA(tle, TargetEntry));
                var = (Var *) tle->expr;
+
                /* We expect only Var nodes here */
-               Assert(IsA(var, Var));
+               if (!IsA(var, Var))
+                       elog(ERROR, "non-Var not expected in target list");
 
                if (i > 0)
                        appendStringInfoString(buf, ", ");