Thread: Unable to create an inheritad table with primary key containing inherited attribute

Unable to create an inheritad table with primary key containing inherited attribute

From
pgsql-bugs@postgresql.org
Date:
Pascal Bourgeois (pbourgeois@atos.be) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
Unable to create an inheritad  table with primary key containing inherited attribute

Long Description
If u create a table basetable having two attributes
mkey and mvalue then create a inherited table subtable (adding mykey2 and mvalue2 attributes) with primary key
containingattributes mkey and mkey2, postgres returns an error indicating that attribute mkey is not known. 

The only way to do is to create a unique index after table creation.

Sample Code
create table basetable (mykey varchar, myvalue int4, primary key (mykey));

create table subtable (mykey2 varchar, myvalue2, int4, primary key (mykey, mykey2)) inherits (basetable);

postgres will return that mykey attribute does not exists

end you have to do

create unique index subtable_pkey on subtable(mykey,mykey2);

No file was uploaded with this report