mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
Support named and default arguments in CALL
We need to call expand_function_arguments() to expand named and default arguments. In PL/pgSQL, we also need to deal with named and default INOUT arguments when receiving the output values into variables. Author: Pavel Stehule <pavel.stehule@gmail.com>
This commit is contained in:
@ -52,6 +52,7 @@
|
||||
#include "executor/execdesc.h"
|
||||
#include "executor/executor.h"
|
||||
#include "miscadmin.h"
|
||||
#include "optimizer/clauses.h"
|
||||
#include "optimizer/var.h"
|
||||
#include "parser/parse_coerce.h"
|
||||
#include "parser/parse_collate.h"
|
||||
@ -2226,8 +2227,31 @@ ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver
|
||||
if (aclresult != ACLCHECK_OK)
|
||||
aclcheck_error(aclresult, OBJECT_PROCEDURE, get_func_name(fexpr->funcid));
|
||||
|
||||
/* Prep the context object we'll pass to the procedure */
|
||||
callcontext = makeNode(CallContext);
|
||||
callcontext->atomic = atomic;
|
||||
|
||||
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(fexpr->funcid));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for function %u", fexpr->funcid);
|
||||
|
||||
/*
|
||||
* If proconfig is set we can't allow transaction commands because of the
|
||||
* way the GUC stacking works: The transaction boundary would have to pop
|
||||
* the proconfig setting off the stack. That restriction could be lifted
|
||||
* by redesigning the GUC nesting mechanism a bit.
|
||||
*/
|
||||
if (!heap_attisnull(tp, Anum_pg_proc_proconfig, NULL))
|
||||
callcontext->atomic = true;
|
||||
|
||||
/*
|
||||
* Expand named arguments, defaults, etc.
|
||||
*/
|
||||
fexpr->args = expand_function_arguments(fexpr->args, fexpr->funcresulttype, tp);
|
||||
nargs = list_length(fexpr->args);
|
||||
|
||||
ReleaseSysCache(tp);
|
||||
|
||||
/* safety check; see ExecInitFunc() */
|
||||
if (nargs > FUNC_MAX_ARGS)
|
||||
ereport(ERROR,
|
||||
@ -2237,23 +2261,6 @@ ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver
|
||||
FUNC_MAX_ARGS,
|
||||
FUNC_MAX_ARGS)));
|
||||
|
||||
/* Prep the context object we'll pass to the procedure */
|
||||
callcontext = makeNode(CallContext);
|
||||
callcontext->atomic = atomic;
|
||||
|
||||
/*
|
||||
* If proconfig is set we can't allow transaction commands because of the
|
||||
* way the GUC stacking works: The transaction boundary would have to pop
|
||||
* the proconfig setting off the stack. That restriction could be lifted
|
||||
* by redesigning the GUC nesting mechanism a bit.
|
||||
*/
|
||||
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(fexpr->funcid));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup failed for function %u", fexpr->funcid);
|
||||
if (!heap_attisnull(tp, Anum_pg_proc_proconfig, NULL))
|
||||
callcontext->atomic = true;
|
||||
ReleaseSysCache(tp);
|
||||
|
||||
/* Initialize function call structure */
|
||||
InvokeFunctionExecuteHook(fexpr->funcid);
|
||||
fmgr_info(fexpr->funcid, &flinfo);
|
||||
|
Reference in New Issue
Block a user