diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 1999-08-25 23:21:43 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 1999-08-25 23:21:43 +0000 |
commit | 42af56e1ead3306d2c056ff96ea770e4eee68e9d (patch) | |
tree | 4d2084947e9f546f4104665cf686b05dedee2428 /src/backend/executor/nodeSubplan.c | |
parent | edda70c0def3f4a4b3bb211cd40f7d169062b95f (diff) | |
download | postgresql-42af56e1ead3306d2c056ff96ea770e4eee68e9d.tar.gz postgresql-42af56e1ead3306d2c056ff96ea770e4eee68e9d.zip |
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.
Diffstat (limited to 'src/backend/executor/nodeSubplan.c')
-rw-r--r-- | src/backend/executor/nodeSubplan.c | 19 |
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) |