* finalize_primnode: add IDs of all PARAM_EXEC params appearing in the given * expression tree to the result set. */
| 3408 | * expression tree to the result set. |
| 3409 | */ |
| 3410 | static bool |
| 3411 | finalize_primnode(Node *node, finalize_primnode_context *context) |
| 3412 | { |
| 3413 | if (node == NULL) |
| 3414 | return false; |
| 3415 | if (IsA(node, Param)) |
| 3416 | { |
| 3417 | if (((Param *) node)->paramkind == PARAM_EXEC) |
| 3418 | { |
| 3419 | int paramid = ((Param *) node)->paramid; |
| 3420 | |
| 3421 | context->paramids = bms_add_member(context->paramids, paramid); |
| 3422 | } |
| 3423 | return false; /* no more to do here */ |
| 3424 | } |
| 3425 | if (IsA(node, SubPlan)) |
| 3426 | { |
| 3427 | SubPlan *subplan = (SubPlan *) node; |
| 3428 | Plan *plan = planner_subplan_get_plan(context->root, subplan); |
| 3429 | ListCell *lc; |
| 3430 | Bitmapset *subparamids; |
| 3431 | |
| 3432 | /* Recurse into the testexpr, but not into the Plan */ |
| 3433 | finalize_primnode(subplan->testexpr, context); |
| 3434 | |
| 3435 | /* |
| 3436 | * Remove any param IDs of output parameters of the subplan that were |
| 3437 | * referenced in the testexpr. These are not interesting for |
| 3438 | * parameter change signaling since we always re-evaluate the subplan. |
| 3439 | * Note that this wouldn't work too well if there might be uses of the |
| 3440 | * same param IDs elsewhere in the plan, but that can't happen because |
| 3441 | * generate_new_exec_param never tries to merge params. |
| 3442 | */ |
| 3443 | foreach(lc, subplan->paramIds) |
| 3444 | { |
| 3445 | context->paramids = bms_del_member(context->paramids, |
| 3446 | lfirst_int(lc)); |
| 3447 | } |
| 3448 | |
| 3449 | /* Also examine args list */ |
| 3450 | finalize_primnode((Node *) subplan->args, context); |
| 3451 | |
| 3452 | /* |
| 3453 | * Add params needed by the subplan to paramids, but excluding those |
| 3454 | * we will pass down to it. (We assume SS_finalize_plan was run on |
| 3455 | * the subplan already.) |
| 3456 | */ |
| 3457 | subparamids = bms_copy(plan->extParam); |
| 3458 | foreach(lc, subplan->parParam) |
| 3459 | { |
| 3460 | subparamids = bms_del_member(subparamids, lfirst_int(lc)); |
| 3461 | } |
| 3462 | context->paramids = bms_join(context->paramids, subparamids); |
| 3463 | |
| 3464 | return false; /* no more to do here */ |
| 3465 | } |
| 3466 | return expression_tree_walker(node, finalize_primnode, |
| 3467 | (void *) context); |
no test coverage detected