I've found an incompatibility between PostgreSQL 8.2.4 and 8.3.0 which
is not clearly documented. Here's a short example:
CREATE TABLE t1 (
id CHAR(5) NOT NULL,
PRIMARY KEY (id)
);
INSERT INTO t1 (id) VALUES ('t1id1');
INSERT INTO t1 (id) VALUES ('t1id2');
INSERT INTO t1 (id) VALUES ('t1id3');
CREATE TABLE t2 (
id SERIAL NOT NULL,
t1id VARCHAR(5) NOT NULL,
PRIMARY KEY (id)
);
INSERT INTO t2 (t1id) VALUES ('t1id1');
INSERT INTO t2 (t1id) VALUES ('t1id2');
INSERT INTO t2 (t1id) VALUES ('t1id3');
ALTER TABLE t2
ADD CONSTRAINT t2_t1id_fk
FOREIGN KEY (t1id) REFERENCES t1 (id);
(Note the different column types.)
This works fine in 8.2.4, but 8.3.0 rejects the ALTER TABLE with the
following (somewhat misleading) error message:
ERROR: insert or update on table "t2" violates foreign key constraint "t2_t1id_fk"
DETAIL: Key (t1id)=(t1id1) is not present in table "t1".
Should this be documented explicitly?
Should the error message look different?