Range type bounds

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Range type bounds
Date: 2014-11-26 18:43:58
Message-ID: 54761F6E.6010900@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am trying out the range types:

http://www.postgresql.org/docs/9.3/interactive/rangetypes.html

and got confused by the documentation wording for specifying no lower or
upper bound:

"The lower-bound may be either a string that is valid input for the
subtype, or empty to indicate no lower bound. Likewise, upper-bound may
be either a string that is valid input for the subtype, or empty to
indicate no upper bound."

What I saw was this:

aklaver(at)test=> select daterange('2014-11-01'::date,) ;
ERROR: syntax error at or near ")"
LINE 1: select daterange('2014-11-01'::date,) ;

aklaver(at)test=> select '[2014-11-01,)'::daterange;
daterange
---------------
[2014-11-01,)
(1 row)

aklaver(at)test=> select daterange('2014-11-01'::date, Null) ;
daterange
---------------
[2014-11-01,)
(1 row)

which when I got further into the docs was shown in this example:

8.17.6. Constructing Ranges

-- Using NULL for either bound causes the range to be unbounded on that
side.
SELECT numrange(NULL, 2.2);

I will leave it to philosophers to decide whether NULL is empty, but it
seems the documentation could be more explicit on what constitutes empty
in the text versus constructor method of creating a range.

Thanks,
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dev Kumkar 2014-11-26 18:57:42 Re: Lock Management: Waiting on locks
Previous Message Stephen Frost 2014-11-26 18:37:17 Re: Active/Active clustering in postgres