From d4f626507ca56bf3e1a8adeea7f158535ddb0220 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 29 Aug 2000 04:20:47 +0000 Subject: This is mostly the same as an earlier patch I didn't hear anything about, but which would have broken with the function manager changes anyway. Well, this patch checks that a unique constraint of some form (unique or pk) is on the referenced columns of an FK constraint and that the columns in the referencing table exist at creation time. The former is to move closer to SQL compatibility and the latter is in answer to a bug report. I also added a basic check of this functionality to the alter table and foreign key regression tests. Stephan Szabo sszabo@bigpanda.com --- src/test/regress/sql/alter_table.sql | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/test/regress/sql/alter_table.sql') diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql index 0642e96ba1..cb7b9a2a46 100644 --- a/src/test/regress/sql/alter_table.sql +++ b/src/test/regress/sql/alter_table.sql @@ -180,6 +180,12 @@ INSERT INTO tmp3 values (1,10); INSERT INTO tmp3 values (1,20); INSERT INTO tmp3 values (5,50); +-- Try (and fail) to add constraint due to invalid source columns +ALTER TABLE tmp3 add constraint tmpconstr foreign key(c) references tmp2 match full; + +-- Try (and fail) to add constraint due to invalide destination columns explicitly given +ALTER TABLE tmp3 add constraint tmpconstr foreign key(a) references tmp2(b) match full; + -- Try (and fail) to add constraint due to invalid data ALTER TABLE tmp3 add constraint tmpconstr foreign key (a) references tmp2 match full; -- cgit v1.2.1