| From: | pgsql-bugs(at)postgresql(dot)org |
|---|---|
| To: | pgsql-bugs(at)postgresql(dot)org |
| Subject: | Bug #765: 'IS NULL' versus '= NULL' |
| Date: | 2002-09-14 08:43:15 |
| Message-ID: | 20020914084315.2DD8A4758C9@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Bhuvan A (bhuvansql(at)myrealbox(dot)com) reports a bug with a severity of 3
The lower the number the more severe it is.
Short Description
'IS NULL' versus '= NULL'
Long Description
I am using postgresql 7.2.1. I suppose NULL keyword refers nullity (null values) in general.
'IS NULL' and '= NULL' behaves differently in where conditions in SELECT sql, but behaves as expected in UPDATE sql. Consider this case.
> select count(*) from my_table where id is NULL;
count
-------
0
(1 row)
> select count(*) from my_table where id = NULL;
count
-------
0
(1 row)
> select count(*) from my_table where id in (NULL);
count
-------
0
(1 row)
> update my_table set id = NULL where id = 12;
UPDATE 1
> select count(*) from my_table where id is NULL;
count
-------
1
(1 row)
> select count(*) from my_table where id = NULL;
count
-------
0
(1 row)
> select count(*) from my_table where id in (NULL);
count
-------
0
(1 row)
Eventhough my_table contain a record with id as null, the last 2 sqls are not resulting that record. Why? Maybe my understanding would be wrong on this behaviour, if so please kindly apologize and give some description on this difference, since i dont have answer in the documentation.
TIA.
regards,
bhuvaneswaran
Sample Code
No file was uploaded with this report
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Vladimir Dozen | 2002-09-14 08:43:42 | performance degradation while doing repeatative updates |
| Previous Message | Rod Taylor | 2002-09-13 14:39:50 | Re: No dependency between fkey constraint and unique index |