]> granicus.if.org Git - postgresql/commitdiff
Prevent creating window functions with default arguments.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 6 Nov 2013 18:32:26 +0000 (13:32 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 6 Nov 2013 18:32:26 +0000 (13:32 -0500)
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
src/backend/catalog/pg_proc.c

index 9e87186bb53315a7292010bc131acee7e9746184..863de8852b08eade5585ab0add35293352ecf9b1 100644 (file)
@@ -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>
 
index ca21faf7b436780d39ca32a773253a72b238fdff..9d5f1a6cbc2295b0f37f122df84b045939befcc9 100644 (file)
@@ -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.
         */