Page MenuHomePhabricator

In or around 8.0.19, MySQL has removed integer display width information, changing the syntax of "SHOW CREATE TABLE"
Closed, ResolvedPublic

Description

See https://discourse.phabricator-community.org/t/wrong-column-type-everywhere-other-errors-on-fresh-db-upgrade/3872/.

Between MySQL 8.0.11 and 8.0.20, the output of SHOW CREATE TABLE has changed for integer columns.

Here's example output from 8.0.11:

MySQL 8.0.11
mysql> CREATE TEMPORARY TABLE t (i INT UNSIGNED NOT NULL);
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW CREATE TABLE t;
+-------+---------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                    |
+-------+---------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TEMPORARY TABLE `t` (
  `i` int(10) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+-------+---------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

Here's example output from 8.0.20:

MySQL 8.0.20
mysql> CREATE TEMPORARY TABLE t (i INT UNSIGNED NOT NULL);
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW CREATE TABLE t;
+-------+-----------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                |
+-------+-----------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TEMPORARY TABLE `t` (
  `i` int unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+-------+-----------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Note that int(10) unsigned is now int unsigned in the output.

This change likely occurred in 8.0.19, although I haven't tested adjacent versions.

Display width specification for integer data types was deprecated in MySQL 8.0.17, and now statements that include data type definitions in their output no longer show the display width for integer types, with these exceptions...
https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-19.html

The 8.0.17 changelog just mentions the deprecation and doesn't appear to provide more details:

The ZEROFILL attribute is deprecated for numeric data types, as is the display width attribute for integer data types.
https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-17.html

This causes bin/storage upgrade to believe that the column type is incorrect and attempt to adjust it.


We don't (knowingly) rely on the integer display width feature, so the fix is likely just to parse int(10) and int as equivalent.

The one case I can think of where we may depend on the behavior of this feature is that BOOL was historically an alias for TINYINT(1).

Related Objects

Event Timeline

epriestley created this task.
epriestley renamed this task from MySQL "SHOW CREATE TABLE" syntax has changed for integers to In or around 8.0.19, MySQL has removed integer display width information, changing the syntax of "SHOW CREATE TABLE".May 17 2020, 3:53 PM

The actual query we use to inspect table information is:

mysql> SELECT ... FROM INFORMATION_SCHEMA.COLUMNS ...;

The behavioral change here is basically equivalent:

8.0.11
mysql> SELECT COLUMN_TYPE FROM COLUMNS ...\G
*************************** 1. row ***************************
COLUMN_TYPE: int(10) unsigned
1 row in set (0.00 sec)
8.0.20
mysql> SELECT COLUMN_TYPE FROM COLUMNS ...\G
*************************** 1. row ***************************
COLUMN_TYPE: int unsigned
1 row in set (0.00 sec)