Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lr48F-0007sk-5O for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Jun 2021 19:44:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lr48C-0005L4-FF for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Jun 2021 19:44:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lr48C-0005Kw-24 for pgsql-hackers@lists.postgresql.org; Wed, 09 Jun 2021 19:44:52 +0000 Received: from meldrar.postgresql.org ([2a02:c0:301:0:ffff::31]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lr485-0002fw-9k for pgsql-hackers@lists.postgresql.org; Wed, 09 Jun 2021 19:44:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:Subject:From:References:Cc:To:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=BICeD2IcSKD7KhbeNS0zcF9rNMLyKxeyr8IC6/zxFuk=; b=Rjgqjjaf9+il028P5Odout+U3M 1yF3rZIPke2DCn5sH9Uh4aEbbQAhbWMADIeaOI0KppkV3JubdrBBjpsGE16IGnYjrtfbYj0OR+vwA nBgcQbo9DcL5SLqp71a5dbL0Gl1Q72I6oIKPnYIp8DUa9PQ36ylcIoxJC29MrUeIZV9tFwmSIszFP 7ZemVrrVQ9SKyx2Pw5DTqkaBfCWPeA7wfvc/3i8+t92/lDunZMatyQycPGrhX/JGGVEhWgy7B+UHv XKk5dqLmTtVazVP02V4wtAns2bfyfNSaXXb4itjbzMmjdr6k+PRQ6boarBG39mQxq2c2VSXkU/Q3S bD8ChRPw==; Received: from [2600:380:bd75:9cc0:d03a:6ece:d149:e76] (helo=Ph33rHippo.local) by meldrar.postgresql.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lr482-0000pM-QY; Wed, 09 Jun 2021 19:44:44 +0000 To: Tom Lane Cc: PostgreSQL Hackers References: <60258efe-bd7e-4886-82e1-196e0cac5433@postgresql.org> <1429042.1623266711@sss.pgh.pa.us> From: "Jonathan S. Katz" Subject: Re: unnesting multirange data types Message-ID: Date: Wed, 9 Jun 2021 15:44:39 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <1429042.1623266711@sss.pgh.pa.us> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="CDxzGNV9newmfj6csfSRGwKWF2xlz70g6" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2600:380:bd75:9cc0:d03a:6ece:d149:e76 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --CDxzGNV9newmfj6csfSRGwKWF2xlz70g6 Content-Type: multipart/mixed; boundary="QM7w3VlmEOaNsXcQ1vB2gDx8w2MKQJLHG"; protected-headers="v1" From: "Jonathan S. Katz" To: Tom Lane Cc: PostgreSQL Hackers Message-ID: Subject: Re: unnesting multirange data types References: <60258efe-bd7e-4886-82e1-196e0cac5433@postgresql.org> <1429042.1623266711@sss.pgh.pa.us> In-Reply-To: <1429042.1623266711@sss.pgh.pa.us> --QM7w3VlmEOaNsXcQ1vB2gDx8w2MKQJLHG Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 6/9/21 3:25 PM, Tom Lane wrote: > "Jonathan S. Katz" writes: >> I would like to decompose the returned multirange into its individual >> ranges, similarly to how I would "unnest" an array: >=20 > +1 for adding such a feature, but I suppose it's too late for v14. Well, the case I would make for v14 is that, as of right now, the onus is on the driver writers / application developers to be able to unpack the multiranges. Maybe it's not terrible as of this moment -- I haven't tried testing it that far yet -- but it may make it a bit more challenging to work with these types outside of Postgres. I recall a similar issue when initially trying to integrate range types into my apps back in the v9.2 days, and I ended up writing some grotty code to handle it. Yes, I worked around it, but I preferably wouldn't have had to. An "unnest" at least lets us bridge the gap a bit, i.e. if you really need to introspect a multirange type, you have a way of getting it into a familiar format. I haven't tried manipulating a multirange in a PL like Python, maybe some exploration there would unveil more or less pain, or if it could be iterated over in PL/pgSQL (I'm suspecting no). That all said, for writing queries within Postgres, the multiranges make a lot of operations way easier. I do think a missing "unnest" function does straddle the line of "omission" and "new feature," so I can understand if it does not make it into v14. > AFAICS, "unnest(anymultirange) returns setof anyrange" could coexist > alongside the existing variants of unnest(), so I don't see any > fundamental stumbling block to having it. Cool. I was initially throwing out "unnest" as the name as it mirrors what we currently have with arrays, and seems to be doing something similar. Open to other names, but this was the one that I was drawn to. "multirange" is an "ordered array of ranges" after all. Thanks, Jonathan --QM7w3VlmEOaNsXcQ1vB2gDx8w2MKQJLHG-- --CDxzGNV9newmfj6csfSRGwKWF2xlz70g6 Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsF5BAABCAAjFiEE+oS2la8r95ogZD/x8QSccp8cZScFAmDBGicFAwAAAAAACgkQ8QSccp8cZSeH 6hAAqsXg672+JPWagagidEKpxppbPGswmFwdG9/jdwqVxYcvVrMuEVK9bPxHRmdKTAYiB6175Bnb 6NDM+BxynCBONe8bDSzfk83DcWCUDftzcOI7z9q5WlLvwdt4o/d02LgE7XqdoQ5bJd5jzvn1cukr P/ht3DJJ/840764aXvP8/EY6OAlM1KgQ2jOdblnB3evZ/yBO/gZ0WlpghHljQqt7t1hScp1B+BUs KE/cIiPV6iM29bby1vDdFKdoXpm41u8rd8x3MWFeyWnB+tbX/xiipIwKHYw0xWezVj8loBRc+m9I He8XyDu52B+a+KSxoCkXmz9H2gFIvRSOA2yb8qdcGcReJVO65uWeszR0fuKihfr6FiBHerwunz6F Ake6SbYYwYHLNAtF/Wr+QxsrNiB1j6hqCIn/YS2n604JZgxzGUC/EwGB+NFYDtXRONaSTgbTmsmq NsRDwRgdbZ3IluVKl14atdGw/dFTGfQCUchUdhJoShaMKN4OSVL70ePiIfLpzxLH8wTKwGUAxUak FmoJ4we9T9H5Js4eAxNVaBc8DekI67uWcItd25HcY+VRcT9utPwo6oxuz9tKJSN7DF44Ze0CjRPz vyZKlT9GfL8p64+670bx3VHNS7Rx5r7BreH9VKeDa0a3uhdKwN1I3cB2+jSjgRs9CX8G/gyZxLtd RsQ= =OSNs -----END PGP SIGNATURE----- --CDxzGNV9newmfj6csfSRGwKWF2xlz70g6--