On Fri, Mar 5, 2021, at 20:46, Joel Jacobson wrote: > My conclusion is that we should use setof int4range[] as the return value for > regexp_positions().
If acceptable by the project, it be even nicer if we could just return the suggested composite type. I don't see any existing catalog functions returning composite types though? Is this due to some policy of not wanting composite types as return values for built-ins or just a coincidence? Example on regexp_positions -> setof range[] where range is: CREATE TYPE range AS (start int8, stop int8); SELECT regexp_positions('foObARbEqUEbAz', $re$(?=beque)$re$, 'i'); regexp_positions ------------------ {"(6,6)"} (1 row) SELECT r FROM regexp_positions('foobarbequebazilbarfbonk', $re$(b[^b]+)(b[^b]+)$re$, 'g') AS r; r ----------------------- {"(3,6)","(6,11)"} {"(11,16)","(16,20)"} (2 rows) SELECT r[1].*, r[2].* FROM regexp_positions('foobarbequebazilbarfbonk', $re$(b[^b]+)(b[^b]+)$re$, 'g') AS r; start | stop | start | stop -------+------+-------+------ 3 | 6 | 6 | 11 11 | 16 | 16 | 20 (2 rows) SELECT r[1].* FROM regexp_positions('','^','g') AS r; start | stop -------+------ 0 | 0 (1 row) Thoughts? /Joel