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 <br...@momjian.us> 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 +
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 **** <title>Infinite (Unbounded) Ranges</title> <para> ! 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. ! </para> ! ! <para> ! This is equivalent to considering that the lower bound is <quote>minus ! infinity</quote>, or the upper bound is <quote>plus infinity</quote>, ! 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.) </para> <para> ! Also, some element types have a notion of <quote>infinity</quote>, but that ! is just another value so far as the range type mechanisms are concerned. ! For example, in timestamp ranges, <literal>[today,]</literal> means the same ! thing as <literal>[today,)</literal>. But <literal>[today,infinity]</literal> means ! something different from <literal>[today,infinity)</literal> — the latter ! excludes the special <type>timestamp</type> value <literal>infinity</literal>. </para> <para> --- 131,156 ---- <title>Infinite (Unbounded) Ranges</title> <para> ! 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., ! <literal>(,3]</literal>. 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., <literal>[,]</literal> is automatically converted ! to <literal>(,)</literal>. 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. </para> <para> ! Element types that have a notion of <quote>infinity</quote> ! can use it as explicit bound values. For example, for timestamp ! ranges, <literal>[today,infinity)</literal> excludes the special ! <type>timestamp</type> value <literal>infinity</literal>, while ! <literal>[today,)</literal>, <literal>[today,]</literal>, and ! <literal>[today,infinity]</literal> include it. </para> <para>