diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c index 7de75e43be..889fb199f1 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -705,7 +705,7 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) outerplan = outerPlan(plan); /* If this var referes to tuple returned by its outer plan then find the original tle from it */ - if (plan != NULL && var->varno == OUTER_VAR) + if (plan && outerplan && !(IsA(plan, Result)) && var->varno == OUTER_VAR) { Assert(plan); Assert(outerplan);