what about uniqueness of inherited primary keys

From: Andreas <maps(dot)on(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: what about uniqueness of inherited primary keys
Date: 2003-12-28 20:17:27
Message-ID: 3FEF3A57.4080407@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello list,

what about uniqueness of inherited primary keys ?

eg you have :

create table objects (
id int4,
date_created timestamp(0),
primary key (id)
);

create table persons (
firstname varchar(100),
lastname varchar(100)
) inherits (objects);

now ...

insert into objects (id) values (1);
A repetition of this line would cause an unique-constraint error of
objects_pkey.

insert into persons (id, firstname, lastname) values (1, 'Super', 'Man');
insert into persons (id, firstname, lastname) values (1, 'Bat', 'Man');
works though it violates the inherited constraint.

A select * from objects; shows id=1 three times.

delete * from objects; empties both tables.

after ALTER TABLE public.persons ADD CONSTRAINT persons_pkey PRIMARY
KEY(id);
I can still insert at least one record with id=1 in each table.

select count(*) from objects where id=1;
results 2

Shouldn't we expect to have unique entries in a primary key collumn ?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-12-28 20:41:59 Re: [GENERAL] Strange permission problem regarding pg_settings
Previous Message Joe Conway 2003-12-28 20:11:59 Re: [GENERAL] Strange permission problem regarding pg_settings