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 1lsV8h-0002x0-7K for pgsql-hackers@arkaria.postgresql.org; Sun, 13 Jun 2021 18:47:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lsV89-00064N-UB for pgsql-hackers@arkaria.postgresql.org; Sun, 13 Jun 2021 18:46:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lsV89-00064F-MO for pgsql-hackers@lists.postgresql.org; Sun, 13 Jun 2021 18:46:45 +0000 Received: from meldrar.postgresql.org ([2a02:c0:301:0:ffff::31]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lsV87-0000U9-IW for pgsql-hackers@lists.postgresql.org; Sun, 13 Jun 2021 18:46:44 +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=eglvgoNC4vu84gzVZoWkdiew3xqf7HOhlVOGTFRPZnc=; b=O+6XUsZB5ngcyrTpIcaDrgryS9 kpy07C1V4gSuVsU2sW2zsS3pqFcqp502vDnNm2v/kUuS5qXi1yQgzacsY8ruMT+QiF7UXkXReZBPe z2saDSke5Rb3EA/aQq/vqgvT2Wxfi/0vjxbjOqh3JQCSDdJBlTcYNy+akXmIVk6dXfMU9Ysa4hNs3 P24E45nRp05Xq84CJ/vu4VZWPJgt8CoCz6eEFj7ae6rRsvd90Fl5lcuub0LDoQ285l+cJvhH5gDoe 4lTqGvX5dj4d/BMUgC8VRSvl4zW82mBCP+ybdSfo4g8l+kFgAZiGlutVSPHpvmjHAAZvnRjIyowMe N5a3vF+g==; Received: from pool-71-105-8-149.nycmny.fios.verizon.net ([71.105.8.149] helo=[192.168.1.153]) by meldrar.postgresql.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lsV84-0003K0-0h; Sun, 13 Jun 2021 18:46:42 +0000 To: Justin Pryzby Cc: Zhihong Yu , Alexander Korotkov , Alvaro Herrera , Tom Lane , pgsql-hackers@lists.postgresql.org References: <20210610220416.GJ16435@telsasoft.com> <20210611233017.GO16435@telsasoft.com> <3648e50c-eb0d-4d16-7194-1a1c62893726@postgresql.org> <20210613154907.GZ16435@telsasoft.com> From: "Jonathan S. Katz" Subject: Re: unnesting multirange data types Message-ID: <11f691df-ce18-c32a-438b-979338d5ea1b@postgresql.org> Date: Sun, 13 Jun 2021 14:46:36 -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: <20210613154907.GZ16435@telsasoft.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WyTZtoJzRZ6lvvMjtT7Qhk7kYf3F2fg3A" 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) --WyTZtoJzRZ6lvvMjtT7Qhk7kYf3F2fg3A Content-Type: multipart/mixed; boundary="Ng9YiMPCSaOoEgD5vKAXjcrNVEjBaQwYJ"; protected-headers="v1" From: "Jonathan S. Katz" To: Justin Pryzby Cc: Zhihong Yu , Alexander Korotkov , Alvaro Herrera , Tom Lane , pgsql-hackers@lists.postgresql.org Message-ID: <11f691df-ce18-c32a-438b-979338d5ea1b@postgresql.org> Subject: Re: unnesting multirange data types References: <20210610220416.GJ16435@telsasoft.com> <20210611233017.GO16435@telsasoft.com> <3648e50c-eb0d-4d16-7194-1a1c62893726@postgresql.org> <20210613154907.GZ16435@telsasoft.com> In-Reply-To: <20210613154907.GZ16435@telsasoft.com> --Ng9YiMPCSaOoEgD5vKAXjcrNVEjBaQwYJ Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 6/13/21 11:49 AM, Justin Pryzby wrote: > On Sun, Jun 13, 2021 at 11:25:05AM -0400, Jonathan S. Katz wrote: >> On 6/13/21 10:57 AM, Zhihong Yu wrote: >>> +/* Turn multirange into a set of ranges */ >>> >>> set of ranges: sequence of ranges >> >> I believe "set of ranges" is accurate here, as the comparable return i= s >> a "SETOF rangetype". Sequences are objects unto themselves. >> >=20 > I believe the point was that (in mathematics) a "set" is unordered, and= a > sequence is ordered. Also, a "setof" tuples in postgres can contain > duplicates. The comment in question is part of the header for the "multirange_unnest" function in the code and AFAICT it is accurate: it is returning a "set of" ranges as it's literally calling into the set-returning function framework. I would suggest leaving it as is. > The docs say "The ranges are read out in storage order (ascending).", s= o I > think this is just a confusion between what "set" means in math vs in p= ostgres. This is nearly identical to the language in the array unnest[1] function, which is what I believed Alexander borrowed from: "Expands an array into a set of rows. The array's elements are read out in storage order." If we tweaked the multirange "unnest" function, we could change it to: + + Expands a multirange into a set of rows. + The ranges are read out in storage order (ascending). + to match what the array "unnest" function docs, or + + Expands a multirange into a set of rows that each + contain an individual range. + The ranges are read out in storage order (ascending). + to be a bit more specific. However, I think this is also bordering on overengineering the text, given there has been a lack of feedback on the "unnest" array function description being confusing. Thanks, Jonathan [1] https://www.postgresql.org/docs/current/functions-array.html --Ng9YiMPCSaOoEgD5vKAXjcrNVEjBaQwYJ-- --WyTZtoJzRZ6lvvMjtT7Qhk7kYf3F2fg3A 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/x8QSccp8cZScFAmDGUowFAwAAAAAACgkQ8QSccp8cZSel NhAAohD3TkVOc23t7QWnboY/5AtRtj9ebVKIvN7oZnUPsPjHC3Vevt4WemnpS7YEuHbyui+DVCer 2NcixcqhH6mESbH8rBwpYNRpNPOPcbXXeV+1+x9obrj+pJexd903Tm10kRx91wq57LcSMdvknNBg qb0ppIim7OWpgWXRAegLdomu0h69lSQnapsriQQE4l598iohNgtZOJpjT1eFAOQl1JZQrmpqUltH UlIN+0v9x4NU+hSGGE1Za87gnSEVzYz6AXTVgeUzSIp60OAyjBYk2sqUr5gefn77FRepKvWnlPNy vTYSUH2sH2jKL/94ox+cwFoDAEBSFDOk9sf+WzGnf6uZ3JSEnoldrZ4ONZuLCImXNvrN0vJ5/P74 X6uoZRHzmAh70M6QBna5NhdmXe626gNVBV5LCZbmFMO3NqboiOaKP2EyQcZlFb6vOFW6yR8cMDtz q0rVTevq+RlNQLBkvbp184gA7HYK/jYmRfLUJ6QpuHITcJOySH+HPg1kuNGkgv2nKcTJLIyQRSju biXMgfMmpV2WFbtgYjuCZjmvchlflqdzNSVei2RJHuIFxjatUEWD1iTRue+RkrDAvOD3+WJdwGNR FZbRxk/gKK6hkMDIv+c7914HWJZKKDFAXCeKKzdh9Rntj3fTNPtxNpFhccW9/l5F4dLG+TDvq4Km hPI= =UArs -----END PGP SIGNATURE----- --WyTZtoJzRZ6lvvMjtT7Qhk7kYf3F2fg3A--