Mysql tip [Warning] Invalid (old) table or database name problem Resolution _MYSQL

Source: Internet
Author: User
Tags function definition table definition
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);
Through the above operation, the warning problem occurs many times. Through the query and tracking debugging source code, there are the following clues and processing methods:
The location of the "[Warning] Invalid (old) table or database name" problem in MySQL occurs:

sql_table.cc:279
UINT Explain_filename (thd* THD, const char *from, char *to, uint to_length, Enum_explain_filename_mode explain_mode)

The trace code finds that only the Explain_filename function is invoked in the ha_innodb.cc:1946 innobase_convert_identifier.
Copy Code code 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 a UTF-8 string */

Follow the leads up, found in two locations called the Innobase_convert_identifier function, two clues to continue to find.

Clue One:
ha_innodb.cc:2034
Calling the Innodb_convert_identifier function
Copy Code code 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 a index name * *

From the function definition and function function, the function is to convert the MySQL table name or index name to UTF8, which is related to the character set. Inference is one of the possible causes for viewing the existing database character set and the generated temporary table character set as Lanti1.
Treatment mode:
Modify the database's character set to UTF8 to see if the database still appears.

Clue Two:
Copy Code code as follows:

ha_innodb.cc:6269
Calling the Innodb_convert_identifier function
/*****************************************************************//**
Creates a table definition to a 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 * *

In the Create_table_def function, when the Row_create_table_for_mysql function is called, the innodb_convert_identifier is invoked when the return value is Db_duplicate_key. Thus triggering the warning.
Copy Code code as follows:

row0mysql.c:1820
Univ_intern int Row_create_table_for_mysql (
/*=======================*/
dict_table_t* table,/*!< in, own:table definition
(would be freed) * *
trx_t* Trx)/*!< in:transaction Handle * *

A deeper function is called in this function, but from the debug code, there is no point to cause the problem for the time being.
Treatment mode:
Further code analysis is carried out in the case where the handling of thread one does not solve the problem.
Summarize:
After debugging and analysis of the above code, two clues have been drawn, but the problem has not been reproduced. As a result, only one thread of the existing server can be processed at this time. If the problem still occurs after the thread is processed, the second step is analyzed in depth.

Author King_wangheng

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.