summaryrefslogtreecommitdiff
path: root/mysql-test/suite/galera/t/galera_fk_selfreferential.test
blob: e2c190010306204421896619fdfb55ec31b38369 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#
# Test self-referential foreign keys
#

--source include/galera_cluster.inc
--source include/have_innodb.inc

CREATE TABLE t1 (
    f1 INT NOT NULL PRIMARY KEY,
    f2 INT,
    FOREIGN KEY (f2)
        REFERENCES t1(f1)
        ON DELETE CASCADE
) ENGINE=InnoDB;

INSERT INTO t1 VALUES (1, 1), (2, 1);

--connection node_2
DELETE FROM t1 WHERE f1 = 1;

--connection node_1
SELECT COUNT(*) = 0 FROM t1;

DROP TABLE t1;