Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iSCos-0005Iy-0y for pgsql-docs@arkaria.postgresql.org; Wed, 06 Nov 2019 04:21:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iSCoq-0007BY-8I for pgsql-docs@arkaria.postgresql.org; Wed, 06 Nov 2019 04:21:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iSCop-0007BQ-UV for pgsql-docs@lists.postgresql.org; Wed, 06 Nov 2019 04:21:20 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iSCoj-0001ZB-FS for pgsql-docs@lists.postgresql.org; Wed, 06 Nov 2019 04:21:18 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1iSCoh-0007T6-1C; Tue, 05 Nov 2019 23:21:11 -0500 Date: Tue, 5 Nov 2019 23:21:11 -0500 From: Bruce Momjian To: Eugen Konkov Cc: Tom Lane , pgsql-docs@lists.postgresql.org Subject: Re: Why 'infinity' is not in range '[2019-01-02, infinity]'? Message-ID: <20191106042111.GC16353@momjian.us> References: <155655432452.1371.6115195379691603427@wrigleys.postgresql.org> <5f6b986b-de4d-8a43-1366-fc8c3aed6319@postgresql.org> <1265663903.20190429212216@yandex.ru> <7991.1556573455@sss.pgh.pa.us> <376945611.20191026161529@yandex.ru> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="1LKvkjL3sHcu1TtY" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <376945611.20191026161529@yandex.ru> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --1LKvkjL3sHcu1TtY Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Sat, Oct 26, 2019 at 04:15:29PM +0300, Eugen Konkov wrote: > Today I got next ambiguous: > > select tstzrange( 'infinity', null ); > tstzrange > ------------- > [infinity,) > (1 row) > > [DOC](https://www.postgresql.org/docs/12/rangetypes.html) stated: > >if the upper bound of the range is omitted, then all points greater than the lower bound are included in the range. > >This is equivalent to considering that the upper bound is “plus infinity”, respectively. > > Thus I can write, can not? > > select tstzrange( 'infinity', 'infinity' ); > tstzrange > ------------- > empty > (1 row) Well, that makes sense since your start/stop are the same, and there are no values greater than the infinity you specified. > But thus it is not not equivalent. > > > >But note that these infinite values are never values of the range's element type, and can never be part of the range > Thus if 'infinite values are never values of the range' then > > “infinity” can not be just another value of any range type > This conclusion contradicts next doc paragraph: > >Also, some element types have a notion of “infinity”, but that is just another value so far as the range type mechanisms are concerned. > > errr... mechanism of date ranges violates basic rules for 'Infinite > (Unbounded) Ranges'? Uh, yeah, those paragraphs need help. You are right that the concept of infinity in ranges is differnt than the range element type's possible values of infinity, if it supports it, and the docs are unclear on that. I have made an attempt at rewriting the paragraphs to clarify the missing-boundry infinity from the possible range element type's infinity, and I think I romoved the contradition, and clarified the description. Patch attached. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription + --1LKvkjL3sHcu1TtY Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="range.diff" diff --git a/doc/src/sgml/rangetypes.sgml b/doc/src/sgml/rangetypes.sgml new file mode 100644 index 3a034d9..c1c210e *** a/doc/src/sgml/rangetypes.sgml --- b/doc/src/sgml/rangetypes.sgml *************** SELECT isempty(numrange(1, 5)); *** 131,159 **** Infinite (Unbounded) Ranges ! The lower bound of a range can be omitted, meaning that all points less ! than the upper bound are included in the range. Likewise, if the upper ! bound of the range is omitted, then all points greater than the lower bound ! are included in the range. If both lower and upper bounds are omitted, all ! values of the element type are considered to be in the range. ! ! ! ! This is equivalent to considering that the lower bound is minus ! infinity, or the upper bound is plus infinity, ! respectively. But note that these infinite values are never values of ! the range's element type, and can never be part of the range. (So there ! is no such thing as an inclusive infinite bound — if you try to ! write one, it will automatically be converted to an exclusive bound.) ! Also, some element types have a notion of infinity, but that ! is just another value so far as the range type mechanisms are concerned. ! For example, in timestamp ranges, [today,] means the same ! thing as [today,). But [today,infinity] means ! something different from [today,infinity) — the latter ! excludes the special timestamp value infinity. --- 131,156 ---- Infinite (Unbounded) Ranges ! The lower bound of a range can be omitted, meaning that all ! values less than the upper bound are included in the range, e.g., ! (,3]. Likewise, if the upper bound of the ! range is omitted, then all values greater than the lower bound are ! included in the range. If both lower and upper bounds are omitted, ! all values of the element type are considered to be in the range. ! Specifying a missing bound as exclusive is automatically converted ! to inclusive, e.g., [,] is automatically converted ! to (,). You can think of these missing values as ! +/-infinity, but they are special range type values and are considerd ! to be beyond any range element type's +/-infinity values. ! Element types that have a notion of infinity ! can use it as explicit bound values. For example, for timestamp ! ranges, [today,infinity) excludes the special ! timestamp value infinity, while ! [today,), [today,], and ! [today,infinity] include it. --1LKvkjL3sHcu1TtY--