Re: Why is NULL = unbounded for rangetypes?

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Andreas Joseph Krogh <andreak(at)officenet(dot)no>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Why is NULL = unbounded for rangetypes?
Date: 2013-07-08 17:16:15
Message-ID: 1373303775.30779.3.camel@jdavis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2013-07-08 at 10:19 +0200, Andreas Joseph Krogh wrote:
> Hi.
>
> Both of these queries return TRUE because NULL means "unmounded":
> select daterange('2013-07-01' :: DATE, null, '[]') && daterange('2013-07-04' :: DATE, '2013-07-30' :: DATE, '[]');
> select daterange(null, '2013-08-11' :: DATE, '[]') && daterange('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?

Regards,
Jeff Davis

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Van Dyk 2013-07-08 17:26:19 domains, case statements, functions: bug?
Previous Message hubert depesz lubaczewski 2013-07-08 14:45:19 Re: Longest Common Subsequence in Postgres - Algorithm Challenge