Re: Range type bounds - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Range type bounds
Date
Msg-id 5476340C.5080306@aklaver.com
Whole thread Raw
In response to Re: Range type bounds  (David G Johnston <david.g.johnston@gmail.com>)
Responses Re: Range type bounds
List pgsql-general
On 11/26/2014 11:07 AM, David G Johnston wrote:
> Adrian Klaver-4 wrote
>> 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.
>
> Would it be sufficient to simply add another paragraph:
>
> "The lower-bound may be either a string that is valid input for the subtype,
> or NULL to indicate no lower bound. Likewise, upper-bound may be either a
> string that is valid input for the subtype, or NULL to indicate no upper
> bound."

Except that does not work in the text mode:( :

test=> select '[2014-11-01, NULL)'::daterange;
ERROR:  invalid input syntax for type date: " NULL"
LINE 1: select '[2014-11-01, NULL)'::daterange;


test=> select '[2014-11-01, "NULL")'::daterange;
ERROR:  invalid input syntax for type date: " NULL"
LINE 1: select '[2014-11-01, "NULL")'::daterange;

While testing the above I also got this:

test=> select '[2014-11-01, )'::daterange;
ERROR:  invalid input syntax for type date: " "
LINE 1: select '[2014-11-01, )'::daterange;

while:

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

worked. Seems there is a specific meaning to empty.


>
> ?
>
> @ 8.17.6. Constructing Ranges
>
> I'm not particularly enamored with the title since "Range Input" is a means
> of "Constructing [a] Range"...incorporating the word function into that
> would seem warranted.
>
> How about: 8.17.6 Functional Range Construction ?
>
> For 8.17.5 The concept of "Input/Output" implies that we are dealing with
> string-like literals and while not something an absolute beginner might pick
> up on is likely sufficient and thus omitting the word "Literal" is OK by me.

I guess what is confusing to me is the transition between the text mode
and the constructor mode is not clear. In particular the page starts
with examples using the constructor mode but then goes to explanations
that actually apply to the text mode before getting back to explaining
the constructor mode. I eventually figured it out. I just thought it
might make it easier for others to make the distinction clearer.

>
> All that said it is taken for granted that you cannot have an empty function
> argument so ('val',) is invalid on its face.  The question becomes whether
> you should use ('val','') or ('val',NULL).  The only place that is answered
> is a single example.  It should be in the body of the text too.

Well I spend my time in Python for the most part so:

def test_fnc(a, b=None):
     print a, b

In [12]: test_fnc('a',)
a None

I will have to plead ignorance on C.

>
> David J.
>
>
>
> --
> View this message in context: http://postgresql.nabble.com/Range-type-bounds-tp5828396p5828402.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: "Doiron, Daniel"
Date:
Subject: Re: [ADMIN] Active/Active clustering in postgres
Next
From: David Johnston
Date:
Subject: Re: Range type bounds