pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: lucybird@126.com
To: pgsql-bugs@postgresql.org
Subject: BUG #10006: 'DO INSTEAD UPDATE' error
Date: Sun, 13 Apr 2014 14:57:40 +0000
Message-ID: <20140413145740.15386.4908@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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?



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)  latest in thread

Message-ID: <20140413145740.15386.4908@wrigleys.postgresql.org>
Permalink:  ../20140413145740.15386.4908@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20140413145740.15386.4908@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: lucybird@126.com
  Subject: Re: BUG #10006: 'DO INSTEAD UPDATE' error
  In-Reply-To: <20140413145740.15386.4908@wrigleys.postgresql.org>
  References: <20140413145740.15386.4908@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox