Re: Why is NULL = unbounded for rangetypes? - Mailing list pgsql-general

From Andreas Joseph Krogh
Subject Re: Why is NULL = unbounded for rangetypes?
Date
Msg-id OrigoEmail.bf5.ac6ff6ffeb116aec.13fc29939e0@prod2
Whole thread Raw
In response to Re: Why is NULL = unbounded for rangetypes?  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: Why is NULL = unbounded for rangetypes?
List pgsql-general
P=C3=A5 mandag 08. juli 2013 kl. 19:16:15, skrev Jeff Davis <<a hre=
f=3D"mailto:pgsql@j-davis.com" target=3D"_blank">pgsql@j-davis.com>:=


<blockquote style=3D"border-left: 1px solid rgb(204, 204, 204); margin: 0pt=
 0pt 0pt 0.8ex; padding-left: 1ex;">
On =
Mon, 2013-07-08 at 10:19 +0200, Andreas Joseph Krogh wrote:
> Hi.
>=C2=A0
> Both of these queries return TRUE because NULL means "unmounded&q=
uot;:
> select daterange('2013-07-01' :: DATE, null, '[]') && daterang=
e('2013-07-04' :: DATE, '2013-07-30' :: DATE, '[]');
> select daterange(null, '2013-08-11' :: DATE, '[]') && daterang=
e('2013-07-04' :: DATE, '2013-07-30' :: DATE, '[]');
> What is the rational behind this behavior of NULL?

It's just a convenience that passing NULL to a constructor creates an
unbounded range. The alternatives of having extra constructors for
unbounded ranges were discussed, but seemed more awkward.

Note that ranges do not allow either bound to be NULL. That would create
a lot of semantic problems.

Does that answer your question?


=C2=A0

I would expect the queries above to return FALSE and have to use INFIN=
ITY to have them return TRUE. I don't understand what you mean by ranges no=
t allowing either bound to be NULL as it seems to be the case (as in "=
it works").

=C2=A0

--
Andreas Joseph Krogh <andreak@officenet.no>=C2=A0 =C2=A0 =C2=A0 mob: =
+47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc

=C2=A0=

pgsql-general by date:

Previous
From: Misa Simic
Date:
Subject: Re: Longest Common Subsequence in Postgres - Algorithm Challenge
Next
From: itishree sukla
Date:
Subject: Support for Foreign keys with arrays