|
|
@ -822,12 +822,12 @@ INSERT INTO PKTABLE VALUES(42);
|
|
|
|
-- This next should fail, because int=inet does not exist
|
|
|
|
-- This next should fail, because int=inet does not exist
|
|
|
|
CREATE TABLE FKTABLE (ftest1 inet REFERENCES pktable);
|
|
|
|
CREATE TABLE FKTABLE (ftest1 inet REFERENCES pktable);
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ftest1" and "ptest1" are of incompatible types: inet and integer.
|
|
|
|
DETAIL: Key columns "ftest1" of the referencing table and "ptest1" of the referenced table are of incompatible types: inet and integer.
|
|
|
|
-- This should also fail for the same reason, but here we
|
|
|
|
-- This should also fail for the same reason, but here we
|
|
|
|
-- give the column name
|
|
|
|
-- give the column name
|
|
|
|
CREATE TABLE FKTABLE (ftest1 inet REFERENCES pktable(ptest1));
|
|
|
|
CREATE TABLE FKTABLE (ftest1 inet REFERENCES pktable(ptest1));
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ftest1" and "ptest1" are of incompatible types: inet and integer.
|
|
|
|
DETAIL: Key columns "ftest1" of the referencing table and "ptest1" of the referenced table are of incompatible types: inet and integer.
|
|
|
|
-- This should succeed, even though they are different types,
|
|
|
|
-- This should succeed, even though they are different types,
|
|
|
|
-- because int=int8 exists and is a member of the integer opfamily
|
|
|
|
-- because int=int8 exists and is a member of the integer opfamily
|
|
|
|
CREATE TABLE FKTABLE (ftest1 int8 REFERENCES pktable);
|
|
|
|
CREATE TABLE FKTABLE (ftest1 int8 REFERENCES pktable);
|
|
|
@ -846,7 +846,7 @@ DROP TABLE FKTABLE;
|
|
|
|
-- of the integer opfamily)
|
|
|
|
-- of the integer opfamily)
|
|
|
|
CREATE TABLE FKTABLE (ftest1 numeric REFERENCES pktable);
|
|
|
|
CREATE TABLE FKTABLE (ftest1 numeric REFERENCES pktable);
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ftest1" and "ptest1" are of incompatible types: numeric and integer.
|
|
|
|
DETAIL: Key columns "ftest1" of the referencing table and "ptest1" of the referenced table are of incompatible types: numeric and integer.
|
|
|
|
DROP TABLE PKTABLE;
|
|
|
|
DROP TABLE PKTABLE;
|
|
|
|
-- On the other hand, this should work because int implicitly promotes to
|
|
|
|
-- On the other hand, this should work because int implicitly promotes to
|
|
|
|
-- numeric, and we allow promotion on the FK side
|
|
|
|
-- numeric, and we allow promotion on the FK side
|
|
|
@ -869,23 +869,23 @@ CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, PRIMARY KEY(ptest1, ptest2));
|
|
|
|
-- This should fail, because we just chose really odd types
|
|
|
|
-- This should fail, because we just chose really odd types
|
|
|
|
CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable);
|
|
|
|
CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable);
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ftest1" and "ptest1" are of incompatible types: cidr and integer.
|
|
|
|
DETAIL: Key columns "ftest1" of the referencing table and "ptest1" of the referenced table are of incompatible types: cidr and integer.
|
|
|
|
-- Again, so should this...
|
|
|
|
-- Again, so should this...
|
|
|
|
CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest1, ptest2));
|
|
|
|
CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest1, ptest2));
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ftest1" and "ptest1" are of incompatible types: cidr and integer.
|
|
|
|
DETAIL: Key columns "ftest1" of the referencing table and "ptest1" of the referenced table are of incompatible types: cidr and integer.
|
|
|
|
-- This fails because we mixed up the column ordering
|
|
|
|
-- This fails because we mixed up the column ordering
|
|
|
|
CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable);
|
|
|
|
CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable);
|
|
|
|
ERROR: foreign key constraint "fktable_ftest2_ftest1_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fktable_ftest2_ftest1_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ftest2" and "ptest1" are of incompatible types: inet and integer.
|
|
|
|
DETAIL: Key columns "ftest2" of the referencing table and "ptest1" of the referenced table are of incompatible types: inet and integer.
|
|
|
|
-- As does this...
|
|
|
|
-- As does this...
|
|
|
|
CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable(ptest1, ptest2));
|
|
|
|
CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable(ptest1, ptest2));
|
|
|
|
ERROR: foreign key constraint "fktable_ftest2_ftest1_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fktable_ftest2_ftest1_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ftest2" and "ptest1" are of incompatible types: inet and integer.
|
|
|
|
DETAIL: Key columns "ftest2" of the referencing table and "ptest1" of the referenced table are of incompatible types: inet and integer.
|
|
|
|
-- And again..
|
|
|
|
-- And again..
|
|
|
|
CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest2, ptest1));
|
|
|
|
CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest2, ptest1));
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ftest1" and "ptest2" are of incompatible types: integer and inet.
|
|
|
|
DETAIL: Key columns "ftest1" of the referencing table and "ptest2" of the referenced table are of incompatible types: integer and inet.
|
|
|
|
-- This works...
|
|
|
|
-- This works...
|
|
|
|
CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable(ptest2, ptest1));
|
|
|
|
CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable(ptest2, ptest1));
|
|
|
|
DROP TABLE FKTABLE;
|
|
|
|
DROP TABLE FKTABLE;
|
|
|
@ -906,17 +906,17 @@ DROP TABLE PKTABLE;
|
|
|
|
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest3,
|
|
|
|
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest3,
|
|
|
|
ptest4) REFERENCES pktable(ptest2, ptest1));
|
|
|
|
ptest4) REFERENCES pktable(ptest2, ptest1));
|
|
|
|
ERROR: foreign key constraint "pktable_ptest3_ptest4_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "pktable_ptest3_ptest4_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ptest3" and "ptest2" are of incompatible types: integer and inet.
|
|
|
|
DETAIL: Key columns "ptest3" of the referencing table and "ptest2" of the referenced table are of incompatible types: integer and inet.
|
|
|
|
-- Nor should this... (same reason, we have 4,3 referencing 1,2 which mismatches types
|
|
|
|
-- Nor should this... (same reason, we have 4,3 referencing 1,2 which mismatches types
|
|
|
|
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest4,
|
|
|
|
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest4,
|
|
|
|
ptest3) REFERENCES pktable(ptest1, ptest2));
|
|
|
|
ptest3) REFERENCES pktable(ptest1, ptest2));
|
|
|
|
ERROR: foreign key constraint "pktable_ptest4_ptest3_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "pktable_ptest4_ptest3_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ptest4" and "ptest1" are of incompatible types: inet and integer.
|
|
|
|
DETAIL: Key columns "ptest4" of the referencing table and "ptest1" of the referenced table are of incompatible types: inet and integer.
|
|
|
|
-- Not this one either... Same as the last one except we didn't defined the columns being referenced.
|
|
|
|
-- Not this one either... Same as the last one except we didn't defined the columns being referenced.
|
|
|
|
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest4,
|
|
|
|
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest4,
|
|
|
|
ptest3) REFERENCES pktable);
|
|
|
|
ptest3) REFERENCES pktable);
|
|
|
|
ERROR: foreign key constraint "pktable_ptest4_ptest3_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "pktable_ptest4_ptest3_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ptest4" and "ptest1" are of incompatible types: inet and integer.
|
|
|
|
DETAIL: Key columns "ptest4" of the referencing table and "ptest1" of the referenced table are of incompatible types: inet and integer.
|
|
|
|
--
|
|
|
|
--
|
|
|
|
-- Now some cases with inheritance
|
|
|
|
-- Now some cases with inheritance
|
|
|
|
-- Basic 2 table case: 1 column of matching types.
|
|
|
|
-- Basic 2 table case: 1 column of matching types.
|
|
|
@ -1009,20 +1009,20 @@ create table pktable(ptest1 inet, primary key(base1, ptest1)) inherits (pktable_
|
|
|
|
-- just generally bad types (with and without column references on the referenced table)
|
|
|
|
-- just generally bad types (with and without column references on the referenced table)
|
|
|
|
create table fktable(ftest1 cidr, ftest2 int[], foreign key (ftest1, ftest2) references pktable);
|
|
|
|
create table fktable(ftest1 cidr, ftest2 int[], foreign key (ftest1, ftest2) references pktable);
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ftest1" and "base1" are of incompatible types: cidr and integer.
|
|
|
|
DETAIL: Key columns "ftest1" of the referencing table and "base1" of the referenced table are of incompatible types: cidr and integer.
|
|
|
|
create table fktable(ftest1 cidr, ftest2 int[], foreign key (ftest1, ftest2) references pktable(base1, ptest1));
|
|
|
|
create table fktable(ftest1 cidr, ftest2 int[], foreign key (ftest1, ftest2) references pktable(base1, ptest1));
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ftest1" and "base1" are of incompatible types: cidr and integer.
|
|
|
|
DETAIL: Key columns "ftest1" of the referencing table and "base1" of the referenced table are of incompatible types: cidr and integer.
|
|
|
|
-- let's mix up which columns reference which
|
|
|
|
-- let's mix up which columns reference which
|
|
|
|
create table fktable(ftest1 int, ftest2 inet, foreign key(ftest2, ftest1) references pktable);
|
|
|
|
create table fktable(ftest1 int, ftest2 inet, foreign key(ftest2, ftest1) references pktable);
|
|
|
|
ERROR: foreign key constraint "fktable_ftest2_ftest1_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fktable_ftest2_ftest1_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ftest2" and "base1" are of incompatible types: inet and integer.
|
|
|
|
DETAIL: Key columns "ftest2" of the referencing table and "base1" of the referenced table are of incompatible types: inet and integer.
|
|
|
|
create table fktable(ftest1 int, ftest2 inet, foreign key(ftest2, ftest1) references pktable(base1, ptest1));
|
|
|
|
create table fktable(ftest1 int, ftest2 inet, foreign key(ftest2, ftest1) references pktable(base1, ptest1));
|
|
|
|
ERROR: foreign key constraint "fktable_ftest2_ftest1_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fktable_ftest2_ftest1_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ftest2" and "base1" are of incompatible types: inet and integer.
|
|
|
|
DETAIL: Key columns "ftest2" of the referencing table and "base1" of the referenced table are of incompatible types: inet and integer.
|
|
|
|
create table fktable(ftest1 int, ftest2 inet, foreign key(ftest1, ftest2) references pktable(ptest1, base1));
|
|
|
|
create table fktable(ftest1 int, ftest2 inet, foreign key(ftest1, ftest2) references pktable(ptest1, base1));
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ftest1" and "ptest1" are of incompatible types: integer and inet.
|
|
|
|
DETAIL: Key columns "ftest1" of the referencing table and "ptest1" of the referenced table are of incompatible types: integer and inet.
|
|
|
|
drop table pktable;
|
|
|
|
drop table pktable;
|
|
|
|
drop table pktable_base;
|
|
|
|
drop table pktable_base;
|
|
|
|
-- 2 columns (1 table), mismatched types
|
|
|
|
-- 2 columns (1 table), mismatched types
|
|
|
@ -1030,19 +1030,19 @@ create table pktable_base(base1 int not null, base2 int);
|
|
|
|
create table pktable(ptest1 inet, ptest2 inet[], primary key(base1, ptest1), foreign key(base2, ptest2) references
|
|
|
|
create table pktable(ptest1 inet, ptest2 inet[], primary key(base1, ptest1), foreign key(base2, ptest2) references
|
|
|
|
pktable(base1, ptest1)) inherits (pktable_base);
|
|
|
|
pktable(base1, ptest1)) inherits (pktable_base);
|
|
|
|
ERROR: foreign key constraint "pktable_base2_ptest2_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "pktable_base2_ptest2_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ptest2" and "ptest1" are of incompatible types: inet[] and inet.
|
|
|
|
DETAIL: Key columns "ptest2" of the referencing table and "ptest1" of the referenced table are of incompatible types: inet[] and inet.
|
|
|
|
create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(base2, ptest2) references
|
|
|
|
create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(base2, ptest2) references
|
|
|
|
pktable(ptest1, base1)) inherits (pktable_base);
|
|
|
|
pktable(ptest1, base1)) inherits (pktable_base);
|
|
|
|
ERROR: foreign key constraint "pktable_base2_ptest2_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "pktable_base2_ptest2_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "base2" and "ptest1" are of incompatible types: integer and inet.
|
|
|
|
DETAIL: Key columns "base2" of the referencing table and "ptest1" of the referenced table are of incompatible types: integer and inet.
|
|
|
|
create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(ptest2, base2) references
|
|
|
|
create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(ptest2, base2) references
|
|
|
|
pktable(base1, ptest1)) inherits (pktable_base);
|
|
|
|
pktable(base1, ptest1)) inherits (pktable_base);
|
|
|
|
ERROR: foreign key constraint "pktable_ptest2_base2_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "pktable_ptest2_base2_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ptest2" and "base1" are of incompatible types: inet and integer.
|
|
|
|
DETAIL: Key columns "ptest2" of the referencing table and "base1" of the referenced table are of incompatible types: inet and integer.
|
|
|
|
create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(ptest2, base2) references
|
|
|
|
create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(ptest2, base2) references
|
|
|
|
pktable(base1, ptest1)) inherits (pktable_base);
|
|
|
|
pktable(base1, ptest1)) inherits (pktable_base);
|
|
|
|
ERROR: foreign key constraint "pktable_ptest2_base2_fkey" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "pktable_ptest2_base2_fkey" cannot be implemented
|
|
|
|
DETAIL: Key columns "ptest2" and "base1" are of incompatible types: inet and integer.
|
|
|
|
DETAIL: Key columns "ptest2" of the referencing table and "base1" of the referenced table are of incompatible types: inet and integer.
|
|
|
|
drop table pktable;
|
|
|
|
drop table pktable;
|
|
|
|
ERROR: table "pktable" does not exist
|
|
|
|
ERROR: table "pktable" does not exist
|
|
|
|
drop table pktable_base;
|
|
|
|
drop table pktable_base;
|
|
|
@ -1154,22 +1154,22 @@ CREATE TEMP TABLE fktable (
|
|
|
|
ALTER TABLE fktable ADD CONSTRAINT fk_2_3
|
|
|
|
ALTER TABLE fktable ADD CONSTRAINT fk_2_3
|
|
|
|
FOREIGN KEY (x2) REFERENCES pktable(id3);
|
|
|
|
FOREIGN KEY (x2) REFERENCES pktable(id3);
|
|
|
|
ERROR: foreign key constraint "fk_2_3" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fk_2_3" cannot be implemented
|
|
|
|
DETAIL: Key columns "x2" and "id3" are of incompatible types: character varying and real.
|
|
|
|
DETAIL: Key columns "x2" of the referencing table and "id3" of the referenced table are of incompatible types: character varying and real.
|
|
|
|
-- nor to int4
|
|
|
|
-- nor to int4
|
|
|
|
ALTER TABLE fktable ADD CONSTRAINT fk_2_1
|
|
|
|
ALTER TABLE fktable ADD CONSTRAINT fk_2_1
|
|
|
|
FOREIGN KEY (x2) REFERENCES pktable(id1);
|
|
|
|
FOREIGN KEY (x2) REFERENCES pktable(id1);
|
|
|
|
ERROR: foreign key constraint "fk_2_1" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fk_2_1" cannot be implemented
|
|
|
|
DETAIL: Key columns "x2" and "id1" are of incompatible types: character varying and integer.
|
|
|
|
DETAIL: Key columns "x2" of the referencing table and "id1" of the referenced table are of incompatible types: character varying and integer.
|
|
|
|
-- real does not promote to int4
|
|
|
|
-- real does not promote to int4
|
|
|
|
ALTER TABLE fktable ADD CONSTRAINT fk_3_1
|
|
|
|
ALTER TABLE fktable ADD CONSTRAINT fk_3_1
|
|
|
|
FOREIGN KEY (x3) REFERENCES pktable(id1);
|
|
|
|
FOREIGN KEY (x3) REFERENCES pktable(id1);
|
|
|
|
ERROR: foreign key constraint "fk_3_1" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fk_3_1" cannot be implemented
|
|
|
|
DETAIL: Key columns "x3" and "id1" are of incompatible types: real and integer.
|
|
|
|
DETAIL: Key columns "x3" of the referencing table and "id1" of the referenced table are of incompatible types: real and integer.
|
|
|
|
-- int4 does not promote to text
|
|
|
|
-- int4 does not promote to text
|
|
|
|
ALTER TABLE fktable ADD CONSTRAINT fk_1_2
|
|
|
|
ALTER TABLE fktable ADD CONSTRAINT fk_1_2
|
|
|
|
FOREIGN KEY (x1) REFERENCES pktable(id2);
|
|
|
|
FOREIGN KEY (x1) REFERENCES pktable(id2);
|
|
|
|
ERROR: foreign key constraint "fk_1_2" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fk_1_2" cannot be implemented
|
|
|
|
DETAIL: Key columns "x1" and "id2" are of incompatible types: integer and character varying.
|
|
|
|
DETAIL: Key columns "x1" of the referencing table and "id2" of the referenced table are of incompatible types: integer and character varying.
|
|
|
|
-- should succeed
|
|
|
|
-- should succeed
|
|
|
|
-- int4 promotes to real
|
|
|
|
-- int4 promotes to real
|
|
|
|
ALTER TABLE fktable ADD CONSTRAINT fk_1_3
|
|
|
|
ALTER TABLE fktable ADD CONSTRAINT fk_1_3
|
|
|
@ -1192,11 +1192,11 @@ FOREIGN KEY (x2,x5,x3) REFERENCES pktable(id2,id1,id3);
|
|
|
|
ALTER TABLE fktable ADD CONSTRAINT fk_123_231
|
|
|
|
ALTER TABLE fktable ADD CONSTRAINT fk_123_231
|
|
|
|
FOREIGN KEY (x1,x2,x3) REFERENCES pktable(id2,id3,id1);
|
|
|
|
FOREIGN KEY (x1,x2,x3) REFERENCES pktable(id2,id3,id1);
|
|
|
|
ERROR: foreign key constraint "fk_123_231" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fk_123_231" cannot be implemented
|
|
|
|
DETAIL: Key columns "x1" and "id2" are of incompatible types: integer and character varying.
|
|
|
|
DETAIL: Key columns "x1" of the referencing table and "id2" of the referenced table are of incompatible types: integer and character varying.
|
|
|
|
ALTER TABLE fktable ADD CONSTRAINT fk_241_132
|
|
|
|
ALTER TABLE fktable ADD CONSTRAINT fk_241_132
|
|
|
|
FOREIGN KEY (x2,x4,x1) REFERENCES pktable(id1,id3,id2);
|
|
|
|
FOREIGN KEY (x2,x4,x1) REFERENCES pktable(id1,id3,id2);
|
|
|
|
ERROR: foreign key constraint "fk_241_132" cannot be implemented
|
|
|
|
ERROR: foreign key constraint "fk_241_132" cannot be implemented
|
|
|
|
DETAIL: Key columns "x2" and "id1" are of incompatible types: character varying and integer.
|
|
|
|
DETAIL: Key columns "x2" of the referencing table and "id1" of the referenced table are of incompatible types: character varying and integer.
|
|
|
|
DROP TABLE pktable, fktable;
|
|
|
|
DROP TABLE pktable, fktable;
|
|
|
|
-- test a tricky case: we can elide firing the FK check trigger during
|
|
|
|
-- test a tricky case: we can elide firing the FK check trigger during
|
|
|
|
-- an UPDATE if the UPDATE did not change the foreign key
|
|
|
|
-- an UPDATE if the UPDATE did not change the foreign key
|
|
|
|