mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Support parameters in CALL
To support parameters in CALL, move the parse analysis of the procedure and arguments into the global transformation phase, so that the parser hooks can be applied. And then at execution time pass the parameters from ProcessUtility on to ExecuteCallStmt.
This commit is contained in:
@@ -36,6 +36,8 @@
|
||||
#include "parser/parse_coerce.h"
|
||||
#include "parser/parse_collate.h"
|
||||
#include "parser/parse_cte.h"
|
||||
#include "parser/parse_expr.h"
|
||||
#include "parser/parse_func.h"
|
||||
#include "parser/parse_oper.h"
|
||||
#include "parser/parse_param.h"
|
||||
#include "parser/parse_relation.h"
|
||||
@@ -74,6 +76,8 @@ static Query *transformExplainStmt(ParseState *pstate,
|
||||
ExplainStmt *stmt);
|
||||
static Query *transformCreateTableAsStmt(ParseState *pstate,
|
||||
CreateTableAsStmt *stmt);
|
||||
static Query *transformCallStmt(ParseState *pstate,
|
||||
CallStmt *stmt);
|
||||
static void transformLockingClause(ParseState *pstate, Query *qry,
|
||||
LockingClause *lc, bool pushedDown);
|
||||
#ifdef RAW_EXPRESSION_COVERAGE_TEST
|
||||
@@ -318,6 +322,10 @@ transformStmt(ParseState *pstate, Node *parseTree)
|
||||
(CreateTableAsStmt *) parseTree);
|
||||
break;
|
||||
|
||||
case T_CallStmt:
|
||||
result = transformCallStmt(pstate,
|
||||
(CallStmt *) parseTree);
|
||||
|
||||
default:
|
||||
|
||||
/*
|
||||
@@ -2571,6 +2579,43 @@ transformCreateTableAsStmt(ParseState *pstate, CreateTableAsStmt *stmt)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* transform a CallStmt
|
||||
*
|
||||
* We need to do parse analysis on the procedure call and its arguments.
|
||||
*/
|
||||
static Query *
|
||||
transformCallStmt(ParseState *pstate, CallStmt *stmt)
|
||||
{
|
||||
List *targs;
|
||||
ListCell *lc;
|
||||
Node *node;
|
||||
Query *result;
|
||||
|
||||
targs = NIL;
|
||||
foreach(lc, stmt->funccall->args)
|
||||
{
|
||||
targs = lappend(targs, transformExpr(pstate,
|
||||
(Node *) lfirst(lc),
|
||||
EXPR_KIND_CALL_ARGUMENT));
|
||||
}
|
||||
|
||||
node = ParseFuncOrColumn(pstate,
|
||||
stmt->funccall->funcname,
|
||||
targs,
|
||||
pstate->p_last_srf,
|
||||
stmt->funccall,
|
||||
true,
|
||||
stmt->funccall->location);
|
||||
|
||||
stmt->funcexpr = castNode(FuncExpr, node);
|
||||
|
||||
result = makeNode(Query);
|
||||
result->commandType = CMD_UTILITY;
|
||||
result->utilityStmt = (Node *) stmt;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Produce a string representation of a LockClauseStrength value.
|
||||
|
Reference in New Issue
Block a user