range_agg() missing support for multirange inputs

From: "Ian R(dot) Campbell" <ian(dot)campbell(at)thepathcentral(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: range_agg() missing support for multirange inputs
Date: 2021-11-24 22:13:17
Message-ID: CAOC8YUcOtAGscPa31ik8UEMzgn8uAWA09s6CYOGPyP9_cBbWTw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Consider the following code:

with a(x) as(

values

('{[10,20],[100,200]}'::int4multirange)

,('{[20,40],[15,55],[100,200]}'::int4multirange)

)

select range_agg(x)

from (

select unnest(x)x

from a

)t;

=> {[10,56),[100,201)}

Here, range_agg() won’t accept a multirange type input, but it outputs a
multirange type.

The only way to aggregate the source multirange rows is to unnest them
first.

However, range_intersect_agg() does not require the unnest step:

with a(x) as(

values

('{[10,20],[100,200]}'::int4multirange)

,('{[20,40],[15,55],[100,200]}'::int4multirange)

)

select range_intersect_agg(x)

from a;

=> {[15,21),[100,201)}

Ian Campbell

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2021-11-25 03:23:41 Re: BUG #17288: PSQL bug with COPY command (Windows)
Previous Message Elvis Pranskevichus 2021-11-24 19:48:37 Re: BUG #17213: Wrong result from a query involving Merge Semi Join and Memoize