Re: Unique Key Violation 7.0 vs. 6.5.3

Поиск
Список
Период
Сортировка
От Tatsuo Ishii
Тема Re: Unique Key Violation 7.0 vs. 6.5.3
Дата
Msg-id 20000407102343X.t-ishii@sra.co.jp
обсуждение исходный текст
Ответ на Unique Key Violation 7.0 vs. 6.5.3  (Brian Hirt <bhirt@mobygames.com>)
Список pgsql-hackers
> In doing some more 7.0 testing, I ran across a difference in functionality
> concerning unique indexes and errors that are reported when you try to 
> violate the index.  I'm not sure if this change is intentional, so I'm 
> bringing it up here.  In 6.5.3, if you try to update a row that violates 
> a unique index, the query fails and said error is reported to the 
> application.  However, in 7.0 the query succeeds, but updates 0 rows.  Hence, 
> no errors are reported back to the application.    This is not normally 
> a problem because I typically check the constrait before updating.  
> 
> 
> in 7.0/beta3
> basement=>  update foobar set unique_colum = '2000-04-09' where foobar_id = 32;
> UPDATE 0
> basement=> 
> 
> in 6.5.3
> basement=> update foobar set unique_colum = '2000-04-09' where foobar_id = 32;
> ERROR:  Cannot insert a duplicate key into a unique index
> basement=> 

I'm not sure how your table looks like, but seems following test with
current (not b3) works here:

test=# create table foobar (unique_column date unique, foobar_id int primary key);
NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'foobar_unique_column_key' for table 'foobar'
NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index 'foobar_pkey' for table 'foobar'
CREATE
test=# insert into foobar values('2000-4-8', 32);
INSERT 2231126 1
test=# insert into foobar values('2000-4-9', 33);
INSERT 2231127 1
test=# update foobar set unique_column = '2000-04-09' where foobar_id = 32;
ERROR:  Cannot insert a duplicate key into unique index foobar_unique_column_key
--
Tatsuo Ishii


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: 7.0 like selectivity
Следующее
От:
Дата:
Сообщение: ...