REFERENCES ignored when there is inheritance? - Mailing list pgsql-general

From Stephane Bortzmeyer
Subject REFERENCES ignored when there is inheritance?
Date
Msg-id 20050513095708.GA4628@generic-nic.net
Whole thread Raw
Responses Re: REFERENCES ignored when there is inheritance?
List pgsql-general
I have a table to store localization information:

CREATE TABLE Localization (
...
 zipcode TEXT NOT NULL,
...
 country INTEGER REFERENCES Countries (id) NOT NULL

The table Countries is like:

CREATE TABLE Countries (
 id SERIAL UNIQUE,
 name TEXT UNIQUE NOT NULL,
 code CHAR(2) UNIQUE NOT NULL);

And a table Contacts_short which inherits from it so all the Contacts
have localization information:

CREATE TABLE Contacts_short (
...
INHERITS (Localization, Objects) WITHOUT OIDS;

I have 240 countries in the database. Because of a programming error,
contacts were entered with a country > 240. I thought that the
"REFERENCES Countries (id)" should have prevented it. Is it because of
inheritance?

PostgreSQL 7.4.7

Example:

registry=> SELECT max(id) FROM Countries;
 max
-----
 240
(1 row)

registry=> SELECT count(*) FROM Contacts_short WHERE country > 240;
 count
-------
    84
(1 row)

To me, the last figure should have been zero.

pgsql-general by date:

Previous
From: "Wolfgang Keller"
Date:
Subject: Re: Please Recommend a Front End App
Next
From: Victor Spång Arthursson
Date:
Subject: How many rows if limit wasn't present?