seq. DEFAULT values and rules

From: salah jubeh <s_jubeh(at)yahoo(dot)com>
To: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: seq. DEFAULT values and rules
Date: 2013-07-03 13:56:26
Message-ID: 1372859786.4232.YahooMailNeo@web122203.mail.ne1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Is this a bug ?,   the new.a_id in my opinion should not be replaced here with nextval () function but with the actual value returned by the sequence. Please have this minimal example .

CREATE TABLE a
(
    a_id serial primary key
);

CREATE TABLE b
(
    b_id serial Primary key
);

CREATE TABLE a_b
(
    a_id INTEGER REFERENCES a (a_id),
    b_id INTEGER REFERENCES b (b_id)
);

INSERT INTO b SELECT n FROM generate_series(1,10) AS n;
CREATE RULE a_a_b_insert AS ON INSERT TO a DO INSERT INTO a_b SELECT new.a_id , b_id FROM b;
 

INSERT INTO a (a_id) VALUES (DEFAULT);

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2013-07-03 14:14:50 Re: seq. DEFAULT values and rules
Previous Message Oleg Bartunov 2013-07-03 13:43:34 Re: Analyzing last run query in psql