MySQL tip [Warning] Invalid table or database name

Source: Internet
Author: User
Tags function definition table definition percona

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.

/*****************************************************************//**
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

/*****************************************************************//**
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:

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.

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.

Foreign website Reference


There is the presence of a bugs in this case for two reasons:

111116 10:48:29 [Warning] Invalid (old) table or database name ' #sql -3z8g_122a#p#p1 '   111116 10:48:29 [Warning] Inva Lid (old) table or database name ' #sql -3z8g_122a#p#p2 '   111116 10:48:29 [Warning] Invalid (old) table or database n Ame ' #sql -3z8g_122a#p#p3 '   111116 10:48:29 [Warning] Invalid (old) table or database name ' #sql -3z8g_122a#p#p4 ' &nbs P 111116 10:48:29 [Warning] Invalid (old) table or database name ' #sql -3z8g_122a#p#p5 '   111116 10:48:29 [Warning] Inva Lid (old) table or database name ' #sql -3z8g_122a#p#p6 '   111116 10:48:29 [Warning] Invalid (old) table or database n Ame ' #sql -3z8g_122a#p#p7 '   111116 10:48:29 [Warning] Invalid (old) table or database name ' #sql -3z8g_122a#p#p8 ' &nbs P 111116 10:48:29 [Warning] Invalid (old) table or database name ' #sql -3z8g_122a#p#p9 '   111116 10:48:29 [Warning] Inva Lid (old) table or database name ' #sql -3z8g_122a#p#p10 '   REASON #1: Any table starting with #sql is a temp table. If These tables are STill present in any database folder and the datetime stamp, simply delete them.

REASON #2: Look carefully in the suffix of each table. #P #p? resembles a partition tag. This is would indicate a attempt to create temp table using Partitiions. That ' s sounds insane. There was Bug is in the Feb, 2006 for MySQL 5.1.7-beta (closed Mar 15, 2006). The bug is based on trying to does this manually. is MySQL attempting to does this internally?

IMHO I would upgrade MySQL away from MySQL 5.1 up to MySQL 5.5


Chinanx Reference


Environment Description:
1. Error recorded in the Percona MySQL 5.5.20 version
2.5.5 version of MySQL for 5.0 from the library

The error log is as follows;
120416 2:50:19 [Warning] Invalid (old) table or database name ' #sql1f58_a_340 '
120416 2:50:19 [Warning] Invalid (old) table or database name ' #sql1f58_a_341 '

Level is a warning and no other exception was found.
View source code for Percona 5.5.20

sql/sql_table.cc
275-283 lines

if (res)
{
/* Better to give something back if we fail parsing, than no at all * *
Dbug_print ("Info", ("Error in Explain_filename:%u", res));
Sql_print_warning ("Invalid old?") Table or database name '%s ', from);
Dbug_return (To, To_length, my_snprintf)
"<result%u when explaining filename '%s ' >",
Res, from));
}


Can you elaborate on the formula you have named for the temporary table?
Previously pushed, not understood, the following is the name of the thread_id=297 manually created temporary table.
-RW-RW----1 mysql mysql 98304 18:28 #sqld0b_7_2. ibd

This temporary high likelihood of LZ is due to the large table's generation of ALTER table.


The general alter will cause the table to be rebuilt, and if the table is large, it will generally create the middle, a bit like your temporary file.
has not been applied to the temporary table for alter, just tested it, there is no error, do not know the specific reasons.

But the direct use of create temporary table will have tables structure of temporary files (*.frm, etc., the name is not the same), is also placed in/tmp below.


Was there any crash before the problem happened?
You can see if there are any of these warning in the temporary files that are open in MySQL

lsof-p MySQL pid | Grep/tmp


Warning] Invalid (old) table or database name ' #sql56c4_4f_48dc '
This problem has come on a large scale. At the same time there
ALTER TABLE T1 ADD UNIQUE idx_id (ID)


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 is still present after the thread is processed, the second step is analyzed in depth.

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.