Problem of " Invalid (old?) table or database name"
通过最近一段时间对该问题的跟踪,与Percona讨论组进行交流和探讨。虽然问题没有最终定位,也未能重现,但鉴于该问题可能触发一些bug。因此,整理往返的邮件,供大家参考。此外,该问题也提交到mysql官方bug列表,其中内容也供大家参考:http://bugs.mysql.com/bug.php?id=66253 。
对于之前对该问题源码的跟踪的相关内容,可以参考 mysql的"[Warning]
Invalid (old?) table or database name"问题
Heng Wang:
Recently, I encountered a problem, the details is: The mysql error log
always reports a warning like “[Warning] Invalid (old?) table or
database name? Through analysis of the binlog, there are two
statements in this period. The statements like these “create temporary
table [TEMP_TABLE_NAME] select col1,col2,... from [TABLE_NAME];?,
“alter table [TEMP_TABLE_NAME] add unique idx_col1(col1);?
I debug the mysql source attempt to trace the problem where happened,
but has not been able to repeat it. However, I get some ideas on the
problem through trace the mysql source (based on 5.5.20 source). The
detail as follows:
The warning information appears only in the function of
explain_filename (THD* thd, const char *from, char *to , uint
to_length , enum_explain_filename_mode explain_mode ) in line 279 of
sql/sql_table.cc.
I continue to trace the source and find that only the function
innobase_convert_identifier() in line 1946 of ha_innodb.cc call
explain_filename, the function implement as follows:
/*****************************************************************//**
Convert an SQL identifier to the MySQL system_charset_info (UTF-8)
and quote it if needed.
@return pointer to the end of buf */
static char* innobase_convert_identifier (
/*========================*/
char* buf, /*!< out: buffer for converted
identifier */
ulint buflen, /*!< in: length of buf,
in bytes */
const char * id, /*!< in: identifier to convert */
ulint idlen, /*!< in: length of id, in bytes
*/
void* thd, /*!< in: MySQL connection thread,
or NULL */
ibool file_id) /*!< in: TRUE=id is a table or
database name;
FALSE=id is an UTF-8 string */
Next, I trace the source where call the function of
innobase_convert_identifier(), I found that there are two clues.
First, in line 2034 of ha_innodb.cc, the function
innobase_co