Bug #26869 TABLE_LIST::table_name_length inconsistent with TABLE_LIST::table_name
Submitted: 6 Mar 2007 10:48 Modified: 18 Jun 2007 16:56
Reporter: Shan Lu Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.1, mysql-5.2.-falcon-alpha OS:Any
Assigned to: Dmitry Lenev CPU Architecture:Any

[6 Mar 2007 10:48] Shan Lu
Based on my understanding, it is better to keep TABLE_LIST::table_name_length consistent with TABLE_LIST::table_name, because one might use the former to read or write the latter string.

In following mysql_create_like_table function, src_tables_list's name-related fields: db, db_length, table_name and alias are all set. However, table_name_length is not set. The table_name_length field is actually 0 at this point due to the earlier bzero function call. 

I just feel this very dangerous: string table_name is non-null, while the variable describing its length, i.e. table_name_length, is 0. 
I think it is at least good habit to add the assignment to src_tables_list.table_name_length.

In file sql/sql_table.cc
4600  bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
4601                             HA_CREATE_INFO *lex_create_info,
4602                             Table_ident *table_ident)
4603  {
4687  bzero((gptr)&src_tables_list, sizeof(src_tables_list));
4688  src_tables_list.db= src_db;
4689  src_tables_list.db_length= table_ident->db.length;
4690  src_tables_list.lock_type= TL_READ;
4691  src_tables_list.table_name= src_table;
4692  src_tables_list.alias= src_table;
4694  if (simple_open_n_lock_tables(thd, &src_tables_list))

How to repeat:
no test case. Find this by source code reading.
[6 Mar 2007 13:24] Sergei Golubchik
will be fixed by the patch for bug#25578
[23 May 2007 15:44] Dmitry Lenev
This problem is fixed by the same patch as bug #23667.

Patch for 5.1: http://lists.mysql.com/commits/27205
[1 Jun 2007 19:21] Bugs System
Pushed into 5.1.20-beta
[18 Jun 2007 16:56] Paul DuBois
No user-visible change. No changelog entry needed.