SHOW TABLES遇到命令执行期间遇到的致命错误

时间:2013-08-21 05:58:15

标签: c# mysql

在代码中,我删除一个表然后创建表,并在一个服务器的多个数据库中执行相同的操作,一切正常。然后我使用 SQL“SHOW TABLES”查询表,有时这个sql抛出异常:Fatal error encountered during command execution,有时它可以正常工作。我确信这不是由 COMMAND TIMEOUT 引发的。应该是其他原因。

这里是drop table和create table sql:

DROP TABLE IF EXISTS `a`;
CREATE TABLE IF NOT EXISTS `a`
SELECT 
  id,
  IF (mapping.name IS NULL, ne.autoname, mapping.name) AS autoname FROM b ne
LEFT JOIN test.a_mapping mapping ON ne.autoName = mapping.autoname;
ALTER TABLE `a` ADD INDEX `id_idx` (`id`); 
DELETE FROM `a` WHERE id = 1000000; 
INSERT INTO `a`(id, autoname) VALUES(1000000, @count);

这是show tables代码:

  MySqlDataReader dataReader = null;
    try{            
        MySqlCommand cmd = new MySqlCommand(MySqlUtils.SQL_GET_TABLES, connection);
        cmd.CommandTimeout = BaseOptimonConfig.Instance.CommandTimeout;
        dataReader = MySqlUtils.ExecuteReader(cmd); // just add try catch in this method.
        while (dataReader.Read())
        {
            if (MySqlUtils.GetSqlString(dataReader, 0).ToLower().Equals(tableName))
            {
                return true;
            }
        }
    }
    finally
    {
        MySqlUtils.CloseSqlReader(dataReader);
    }

0 个答案:

没有答案