BUG #5188: Inheritance: bug or feature?

From: "Peter Dobos" <dvc1201(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5188: Inheritance: bug or feature?
Date: 2009-11-15 12:15:45
Message-ID: 200911151215.nAFCFjFL029044@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5188
Logged by: Peter Dobos
Email address: dvc1201(at)gmail(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Brice Maron 2009-11-15 12:36:31 BUG #5189: Postgres Crash when trying to ts_stat a empty tsvector
Previous Message Magnus Hagander 2009-11-15 09:09:14 Re: BUG #5065: pg_ctl start fails as administrator, with "could not locate matching postgres executable"