mysql提示[Warning] Invalid (old?) table or database name问题的解决方法
2012-07-29 10:54
731 查看
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* thd, const char *from, char *to , uint to_length , enum_explain_filename_mode explain_mode )
跟踪代码发现,只有在ha_innodb.cc:1946的innobase_convert_identifier 中调用explain_filename函数。
复制代码 代码如下:
/*****************************************************************//**
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 */
顺着线索向上查找,发现在有两个位置调用了innobase_convert_identifier 函数,分两个线索继续查找。
线索一:
ha_innodb.cc:2034
调用innodb_convert_identifier函数
复制代码 代码如下:
/*****************************************************************//**
Convert a table or index name to the MySQL system_charset_info (UTF-8)
and quote it if needed.
@return pointer to the end of buf */
extern "C" UNIV_INTERN char* innobase_convert_name (
/*==================*/
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 table_id) /*!< in: TRUE=id is a table or database name;
FALSE=id is an index name */
从函数定义和函数功能来看,该函数是将mysql的表名或者索引名转换成utf8,与字符集相关。查看现有数据库字符集和生成的临时表字符集均为lanti1,推断是可能的原因之一。
处理方式:
修改数据库的字符集为utf8,观察数据库是否仍然出现该错误。
线索二:
复制代码 代码如下:
ha_innodb.cc:6269
调用innodb_convert_identifier函数
/*****************************************************************//**
Creates a table definition to an InnoDB database. */
static create_table_def (
/*=============*/
trx_t* trx, /*!< in: InnoDB transaction handle */
TABLE* form, /*!< in: information on table
columns and indexes */
const char * table_name, /*!< in: table name */
const char * path_of_temp_table, /*!< in: if this is a table explicitly
created by the user with the
TEMPORARY keyword, then this
parameter is the dir path where the
table should be placed if we create
an .ibd file for it (no .ibd extension
in the path, though); otherwise this
is NULL */
ulint flags) /*!< in: table flags */
在create_table_def 函数中,调用row_create_table_for_mysql函数后,当返回值为DB_DUPLICATE_KEY时,调用innodb_convert_identifier,从而触发该warning。
复制代码 代码如下:
row0mysql.c:1820
UNIV_INTERN int row_create_table_for_mysql(
/*=======================*/
dict_table_t* table, /*!< in, own: table definition
(will be freed) */
trx_t* trx) /*!< in: transaction handle */
该函数中调用了更深层次的函数,但从调试代码来看,暂时没有发现导致该问题的点。
处理方式:
在线索一中的处理方式不能解决问题的情况下,再进行进一步的代码分析。
总结:
经过以上代码调试和分析,得出两条线索,但是一直未能重现该问题。因此,目前只能对现有服务器进行线索一的处理。如果按照线索一处理方式处理后,仍然出现该问题,将对第二步进行深入的分析。
作者 king_wangheng
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* thd, const char *from, char *to , uint to_length , enum_explain_filename_mode explain_mode )
跟踪代码发现,只有在ha_innodb.cc:1946的innobase_convert_identifier 中调用explain_filename函数。
复制代码 代码如下:
/*****************************************************************//**
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 */
顺着线索向上查找,发现在有两个位置调用了innobase_convert_identifier 函数,分两个线索继续查找。
线索一:
ha_innodb.cc:2034
调用innodb_convert_identifier函数
复制代码 代码如下:
/*****************************************************************//**
Convert a table or index name to the MySQL system_charset_info (UTF-8)
and quote it if needed.
@return pointer to the end of buf */
extern "C" UNIV_INTERN char* innobase_convert_name (
/*==================*/
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 table_id) /*!< in: TRUE=id is a table or database name;
FALSE=id is an index name */
从函数定义和函数功能来看,该函数是将mysql的表名或者索引名转换成utf8,与字符集相关。查看现有数据库字符集和生成的临时表字符集均为lanti1,推断是可能的原因之一。
处理方式:
修改数据库的字符集为utf8,观察数据库是否仍然出现该错误。
线索二:
复制代码 代码如下:
ha_innodb.cc:6269
调用innodb_convert_identifier函数
/*****************************************************************//**
Creates a table definition to an InnoDB database. */
static create_table_def (
/*=============*/
trx_t* trx, /*!< in: InnoDB transaction handle */
TABLE* form, /*!< in: information on table
columns and indexes */
const char * table_name, /*!< in: table name */
const char * path_of_temp_table, /*!< in: if this is a table explicitly
created by the user with the
TEMPORARY keyword, then this
parameter is the dir path where the
table should be placed if we create
an .ibd file for it (no .ibd extension
in the path, though); otherwise this
is NULL */
ulint flags) /*!< in: table flags */
在create_table_def 函数中,调用row_create_table_for_mysql函数后,当返回值为DB_DUPLICATE_KEY时,调用innodb_convert_identifier,从而触发该warning。
复制代码 代码如下:
row0mysql.c:1820
UNIV_INTERN int row_create_table_for_mysql(
/*=======================*/
dict_table_t* table, /*!< in, own: table definition
(will be freed) */
trx_t* trx) /*!< in: transaction handle */
该函数中调用了更深层次的函数,但从调试代码来看,暂时没有发现导致该问题的点。
处理方式:
在线索一中的处理方式不能解决问题的情况下,再进行进一步的代码分析。
总结:
经过以上代码调试和分析,得出两条线索,但是一直未能重现该问题。因此,目前只能对现有服务器进行线索一的处理。如果按照线索一处理方式处理后,仍然出现该问题,将对第二步进行深入的分析。
作者 king_wangheng
相关文章推荐
- mysql提示[Warning] Invalid (old?) table or database name问题的解决方法
- mysql的"[Warning] Invalid (old?) table or database name"问题
- Problem of " Invalid (old?) table or database name"
- [问题解决] asp.net 中调用 Excel 出现以下提示: Old format or invalid type library.
- Warning: ZipArchive::getFromName(): Invalid or unitialized Zip object 解决方法
- Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 问题的解决方法
- mysql: "tablename" is marked as crashed and should be repaired修复 问题分析: 当mysql出现这类提示时,大部分的现象为查询不到正常的
- IE8提示Invalid procedure call or argument 异常的解决方法
- Visual C++ 2010项目在Visual Studio 2013中打开.rc文件提示"undefined keyword or key name: SS_REALSIZECONTROL"解决方法
- Invalid postback or callback argument问题解决方法
- php下foreach()错误提示Warning Invalid argument supplied for foreach() 的解决方法
- 安装JDK时提示 IllegalArgumentException:Invalid characters in hostname的解决方法
- php提示Warning:mysql_fetch_array() expects的解决方法
- mysql处理添加外键时提示error 150 问题的解决方法
- ubuntu 10.10编译安装mysql 提示libtoolt': No such file or directory的解决方法
- mysql 直接从date 文件夹备份表,还原数据库之后提示 table doesn`t exist的原因和解决方法
- phpcms2008 信息管理 Warning: Invalid argument supplied for foreach() in 问题的解决方法
- adb install命令安装含有中文名apk提示INSTALL_FAILED_INVALID_URI问题解决方法
- mysql连接linux系统提示“登录出现1130 is not allowed to connect to this MySql server”问题的解决方法
- error: invalid deployment target '6.1.0' for architecture 'arm64' (requires '7.0.0' or later)问题的解决方法