Search Postgresql Archives

8.2/8.3 incompatibility

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux