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

Function pre_dispatch_function_evaluation_mutator

src/backend/cdb/cdbmutate.c:1521–1790  ·  view source on GitHub ↗

* Let's evaluate all STABLE functions that have constant args before * dispatch, so we get a consistent view across QEs * * Also, if this is a single_row insert, let's evaluate nextval() and * currval() before dispatching */

Source from the content-addressed store, hash-verified

1519 * currval() before dispatching
1520 */
1521static Node *
1522pre_dispatch_function_evaluation_mutator(Node *node,
1523 pre_dispatch_function_evaluation_context *context)
1524{
1525 Node *new_node = 0;
1526
1527 if (node == NULL)
1528 return NULL;
1529
1530 if (IsA(node, Param))
1531 {
1532 Param *param = (Param *) node;
1533
1534 /* Not replaceable, so just copy the Param (no need to recurse) */
1535 return (Node *) copyObject(param);
1536 }
1537 else if (IsA(node, FuncExpr))
1538 {
1539 FuncExpr *expr = (FuncExpr *) node;
1540 List *args;
1541 ListCell *arg;
1542 Expr *simple;
1543 FuncExpr *newexpr;
1544 bool has_nonconst_input;
1545
1546 Form_pg_proc funcform;
1547 EState *estate;
1548 ExprState *exprstate;
1549 MemoryContext oldcontext;
1550 Datum const_val;
1551 bool const_is_null;
1552 int16 resultTypLen;
1553 bool resultTypByVal;
1554
1555 Oid funcid;
1556 HeapTuple func_tuple;
1557
1558 /*
1559 * Reduce constants in the FuncExpr's arguments. We know args is
1560 * either NIL or a List node, so we can call expression_tree_mutator
1561 * directly rather than recursing to self.
1562 */
1563 args = (List *) expression_tree_mutator((Node *) expr->args,
1564 pre_dispatch_function_evaluation_mutator,
1565 (void *) context);
1566
1567 funcid = expr->funcid;
1568
1569 newexpr = makeNode(FuncExpr);
1570 newexpr->funcid = expr->funcid;
1571 newexpr->funcresulttype = expr->funcresulttype;
1572 newexpr->funcretset = expr->funcretset;
1573 newexpr->funcvariadic = expr->funcvariadic;
1574 newexpr->funcformat = expr->funcformat;
1575 newexpr->funccollid = expr->funccollid;
1576 newexpr->inputcollid = expr->inputcollid;
1577 newexpr->args = args;
1578 newexpr->location = expr->location;

Callers 1

exec_make_plan_constantFunction · 0.85

Calls 15

expression_tree_mutatorFunction · 0.85
SearchSysCache1Function · 0.85
ObjectIdGetDatumFunction · 0.85
type_is_rowtypeFunction · 0.85
ReleaseSysCacheFunction · 0.85
CreateExecutorStateFunction · 0.85
MemoryContextSwitchToFunction · 0.85
ExecPrepareExprFunction · 0.85
get_typlenbyvalFunction · 0.85
datumCopyFunction · 0.85

Tested by

no test coverage detected