Mysql prompts [Warning] Invalid (old ?) Tableordatabasename

Source: Internet
Author: User
Today, a friend's server displays [Warning] Invalid (old ?) Tableordatabasename problem. By analyzing binlog logs, we can find that the following SQL statements contain problems. Because sensitive content is involved, it is represented by SQL syntax.

Today, a friend's server displays [Warning] Invalid (old ?) The table or database name problem is found in the following SQL statements by analyzing the binlog. Because sensitive content is involved, it is represented by SQL syntax.

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 );
This warning problem occurs multiple times during the preceding operations. By querying and tracking the debugging source code, there are the following clues and handling methods:
Mysql "[Warning] Invalid (old ?) Table or database name "problem location:

SQL _table.cc: 279
Uint explain_filename (THD * thd, const char * from, char * to, uint to_length, enum_explain_filename_mode explain_mode)

The tracing code finds that the explain_filename function is called only in innobase_convert_identifier of ha_innodb.cc: 1946.
The Code is as follows:
/*************************************** **************************//**
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 */

Search up the clues and find that the innobase_convert_identifier function is called in two locations, and the query continues in two locations.

Clue 1:
Ha_innodb.cc: 2034
Call the innodb_convert_identifier Function
The Code is as follows:
/*************************************** **************************//**
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 */

From the perspective of function definitions and functions, this function converts the mysql table name or index name to utf8, which is related to the character set. Check that both the existing database character set and the generated temporary table character set are lanti1. inference is one of the possible reasons.
Processing Method:
Modify the character set of the database to utf8 and check whether the database still has this error.

Clue 2:
The Code is as follows:
Ha_innodb.cc: 6269
Call the innodb_convert_identifier Function
/*************************************** **************************//**
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
TEMPORARY keyword, then this
Parameter is the dir path where
Table shoshould 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 */

In the create_table_def function, when the row_create_table_for_mysql function is called and the return value is DB_DUPLICATE_KEY, innodb_convert_identifier is called to trigger the warning.
The Code is as follows:
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 */

This function calls a deeper function, but from the perspective of the debugging code, no points are found that cause this problem.
Processing Method:
Further code analysis is performed when the solution in Clue 1 cannot solve the problem.
Summary:
After the above Code debugging and analysis, two clues are obtained, but the problem has not been reproduced. Therefore, currently, only thread 1 can be processed on existing servers. If the problem still persists after processing according to clue 1, the second step will be analyzed in depth.

Author king_wangheng
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.