mysql提示[Warning]Invalid(old?)tableordatabasename问题的解决方法
2023-06-13 09:14:34 时间
DROPTABLEIFEXISTS[TEMP_TABLE_NAME];
createtemporarytable[TEMP_TABLE_NAME]selectcol1,col2,...from[TABLE_NAME];
altertable[TEMP_TABLE_NAME]adduniqueidx_col1(col1);
经过以上操作中,多次出现该warning问题。通过查询和跟踪调试源码,有以下线索和处理方式:
mysql的"[Warning]Invalid(old?)tableordatabasename"问题出现位置:
sql_table.cc:279
uintexplain_filename(THD*thd,constchar*from,char*to,uintto_length,enum_explain_filename_modeexplain_mode)
跟踪代码发现,只有在ha_innodb.cc:1946的innobase_convert_identifier中调用explain_filename函数。
复制代码代码如下:
createtemporarytable[TEMP_TABLE_NAME]selectcol1,col2,...from[TABLE_NAME];
altertable[TEMP_TABLE_NAME]adduniqueidx_col1(col1);
经过以上操作中,多次出现该warning问题。通过查询和跟踪调试源码,有以下线索和处理方式:
mysql的"[Warning]Invalid(old?)tableordatabasename"问题出现位置:
sql_table.cc:279
uintexplain_filename(THD*thd,constchar*from,char*to,uintto_length,enum_explain_filename_modeexplain_mode)
跟踪代码发现,只有在ha_innodb.cc:1946的innobase_convert_identifier中调用explain_filename函数。
/*****************************************************************//**
ConvertanSQLidentifiertotheMySQLsystem_charset_info(UTF-8)
andquoteitifneeded.
@returnpointertotheendofbuf*/
staticchar*innobase_convert_identifier(
/*========================*/
char*buf,/*!<out:bufferforconvertedidentifier*/
ulintbuflen,/*!<in:lengthofbuf,inbytes*/
constchar*id,/*!<in:identifiertoconvert*/
ulintidlen,/*!<in:lengthofid,inbytes*/
void*thd,/*!<in:MySQLconnectionthread,orNULL*/
iboolfile_id)/*!<in:TRUE=idisatableordatabasename;
FALSE=idisanUTF-8string*/
顺着线索向上查找,发现在有两个位置调用了innobase_convert_identifier函数,分两个线索继续查找。
线索一:
ha_innodb.cc:2034
调用innodb_convert_identifier函数
/*****************************************************************//**
ConvertatableorindexnametotheMySQLsystem_charset_info(UTF-8)
andquoteitifneeded.
@returnpointertotheendofbuf*/
extern"C"UNIV_INTERNchar*innobase_convert_name(
/*==================*/
char*buf,/*!<out:bufferforconvertedidentifier*/
ulintbuflen,/*!<in:lengthofbuf,inbytes*/
constchar*id,/*!<in:identifiertoconvert*/
ulintidlen,/*!<in:lengthofid,inbytes*/
void*thd,/*!<in:MySQLconnectionthread,orNULL*/
ibooltable_id)/*!<in:TRUE=idisatableordatabasename;
FALSE=idisanindexname*/
从函数定义和函数功能来看,该函数是将mysql的表名或者索引名转换成utf8,与字符集相关。查看现有数据库字符集和生成的临时表字符集均为lanti1,推断是可能的原因之一。
处理方式:
修改数据库的字符集为utf8,观察数据库是否仍然出现该错误。
线索二:
ha_innodb.cc:6269
调用innodb_convert_identifier函数
/*****************************************************************//**
CreatesatabledefinitiontoanInnoDBdatabase.*/
staticcreate_table_def(
/*=============*/
trx_t*trx,/*!<in:InnoDBtransactionhandle*/
TABLE*form,/*!<in:informationontable
columnsandindexes*/
constchar*table_name,/*!<in:tablename*/
constchar*path_of_temp_table,/*!<in:ifthisisatableexplicitly
createdbytheuserwiththe
TEMPORARYkeyword,thenthis
parameteristhedirpathwherethe
tableshouldbeplacedifwecreate
an.ibdfileforit(no.ibdextension
inthepath,though);otherwisethis
isNULL*/
ulintflags)/*!<in:tableflags*/
在create_table_def函数中,调用row_create_table_for_mysql函数后,当返回值为DB_DUPLICATE_KEY时,调用innodb_convert_identifier,从而触发该warning。
row0mysql.c:1820
UNIV_INTERNintrow_create_table_for_mysql(
/*=======================*/
dict_table_t*table,/*!<in,own:tabledefinition
(willbefreed)*/
trx_t*trx)/*!<in:transactionhandle*/
该函数中调用了更深层次的函数,但从调试代码来看,暂时没有发现导致该问题的点。
处理方式:
在线索一中的处理方式不能解决问题的情况下,再进行进一步的代码分析。
总结:
经过以上代码调试和分析,得出两条线索,但是一直未能重现该问题。因此,目前只能对现有服务器进行线索一的处理。如果按照线索一处理方式处理后,仍然出现该问题,将对第二步进行深入的分析。
作者king_wangheng
相关文章
- 使用MySQL最高效率的工具(最好用的mysql工具)
- MySQL中实现随机字符串生成的方法(mysql随机字符串)
- MySQL拼接字段:一种有效的数据处理方式(mysql拼接字段)
- MySQL转换为字符串的简单方法(mysql转换成字符串)
- MySQL查询改变了多少行?(mysql影响行数)
- MySQL 查询实现用户授权(mysql查询用户授权)
- MySQL修改用户名:操作指南(mysql修改用户名)
- 进入MySQL命令行的简单方法(mysql如何进入命令行)
- MySQL缓冲池:提升数据库性能的好帮手(mysql缓冲池)
- MySQL中导入BLOB字段的方法(mysql导入blob)
- MySQL中导出视图数据的步骤指南(mysql导出视图数据)
- MySQL中的SQL分析工具:强大而实用(mysql分析sql工具)
- MySQL存储过程返回表:实现高效数据处理(mysql存储过程返回表)
- MySQL 实例的详解及使用方法(mysql实例)
- 快速实现MySQL数据库导出的方法!(mysql导出全部数据库)
- MySQL 性能优化:最佳实践与工具介绍(mysql性能优化工具)
- 将DB2迁移到MySQL:一种转移数据库的有效方法(db2迁移到mysql)
- IIS无法连接MySQL数据库:解决方法(iis不支持mysql)
- MySQL数据库简单导出SQL脚本方法(mysql导出sql脚本)
- Linux下MySQL服务快速启动方法(linux mysql启动命令)
- 一键操作,MySQL表格快速清空(c mysql清空表)
- MySQL中AS的使用方法(mysql中as用法)
- 如何快速计算MySQL两表数据差(mysql两表数据差)
- B站MySQL转播令视频市场更具激情(b站mysql转播)
- MySQL升序排序方法简介(mysql中升序表示方法)
- MySQL的相同函数判断方法(mysql中判断相同函数)
- 解决MySQL不可写权限问题的方法(mysql不可写权限)
- MySQL下载遇到未响应该怎么办快速解决方法(mysql下载过程未响应)
- 菜鸟教程推荐MySQL下载指南(mysql下载菜鸟教程)
- MySQL上传语句方便快捷的数据库数据导入方法(mysql上传语句)
- MySQL注册服务失败的解决方法(mysql不能注册服务)