So I've tried to rough out a decision tree for the various options on how this might be implemented (discarding the "use precedence hacks" option). Opinions? Additions?
(formatted for emacs outline-mode) * 1. use lexical lookahead +: relatively straightforward parser changes +: no new reserved words +: has the option of working extensibly with all functions -: base_yylex needs extending to 3 lookahead tokens ** 1.1. Allow from/ignore clause on all (or all non-agg) window function calls If the clauses are legal on all window functions, what to do about existing window functions for which the clauses do not make sense? *** 1.1.1. Ignore the clause when the function isn't aware of it +: simple -: somewhat surprising for users perhaps? *** 1.1.2. Change the behavior of the windowapi in some consistent way Not sure if this can work. +: fairly simple(maybe?) and predictable -: changes the behavior of existing window functions ** 1.2. Allow from/ignore clause on only certain functions +: avoids any unexpected behavior -: needs some way to control what functions allow it *** 1.2.1. Check the function name in parse analysis against a fixed list. +: simple -: not extensible *** 1.2.2. Provide some option in CREATE FUNCTION +: extensible -: fairly intrusive, adding stuff to create function and pg_proc *** 1.2.3. Do something magical with function argument types +: doesn't need changes in create function / pg_proc -: it's an ugly hack * 2. reserve nth_value etc. as functions +: follows the spec reasonably well +: less of a hack than extending base_yylex -: new reserved words -: more parser rules -: not extensible (now goto 1.2.1) * 3. "just say no" to the spec e.g. add new functions like lead_ignore_nulls(), or add extra boolean args to lead() etc. telling them to skip nulls +: simple -: doesn't conform to spec -: using extra args isn't quite the right semantics -- Andrew (irc:RhodiumToad)