Re: Why is NULL = unbounded for rangetypes?
Andreas Joseph Krogh <andreak@officenet.no>
From: Andreas Joseph Krogh <andreak@officenet.no>
To: pgsql-general@postgresql.org
Date: 2013-07-09T08:45:34Z
Lists: pgsql-general
Attachments
- (unnamed) (text/html)
<div>På mandag 08. juli 2013 kl. 19:16:15, skrev Jeff Davis <<a href="mailto:pgsql@j-davis.com" target="_blank">pgsql@j-davis.com</a>>:</div>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="display:inline; font-family: monospace; font-size: 12px;">On Mon, 2013-07-08 at 10:19 +0200, Andreas Joseph Krogh wrote:<br>
> Hi.<br>
> <br>
> Both of these queries return TRUE because NULL means "unmounded":<br>
> select daterange('2013-07-01' :: DATE, null, '[]') && daterange('2013-07-04' :: DATE, '2013-07-30' :: DATE, '[]');<br>
> select daterange(null, '2013-08-11' :: DATE, '[]') && daterange('2013-07-04' :: DATE, '2013-07-30' :: DATE, '[]');<br>
> What is the rational behind this behavior of NULL?<br>
<br>
It's just a convenience that passing NULL to a constructor creates an<br>
unbounded range. The alternatives of having extra constructors for<br>
unbounded ranges were discussed, but seemed more awkward.<br>
<br>
Note that ranges do not allow either bound to be NULL. That would create<br>
a lot of semantic problems.<br>
<br>
Does that answer your question?</div>
</blockquote>
<div> </div>
<div>I would expect the queries above to return FALSE and have to use INFINITY to have them return TRUE. I don't understand what you mean by ranges not allowing either bound to be NULL as it seems to be the case (as in "it works").</div>
<div> </div>
<div class="origo-email-signature">--<br>
Andreas Joseph Krogh <andreak@officenet.no> mob: +47 909 56 963<br>
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no<br>
Public key: http://home.officenet.no/~andreak/public_key.asc</div>
<div> </div>