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

Function get_rule_expr

src/backend/utils/adt/ruleutils.c:8470–9857  ·  view source on GitHub ↗

---------- * get_rule_expr - Parse back an expression * * Note: showimplicit determines whether we display any implicit cast that * is present at the top of the expression tree. It is a passed argument, * not a field of the context struct, because we change the value as we * recurse down into the expression. In general we suppress implicit casts * when the result type is known with cert

Source from the content-addressed store, hash-verified

8468 * ----------
8469 */
8470static void
8471get_rule_expr(Node *node, deparse_context *context,
8472 bool showimplicit)
8473{
8474 StringInfo buf = context->buf;
8475
8476 if (node == NULL)
8477 return;
8478
8479 /* Guard against excessively long or deeply-nested queries */
8480 CHECK_FOR_INTERRUPTS();
8481 check_stack_depth();
8482
8483 /*
8484 * Each level of get_rule_expr must emit an indivisible term
8485 * (parenthesized if necessary) to ensure result is reparsed into the same
8486 * expression tree. The only exception is that when the input is a List,
8487 * we emit the component items comma-separated with no surrounding
8488 * decoration; this is convenient for most callers.
8489 */
8490 switch (nodeTag(node))
8491 {
8492 case T_Var:
8493 (void) get_variable((Var *) node, 0, false, context);
8494 break;
8495
8496 case T_Const:
8497 get_const_expr((Const *) node, context, 0);
8498 break;
8499
8500 case T_Param:
8501 get_parameter((Param *) node, context);
8502 break;
8503
8504 case T_Aggref:
8505 get_agg_expr((Aggref *) node, context, (Aggref *) node);
8506 break;
8507 case T_DQAExpr:
8508 get_dqa_expr((DQAExpr *) node, context);
8509 break;
8510
8511 case T_GroupingFunc:
8512 {
8513 GroupingFunc *gexpr = (GroupingFunc *) node;
8514
8515 appendStringInfoString(buf, "GROUPING(");
8516 get_rule_expr((Node *) gexpr->args, context, true);
8517 appendStringInfoChar(buf, ')');
8518 }
8519 break;
8520 case T_GroupId:
8521 appendStringInfo(buf, "GROUP_ID()");
8522 break;
8523
8524 case T_GroupingSetId:
8525 appendStringInfo(buf, "GROUPINGSET_ID()");
8526 break;
8527

Callers 15

pg_get_triggerdef_workerFunction · 0.85
make_ruledefFunction · 0.85
get_with_clauseFunction · 0.85
get_select_query_defFunction · 0.85
get_basic_select_queryFunction · 0.85
get_target_listFunction · 0.85
get_rule_sortgroupclauseFunction · 0.85
get_rule_windowspecFunction · 0.85
get_insert_query_defFunction · 0.85
get_update_query_defFunction · 0.85

Calls 15

check_stack_depthFunction · 0.85
get_variableFunction · 0.85
get_const_exprFunction · 0.85
get_agg_exprFunction · 0.85
get_dqa_exprFunction · 0.85
appendStringInfoStringFunction · 0.85
appendStringInfoCharFunction · 0.85
appendStringInfoFunction · 0.85
get_windowfunc_exprFunction · 0.85
processIndirectionFunction · 0.85
printSubscriptsFunction · 0.85
get_func_exprFunction · 0.85

Tested by

no test coverage detected