aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/nodeSubplan.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c
index e4e83d654ac..4bd0eb2ff31 100644
--- a/src/backend/executor/nodeSubplan.c
+++ b/src/backend/executor/nodeSubplan.c
@@ -94,8 +94,25 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext)
Const *con = lsecond(expr->args);
bool isnull;
+ /*
+ * The righthand side of the expression should be either a Const
+ * or a function call taking a Const as arg (the function would
+ * be a run-time type coercion inserted by the parser to get to
+ * the input type needed by the operator). Find the Const node
+ * and insert the actual righthand side value into it.
+ */
+ if (! IsA(con, Const))
+ {
+ Assert(IsA(con, Expr));
+ con = lfirst(((Expr *) con)->args);
+ Assert(IsA(con, Const));
+ }
con->constvalue = heap_getattr(tup, i, tdesc, &(con->constisnull));
- result = ExecEvalExpr((Node *) expr, econtext, &isnull, (bool *) NULL);
+ /*
+ * Now we can eval the expression.
+ */
+ result = ExecEvalExpr((Node *) expr, econtext, &isnull,
+ (bool *) NULL);
if (isnull)
{
if (subLinkType == EXPR_SUBLINK)