]> 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:36 +0000 (13:32 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 6 Nov 2013 18:32:36 +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.

src/backend/catalog/pg_proc.c

index 3a2c817a8b3e84c6b50dd9d5aec3de85760839b1..45d224ef409e5dd299d257f81d7a44c712b608d9 100644 (file)
@@ -283,6 +283,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.
         */