@@ -822,12 +822,12 @@ INSERT INTO PKTABLE VALUES(42);
822
822
-- This next should fail, because int=inet does not exist
823
823
CREATE TABLE FKTABLE (ftest1 inet REFERENCES pktable);
824
824
ERROR: foreign key constraint "fktable_ftest1_fkey" cannot be implemented
825
- DETAIL: Key columns "ftest1" and "ptest1" are of incompatible types: inet and integer.
825
+ DETAIL: Key columns "ftest1" of the referencing table and "ptest1" of the referenced table are of incompatible types: inet and integer.
826
826
-- This should also fail for the same reason, but here we
827
827
-- give the column name
828
828
CREATE TABLE FKTABLE (ftest1 inet REFERENCES pktable(ptest1));
829
829
ERROR: foreign key constraint "fktable_ftest1_fkey" cannot be implemented
830
- DETAIL: Key columns "ftest1" and "ptest1" are of incompatible types: inet and integer.
830
+ DETAIL: Key columns "ftest1" of the referencing table and "ptest1" of the referenced table are of incompatible types: inet and integer.
831
831
-- This should succeed, even though they are different types,
832
832
-- because int=int8 exists and is a member of the integer opfamily
833
833
CREATE TABLE FKTABLE (ftest1 int8 REFERENCES pktable);
@@ -846,7 +846,7 @@ DROP TABLE FKTABLE;
846
846
-- of the integer opfamily)
847
847
CREATE TABLE FKTABLE (ftest1 numeric REFERENCES pktable);
848
848
ERROR: foreign key constraint "fktable_ftest1_fkey" cannot be implemented
849
- DETAIL: Key columns "ftest1" and "ptest1" are of incompatible types: numeric and integer.
849
+ DETAIL: Key columns "ftest1" of the referencing table and "ptest1" of the referenced table are of incompatible types: numeric and integer.
850
850
DROP TABLE PKTABLE;
851
851
-- On the other hand, this should work because int implicitly promotes to
852
852
-- numeric, and we allow promotion on the FK side
@@ -869,23 +869,23 @@ CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, PRIMARY KEY(ptest1, ptest2));
869
869
-- This should fail, because we just chose really odd types
870
870
CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable);
871
871
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
872
- DETAIL: Key columns "ftest1" and "ptest1" are of incompatible types: cidr and integer.
872
+ DETAIL: Key columns "ftest1" of the referencing table and "ptest1" of the referenced table are of incompatible types: cidr and integer.
873
873
-- Again, so should this...
874
874
CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest1, ptest2));
875
875
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
876
- DETAIL: Key columns "ftest1" and "ptest1" are of incompatible types: cidr and integer.
876
+ DETAIL: Key columns "ftest1" of the referencing table and "ptest1" of the referenced table are of incompatible types: cidr and integer.
877
877
-- This fails because we mixed up the column ordering
878
878
CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable);
879
879
ERROR: foreign key constraint "fktable_ftest2_ftest1_fkey" cannot be implemented
880
- DETAIL: Key columns "ftest2" and "ptest1" are of incompatible types: inet and integer.
880
+ DETAIL: Key columns "ftest2" of the referencing table and "ptest1" of the referenced table are of incompatible types: inet and integer.
881
881
-- As does this...
882
882
CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable(ptest1, ptest2));
883
883
ERROR: foreign key constraint "fktable_ftest2_ftest1_fkey" cannot be implemented
884
- DETAIL: Key columns "ftest2" and "ptest1" are of incompatible types: inet and integer.
884
+ DETAIL: Key columns "ftest2" of the referencing table and "ptest1" of the referenced table are of incompatible types: inet and integer.
885
885
-- And again..
886
886
CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest2, ptest1));
887
887
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
888
- DETAIL: Key columns "ftest1" and "ptest2" are of incompatible types: integer and inet.
888
+ DETAIL: Key columns "ftest1" of the referencing table and "ptest2" of the referenced table are of incompatible types: integer and inet.
889
889
-- This works...
890
890
CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable(ptest2, ptest1));
891
891
DROP TABLE FKTABLE;
@@ -906,17 +906,17 @@ DROP TABLE PKTABLE;
906
906
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest3,
907
907
ptest4) REFERENCES pktable(ptest2, ptest1));
908
908
ERROR: foreign key constraint "pktable_ptest3_ptest4_fkey" cannot be implemented
909
- DETAIL: Key columns "ptest3" and "ptest2" are of incompatible types: integer and inet.
909
+ DETAIL: Key columns "ptest3" of the referencing table and "ptest2" of the referenced table are of incompatible types: integer and inet.
910
910
-- Nor should this... (same reason, we have 4,3 referencing 1,2 which mismatches types
911
911
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest4,
912
912
ptest3) REFERENCES pktable(ptest1, ptest2));
913
913
ERROR: foreign key constraint "pktable_ptest4_ptest3_fkey" cannot be implemented
914
- DETAIL: Key columns "ptest4" and "ptest1" are of incompatible types: inet and integer.
914
+ DETAIL: Key columns "ptest4" of the referencing table and "ptest1" of the referenced table are of incompatible types: inet and integer.
915
915
-- Not this one either... Same as the last one except we didn't defined the columns being referenced.
916
916
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest4,
917
917
ptest3) REFERENCES pktable);
918
918
ERROR: foreign key constraint "pktable_ptest4_ptest3_fkey" cannot be implemented
919
- DETAIL: Key columns "ptest4" and "ptest1" are of incompatible types: inet and integer.
919
+ DETAIL: Key columns "ptest4" of the referencing table and "ptest1" of the referenced table are of incompatible types: inet and integer.
920
920
--
921
921
-- Now some cases with inheritance
922
922
-- Basic 2 table case: 1 column of matching types.
@@ -1009,40 +1009,40 @@ create table pktable(ptest1 inet, primary key(base1, ptest1)) inherits (pktable_
1009
1009
-- just generally bad types (with and without column references on the referenced table)
1010
1010
create table fktable(ftest1 cidr, ftest2 int[], foreign key (ftest1, ftest2) references pktable);
1011
1011
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
1012
- DETAIL: Key columns "ftest1" and "base1" are of incompatible types: cidr and integer.
1012
+ DETAIL: Key columns "ftest1" of the referencing table and "base1" of the referenced table are of incompatible types: cidr and integer.
1013
1013
create table fktable(ftest1 cidr, ftest2 int[], foreign key (ftest1, ftest2) references pktable(base1, ptest1));
1014
1014
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
1015
- DETAIL: Key columns "ftest1" and "base1" are of incompatible types: cidr and integer.
1015
+ DETAIL: Key columns "ftest1" of the referencing table and "base1" of the referenced table are of incompatible types: cidr and integer.
1016
1016
-- let's mix up which columns reference which
1017
1017
create table fktable(ftest1 int, ftest2 inet, foreign key(ftest2, ftest1) references pktable);
1018
1018
ERROR: foreign key constraint "fktable_ftest2_ftest1_fkey" cannot be implemented
1019
- DETAIL: Key columns "ftest2" and "base1" are of incompatible types: inet and integer.
1019
+ DETAIL: Key columns "ftest2" of the referencing table and "base1" of the referenced table are of incompatible types: inet and integer.
1020
1020
create table fktable(ftest1 int, ftest2 inet, foreign key(ftest2, ftest1) references pktable(base1, ptest1));
1021
1021
ERROR: foreign key constraint "fktable_ftest2_ftest1_fkey" cannot be implemented
1022
- DETAIL: Key columns "ftest2" and "base1" are of incompatible types: inet and integer.
1022
+ DETAIL: Key columns "ftest2" of the referencing table and "base1" of the referenced table are of incompatible types: inet and integer.
1023
1023
create table fktable(ftest1 int, ftest2 inet, foreign key(ftest1, ftest2) references pktable(ptest1, base1));
1024
1024
ERROR: foreign key constraint "fktable_ftest1_ftest2_fkey" cannot be implemented
1025
- DETAIL: Key columns "ftest1" and "ptest1" are of incompatible types: integer and inet.
1025
+ DETAIL: Key columns "ftest1" of the referencing table and "ptest1" of the referenced table are of incompatible types: integer and inet.
1026
1026
drop table pktable;
1027
1027
drop table pktable_base;
1028
1028
-- 2 columns (1 table), mismatched types
1029
1029
create table pktable_base(base1 int not null, base2 int);
1030
1030
create table pktable(ptest1 inet, ptest2 inet[], primary key(base1, ptest1), foreign key(base2, ptest2) references
1031
1031
pktable(base1, ptest1)) inherits (pktable_base);
1032
1032
ERROR: foreign key constraint "pktable_base2_ptest2_fkey" cannot be implemented
1033
- DETAIL: Key columns "ptest2" and "ptest1" are of incompatible types: inet[] and inet.
1033
+ DETAIL: Key columns "ptest2" of the referencing table and "ptest1" of the referenced table are of incompatible types: inet[] and inet.
1034
1034
create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(base2, ptest2) references
1035
1035
pktable(ptest1, base1)) inherits (pktable_base);
1036
1036
ERROR: foreign key constraint "pktable_base2_ptest2_fkey" cannot be implemented
1037
- DETAIL: Key columns "base2" and "ptest1" are of incompatible types: integer and inet.
1037
+ DETAIL: Key columns "base2" of the referencing table and "ptest1" of the referenced table are of incompatible types: integer and inet.
1038
1038
create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(ptest2, base2) references
1039
1039
pktable(base1, ptest1)) inherits (pktable_base);
1040
1040
ERROR: foreign key constraint "pktable_ptest2_base2_fkey" cannot be implemented
1041
- DETAIL: Key columns "ptest2" and "base1" are of incompatible types: inet and integer.
1041
+ DETAIL: Key columns "ptest2" of the referencing table and "base1" of the referenced table are of incompatible types: inet and integer.
1042
1042
create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(ptest2, base2) references
1043
1043
pktable(base1, ptest1)) inherits (pktable_base);
1044
1044
ERROR: foreign key constraint "pktable_ptest2_base2_fkey" cannot be implemented
1045
- DETAIL: Key columns "ptest2" and "base1" are of incompatible types: inet and integer.
1045
+ DETAIL: Key columns "ptest2" of the referencing table and "base1" of the referenced table are of incompatible types: inet and integer.
1046
1046
drop table pktable;
1047
1047
ERROR: table "pktable" does not exist
1048
1048
drop table pktable_base;
@@ -1154,22 +1154,22 @@ CREATE TEMP TABLE fktable (
1154
1154
ALTER TABLE fktable ADD CONSTRAINT fk_2_3
1155
1155
FOREIGN KEY (x2) REFERENCES pktable(id3);
1156
1156
ERROR: foreign key constraint "fk_2_3" cannot be implemented
1157
- DETAIL: Key columns "x2" and "id3" are of incompatible types: character varying and real.
1157
+ DETAIL: Key columns "x2" of the referencing table and "id3" of the referenced table are of incompatible types: character varying and real.
1158
1158
-- nor to int4
1159
1159
ALTER TABLE fktable ADD CONSTRAINT fk_2_1
1160
1160
FOREIGN KEY (x2) REFERENCES pktable(id1);
1161
1161
ERROR: foreign key constraint "fk_2_1" cannot be implemented
1162
- DETAIL: Key columns "x2" and "id1" are of incompatible types: character varying and integer.
1162
+ DETAIL: Key columns "x2" of the referencing table and "id1" of the referenced table are of incompatible types: character varying and integer.
1163
1163
-- real does not promote to int4
1164
1164
ALTER TABLE fktable ADD CONSTRAINT fk_3_1
1165
1165
FOREIGN KEY (x3) REFERENCES pktable(id1);
1166
1166
ERROR: foreign key constraint "fk_3_1" cannot be implemented
1167
- DETAIL: Key columns "x3" and "id1" are of incompatible types: real and integer.
1167
+ DETAIL: Key columns "x3" of the referencing table and "id1" of the referenced table are of incompatible types: real and integer.
1168
1168
-- int4 does not promote to text
1169
1169
ALTER TABLE fktable ADD CONSTRAINT fk_1_2
1170
1170
FOREIGN KEY (x1) REFERENCES pktable(id2);
1171
1171
ERROR: foreign key constraint "fk_1_2" cannot be implemented
1172
- DETAIL: Key columns "x1" and "id2" are of incompatible types: integer and character varying.
1172
+ DETAIL: Key columns "x1" of the referencing table and "id2" of the referenced table are of incompatible types: integer and character varying.
1173
1173
-- should succeed
1174
1174
-- int4 promotes to real
1175
1175
ALTER TABLE fktable ADD CONSTRAINT fk_1_3
@@ -1192,11 +1192,11 @@ FOREIGN KEY (x2,x5,x3) REFERENCES pktable(id2,id1,id3);
1192
1192
ALTER TABLE fktable ADD CONSTRAINT fk_123_231
1193
1193
FOREIGN KEY (x1,x2,x3) REFERENCES pktable(id2,id3,id1);
1194
1194
ERROR: foreign key constraint "fk_123_231" cannot be implemented
1195
- DETAIL: Key columns "x1" and "id2" are of incompatible types: integer and character varying.
1195
+ DETAIL: Key columns "x1" of the referencing table and "id2" of the referenced table are of incompatible types: integer and character varying.
1196
1196
ALTER TABLE fktable ADD CONSTRAINT fk_241_132
1197
1197
FOREIGN KEY (x2,x4,x1) REFERENCES pktable(id1,id3,id2);
1198
1198
ERROR: foreign key constraint "fk_241_132" cannot be implemented
1199
- DETAIL: Key columns "x2" and "id1" are of incompatible types: character varying and integer.
1199
+ DETAIL: Key columns "x2" of the referencing table and "id1" of the referenced table are of incompatible types: character varying and integer.
1200
1200
DROP TABLE pktable, fktable;
1201
1201
-- test a tricky case: we can elide firing the FK check trigger during
1202
1202
-- an UPDATE if the UPDATE did not change the foreign key
0 commit comments