looping over multirange segments?

From: Ben Chobot <bench(at)silentmedia(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: looping over multirange segments?
Date: 2021-07-14 23:19:48
Message-ID: 623b65ef-6bfe-ec35-45c0-341e8f9ab7a8@silentmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Csanyi Pal 2021-07-15 04:12:09 Re: How to display stored image as bytea or as large objects?
Previous Message Ho John Lee 2021-07-14 20:17:32 Re: How to display stored image as bytea or as large objects?