From: Robert Haas Date: Tue, 14 Jun 2016 12:55:50 +0000 (-0400) Subject: postgres_fdw: Promote an Assert() to elog(). X-Git-Tag: REL9_6_BETA2~46 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=332fdbef20b5b5f2588447793dbcc3bb9b88eb51;p=postgresql postgres_fdw: Promote an Assert() to elog(). 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. --- diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c index 7d2512cf04..f38da5d0dc 100644 --- a/contrib/postgres_fdw/deparse.c +++ b/contrib/postgres_fdw/deparse.c @@ -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, ", ");