content_image/762821.jpg
## Foreign Key Errors 

POS: 0 

In the event of a foreign key error involving InnoDB  tables (usually Error 150 in the MySQL Server), information about the latest foreign key error can be obtained by checking SHOW ENGINE INNODB STATUS  output. 

mysql> SHOW ENGINE INNODB STATUS\G ... ------------------------ LATEST FOREIGN KEY ERROR ------------------------ 2018-04-12 14:57:24 0x7f97a9c91700 Transaction: TRANSACTION 7717, ACTIVE 0 sec inserting mysql tables in use 1, locked 1 4 lock struct(s), heap size 1136, 3 row lock(s), undo log entries 3 MySQL thread id 8, OS thread handle 140289365317376, query id 14 localhost root update INSERT INTO child VALUES (NULL, 1), (NULL, 2), (NULL, 3), (NULL, 4), (NULL, 5), (NULL, 6) Foreign key constraint fails for table ‘test‘.‘child‘: , CONSTRAINT ‘child_ibfk_1‘ FOREIGN KEY (‘parent_id‘) REFERENCES ‘parent‘ (‘id‘) ON DELETE CASCADE ON UPDATE CASCADE Trying to add in child table, in index par_ind tuple: DATA TUPLE: 2 fields;  0: len 4; hex 80000003; asc ;;  1: len 4; hex 80000003; asc ;; But in parent table ‘test‘.‘parent‘, in index PRIMARY, the closest match we can find is record: PHYSICAL RECORD: n_fields 3; compact format; info bits 0  0: len 4; hex 80000004; asc ;;  1: len 6; hex 000000001e19; asc ;;  2: len 7; hex 81000001110137; asc 7;; ... 

<img src='content_image/762821.jpg'>

## Warning 

If a user has table-level privileges for all parent tables, ER_NO_REFERENCED_ROW_2  and ER_ROW_IS_REFERENCED_2  error messages for foreign key operations expose information about parent tables. If a user does not have table-level privileges for all parent tables, more generic error messages are displayed instead ( ER_NO_REFERENCED_ROW  and ER_ROW_IS_REFERENCED ). 

An exception is that, for stored programs defined to execute with DEFINER privileges, the user against which privileges are assessed is the user in the program DEFINER  clause, not the invoking user. If that user has table-level parent table privileges, parent table information is still displayed. In this case, it is the responsibility of the stored program creator to hide the information by including appropriate condition handlers. 

## 13.1.20.6 CHECK Constraints 

Prior to MySQL 8.0.16, CREATE TABLE  permits only the following limited version of table CHECK  constraint syntax, which is parsed and ignored: 

CHECK ( expr ) 

As of MySQL 8.0.16, CREATE TABLE  permits the core features of table and column CHECK  constraints, for all storage engines. CREATE TABLE  permits the following CHECK  constraint syntax, for both table constraints and column constraints: 

