summaryrefslogtreecommitdiff
path: root/src/test/regress
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/regress')
-rw-r--r--src/test/regress/expected/foreign_key.out32
-rw-r--r--src/test/regress/sql/foreign_key.sql22
2 files changed, 54 insertions, 0 deletions
diff --git a/src/test/regress/expected/foreign_key.out b/src/test/regress/expected/foreign_key.out
index 0807423597..589ee337b1 100644
--- a/src/test/regress/expected/foreign_key.out
+++ b/src/test/regress/expected/foreign_key.out
@@ -1276,3 +1276,35 @@ SELECT * FROM tasks;
(3 rows)
COMMIT;
+--
+-- Test self-referential FK with CASCADE (bug #6268)
+--
+create temp table selfref (
+ a int primary key,
+ b int,
+ foreign key (b) references selfref (a)
+ on update cascade on delete cascade
+);
+NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "selfref_pkey" for table "selfref"
+insert into selfref (a, b)
+values
+ (0, 0),
+ (1, 1);
+begin;
+ update selfref set a = 123 where a = 0;
+ select a, b from selfref;
+ a | b
+-----+-----
+ 1 | 1
+ 123 | 123
+(2 rows)
+
+ update selfref set a = 456 where a = 123;
+ select a, b from selfref;
+ a | b
+-----+-----
+ 1 | 1
+ 456 | 456
+(2 rows)
+
+commit;
diff --git a/src/test/regress/sql/foreign_key.sql b/src/test/regress/sql/foreign_key.sql
index 0135368db8..1d92c91e74 100644
--- a/src/test/regress/sql/foreign_key.sql
+++ b/src/test/regress/sql/foreign_key.sql
@@ -899,3 +899,25 @@ SELECT * FROM tasks;
DELETE FROM users WHERE id = 2;
SELECT * FROM tasks;
COMMIT;
+
+--
+-- Test self-referential FK with CASCADE (bug #6268)
+--
+create temp table selfref (
+ a int primary key,
+ b int,
+ foreign key (b) references selfref (a)
+ on update cascade on delete cascade
+);
+
+insert into selfref (a, b)
+values
+ (0, 0),
+ (1, 1);
+
+begin;
+ update selfref set a = 123 where a = 0;
+ select a, b from selfref;
+ update selfref set a = 456 where a = 123;
+ select a, b from selfref;
+commit;