Skip to content

Commit 42af56e

Browse files
committed
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.
1 parent edda70c commit 42af56e

File tree

8 files changed

+325
-321
lines changed

8 files changed

+325
-321
lines changed

src/backend/executor/nodeSubplan.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,25 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext)
9494
Const *con = lsecond(expr->args);
9595
bool isnull;
9696

97+
/*
98+
* The righthand side of the expression should be either a Const
99+
* or a function call taking a Const as arg (the function would
100+
* be a run-time type coercion inserted by the parser to get to
101+
* the input type needed by the operator). Find the Const node
102+
* and insert the actual righthand side value into it.
103+
*/
104+
if (! IsA(con, Const))
105+
{
106+
Assert(IsA(con, Expr));
107+
con = lfirst(((Expr *) con)->args);
108+
Assert(IsA(con, Const));
109+
}
97110
con->constvalue = heap_getattr(tup, i, tdesc, &(con->constisnull));
98-
result = ExecEvalExpr((Node *) expr, econtext, &isnull, (bool *) NULL);
111+
/*
112+
* Now we can eval the expression.
113+
*/
114+
result = ExecEvalExpr((Node *) expr, econtext, &isnull,
115+
(bool *) NULL);
99116
if (isnull)
100117
{
101118
if (subLinkType == EXPR_SUBLINK)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy