* attributes.
*/
static void
-compute_attributes_sql_style(ParseState *pstate,
- bool is_procedure,
- List *options,
- List **as,
- char **language,
- Node **transform,
- bool *windowfunc_p,
- char *volatility_p,
- bool *strict_p,
- bool *security_definer,
- bool *leakproof_p,
- ArrayType **proconfig,
- float4 *procost,
- float4 *prorows,
- char *parallel_p)
+compute_function_attributes(ParseState *pstate,
+ bool is_procedure,
+ List *options,
+ List **as,
+ char **language,
+ Node **transform,
+ bool *windowfunc_p,
+ char *volatility_p,
+ bool *strict_p,
+ bool *security_definer,
+ bool *leakproof_p,
+ ArrayType **proconfig,
+ float4 *procost,
+ float4 *prorows,
+ char *parallel_p)
{
ListCell *option;
DefElem *as_item = NULL;
}
-/*-------------
- * Interpret the parameters *parameters and return their contents via
- * *isStrict_p and *volatility_p.
- *
- * These parameters supply optional information about a function.
- * All have defaults if not specified. Parameters:
- *
- * * isStrict means the function should not be called when any NULL
- * inputs are present; instead a NULL result value should be assumed.
- *
- * * volatility tells the optimizer whether the function's result can
- * be assumed to be repeatable over multiple evaluations.
- *------------
- */
-static void
-compute_attributes_with_style(ParseState *pstate, bool is_procedure, List *parameters, bool *isStrict_p, char *volatility_p)
-{
- ListCell *pl;
-
- foreach(pl, parameters)
- {
- DefElem *param = (DefElem *) lfirst(pl);
-
- if (pg_strcasecmp(param->defname, "isstrict") == 0)
- {
- if (is_procedure)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
- errmsg("invalid attribute in procedure definition"),
- parser_errposition(pstate, param->location)));
- *isStrict_p = defGetBoolean(param);
- }
- else if (pg_strcasecmp(param->defname, "iscachable") == 0)
- {
- /* obsolete spelling of isImmutable */
- if (is_procedure)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
- errmsg("invalid attribute in procedure definition"),
- parser_errposition(pstate, param->location)));
- if (defGetBoolean(param))
- *volatility_p = PROVOLATILE_IMMUTABLE;
- }
- else
- ereport(WARNING,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("unrecognized function attribute \"%s\" ignored",
- param->defname),
- parser_errposition(pstate, param->location)));
- }
-}
-
-
/*
* For a dynamically linked C language object, the form of the clause is
*
/*
* CreateFunction
- * Execute a CREATE FUNCTION utility statement.
+ * Execute a CREATE FUNCTION (or CREATE PROCEDURE) utility statement.
*/
ObjectAddress
CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt)
aclcheck_error(aclresult, OBJECT_SCHEMA,
get_namespace_name(namespaceId));
- /* default attributes */
+ /* Set default attributes */
isWindowFunc = false;
isStrict = false;
security = false;
prorows = -1; /* indicates not set */
parallel = PROPARALLEL_UNSAFE;
- /* override attributes from explicit list */
- compute_attributes_sql_style(pstate,
- stmt->is_procedure,
- stmt->options,
- &as_clause, &language, &transformDefElem,
- &isWindowFunc, &volatility,
- &isStrict, &security, &isLeakProof,
- &proconfig, &procost, &prorows, ¶llel);
+ /* Extract non-default attributes from stmt->options list */
+ compute_function_attributes(pstate,
+ stmt->is_procedure,
+ stmt->options,
+ &as_clause, &language, &transformDefElem,
+ &isWindowFunc, &volatility,
+ &isStrict, &security, &isLeakProof,
+ &proconfig, &procost, &prorows, ¶llel);
/* Look up the language and validate permissions */
languageTuple = SearchSysCache1(LANGNAME, PointerGetDatum(language));
trftypes = NULL;
}
- compute_attributes_with_style(pstate, stmt->is_procedure, stmt->withClause, &isStrict, &volatility);
-
interpret_AS_clause(languageOid, language, funcname, as_clause,
&prosrc_str, &probin_str);
FuncExpr *fexpr;
int nargs;
int i;
- AclResult aclresult;
+ AclResult aclresult;
FmgrInfo flinfo;
FunctionCallInfoData fcinfo;
CallContext *callcontext;
InitFunctionCallInfoData(fcinfo, &flinfo, nargs, fexpr->inputcollid, (Node *) callcontext, NULL);
i = 0;
- foreach (lc, fexpr->args)
+ foreach(lc, fexpr->args)
{
EState *estate;
ExprState *exprstate;
CreateFunctionStmt:
CREATE opt_or_replace FUNCTION func_name func_args_with_defaults
- RETURNS func_return createfunc_opt_list opt_definition
+ RETURNS func_return createfunc_opt_list
{
CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
+ n->is_procedure = false;
n->replace = $2;
n->funcname = $4;
n->parameters = $5;
n->returnType = $7;
n->options = $8;
- n->withClause = $9;
$$ = (Node *)n;
}
| CREATE opt_or_replace FUNCTION func_name func_args_with_defaults
- RETURNS TABLE '(' table_func_column_list ')' createfunc_opt_list opt_definition
+ RETURNS TABLE '(' table_func_column_list ')' createfunc_opt_list
{
CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
+ n->is_procedure = false;
n->replace = $2;
n->funcname = $4;
n->parameters = mergeTableFuncParameters($5, $9);
n->returnType = TableFuncTypeName($9);
n->returnType->location = @7;
n->options = $11;
- n->withClause = $12;
$$ = (Node *)n;
}
| CREATE opt_or_replace FUNCTION func_name func_args_with_defaults
- createfunc_opt_list opt_definition
+ createfunc_opt_list
{
CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
+ n->is_procedure = false;
n->replace = $2;
n->funcname = $4;
n->parameters = $5;
n->returnType = NULL;
n->options = $6;
- n->withClause = $7;
$$ = (Node *)n;
}
| CREATE opt_or_replace PROCEDURE func_name func_args_with_defaults
createfunc_opt_list
{
CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
+ n->is_procedure = true;
n->replace = $2;
n->funcname = $4;
n->parameters = $5;
n->returnType = NULL;
- n->is_procedure = true;
n->options = $6;
$$ = (Node *)n;
}