WL#13528: Remove integer display width from SHOW CREATE output
Affects: Server-8.0
—
Status: Complete
In WL#13127, the display width attribute was deprecated for integer types. Currently SHOW CREATE statements still always uses this deprecated attribute. This means that we generate statements that we ourselves have deprecated. This WL is about changing SHOW CREATE to not output integer display width unless ZEROFILL is also used. Without ZEROFILL, integer display width has no effect. Example from 8.0.19: mysql> create table t1(a int); Query OK, 0 rows affected (0,02 sec) mysql> show create table t1; +-------+--------------------------------------------------------------------- | Table | Create Table | +-------+--------------------------------------------------------------------- | t1 | CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci | +-------+--------------------------------------------------------------------- 1 row in set (0,01 sec) Notice that int(11) is part of SHOW CREATE output. We should only omit integer display width in SHOW CREATE if ZEROFILL is not also given as display width + ZEROFILL has consequences for current behavior. The example below illustrates the current 5.7 behavior: mysql> create table t1(a int(4)); Query OK, 0 rows affected (0,01 sec) mysql> insert into t1 values (1),(10),(100),(1000),(10000),(100000); Query OK, 6 rows affected (0,01 sec) Records: 6 Duplicates: 0 Warnings: 0 mysql> select * from t1; +--------+ | a | +--------+ | 1 | | 10 | | 100 | | 1000 | | 10000 | | 100000 | +--------+ 6 rows in set (0,00 sec) Notice that the output above for int(4) is no different from int. mysql> create table t2(a int(4) zerofill); Query OK, 0 rows affected (0,00 sec) mysql> insert into t2 values (1),(10),(100),(1000),(10000),(100000); Query OK, 6 rows affected (0,01 sec) Records: 6 Duplicates: 0 Warnings: 0 mysql> select * from t2; +--------+ | a | +--------+ | 0001 | | 0010 | | 0100 | | 1000 | | 10000 | | 100000 | +--------+ 6 rows in set (0,01 sec) Notice that the output above for int(4) + ZEROFILL is different from int.
F-1: SHOW CREATE TABLE should not show display width for columns width integer datatypes (TINYINT, SMALLINT, MEDIUMINT, INT or BIGINT) unless they have been created with ZEROFILL. F-2: SHOW CREATE FUNCTION should not show display width for return values using integer datatypes (TINYINT, SMALLINT, MEDIUMINT, INT or BIGINT) unless they have been created with ZEROFILL. F-3: INFORMATION_SCHEMA.COLUMNS should not show display width for columns width integer datatypes (TINYINT, SMALLINT, MEDIUMINT, INT or BIGINT) unless they have been created with ZEROFILL. This applies both to tables and views. F-4: INFORMATION_SCHEMA.ROUTINES should not show display width for return values using integer datatypes (TINYINT, SMALLINT, MEDIUMINT, INT or BIGINT) unless they have been created with ZEROFILL. F-5: INFORMATION_SCHEMA.PARAMETERS should not show display width for stored routine parameters and return values using integer datatypes (TINYINT, SMALLINT, MEDIUMINT, INT or BIGINT) unless they have been created with ZEROFILL. F-6: DESCRIBE for tables and views should not show display width for columns width integer datatypes (TINYINT, SMALLINT, MEDIUMINT, INT or BIGINT) unless they have been created with ZEROFILL. Note that F-3 to F-6 do not apply to tables/views/routines that were created before this worklog. This is because INFORMATION_SCHEMA queries get data directly from the data dictionary and this worklog does not affect information already stored in the data dictionary. An exception is when an existing database is upgraded directly from 5.7 to a version containing this worklog. Due to the new transactional data dictionary introduced in 8.0, all dictionary information is recreated in such an upgrade so that definitions will be updated to not contain display width.
Copyright (c) 2000, 2024, Oracle Corporation and/or its affiliates. All rights reserved.