PostgreSQLのバグ?
バグか?これ
create table t3 (id integer not null primary key,name varchar(255) null);
insert into t3 select 1,null;
insert into t3 select 2,'aaa';
insert into t3 select 3,'';
1個目のnameはnull、2個目はaaa、3個目は''(空文字)
でselect
test=# select * from t3;
id | name
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
1 |
3 |
2 | aaa
(3 rows)
test=# select * from t3 where name is null;
id | name
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
1 |
(1 row)
test=# select * from t3 where name is not null;
id | name
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
3 |
2 | aaa
(2 rows)
test=# select * from t3 where name = '';
id | name
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
3 |
(1 row)
test=# select * from t3 where name != '';
id | name
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
2 | aaa
(1 row)
最後のselectおかしくないか?
name is not nullの時の挙動考えると空文字以外とってくるはずなのに
id=2のデータしか取ってこない
この最後のselect間違ってないならselect * from t3 where name = '';のときにid=1のデータ取ってこないとおかしくない?
なんだこれ・・・
ちなみにバージョンはPostgreSQL 8.2.0 on i386-unknown-freebsd6.1,