mysql提示[Warning] Invalid (old?) table or database name问题的解决方法
发布时间:2024-01-14 18:18:54
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.1 案例分析适用场景:单例布局1.2 方 * V视图 HTML+CSS+调试C js实现控制流程D数据 优化扩展二、代码结构&
- 如何利用网页弹出各种形式的窗口,我想大家大多都是知道些的,但那种多种多样的弹出式窗口是怎么搞出来的,我们今天就来学习一下:推荐:网页弹出窗口
- 测试代码1:def test(self): data = {"add": {"doc":
- 本文实例讲述了JS扩展方法实现技巧。分享给大家供大家参考。具体分析如下:JS扩展方法与C#的扩展方法非常相似,也是可以链式调用的,也是通过对
- 具体代码如下所示:#coding:utf-8#!/usr/bin/python3from selenium import webdriver
- 前言当我们在用python时可能会遇到想要把txt文档里的数据读取出来然后进行绘图,那么我们要怎么才能够将txt里的数据读取出来呢?假设有t
- 引言“ 这是MySQL系列笔记的第七篇,文章内容均为本人通过实践及查阅资料相关整理所得,可用作新手入门指南,或
- 背景 还是学院和专业的关系,我需要保持点击提交按钮后,页面select中继续维持提交前的值 网上有几种办法,要么通过url跳转时候附带参数形
- 在任何有监督机器学习项目的模型构建阶段,我们训练模型的目的是从标记的示例中学习所有权重和偏差的最佳值。如果我们使用相同的标记示例来测试我们的
- 最近写一个爬虫系统,需要用到python的日志记录模块,于是便学习了一下。python的标准库里的日志系统从Python2.3开始支持。只要
- 这篇文章主要为大家详细介绍了python批量爬取下载抖音视频,具有一定的参考价值,感兴趣的小伙伴们可以参考一下项目源码展示:'
- 一、应用场景为了避免反复的手手工从后台数据库导出某些数据表到Excel文件、高效率到多份离线数据。二、功能事项支持一次性导出多个数据源表、自
- 首先说明一点,每天的访问量并不大每天才2W的访问量,按道理说,访问量再增加一倍这样的服务器也应该足以承受。可是我们的服务器为什么总是这样频频
- 一、安装 → pyinstaller1.1 方式1:cmd1. 调出运行窗口:win + r, 并输入 cmd2. 切换到 pip.exe
- 近来想要做一做人脸识别相关的内容,主要是想集成一个系统,看到opencv已经集成了三种性能较好的算法,但是还是想自己动手试一下,毕竟算法都比
- 一、表结构TABLE personidname1你2你(一个空格)3你(二个空格)二、查询与结果select * from person w
- 装tensorflow-gpu的时候经常遇到问题,自己装过几次,经常遇到相同或者类似的问题,所以打算记录一下,也希望对其他人有所帮助基本信息
- 命令解释@echo on开户回显,默认开启@echo off关闭回显这个命令一般写在第一行,意思就是当你开启回显的时候,执行命令时,会先把你
- 记录训练过程history=model.fit(X_train, Y_train, epochs=epochs,batch_size=bat
- 大小写字母转换:函数 uc (uppercase) 将所有的小写字母转成大写;函数 lc (lowercase) 将所有的大写字母转成小写;