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 1lrOwF-0005J7-Bf for pgsql-hackers@arkaria.postgresql.org; Thu, 10 Jun 2021 17:57:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lrOwD-000771-A7 for pgsql-hackers@arkaria.postgresql.org; Thu, 10 Jun 2021 17:57:53 +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 1lrOwC-00076t-T2 for pgsql-hackers@lists.postgresql.org; Thu, 10 Jun 2021 17:57:53 +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 1lrOwA-0005AI-R8 for pgsql-hackers@lists.postgresql.org; Thu, 10 Jun 2021 17:57:52 +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:From:References:Cc:To:Subject:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=WFiGF2/nI4F/BbmkH6uLWJx076JWmMgq8LsTeLVAEzQ=; b=2UuopLFbksEsv8iCcMcbUBtrO3 XcUcYlRN9dLXi3Vq9pZDCdoS310NDwt4cdo5BieoLBo4SKLK1uq1L1H3zSp6Wf9ec8RfnSM7xLOKv OQFf79LdOwgmrnQ8O1fK+BsiSa3VrBvJXzUEsuRACBnbI4RxsftLCjsKryw5BmmGd0OseGqxHj22t D7QY8K7Pm0GhW4G3gtltWi86tJd/UR7LcjNcwyXOkABsFHjLL7OHNBfriZ6nWnCKnQ5TLS0DyvmGy 8z1hmV8a48Kj4uv41QBG55ec+6iGnt+8yqzjLf8LkxiwBr+yvLW1No+B3nH99v9/fcISOB/QUJzNj hO5zUReg==; Received: from [2600:380:bd3e:dd94:41cc:f953:45cf:ad8d] (helo=Ph33rHippo.local) by meldrar.postgresql.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lrOw6-0000PX-EV; Thu, 10 Jun 2021 17:57:48 +0000 Subject: Re: unnesting multirange data types To: Alexander Korotkov Cc: Alvaro Herrera , Tom Lane , PostgreSQL Hackers References: <202106092056.qitkvnvmpadu@alvherre.pgsql> <95432464-1b63-bc84-6f84-e9e9d79f9687@postgresql.org> From: "Jonathan S. Katz" Message-ID: <76f9f930-3451-fca5-2c43-a336dfa2814b@postgresql.org> Date: Thu, 10 Jun 2021 13:57:42 -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="XuUf6g8SLydQgGpnNPdXIjlHPtAfDIkfM" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2600:380:bd3e:dd94:41cc:f953:45cf:ad8d (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) --XuUf6g8SLydQgGpnNPdXIjlHPtAfDIkfM Content-Type: multipart/mixed; boundary="wqhvucCuLlTxusETBHmaR8VtBsCuKHxkb"; protected-headers="v1" From: "Jonathan S. Katz" To: Alexander Korotkov Cc: Alvaro Herrera , Tom Lane , PostgreSQL Hackers Message-ID: <76f9f930-3451-fca5-2c43-a336dfa2814b@postgresql.org> Subject: Re: unnesting multirange data types References: <202106092056.qitkvnvmpadu@alvherre.pgsql> <95432464-1b63-bc84-6f84-e9e9d79f9687@postgresql.org> In-Reply-To: --wqhvucCuLlTxusETBHmaR8VtBsCuKHxkb Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 6/10/21 1:24 PM, Alexander Korotkov wrote: > Hi, all! >=20 > On Thu, Jun 10, 2021 at 2:00 AM Jonathan S. Katz = wrote: >> On 6/9/21 4:56 PM, Alvaro Herrera wrote: >>> On 2021-Jun-09, Jonathan S. Katz wrote: >>> >>>> 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. >>> >>> Uh. This is disappointing; the need for some way to unnest or unpack= a >>> multirange was mentioned multiple times in the range_agg thread. I h= ad >>> assumed that there was some way to cast the multirange to a range arr= ay, >>> or somehow convert it, but apparently that doesn't work. >> >> Just to be pedantic with examples: >> >> SELECT datemultirange( >> daterange(current_date, current_date + 2), >> daterange(current_date + 5, current_date + 7))::daterange[]; >> >> ERROR: cannot cast type datemultirange to daterange[] >> LINE 1: ...2), daterange(current_date + 5, current_date + 7))::dater= ang... >> >> IF there was an array to cast it into an array, we could then use the >> array looping construct in PL/pgSQL, but if we could only choose one, = I >> think it'd be more natural/less verbose to have an "unnest". >> >>> If the supporting pieces are mostly there, then I opine we should add= >>> something. >> >> Agreed. >=20 > I agree that unnest(), cast to array and subscription are missing > points. Proper subscription support requires expanded object > handling. And that seems too late for v14. Agreed, the subscripting functionality is too late for v14. (Though perhaps someone ambitious could bridge that gap temporarily with the ability to add subscripting to types!). > But unnset() and cast to > array seems trivial. I've drafted unnest support (attached). I'm > going to add also cast to the array, tests, and docs within a day. > Stay tuned :) Awesome. I'll defer to others on the implementation. I'll try to test out the patch in a bit to see how it works. Are there any objections adding this as a v14 open item? Thanks, Jonathan --wqhvucCuLlTxusETBHmaR8VtBsCuKHxkb-- --XuUf6g8SLydQgGpnNPdXIjlHPtAfDIkfM 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/x8QSccp8cZScFAmDCUpYFAwAAAAAACgkQ8QSccp8cZSdK sA//VZ7Lw2pw8EdPHtsCx13b2i4vBdQ68S62MoQ0ZKwHqj2hCLuLmeBgxC5dlEKh9a/SR9l8t+1M gjolWm9HF8cjSBQpdiR71OhXS51cfaxkoHUkCrPRj4DhtfE1Pk3tP00AXJXr3lCnPy9/fpaNHB7B P9xUcnozGCQ5vd3f7voVohjVF76+yNtXxyzlYASuvQQ+LsvwrXaZ/aOYu5rbeAsOf7rRskgQzgoI MTKDZQce9aoojxXrcYfO3uLQbx0ndkyS5RzS4y1ZZTXA//mJidxfxK0ieJw54/toQ3QzOymKyEp6 4/6KsY4z73A/PV/aLdN1J1QgY+Mhkiu8KeN4ituE3e4vvnoNQOWUxC54zcl7YXNra15sfW8kWWs4 Q486/auBDsnU9oZ25Jsh6fTGgMsYXLnSraUkVp2hRxDqmTFZ5tMCnPFYZKydNH78pEyF3AC68/fp fCtxMYLoJKzHEPlj0Ic79LHK4Zq7LL2F+rza/2ScSwMoKAFGj/+fAK5Xx46A7uq6BbXusnzqeZLm SGz/FogMVKcx6NDbUC7CM+LzP+NVwV7EHbrcjRO5goYW38NJI481yzxp5Ixpkj06YTId2qjOEDNG nxwIAfu5z8kk3O2h/WA4ZosezD2XumZAFidtBJlVefbZhV2x8m/2TSocl/c93hauojuXjQ21VMVR hBI= =l2tO -----END PGP SIGNATURE----- --XuUf6g8SLydQgGpnNPdXIjlHPtAfDIkfM--