Bug #75839 Wrong length in INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO.NAME
Submitted: 10 Feb 2015 12:23 Modified: 12 Feb 2015 19:57
Reporter: Marko Mäkelä Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.7.1 OS:Any
Assigned to: CPU Architecture:Any

[10 Feb 2015 12:23] Marko Mäkelä
Description:
The NAME column in the read-only table INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO is incorrectly declared as 192 characters wide. The correct length is 64 characters. The maximum length of the column is 192 bytes, not 192 characters.

How to repeat:
SHOW CREATE TABLE INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO;

Suggested fix:
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index 7f9c6b6..8a38472 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -4159,7 +4159,7 @@ static ST_FIELD_INFO	i_s_innodb_temp_table_info_fields_info[] =
 
 #define IDX_TEMP_TABLE_NAME		1
 	{STRUCT_FLD(field_name,		"NAME"),
-	 STRUCT_FLD(field_length,	MAX_TABLE_UTF8_LEN),
+	 STRUCT_FLD(field_length,	NAME_CHAR_LEN),
 	 STRUCT_FLD(field_type,		MYSQL_TYPE_STRING),
 	 STRUCT_FLD(value,		0),
 	 STRUCT_FLD(field_flags,	MY_I_S_MAYBE_NULL),

Also, consider adjusting the field_flags attribute. Tables should always have names; they are never NULL.
[11 Feb 2015 7:16] Marko Mäkelä
Posted by developer:
 
INNODB_SYS_TABLES.NAME is not a good comparison, because that name is usually in ASCII (the so-called filename-safe encoding), using 1, 3 or 5 ASCII characters per encoded utf8mb3 character.

INNODB_SYS_INDEXES.NAME is in utf8mb3 (system_charset_info), and you seem to say that we have a bug there as well (it is VARCHAR(193) instead of the proper VARCHAR(64)).

As far as I can tell, the length in the declaration is the field display length, which is shown by SHOW CREATE TABLE. It is in characters. In the Field object, I see field_len=192 when declaring the length as NAME_CHAR_LEN (64). When changing it to 10, the field_len was 30.

The proper length for this table name seems to be 64 characters or less. The NAME field seems to match the internally generated .frm file name. When I tested this with two CREATE TEMPORARY TABLE statements, I got these two names:
#sql3f77_3_1
#sql3f77_3_0
[12 Feb 2015 19:57] Daniel Price
Fixed as of the upcoming 5.7.6, 5.8.0 release, and here's the changelog entry:

The "NAME" column of the "INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO"
table was incorrectly declared as 192 characters wide. The correct length
is 64 characters. 

Thank you for the bug report.