Skip to content

Commit 352ab59

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 3dd1310 commit 352ab59

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
@@ -2373,6 +2373,13 @@ SELECT concat_lower_or_upper('Hello', 'World', uppercase := true);
23732373
having numerous parameters that have default values, named or mixed
23742374
notation can save a great deal of writing and reduce chances for error.
23752375
</para>
2376+
2377+
<note>
2378+
<para>
2379+
Named and mixed call notations can currently be used only with regular
2380+
functions, not with aggregate functions or window functions.
2381+
</para>
2382+
</note>
23762383
</sect2>
23772384
</sect1>
23782385

src/backend/catalog/pg_proc.c

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

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

0 commit comments

Comments
 (0)