Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法关闭MySQL UDF(V5.6)中的表_Mysql - Fatal编程技术网

无法关闭MySQL UDF(V5.6)中的表

无法关闭MySQL UDF(V5.6)中的表,mysql,Mysql,我已经花了三天的时间试图解决这个问题,任何帮助都将不胜感激。我试图在MySQL的UDF中打开几个表(以InnoDB格式存储)。如果我创建一个新的THD实例并将其设置为“当前THD”,我可以打开它们。但是,我无法正确关闭这些表。我用来打开表的代码如下所示 THD *thd = new THD; thd->thread_stack = (char*) &thd; thd->set_db(db_name, strlen(db_name)); my_pthread_setspecif

我已经花了三天的时间试图解决这个问题,任何帮助都将不胜感激。我试图在MySQL的UDF中打开几个表(以InnoDB格式存储)。如果我创建一个新的THD实例并将其设置为“当前THD”,我可以打开它们。但是,我无法正确关闭这些表。我用来打开表的代码如下所示

THD *thd = new THD;
thd->thread_stack = (char*) &thd;
thd->set_db(db_name, strlen(db_name));
my_pthread_setspecific_ptr(THR_THD,  thd);

const unsigned int NUMBER_OF_TABLES = 5;
char* tableNames[NUMBER_OF_TABLES];

... set table name here ...

TABLE_LIST tables[NUMBER_OF_TABLES];
for (unsigned int i = 0; i < NUMBER_OF_TABLES; i++) 
{
  tables[i].init_one_table((char*)db_name, strlen(db_name), tableNames[i],   
                 strlen(tableNames[i]), tableNames[i], TL_WRITE_ALLOW_WRITE);
  if (i != NUMBER_OF_TABLES-1)
    tables[i].next_local = tables[i].next_global = tables + 1 + i;
  }
}
if (open_and_lock_tables(thd, tables, false, MYSQL_LOCK_IGNORE_TIMEOUT))
{
  goto end;
}
失败的断言与thd->transaction.stmt.is_empty()有关。 is_empty()方法只是检查ha_list==NULL。 我想了解如何正确关闭这些表

我正在Windows7上开发MySQL 5.6

thd->cleanup_after_query();
close_thread_tables(thd);
delete thd;