程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> mysql提醒[Warning] Invalid (old?) table or database name成績的處理辦法

mysql提醒[Warning] Invalid (old?) table or database name成績的處理辦法

編輯:MySQL綜合教程

mysql提醒[Warning] Invalid (old?) table or database name成績的處理辦法。本站提示廣大學習愛好者:(mysql提醒[Warning] Invalid (old?) table or database name成績的處理辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是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, /*!< 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
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved