pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Daniel Fredouille <daniel.fredouille@gmail.com>
Cc: pgsql-docs@lists.postgresql.org
Subject: Re: unnest multirange, returned order
Date: Thu, 05 Oct 2023 08:50:24 +0200
Message-ID: <fd85a22502ce44458bc3ddc616bf352c077e67f4.camel@cybertec.at> (raw)
In-Reply-To: <CAEpV6kWcAVFvmtw9amVubL7F9LWX==nE5N96uFrGm4XX6aFdVQ@mail.gmail.com>
References: <169627213477.3727338.17653654241633692682@wrigleys.postgresql.org>
	<2bad53942920d2e501661af4cd49d6644a22b801.camel@cybertec.at>
	<CAEpV6kX9PJAuQ_=5c7ZxCSASu76hkvGfVvwU6WkHTRXzApknfQ@mail.gmail.com>
	<47e801481db9947c4a597575ad45e1c6304130ca.camel@cybertec.at>
	<CAEpV6kVJc7a3i86G5ifzn9hONxpbgvbP1g_xqidW3fMhTQ54yA@mail.gmail.com>
	<CAEpV6kWcAVFvmtw9amVubL7F9LWX==nE5N96uFrGm4XX6aFdVQ@mail.gmail.com>

On Wed, 2023-10-04 at 20:12 -0400, Daniel Fredouille wrote:
> unnest ( anymultirange ) → setof anyrange
> Expands a multirange into a set of ranges. The ranges are read out in storage order (ascending) and therefore order cannot be relied upon.

That's not true.  The order is deterministic and can be relied on.

How about the attached patch, which does away with the confusing
mention of "storage order"?

Yours,
Laurenz Albe

Attachments:

  [text/x-patch] 0001-Clarify-the-result-order-of-unnest-multirange.patch (1.3K, ../fd85a22502ce44458bc3ddc616bf352c077e67f4.camel@cybertec.at/2-0001-Clarify-the-result-order-of-unnest-multirange.patch)
  download | inline diff:
From e39d1b5760d6fa0ed143c13589f717846cc82574 Mon Sep 17 00:00:00 2001
From: Laurenz Albe <laurenz.albe@cybertec.at>
Date: Thu, 5 Oct 2023 08:48:21 +0200
Subject: [PATCH] Clarify the result order of unnest(multirange)

It is best not to mention the storage order, because that is
an implementation detail and has confused at least one user,
who assumed that the storage order is the order in which the
constituent ranges were written in SQL.

Since the sorting order is explained at the beginning of the
page, it should be sufficient to say that the ranges are
returned in ascending order.

Discussion: https://postgr.es/m/169627213477.3727338.17653654241633692682%40wrigleys.postgresql.org
---
 doc/src/sgml/func.sgml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 24ad87f910..bbb6e878ab 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -20121,7 +20121,7 @@ SELECT NULLIF(value, '(none)') ...
        </para>
        <para>
         Expands a multirange into a set of ranges.
-        The ranges are read out in storage order (ascending).
+        The ranges are read out in ascending order.
        </para>
        <para>
         <literal>unnest('{[1,2), [3,4)}'::int4multirange)</literal>
-- 
2.41.0



view thread (11+ messages)  latest in thread

Message-ID: <fd85a22502ce44458bc3ddc616bf352c077e67f4.camel@cybertec.at>
Permalink:  ../fd85a22502ce44458bc3ddc616bf352c077e67f4.camel@cybertec.at/
Also on:    postgresql.org/message-id/fd85a22502ce44458bc3ddc616bf352c077e67f4.camel@cybertec.at

 ·  · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: laurenz.albe@cybertec.at, daniel.fredouille@gmail.com, pgsql-docs@lists.postgresql.org
  Subject: Re: unnest multirange, returned order
  In-Reply-To: <fd85a22502ce44458bc3ddc616bf352c077e67f4.camel@cybertec.at>

* 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