|
7 | 7 | * Portions Copyright (c) 1994, Regents of the University of California
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.41 2003/01/09 20:50:50 tgl Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.42 2003/01/10 21:08:08 tgl Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -110,6 +110,7 @@ ExecSubPlan(SubPlanState *node,
|
110 | 110 | Datum rowresult = BoolGetDatum(!useOr);
|
111 | 111 | bool rownull = false;
|
112 | 112 | int col = 1;
|
| 113 | + List *plst; |
113 | 114 |
|
114 | 115 | if (subLinkType == EXISTS_SUBLINK)
|
115 | 116 | {
|
@@ -155,45 +156,19 @@ ExecSubPlan(SubPlanState *node,
|
155 | 156 | * For ALL, ANY, and MULTIEXPR sublinks, iterate over combining
|
156 | 157 | * operators for columns of tuple.
|
157 | 158 | */
|
158 |
| - foreach(lst, node->oper) |
| 159 | + plst = subplan->paramIds; |
| 160 | + foreach(lst, node->exprs) |
159 | 161 | {
|
160 | 162 | ExprState *exprstate = (ExprState *) lfirst(lst);
|
161 |
| - OpExpr *expr = (OpExpr *) exprstate->expr; |
162 |
| - Param *prm = lsecond(expr->args); |
| 163 | + int paramid = lfirsti(plst); |
163 | 164 | ParamExecData *prmdata;
|
164 | 165 | Datum expresult;
|
165 | 166 | bool expnull;
|
166 | 167 |
|
167 | 168 | /*
|
168 |
| - * The righthand side of the expression should be either a |
169 |
| - * Param or a function call or RelabelType node taking a Param |
170 |
| - * as arg (these nodes represent run-time type coercions |
171 |
| - * inserted by the parser to get to the input type needed by |
172 |
| - * the operator). Find the Param node and insert the actual |
173 |
| - * righthand-side value into the param's econtext slot. |
174 |
| - * |
175 |
| - * XXX possible improvement: could make a list of the ParamIDs |
176 |
| - * at startup time, instead of repeating this check at each row. |
| 169 | + * Load up the Param representing this column of the sub-select. |
177 | 170 | */
|
178 |
| - if (!IsA(prm, Param)) |
179 |
| - { |
180 |
| - switch (nodeTag(prm)) |
181 |
| - { |
182 |
| - case T_FuncExpr: |
183 |
| - prm = lfirst(((FuncExpr *) prm)->args); |
184 |
| - break; |
185 |
| - case T_RelabelType: |
186 |
| - prm = (Param *) (((RelabelType *) prm)->arg); |
187 |
| - break; |
188 |
| - default: |
189 |
| - /* will fail below */ |
190 |
| - break; |
191 |
| - } |
192 |
| - if (!IsA(prm, Param)) |
193 |
| - elog(ERROR, "ExecSubPlan: failed to find placeholder for subplan result"); |
194 |
| - } |
195 |
| - Assert(prm->paramkind == PARAM_EXEC); |
196 |
| - prmdata = &(econtext->ecxt_param_exec_vals[prm->paramid]); |
| 171 | + prmdata = &(econtext->ecxt_param_exec_vals[paramid]); |
197 | 172 | Assert(prmdata->execPlan == NULL);
|
198 | 173 | prmdata->value = heap_getattr(tup, col, tdesc,
|
199 | 174 | &(prmdata->isnull));
|
@@ -236,6 +211,8 @@ ExecSubPlan(SubPlanState *node,
|
236 | 211 | break; /* needn't look at any more columns */
|
237 | 212 | }
|
238 | 213 | }
|
| 214 | + |
| 215 | + plst = lnext(plst); |
239 | 216 | col++;
|
240 | 217 | }
|
241 | 218 |
|
@@ -312,6 +289,8 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
|
312 | 289 | */
|
313 | 290 | node->needShutdown = false;
|
314 | 291 | node->curTuple = NULL;
|
| 292 | + node->hashtable = NULL; |
| 293 | + node->hashnulls = NULL; |
315 | 294 |
|
316 | 295 | /*
|
317 | 296 | * create an EState for the subplan
|
|
0 commit comments