]> 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:30 +0000 (13:32 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 6 Nov 2013 18:32:30 +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 0b1e5c4e2f0151ce0678b2ee4a66644136557b16..7a94870b6491818ceaec77023a706bf661a39c20 100644 (file)
@@ -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.
    </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 ccec1102d0b60ace51a51209b46ffc805cab0c3a..b985d63d77b671e2d1d6e155eafa39579722d567 100644 (file)
@@ -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.
         */