@@ -307,26 +307,21 @@ INSERT INTO tmp3 values (1,20);
307307INSERT INTO tmp3 values (5,50);
308308-- Try (and fail) to add constraint due to invalid source columns
309309ALTER TABLE tmp3 add constraint tmpconstr foreign key(c) references tmp2 match full;
310- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
311310ERROR: column "c" referenced in foreign key constraint does not exist
312311-- Try (and fail) to add constraint due to invalide destination columns explicitly given
313312ALTER TABLE tmp3 add constraint tmpconstr foreign key(a) references tmp2(b) match full;
314- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
315313ERROR: column "b" referenced in foreign key constraint does not exist
316314-- Try (and fail) to add constraint due to invalid data
317315ALTER TABLE tmp3 add constraint tmpconstr foreign key (a) references tmp2 match full;
318- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
319316ERROR: insert or update on table "tmp3" violates foreign key constraint "tmpconstr"
320317DETAIL: Key (a)=(5) is not present in table "tmp2".
321318-- Delete failing row
322319DELETE FROM tmp3 where a=5;
323320-- Try (and succeed)
324321ALTER TABLE tmp3 add constraint tmpconstr foreign key (a) references tmp2 match full;
325- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
326322-- Try (and fail) to create constraint from tmp5(a) to tmp4(a) - unique constraint on
327323-- tmp4 is a,b
328324ALTER TABLE tmp5 add constraint tmpconstr foreign key(a) references tmp4(a) match full;
329- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
330325ERROR: there is no unique constraint matching given keys for referenced table "tmp4"
331326DROP TABLE tmp5;
332327DROP TABLE tmp4;
@@ -340,24 +335,20 @@ NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" fo
340335CREATE TEMP TABLE FKTABLE (ftest1 inet);
341336-- This next should fail, because inet=int does not exist
342337ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable;
343- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
344338ERROR: operator does not exist: inet = integer
345339HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts.
346340-- This should also fail for the same reason, but here we
347341-- give the column name
348342ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable(ptest1);
349- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
350343ERROR: operator does not exist: inet = integer
351344HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts.
352345-- This should succeed, even though they are different types
353346-- because varchar=int does exist
354347DROP TABLE FKTABLE;
355348CREATE TEMP TABLE FKTABLE (ftest1 varchar);
356349ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable;
357- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
358350-- As should this
359351ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable(ptest1);
360- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
361352DROP TABLE pktable cascade;
362353NOTICE: drop cascades to constraint $2 on table fktable
363354NOTICE: drop cascades to constraint $1 on table fktable
@@ -368,29 +359,25 @@ NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" fo
368359-- This should fail, because we just chose really odd types
369360CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
370361ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) references pktable;
371- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
372362ERROR: operator does not exist: cidr = integer
373363HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts.
374364DROP TABLE FKTABLE;
375365-- Again, so should this...
376366CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
377367ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2)
378368 references pktable(ptest1, ptest2);
379- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
380369ERROR: operator does not exist: cidr = integer
381370HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts.
382371DROP TABLE FKTABLE;
383372-- This fails because we mixed up the column ordering
384373CREATE TEMP TABLE FKTABLE (ftest1 int, ftest2 inet);
385374ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2)
386375 references pktable(ptest2, ptest1);
387- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
388376ERROR: operator does not exist: integer = inet
389377HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts.
390378-- As does this...
391379ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest2, ftest1)
392380 references pktable(ptest1, ptest2);
393- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
394381ERROR: operator does not exist: inet = integer
395382HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts.
396383-- temp tables should go away by themselves, need not drop them.
@@ -907,16 +894,12 @@ ERROR: column "........pg.dropped.1........" does not exist
907894create table atacc2 (id int4 unique);
908895NOTICE: CREATE TABLE / UNIQUE will create implicit index "atacc2_id_key" for table "atacc2"
909896alter table atacc1 add foreign key (a) references atacc2(id);
910- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
911897ERROR: column "a" referenced in foreign key constraint does not exist
912898alter table atacc1 add foreign key ("........pg.dropped.1........") references atacc2(id);
913- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
914899ERROR: column "........pg.dropped.1........" referenced in foreign key constraint does not exist
915900alter table atacc2 add foreign key (id) references atacc1(a);
916- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
917901ERROR: column "a" referenced in foreign key constraint does not exist
918902alter table atacc2 add foreign key (id) references atacc1("........pg.dropped.1........");
919- NOTICE: ALTER TABLE will create implicit triggers for foreign-key checks
920903ERROR: column "........pg.dropped.1........" referenced in foreign key constraint does not exist
921904drop table atacc2;
922905create index "testing_idx" on atacc1(a);