Skip site navigation (1) Skip section navigation (2)

Inheritance and constraints duplicate values

From: "Marian Lojka" <911(at)inmail(dot)sk>
To: <pgsql-bugs(at)postgresql(dot)org>
Subject: Inheritance and constraints duplicate values
Date: 2004-08-21 11:44:44
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
After doing some research, this is apparently a known long-standing issue
with inheritance in Postgres. Nobody calls it a "bug" outright, though. Just
a limitation. It makes me wonder how others have tackled problems of a
similar nature.

I've since devised a different way
(, but if
you guys have any other suggestions for how you've handled this sort of
thing in PostgreSQL, let me know.

To grossly simplify, here's what I was trying to do. 

CREATE TABLE products (
name varchar(64) NOT NULL,
price numeric(6,2)

waist smallint,
length smallint,
colour varchar(12)
) inherits (products);

CREATE TABLE computers (
 <> cpu varchar(12),
mhz smallint,
) inherits (products);

INSERT INTO pants (name,price,waist,length,colour)
VALUES ('Brand-X Cargo Pants', 49.95, 32, 34, 'khaki');

INSERT INTO computers (name,price,cpu,mhz)
VALUES ('Flower Power iMac', $666.66, '
<> Motorola 750', 500);

SELECT id,name FROM products;

--> 1 Brand-X Cargo Pants
--> 2 Flower Power iMac

INSERT INTO computers (id, name,price,cpu,mhz)
VALUES (1, ' <> Mac Plus',
$5.00, 'Motorola 68000', 8);

SELECT id,name FROM products;

--> 1 Brand-X Cargo Pants
--> 1 Mac Plus
--> 2 Flower Power iMac

Huh? But is a primary key! The "Mac Plus" screwed it up by
inserting duplicate values!



Thanks for all



John Luise


pgsql-bugs by date

Next:From: Thomas WegnerDate: 2004-08-21 13:28:00
Subject: pg_dumpall win32: could not translate host name "" to address: Unknown host
Previous:From: PostgreSQL Bugs ListDate: 2004-08-21 11:14:07
Subject: BUG #1227: authentiation failed via web

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group