Re: Add RANGE with values and exclusions clauses to the Window Functions - Mailing list pgsql-hackers

From Oliver Ford
Subject Re: Add RANGE with values and exclusions clauses to the Window Functions
Date
Msg-id CAGMVOdtYSNJusckQ_9vBkMsZBQzan=Uw-Z-uYG2fD9rZ2TP7pA@mail.gmail.com
Whole thread Raw
In response to Re: Add RANGE with values and exclusions clauses to the Window Functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Add RANGE with values and exclusions clauses to the Window Functions
List pgsql-hackers


On Tuesday, 9 January 2018, Tom Lane <tgl@sss.pgh.pa.us> wrote:
So the approach I'm imagining now is a datatype-specific support function
along the lines of

        in_range(a, b, delta) returns bool

which is supposed to return true if a <= b + delta, or something along
that line --- exact details of the definition TBD --- with the proviso
that if b + delta would overflow then the result is automatically true.

We could probably also delegate the requirement of throwing an error
for negative delta to this function, eliminating the need for the
datatype-independent core code to know how to tell that, which is the
other datatype-dependent behavior needed per spec.

Likely there are two of these, one each for the PRECEDING and FOLLOWING
cases.



Would you prefer two functions, or a single function with a parameter for PRECEDING/FOLLOWING? Maybe:

  in_range(a, b, delta, following) returns bool

Where following is a bool which is true if FOLLOWING was specified and false if PRECEDING was specified?

pgsql-hackers by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: [HACKERS] SQL/JSON in PostgreSQL
Next
From: Tom Lane
Date:
Subject: Re: Add RANGE with values and exclusions clauses to the Window Functions