@@ -314,9 +314,11 @@ NOTICE: DROP TABLE implicitly drops referential integrity trigger from table "t
314314NOTICE: DROP TABLE implicitly drops referential integrity trigger from table "tmp2"
315315DROP TABLE tmp2;
316316-- Foreign key adding test with mixed types
317- CREATE TABLE PKTABLE (ptest1 int PRIMARY KEY);
317+ -- Note: these tables are TEMP to avoid name conflicts when this test
318+ -- is run in parallel with foreign_key.sql.
319+ CREATE TEMP TABLE PKTABLE (ptest1 int PRIMARY KEY);
318320NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
319- CREATE TABLE FKTABLE (ftest1 text);
321+ CREATE TEMP TABLE FKTABLE (ftest1 text);
320322-- This next should fail, because text=int does not exist
321323ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable;
322324NOTICE: ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s) for FOREIGN KEY check(s)
@@ -331,7 +333,7 @@ ERROR: Unable to identify an operator '=' for types 'text' and 'int4'
331333-- This should succeed, even though they are different types
332334-- because varchar=int does exist
333335DROP TABLE FKTABLE;
334- CREATE TABLE FKTABLE (ftest1 varchar);
336+ CREATE TEMP TABLE FKTABLE (ftest1 varchar);
335337ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable;
336338NOTICE: ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s) for FOREIGN KEY check(s)
337339-- As should this
@@ -341,32 +343,35 @@ DROP TABLE pktable;
341343NOTICE: DROP TABLE implicitly drops referential integrity trigger from table "fktable"
342344NOTICE: DROP TABLE implicitly drops referential integrity trigger from table "fktable"
343345DROP TABLE fktable;
344- CREATE TABLE PKTABLE (ptest1 int, ptest2 text, PRIMARY KEY(ptest1, ptest2));
346+ CREATE TEMP TABLE PKTABLE (ptest1 int, ptest2 text,
347+ PRIMARY KEY(ptest1, ptest2));
345348NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
346349-- This should fail, because we just chose really odd types
347- CREATE TABLE FKTABLE (ftest1 cidr, ftest2 datetime);
350+ CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 datetime);
348351ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) references pktable;
349352NOTICE: ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s) for FOREIGN KEY check(s)
350353ERROR: Unable to identify an operator '=' for types 'cidr' and 'int4'
351354 You will have to retype this query using an explicit cast
352355-- Again, so should this...
353356DROP TABLE FKTABLE;
354- CREATE TABLE FKTABLE (ftest1 cidr, ftest2 datetime);
355- ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) references pktable(ptest1, ptest2);
357+ CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 datetime);
358+ ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2)
359+ references pktable(ptest1, ptest2);
356360NOTICE: ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s) for FOREIGN KEY check(s)
357361ERROR: Unable to identify an operator '=' for types 'cidr' and 'int4'
358362 You will have to retype this query using an explicit cast
359363-- This fails because we mixed up the column ordering
360364DROP TABLE FKTABLE;
361- CREATE TABLE FKTABLE (ftest1 int, ftest2 text);
362- ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) references pktable(ptest2, ptest1);
365+ CREATE TEMP TABLE FKTABLE (ftest1 int, ftest2 text);
366+ ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2)
367+ references pktable(ptest2, ptest1);
363368NOTICE: ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s) for FOREIGN KEY check(s)
364369ERROR: Unable to identify an operator '=' for types 'int4' and 'text'
365370 You will have to retype this query using an explicit cast
366371-- As does this...
367- ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest2, ftest1) references pktable(ptest1, ptest2);
372+ ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest2, ftest1)
373+ references pktable(ptest1, ptest2);
368374NOTICE: ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s) for FOREIGN KEY check(s)
369375ERROR: Unable to identify an operator '=' for types 'text' and 'int4'
370376 You will have to retype this query using an explicit cast
371- DROP TABLE FKTABLE;
372- DROP TABLE PKTABLE;
377+ -- temp tables should go away by themselves, need not drop them.
0 commit comments