How to substract a smaller subrange from a bigger range?
123456789
567
Result:
1234 89
SQL:
select '[1,9]'::int4range - '[5,7]'::int4range;
ERROR: result of range difference would not be contiguous
The result does not fit into a int4range since it is not contiguous.
How to get the result as a set of int4ranges?
Best Answer
You could define your own functions range_add/range_sub (intersection doesn't need special handling):
You could define them like this:
Unfortunately, PostgreSQL is missing native support for this set-based behavior.