---------- * 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
| 8468 | * ---------- |
| 8469 | */ |
| 8470 | static void |
| 8471 | get_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 |
no test coverage detected