Re: Odd behavior with NULL value

From: Phill Kenoyer <pgsql(at)c0de(dot)net>
To: "Bob Smith, Hammett & Edison, Inc(dot)" <bsmith(at)h-e(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Odd behavior with NULL value
Date: 2001-12-21 01:22:35
Message-ID: 20011221012235.GW19766@c0de.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I think that this page will explain it all:
http://www.postgresql.org/idocs/index.php?functions-comparison.html

|On 011220 17:05
|Bob Smith, Hammett & Edison, Inc. (bsmith(at)h-e(dot)com) wrote the following...
|
|See example below of using NULL values with type DATE. It behaves
|strangely in expressions, "(x <> null)" gives an entirely different
|result than "not(x = null)". Is this intended behavior, if so, why?
|If not, is this a bug?
|
|On a related note, does anyone know if 'current' works with DATE? With
|TIMESTAMP it always evaluates to the time as of the retrieval of the
|value, not as of the insertion, but for DATE it looks like it gets
|evaluated at insertion (I can't tell for sure from my test db for another
|8 hours or so, I could just roll the date forward on the server, but I'd
|like to keep my job...)
|
|Thanks to anyone who can shed some light on this!
|
|rsj=> \d test
| Table "test"
| Attribute | Type | Modifier
|-----------+---------+----------
| key | integer |
| date | date |
|
|rsj=> select * from test;
| key | date
|-----+------------
| 1 | 2001-12-20
| 2 | 2001-12-20
| 3 |
|(3 rows)
|
|rsj=> select * from test where date = null;
| key | date
|-----+------
| 3 |
|(1 row)
|
|rsj=> select * from test where date <> null;
| key | date
|-----+------
|(0 rows)
|
|rsj=> select * from test where not(date = null);
| key | date
|-----+------------
| 1 | 2001-12-20
| 2 | 2001-12-20
|(2 rows)
--
Reason: Typo in the code
_ | _
(_()(|('.|)('||.|()|`|(

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2001-12-21 02:55:18 Re: Odd behavior with NULL value
Previous Message Bruno Wolff III 2001-12-21 01:09:35 Re: Odd behavior with NULL value