pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jonathan S. Katz <jkatz@postgresql.org>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: Zhihong Yu <zyu@yugabyte.com>
Cc: Alexander Korotkov <aekorotkov@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: unnesting multirange data types
Date: Sun, 13 Jun 2021 14:46:36 -0400
Message-ID: <11f691df-ce18-c32a-438b-979338d5ea1b@postgresql.org> (raw)
In-Reply-To: <20210613154907.GZ16435@telsasoft.com>
References: <CAPpHfds8F7Oh2H5jGQ5+K1A8DjjxmSx-1VJ1F1VVyAP_eazPvQ@mail.gmail.com>
	<20210610220416.GJ16435@telsasoft.com>
	<CAPpHfdufDWMVX5xjOv8LV-s0e4=QUt2P+Gksb8cWi6yjtEZPgA@mail.gmail.com>
	<20210611233017.GO16435@telsasoft.com>
	<CAPpHfdsrAZoJm08wi5k76Gd3FEAa3HprFJG-TzSoC3UHfEQ=QQ@mail.gmail.com>
	<CAPpHfdtwVh4b-7vnjg0fV6AR0tPX6hUVgQY0CPG--j78_7uVDA@mail.gmail.com>
	<3648e50c-eb0d-4d16-7194-1a1c62893726@postgresql.org>
	<CAPpHfdsbQPb6OVpW_XSFfR8fAOCXaaOX+1WrXEZXHUDXp7i4uw@mail.gmail.com>
	<CALNJ-vTFcG=jen6gf1XZYnOSVVHpBys2R_X-q_4bu4siYUzUdg@mail.gmail.com>
	<e60c3955-7fde-8007-e0d4-685776150a91@postgresql.org>
	<20210613154907.GZ16435@telsasoft.com>

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 is
>> a "SETOF rangetype". Sequences are objects unto themselves.
>>
> 
> 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).", so I
> think this is just a confusion between what "set" means in math vs in postgres.

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:

+       <para>
+        Expands a multirange into a set of rows.
+        The ranges are read out in storage order (ascending).
+       </para>

to match what the array "unnest" function docs, or

+       <para>
+        Expands a multirange into a set of rows that each
+        contain an individual range.
+        The ranges are read out in storage order (ascending).
+       </para>

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

Attachments:

  OpenPGP_signature (application/pgp-signature, 839B) download

view thread (66+ messages)  latest in thread

Message-ID: <11f691df-ce18-c32a-438b-979338d5ea1b@postgresql.org>
Permalink:  ../11f691df-ce18-c32a-438b-979338d5ea1b@postgresql.org/
Also on:    postgresql.org/message-id/11f691df-ce18-c32a-438b-979338d5ea1b@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: jkatz@postgresql.org, pryzby@telsasoft.com, zyu@yugabyte.com, aekorotkov@gmail.com, alvherre@alvh.no-ip.org, tgl@sss.pgh.pa.us
  Subject: Re: unnesting multirange data types
  In-Reply-To: <11f691df-ce18-c32a-438b-979338d5ea1b@postgresql.org>
  References: <CAPpHfds8F7Oh2H5jGQ5+K1A8DjjxmSx-1VJ1F1VVyAP_eazPvQ@mail.gmail.com> <20210610220416.GJ16435@telsasoft.com> <CAPpHfdufDWMVX5xjOv8LV-s0e4=QUt2P+Gksb8cWi6yjtEZPgA@mail.gmail.com> <20210611233017.GO16435@telsasoft.com> <CAPpHfdsrAZoJm08wi5k76Gd3FEAa3HprFJG-TzSoC3UHfEQ=QQ@mail.gmail.com> <CAPpHfdtwVh4b-7vnjg0fV6AR0tPX6hUVgQY0CPG--j78_7uVDA@mail.gmail.com> <3648e50c-eb0d-4d16-7194-1a1c62893726@postgresql.org> <CAPpHfdsbQPb6OVpW_XSFfR8fAOCXaaOX+1WrXEZXHUDXp7i4uw@mail.gmail.com> <CALNJ-vTFcG=jen6gf1XZYnOSVVHpBys2R_X-q_4bu4siYUzUdg@mail.gmail.com> <e60c3955-7fde-8007-e0d4-685776150a91@postgresql.org> <20210613154907.GZ16435@telsasoft.com> <11f691df-ce18-c32a-438b-979338d5ea1b@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox