日期:2014-05-16  浏览次数:20473 次

mysql的"[Warning] Invalid (old?) table or database name"问题
        线上服务器出现[Warning] Invalid (old?) table or database name问题,通过分析binlog日志发现,在以下sql语句中出现问题,由于涉及敏感内容,用sql语法表示。
        DROP TABLE IF EXISTS [TEMP_TABLE_NAME];
        create temporary table [TEMP_TABLE_NAME] select col1,col2,... from [TABLE_NAME];
        alter table [TEMP_TABLE_NAME] add unique idx_col1(col1);
        经过以上操作中,多次出现该warning问题。通过查询和跟踪调试源码,有以下线索和处理方式:
 

        mysql的"[Warning] Invalid (old?) table or database name"问题出现位置:

sql_table.cc:279
uint explain_filename (THD* thdconst char *fromchar *to uint to_length enum_explain_filename_mode explain_mode )

        跟踪代码发现,只有在ha_innodb.cc:1946的innobase_convert_identifier 中调用explain_filename函数。