pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Александр <alexander_8901@mail.ru>
To: pgsql-bugs@postgresql.org
Subject: bug in RULE insert
Date: Fri, 09 Dec 2016 15:18:40 +0300
Message-ID: <1481285920.491235434@f66.i.mail.ru> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>



Strange the rule works for an insertion


example:

CREATE TABLE public.test
(
id bigserial NOT NULL,
name text
);

ALTER TABLE public.test
ADD CONSTRAINT test_constraint_pkey PRIMARY KEY(id);

CREATE TABLE public.v_test
(
id bigserial NOT NULL,
v_id bigint,
v_name text
);

ALTER TABLE public.v_test
ADD CONSTRAINT v_test_constraint_pkey PRIMARY KEY(id);

CREATE OR REPLACE RULE insert AS
ON INSERT TO test DO INSERT INTO v_test (v_id, v_name)
VALUES (new.id, new.name);



then execute

insert into test(name)
values 
('1'),
('2'),
('3')

values in test.id <> v_test.v_id
Tested on postgresql 9.5/9.6 install from PPA   http://apt.postgresql.org/pub/repos/apt
OS ubuntu-sever 14.04/16.04
Bbest regards
Alexander Pokolenko.


view thread (2+ messages)  latest in thread

Message-ID: <1481285920.491235434@f66.i.mail.ru>
Permalink:  ../1481285920.491235434@f66.i.mail.ru/
Also on:    postgresql.org/message-id/1481285920.491235434@f66.i.mail.ru

 · 

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: alexander_8901@mail.ru
  Subject: Re: bug in RULE insert
  In-Reply-To: <1481285920.491235434@f66.i.mail.ru>
  References: <1481285920.491235434@f66.i.mail.ru>

* 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