summaryrefslogtreecommitdiff
path: root/src/test/regress/expected/alter_table.out
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/regress/expected/alter_table.out')
-rw-r--r--src/test/regress/expected/alter_table.out24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 174925df84..6ef19f56cf 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -269,3 +269,27 @@ SELECT unique1 FROM tenk1 WHERE unique1 < 5;
4
(5 rows)
+-- FOREIGN KEY CONSTRAINT adding TEST
+CREATE TABLE tmp2 (a int primary key);
+NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index 'tmp2_pkey' for table 'tmp2'
+CREATE TABLE tmp3 (a int, b int);
+-- Insert rows into tmp2 (pktable)
+INSERT INTO tmp2 values (1);
+INSERT INTO tmp2 values (2);
+INSERT INTO tmp2 values (3);
+INSERT INTO tmp2 values (4);
+-- Insert rows into tmp3
+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 data
+ALTER TABLE tmp3 add constraint tmpconstr foreign key (a) references tmp2 match full;
+NOTICE: ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s) for FOREIGN KEY check(s)
+ERROR: <unnamed> referential integrity violation - key referenced from tmp3 not found in tmp2
+-- Delete failing row
+DELETE FROM tmp3 where a=5;
+-- Try (and succeed)
+ALTER TABLE tmp3 add constraint tmpconstr foreign key (a) references tmp2 match full;
+NOTICE: ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s) for FOREIGN KEY check(s)
+DROP TABLE tmp3
+DROP TABLE tmp2