MYSQL数据库mysql提示[Warning] Invalid (old?) table or database name问题的解决方法

MYSQL数据库mysql提示[Warning] Invalid (old?) table or database name问题的解决方法,第1张

概述介绍《MYSQL数据库mysql提示[Warning] Invalid (old?) table or database name问题的解决方法》开发教程,希望对您有用。

《MysqL数据库MysqL提示[Warning] InvalID (old?) table or database name问题的解决方法》要点:
本文介绍了MysqL数据库MysqL提示[Warning] InvalID (old?) table or database name问题的解决方法,希望对您有用。如果有疑问,可以联系我们。

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,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数据库mysql提示[Warning] Invalid (old?) table or database name问题的解决方法全部内容,希望文章能够帮你解决MYSQL数据库mysql提示[Warning] Invalid (old?) table or database name问题的解决方法所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/1163730.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-01
下一篇 2022-06-01

发表评论

登录后才能评论

评论列表(0条)

保存