Skip to content

Commit aad87e3

Browse files
committed
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.
1 parent db157fb commit aad87e3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

doc/src/sgml/syntax.sgml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2464,6 +2464,13 @@ SELECT concat_lower_or_upper('Hello', 'World', uppercase := true);
24642464
having numerous parameters that have default values, named or mixed
24652465
notation can save a great deal of writing and reduce chances for error.
24662466
</para>
2467+
2468+
<note>
2469+
<para>
2470+
Named and mixed call notations can currently be used only with regular
2471+
functions, not with aggregate functions or window functions.
2472+
</para>
2473+
</note>
24672474
</sect2>
24682475
</sect1>
24692476

src/backend/catalog/pg_proc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@ ProcedureCreate(const char *procedureName,
285285
}
286286
}
287287

288+
/* Guard against a case the planner doesn't handle yet */
289+
if (isWindowFunc && parameterDefaults != NIL)
290+
ereport(ERROR,
291+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
292+
errmsg("window functions cannot have default arguments")));
293+
288294
/*
289295
* All seems OK; prepare the data to be inserted into pg_proc.
290296
*/

0 commit comments

Comments
 (0)