Bug #120929 LATEST FOREIGN KEY ERROR is not printed in SHOW ENGINE INNODB STATUS
Submitted: 14 Jul 16:35 Modified: 21 Jul 8:24
Reporter: Sveta Smirnova (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:9.7.1 OS:Any
Assigned to: CPU Architecture:Any
Tags: regression

[14 Jul 16:35] Sveta Smirnova
Description:
Starting from version 9.7, the section "LATEST FOREIGN KEY ERROR" is not printed in the SHOW ENGINE INNODB STATUS even if a foreign key error happens.

How to repeat:
sveta@lemurr:~/src/percona/percona-toolkit$ mysql 
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 9.7.1 MySQL Community Server - GPL

Copyright (c) 2000, 2026, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database test;
Query OK, 1 row affected (0.001 sec)

mysql> use test;
Database changed
mysql> DROP TABLE IF EXISTS child;
Query OK, 0 rows affected, 1 warning (0.001 sec)

mysql> DROP TABLE IF EXISTS parent;
Query OK, 0 rows affected, 1 warning (0.001 sec)

mysql> 
mysql> CREATE TABLE parent (
    ->    id INT NOT NULL,
    ->    PRIMARY KEY (id)
    -> ) ENGINE=INNODB;
Query OK, 0 rows affected (0.003 sec)

mysql> 
mysql> 
mysql> CREATE TABLE child (
    ->    id INT,
    ->    parent_id INT,
    ->    INDEX par_ind (parent_id),
    ->    FOREIGN KEY (parent_id) REFERENCES parent(id)
    -> ) ENGINE=INNODB;
Query OK, 0 rows affected (0.004 sec)

mysql> 
mysql> INSERT INTO parent VALUES (1), (2), (3);
Query OK, 3 rows affected (0.001 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> INSERT INTO child VALUES (1, 9);  -- Error!
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`))
mysql> \P grep -A5 "LATEST FOREIGN KEY ERROR"
PAGER set to 'grep "LATEST FOREIGN KEY ERROR"'
mysql> show engine innodb status\G
1 row in set (0.000 sec)

Suggested fix:
Return 8.4 behavior:

...
mysql> INSERT INTO child VALUES (1, 9);  -- Error!
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`))
mysql> \P grep -A5 "LATEST FOREIGN KEY ERROR"
PAGER set to 'grep "LATEST FOREIGN KEY ERROR"'
mysql> show engine innodb status\G
LATEST FOREIGN KEY ERROR
------------------------
2026-07-14 19:34:25 128303396157120 Transaction:
TRANSACTION 1878, ACTIVE 0 sec inserting
mysql tables in use 1, locked 1
3 lock struct(s), heap size 1128, 1 row lock(s), undo log entries 1
1 row in set (0.001 sec)
[20 Jul 8:11] Shane Bester
Thank you for the report Sveta,  I verified this on current trunk.
[20 Jul 8:16] Shane Bester
Actually, it's not a bug but an intentional change.
To restore the old behaviour you need:

[mysqld]
innodb_native_foreign_keys=ON

https://dev.mysql.com/doc/refman/9.7/en/innodb-parameters.html#sysvar_innodb_native_foreig...
[20 Jul 16:12] Sveta Smirnova
Here is the user manual at https://dev.mysql.com/doc/refman/9.7/en/create-table-foreign-keys.html#foreign-key-errors:

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. 

If this is not a bug, the user manual should be updated.