diff options
Diffstat (limited to 'src/backend/commands/functioncmds.c')
-rw-r--r-- | src/backend/commands/functioncmds.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index 8963f981178..13f1debf669 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.104 2008/12/28 18:53:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.105 2008/12/31 02:25:03 tgl Exp $ * * DESCRIPTION * These routines take the parse tree and pick out the @@ -503,6 +503,7 @@ static void compute_attributes_sql_style(List *options, List **as, char **language, + bool *windowfunc_p, char *volatility_p, bool *strict_p, bool *security_definer, @@ -513,6 +514,7 @@ compute_attributes_sql_style(List *options, ListCell *option; DefElem *as_item = NULL; DefElem *language_item = NULL; + DefElem *windowfunc_item = NULL; DefElem *volatility_item = NULL; DefElem *strict_item = NULL; DefElem *security_item = NULL; @@ -540,6 +542,14 @@ compute_attributes_sql_style(List *options, errmsg("conflicting or redundant options"))); language_item = defel; } + else if (strcmp(defel->defname, "window") == 0) + { + if (windowfunc_item) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("conflicting or redundant options"))); + windowfunc_item = defel; + } else if (compute_common_attribute(defel, &volatility_item, &strict_item, @@ -578,6 +588,8 @@ compute_attributes_sql_style(List *options, } /* process optional items */ + if (windowfunc_item) + *windowfunc_p = intVal(windowfunc_item->arg); if (volatility_item) *volatility_p = interpret_func_volatility(volatility_item); if (strict_item) @@ -735,7 +747,8 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString) ArrayType *parameterNames; List *parameterDefaults; Oid requiredResultType; - bool isStrict, + bool isWindowFunc, + isStrict, security; char volatility; ArrayType *proconfig; @@ -756,6 +769,7 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString) get_namespace_name(namespaceId)); /* default attributes */ + isWindowFunc = false; isStrict = false; security = false; volatility = PROVOLATILE_VOLATILE; @@ -766,7 +780,8 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString) /* override attributes from explicit list */ compute_attributes_sql_style(stmt->options, &as_clause, &language, - &volatility, &isStrict, &security, + &isWindowFunc, &volatility, + &isStrict, &security, &proconfig, &procost, &prorows); /* Convert language name to canonical case */ @@ -892,6 +907,7 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString) prosrc_str, /* converted to text later */ probin_str, /* converted to text later */ false, /* not an aggregate */ + isWindowFunc, security, isStrict, volatility, |