---
- Properties: sys-mysql
- suppressed: true
---
- CreateTable: p (id INT PRIMARY KEY NOT NULL, n INT NOT NULL, UNIQUE(n))
---
- CreateTable: c (id INT PRIMARY KEY NOT NULL, m INT, FOREIGN KEY(m) REFERENCES p(n))
---
- Statement: INSERT INTO p VALUES(1, 100), (2, 200), (3, 300), (4, 400)
---
- Statement: INSERT INTO c VALUES(10, 100), (40, 400)
---
# Just DEFERRED would check uniqueness on c.PRIMARY and might see completed FK check.
- Statement: SET constraintCheckTime = 'DEFERRED_ALWAYS_UNTIL_COMMIT'
---
- Statement: BEGIN
---
- Statement: INSERT INTO c VALUES(50, 500)
---
- Statement: COMMIT
- error: [23503, 'ERROR: Cannot insert into table `test`.`c` with m = 500 due to foreign key constraint `__fk_1` since no matching row exists in `test`.`p`']
---
- Statement: BEGIN
---
- Statement: DELETE FROM p WHERE id = 4
---
- Statement: COMMIT
- error: [23504, 'ERROR: Cannot delete from table `test`.`p` with n = 400 due to foreign key constraint `__fk_1` on `test`.`c`']
---
# TRUNCATE TABLE isn't transactional, so this is just testing that the right error
# comes from auto-commit.
- Statement: TRUNCATE TABLE p
- error: [23504, 'ERROR: Cannot truncate table `test`.`p` with n = 100 due to foreign key constraint `__fk_1` on `test`.`c`']
---
- Statement: SET constraintCheckTime = DEFAULT
---
- Statement: ALTER TABLE c DROP FOREIGN KEY
...
Add some tests of deferred.
Add some tests of deferred.
