check contraints incorrectly reject "null"

Поиск
Список
Период
Сортировка
От Don Baccus
Тема check contraints incorrectly reject "null"
Дата
Msg-id 3.0.1.32.19991209080050.00e553f0@mail.pacifier.com
обсуждение исходный текст
Ответы Re: [HACKERS] check contraints incorrectly reject "null"  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Given a table definition like:

create table foo (i integer check (i > 0));

I noticed the following works in Oracle but fails in Postgres:

insert into foo values(null);

I was curious about what the standard might say, and had been
meaning to buy Date's book for some time, so broke down and
did so.

According to Date, a check contraint should fail if the expression
evaluates to false.  It appears that Postgres only passes the
check constraint if it evaluates to true.  In three-valued logic,
these statements aren't equivalent.  He has a paragraph about
nulls and check contraints in chapter 14, I believe, and his
explanation makes it clear that Oracle is right, Postgres wrong.

It's easy to fix by adding a check for null to the constraint,
and afterwards the SQL still works with Oracle, but it's still
a bug...



- Don Baccus, Portland OR <dhogaza@pacifier.com> Nature photos, on-line guides, Pacific Northwest Rare Bird Alert
Serviceand other goodies at http://donb.photo.net.
 


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Don Baccus
Дата:
Сообщение: alter table crashes back end
Следующее
От: Don Baccus
Дата:
Сообщение: Re: PostgreSQL front ends (was Re: [HACKERS] Parallel regress tests (was Re: FOREIGN KEY andshift/reduce))