Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WZkoh-000396-0I for pgsql-bugs@arkaria.postgresql.org; Mon, 14 Apr 2014 17:37:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WZkog-0006Rf-AW for pgsql-bugs@arkaria.postgresql.org; Mon, 14 Apr 2014 17:37:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WZLrJ-0005VD-Fq for pgsql-bugs@postgresql.org; Sun, 13 Apr 2014 14:58:13 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WZLrC-00026s-54 for pgsql-bugs@postgresql.org; Sun, 13 Apr 2014 14:58:13 +0000 MIME-Version: 1.0 Subject: BUG #10006: 'DO INSTEAD UPDATE' error To: pgsql-bugs@postgresql.org From: lucybird@126.com Date: Sun, 13 Apr 2014 14:57:40 +0000 Message-ID: <20140413145740.15386.4908@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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