Bug #86926 The field table_name (varchar(64)) from mysql.innodb_table_stats can overflow.
Submitted: 4 Jul 11:24 Modified: 4 Jul 15:47
Reporter: Jean-François Gagné Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Partitions Severity:S2 (Serious)
Version:5.7.17-log OS:Any
Assigned to:

[4 Jul 11:24] Jean-François Gagné
Description:
Hi,

the field table_name from the mysql.innodb_table_stats is a varchar(64).  But with creating a partitioned table, I was able to end-up with more than 64 characters in this field.

This looks like a ticking bomb...

Many thanks for looking into that,

JFG

How to repeat:
> select version();
+------------+
| version()  |
+------------+
| 5.7.17-log |
+------------+
1 row in set (0.00 sec)

> select database_name, table_name, length(table_name) from mysql.innodb_table_stats where database_name = 'test_jfg';
Empty set (0.00 sec)

> create database test_jfg;
Query OK, 1 row affected (0.01 sec)

> CREATE TABLE test_jfg.test_jfg_table_name_with_64_chars_123456789012345678901234567890 (
    ->   id int(10) unsigned NOT NULL,
    ->   PRIMARY KEY (id)
    -> ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
    -> PARTITION BY RANGE ( id ) (
    ->   PARTITION p1000 VALUES LESS THAN (1000) ENGINE = InnoDB,
    ->   PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
Query OK, 0 rows affected (0.01 sec)

> select database_name, table_name, length(table_name) from mysql.innodb_table_stats where database_name = 'test_jfg';
+---------------+--------------------------------------------------------------------------+--------------------+
| database_name | table_name                                                               | length(table_name) |
+---------------+--------------------------------------------------------------------------+--------------------+
| test_jfg      | test_jfg_table_name_with_64_chars_123456789012345678901234567890#P#p1000 |                 72 |
| test_jfg      | test_jfg_table_name_with_64_chars_123456789012345678901234567890#P#pmax  |                 71 |
+---------------+--------------------------------------------------------------------------+--------------------+
2 rows in set (0.00 sec)

> show create table mysql.innodb_table_stats\G
*************************** 1. row ***************************
       Table: innodb_table_stats
Create Table: CREATE TABLE `innodb_table_stats` (
  `database_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `table_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `n_rows` bigint(20) unsigned NOT NULL,
  `clustered_index_size` bigint(20) unsigned NOT NULL,
  `sum_of_other_index_sizes` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`database_name`,`table_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0
1 row in set (0.00 sec)
[4 Jul 15:56] Bogdan Kecman
Hi,

verified as reported. Thanks for reporting!

all best
Bogdan