From: Tom Lane Date: Wed, 6 Nov 2013 18:32:30 +0000 (-0500) Subject: Prevent creating window functions with default arguments. X-Git-Tag: REL9_0_15~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=352ab596fa5a8a4ceec6d308ebae34176cc09c13;p=thirdparty%2Fpostgresql.git Prevent creating window functions with default arguments. Insertion of default arguments doesn't work for window functions, which is likely to cause a crash at runtime if the implementation code doesn't check the number of actual arguments carefully. It doesn't seem worth working harder than this for pre-9.2 branches. --- diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml index 0b1e5c4e2f0..7a94870b649 100644 --- a/doc/src/sgml/syntax.sgml +++ b/doc/src/sgml/syntax.sgml @@ -2373,6 +2373,13 @@ SELECT concat_lower_or_upper('Hello', 'World', uppercase := true); having numerous parameters that have default values, named or mixed notation can save a great deal of writing and reduce chances for error. + + + + Named and mixed call notations can currently be used only with regular + functions, not with aggregate functions or window functions. + + diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index ccec1102d0b..b985d63d77b 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -284,6 +284,12 @@ ProcedureCreate(const char *procedureName, } } + /* Guard against a case the planner doesn't handle yet */ + if (isWindowFunc && parameterDefaults != NIL) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("window functions cannot have default arguments"))); + /* * All seems OK; prepare the data to be inserted into pg_proc. */