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?