The following bug has been logged online: Bug reference: 5188 Logged by: Peter Dobos Email address: dvc1...@gmail.com PostgreSQL version: 8.3.8 Operating system: Win XP Description: Inheritance: bug or feature? Details:
Hi, I'm not sure that inherited table records are 'real' records in the ancestor table. Table definitions: CREATE TABLE table1 ( tbl1_id integer NOT NULL, CONSTRAINT pk_table1 PRIMARY KEY (tbl1_id) ) WITH ( OIDS=FALSE ); ALTER TABLE table1 OWNER TO postgres; GRANT ALL ON TABLE table1 TO postgres; GRANT ALL ON TABLE table1 TO public; -- Table: table1x -- DROP TABLE table1x; CREATE TABLE table1x ( -- Inherited from table table1x: tbl1_id integer NOT NULL, CONSTRAINT pk_table1x PRIMARY KEY (tbl1_id) ) INHERITS (table1) WITH ( OIDS=FALSE ); ALTER TABLE table1x OWNER TO postgres; GRANT ALL ON TABLE table1x TO postgres; GRANT ALL ON TABLE table1x TO public; -- Table: table2 -- DROP TABLE table2; CREATE TABLE table2 ( tbl1_id integer, CONSTRAINT fk_table1_of_table2 FOREIGN KEY (tbl1_id) REFERENCES table1 (tbl1_id) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT ) WITH ( OIDS=TRUE ); ALTER TABLE table2 OWNER TO postgres; GRANT ALL ON TABLE table2 TO postgres; GRANT ALL ON TABLE table2 TO public; insert into table1x (tbl1_id) values (1); select * from table1; You can see a record in table1 where tbl1_id=1 insert into table2 (tbl1_id) values (1); ********** Error ********** ERROR: insert or update on table "table2" violates foreign key constraint "fk_table1_of_table2" SQL state: 23503 Detail: Key (tbl1_id)=(1) is not present in table "table1". I can't use a table1x record as a table1 record. Best regards, Peter Dobos -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs