BUG #10006: 'DO INSTEAD UPDATE' error

From: lucybird(at)126(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #10006: 'DO INSTEAD UPDATE' error
Date: 2014-04-13 14:57:40
Message-ID: 20140413145740.15386.4908@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 10006
Logged by: lucybird
Email address: lucybird(at)126(dot)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?

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Euler Taveira 2014-04-13 16:04:15 Re: Debug strategy for musl Postgres?
Previous Message John Mudd 2014-04-13 03:40:34 Debug strategy for musl Postgres?