|
36 | 36 | #include "parser/parse_coerce.h"
|
37 | 37 | #include "parser/parse_collate.h"
|
38 | 38 | #include "parser/parse_cte.h"
|
| 39 | +#include "parser/parse_expr.h" |
| 40 | +#include "parser/parse_func.h" |
39 | 41 | #include "parser/parse_oper.h"
|
40 | 42 | #include "parser/parse_param.h"
|
41 | 43 | #include "parser/parse_relation.h"
|
@@ -74,6 +76,8 @@ static Query *transformExplainStmt(ParseState *pstate,
|
74 | 76 | ExplainStmt *stmt);
|
75 | 77 | static Query *transformCreateTableAsStmt(ParseState *pstate,
|
76 | 78 | CreateTableAsStmt *stmt);
|
| 79 | +static Query *transformCallStmt(ParseState *pstate, |
| 80 | + CallStmt *stmt); |
77 | 81 | static void transformLockingClause(ParseState *pstate, Query *qry,
|
78 | 82 | LockingClause *lc, bool pushedDown);
|
79 | 83 | #ifdef RAW_EXPRESSION_COVERAGE_TEST
|
@@ -318,6 +322,10 @@ transformStmt(ParseState *pstate, Node *parseTree)
|
318 | 322 | (CreateTableAsStmt *) parseTree);
|
319 | 323 | break;
|
320 | 324 |
|
| 325 | + case T_CallStmt: |
| 326 | + result = transformCallStmt(pstate, |
| 327 | + (CallStmt *) parseTree); |
| 328 | + |
321 | 329 | default:
|
322 | 330 |
|
323 | 331 | /*
|
@@ -2571,6 +2579,43 @@ transformCreateTableAsStmt(ParseState *pstate, CreateTableAsStmt *stmt)
|
2571 | 2579 | return result;
|
2572 | 2580 | }
|
2573 | 2581 |
|
| 2582 | +/* |
| 2583 | + * transform a CallStmt |
| 2584 | + * |
| 2585 | + * We need to do parse analysis on the procedure call and its arguments. |
| 2586 | + */ |
| 2587 | +static Query * |
| 2588 | +transformCallStmt(ParseState *pstate, CallStmt *stmt) |
| 2589 | +{ |
| 2590 | + List *targs; |
| 2591 | + ListCell *lc; |
| 2592 | + Node *node; |
| 2593 | + Query *result; |
| 2594 | + |
| 2595 | + targs = NIL; |
| 2596 | + foreach(lc, stmt->funccall->args) |
| 2597 | + { |
| 2598 | + targs = lappend(targs, transformExpr(pstate, |
| 2599 | + (Node *) lfirst(lc), |
| 2600 | + EXPR_KIND_CALL_ARGUMENT)); |
| 2601 | + } |
| 2602 | + |
| 2603 | + node = ParseFuncOrColumn(pstate, |
| 2604 | + stmt->funccall->funcname, |
| 2605 | + targs, |
| 2606 | + pstate->p_last_srf, |
| 2607 | + stmt->funccall, |
| 2608 | + true, |
| 2609 | + stmt->funccall->location); |
| 2610 | + |
| 2611 | + stmt->funcexpr = castNode(FuncExpr, node); |
| 2612 | + |
| 2613 | + result = makeNode(Query); |
| 2614 | + result->commandType = CMD_UTILITY; |
| 2615 | + result->utilityStmt = (Node *) stmt; |
| 2616 | + |
| 2617 | + return result; |
| 2618 | +} |
2574 | 2619 |
|
2575 | 2620 | /*
|
2576 | 2621 | * Produce a string representation of a LockClauseStrength value.
|
|
0 commit comments