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 1lr4ke-0001Te-2z for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Jun 2021 20:24:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lr4kd-0004L6-3C for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Jun 2021 20:24:35 +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 1lr4kc-0004Kw-Rw for pgsql-hackers@lists.postgresql.org; Wed, 09 Jun 2021 20:24:34 +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 1lr4ka-00030s-W8 for pgsql-hackers@lists.postgresql.org; Wed, 09 Jun 2021 20:24:34 +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:References:Cc:To:From:Subject:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=B3KBO3ndU0g7c31sL+fR04E3pC+QPbRXuvmo9oiiMIQ=; b=D5cOd53MqZlrMZzWoQc/8Ofs8X lwM4OO8lbc1w4AaLI3r0ByQf59WY8oL9eAYTn3l7C8IpsSsllAsTXQbUiDvYVL4nANtvXJGI4yyln leb7tKNkFEV9VtjWTstOSHiRVlLKIEoZpts1N/UDwB8XNlJ/XGR7Y9dMMYJeJNdFeEWf5lk0K/gab TOERxQvRA5+/XpwASRTtlE9x3Zq1FFE32g/4z7gcbNueCkXixcQLKD0D7s8O6BwQhsOALNlQJPbd7 Hayi2TQTP35Zo2j3+GtNKOlRyhB6JokMlrSkw3CfS5OxQuk8Nb8uGO2wNeTZoy+p7VmcAhZmFgQQk J9pMaSwA==; 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 1lr4kY-0001GY-Ls; Wed, 09 Jun 2021 20:24:32 +0000 Subject: Re: unnesting multirange data types From: "Jonathan S. Katz" To: Tom Lane Cc: PostgreSQL Hackers References: <60258efe-bd7e-4886-82e1-196e0cac5433@postgresql.org> <1429042.1623266711@sss.pgh.pa.us> Message-ID: <429daa9c-0fa0-1b0b-fc2f-54fe2e8db80f@postgresql.org> Date: Wed, 9 Jun 2021 16:24:27 -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: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hTqvm8Cai6Z7dmxs0aBX0VC9PYPVmuHU0" 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) --hTqvm8Cai6Z7dmxs0aBX0VC9PYPVmuHU0 Content-Type: multipart/mixed; boundary="SwB0CoVGEIW4gxzXo3vO7zorPzjjAXMnl"; protected-headers="v1" From: "Jonathan S. Katz" To: Tom Lane Cc: PostgreSQL Hackers Message-ID: <429daa9c-0fa0-1b0b-fc2f-54fe2e8db80f@postgresql.org> Subject: Re: unnesting multirange data types References: <60258efe-bd7e-4886-82e1-196e0cac5433@postgresql.org> <1429042.1623266711@sss.pgh.pa.us> In-Reply-To: --SwB0CoVGEIW4gxzXo3vO7zorPzjjAXMnl Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 6/9/21 3:44 PM, Jonathan S. Katz wrote: > 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: >> >> +1 for adding such a feature, but I suppose it's too late for v14. >=20 > 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. >=20 > 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 b= e > iterated over in PL/pgSQL (I'm suspecting no). I did a couple more tests around this. As suspected, in PL/pgSQL, there is no way to unpack or iterate over a multirange type. In PL/Python, both range types and multirange types are treated as strings. From there, you can at least ultimately parse and manipulate it into your preferred Python types, but this goes back to my earlier point about putting the onus on the developer to do so. Thanks, Jonathan --SwB0CoVGEIW4gxzXo3vO7zorPzjjAXMnl-- --hTqvm8Cai6Z7dmxs0aBX0VC9PYPVmuHU0 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/x8QSccp8cZScFAmDBI3sFAwAAAAAACgkQ8QSccp8cZScS qw/7BRf0KwDGpSwoZJGJYD2s7YV4MUcdFUant5g8RetYUnERU7n+KKa2rm/w7r5rWe8eCIXHIlTt WL0TtIS6C9T2aEeidZuu7GwjZAndqM+aWyOL6kVuF4fUgF5qlSwgfE5kGXf7aR2bGDV6Cc8z3nRS NmMBTU7IGap0/m2yhX0tX/3/6/3Qb0Sr37dEyTMBwgKfUcRyUX6CPZbeflzSTpyo4nBWifyyG1zI 5N0MP+jGstvdNe6ujDVqL6i2qK2pJ5gE+qOlDB4hLJlU4kiSls64mkrgKa9GpkZglMjxf1CI7jeV mmx6BveHKHw4DJkQuKgixBLmlOltXurM/deSPMKjB6YtRWiNfKMUNymSwH2TWU6XnAbDNgDCUz23 aTUaDhV6Xf5/MNMvDATgOdd2lpNsXwb+bj56gUtLDyDli34rGIXg1jNDSv86LqOX3bAZV86OzfxP suWyziOwrFVBy3/zRl+VFagRHJW/Dtmhx40ST+fJRDADAtrPlriL6rl08TiKQa8/cszg2voLfbud rgRG+PbwzBonwFMX+N3C8a26jJbQ90aviUedXu0ifCQrDbKLDbopHhhkIWydapBnH9i5bg1yW+y7 uQJ0e8pWwPovCYyIqOuBHozcZveOlqQhJKQ1LyBUzFvfesi0YItDynVAbVgVKjDDOog1a6bxJUeA tdw= =o8AW -----END PGP SIGNATURE----- --hTqvm8Cai6Z7dmxs0aBX0VC9PYPVmuHU0--