postgres.git / summary / log / commit / refs
commit aad87e3f25ad751a3d021c139fd3adbbe1d19fce
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Wed Nov 06 18:32:26 2013 +0000
First released in: 8.4.19, 9.0.15, 9.1.11
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.
doc/src/sgml/syntax.sgml | 7 +++++++
src/backend/catalog/pg_proc.c | 6 ++++++
2 files changed, 13 insertions(+)
diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml
index 9e87186bb53..863de8852b0 100644
--- a/doc/src/sgml/syntax.sgml
+++ b/doc/src/sgml/syntax.sgml
@@ -2464,6 +2464,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.
</para>
+
+ <note>
+ <para>
+ Named and mixed call notations can currently be used only with regular
+ functions, not with aggregate functions or window functions.
+ </para>
+ </note>
</sect2>
</sect1>
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index ca21faf7b43..9d5f1a6cbc2 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -285,6 +285,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.
*/
[parent: db157fb141df]