From 42af56e1ead3306d2c056ff96ea770e4eee68e9d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 25 Aug 1999 23:21:43 +0000 Subject: Revise implementation of SubLinks so that there is a consistent, documented intepretation of the lefthand and oper fields. Fix a number of obscure problems while at it --- for example, the old code failed if the parser decided to insert a type-coercion function just below the operator of a SubLink. CAUTION: this will break stored rules that contain subplans. You may need to initdb. --- src/backend/executor/nodeSubplan.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/backend/executor/nodeSubplan.c') 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) -- cgit v1.2.3