range_agg - Mailing list pgsql-hackers

From Paul Jungwirth
Subject range_agg
Date
Msg-id 16d71dc8-34cf-5ebd-1ce5-ccd93c0a14f9@illuminatedcomputing.com
Whole thread Raw
Responses Re: range_agg
Re: range_agg
Re: range_agg
Re: range_agg
List pgsql-hackers
Hello,

I wrote an extension to add a range_agg function with similar behavior 
to existing *_agg functions, and I'm wondering if folks would like to 
have it in core? Here is the repo: https://github.com/pjungwir/range_agg

I'm also working on a patch for temporal foreign keys, and having 
range_agg would make the FK check easier and faster, which is why I'd 
like to get it added. But also it just seems useful, like array_agg, 
json_agg, etc.

One question is how to aggregate ranges that would leave gaps and/or 
overlaps. So in my extension there is a one-param version that forbids 
gaps & overlaps, but I let you permit them by passing extra parameters, 
so the signature is:

     range_agg(r anyrange, permit_gaps boolean, permit_overlaps boolean)

Perhaps another useful choice would be to return NULL if a gap/overlap 
is found, so that each param would have three choices instead of just 
two: accept the inputs, raise an error, return a NULL.

What do people think? I plan to work on a patch regardless, so that I 
can use it for temporal FKs, but I'd appreciate some feedback on the 
"user interface".

Thanks,

-- 
Paul              ~{:-)
pj@illuminatedcomputing.com



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: improving wraparound behavior
Next
From: David Rowley
Date:
Subject: Re: using index or check in ALTER TABLE SET NOT NULL