MCPcopy Create free account
hub / github.com/apache/cloudberry / make_datum_param

Function make_datum_param

src/pl/plpgsql/src/pl_comp.c:1361–1392  ·  view source on GitHub ↗

* Helper for columnref parsing: build a Param referencing a plpgsql datum, * and make sure that that datum is listed in the expression's paramnos. */

Source from the content-addressed store, hash-verified

1359 * and make sure that that datum is listed in the expression's paramnos.
1360 */
1361static Node *
1362make_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 &param->paramtype,
1387 &param->paramtypmod,
1388 &param->paramcollid);
1389 param->location = location;
1390
1391 return (Node *) param;
1392}
1393
1394
1395/* ----------

Callers 2

plpgsql_param_refFunction · 0.85
resolve_column_refFunction · 0.85

Calls 3

MemoryContextSwitchToFunction · 0.85
bms_add_memberFunction · 0.85

Tested by

no test coverage detected