* Helper for columnref parsing: build a Param referencing a plpgsql datum, * and make sure that that datum is listed in the expression's paramnos. */
| 1359 | * and make sure that that datum is listed in the expression's paramnos. |
| 1360 | */ |
| 1361 | static Node * |
| 1362 | make_datum_param(PLpgSQL_expr *expr, int dno, int location) |
| 1363 | { |
| 1364 | PLpgSQL_execstate *estate; |
| 1365 | PLpgSQL_datum *datum; |
| 1366 | Param *param; |
| 1367 | MemoryContext oldcontext; |
| 1368 | |
| 1369 | /* see comment in resolve_column_ref */ |
| 1370 | estate = expr->func->cur_estate; |
| 1371 | Assert(dno >= 0 && dno < estate->ndatums); |
| 1372 | datum = estate->datums[dno]; |
| 1373 | |
| 1374 | /* |
| 1375 | * Bitmapset must be allocated in function's permanent memory context |
| 1376 | */ |
| 1377 | oldcontext = MemoryContextSwitchTo(expr->func->fn_cxt); |
| 1378 | expr->paramnos = bms_add_member(expr->paramnos, dno); |
| 1379 | MemoryContextSwitchTo(oldcontext); |
| 1380 | |
| 1381 | param = makeNode(Param); |
| 1382 | param->paramkind = PARAM_EXTERN; |
| 1383 | param->paramid = dno + 1; |
| 1384 | plpgsql_exec_get_datum_type_info(estate, |
| 1385 | datum, |
| 1386 | ¶m->paramtype, |
| 1387 | ¶m->paramtypmod, |
| 1388 | ¶m->paramcollid); |
| 1389 | param->location = location; |
| 1390 | |
| 1391 | return (Node *) param; |
| 1392 | } |
| 1393 | |
| 1394 | |
| 1395 | /* ---------- |
no test coverage detected