From: Ben Chobot <bench@silentmedia.com>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: looping over multirange segments?
Date: Wed, 14 Jul 2021 16:19:48 -0700
Message-ID: <623b65ef-6bfe-ec35-45c0-341e8f9ab7a8@silentmedia.com> (raw)
I'm really, really liking the multirange types in PG14. Thank you for
making them! Unfortunately I am struggling with how to loop over the
segments of a multirange. There doesn't seem to be a way to convert them
to arrays, and I can't just use plpgsql's FOREACH on one. Am I missing
something obvious? It seems like a reasonable thing to want to do.
FWIW, my actual end goal is to take something like this:
select int8range(1,10)::int8multirange - int8range(4,6)::int8multirange;
?column?
────────────────
{[1,4),[6,10)}
...and turn it into this:
select ???;
int8range │ ?column?
───────────┼──────────
[1,4) │ 0
[6,10) │ 0
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: bench@silentmedia.com
Subject: Re: looping over multirange segments?
In-Reply-To: <623b65ef-6bfe-ec35-45c0-341e8f9ab7a8@silentmedia.com>
References: <623b65ef-6bfe-ec35-45c0-341e8f9ab7a8@silentmedia.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox