国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

mysql提示[Warning] Invalid (old?) table or database name問題的解決方

2024-07-24 12:49:11
字體:
來源:轉載
供稿:網友
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 */
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 调兵山市| 息烽县| 赞皇县| 特克斯县| 青阳县| 阿瓦提县| 湖口县| 南召县| 香港 | 安新县| 喀喇| 呼玛县| 奈曼旗| 当阳市| 武平县| 阳原县| 永善县| 清丰县| 九龙城区| 六盘水市| 邻水| 出国| 奉化市| 高尔夫| 辽中县| 简阳市| 邢台市| 杭锦旗| 青冈县| 三明市| 山西省| 达尔| 黄平县| 年辖:市辖区| 阿拉善右旗| 萝北县| 保山市| 通化县| 阿克| 宁远县| 左贡县|