BUG #10006: 'DO INSTEAD UPDATE' error

Поиск
Список
Период
Сортировка
От lucybird@126.com
Тема BUG #10006: 'DO INSTEAD UPDATE' error
Дата
Msg-id 20140413145740.15386.4908@wrigleys.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #10006: 'DO INSTEAD UPDATE' error  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      10006
Logged by:          lucybird
Email address:      lucybird@126.com
PostgreSQL version: 9.1.13
Operating system:   ubuntu 12.04 server
Description:

CREATE TABLE dns (
    customer_id integer NOT NULL,
    hits integer,
        primary key (customer_id)
);

CREATE RULE replace_dns AS
    ON INSERT TO dns
    WHERE EXISTS (SELECT 1 FROM dns WHERE dns.customer_id =
new.customer_id)
    DO INSTEAD UPDATE dns
        SET hits = hits + 1
        WHERE  dns.customer_id = new.customer_id;

insert into dns (customer_id, hits) values (1,0);

select * from dns;

customer_id,hits
1,    1

why? hits value must be 0, why 1?

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

Предыдущее
От: kona ajay
Дата:
Сообщение: cant insert into a post gre sql table...Can u please help in fixing this
Следующее
От: John R Pierce
Дата:
Сообщение: Re: Fwd: cant insert into a post gre sql table...Can u please help in fixing this