Categories
Database Development

How to make MySQL 8 alert when integer overflow happens during INSERT … ON DUPLICATE KEY?

Let’s consider we have a simple table with auto-incrementing integer ID and some unique column: CREATE TABLE `test` ( `id` int unsigned NOT NULL AUTO_INCREMENT, `value` tinyint DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `value` (`value`) ); Imagine we inserted into it so many times that ID reached the maximum: INSERT INTO test VALUES (4294967294, […]