Note that there are some explanatory texts on larger screens.

plurals
  1. POFailed to close tables within MySQL UDF (V5.6)
    text
    copied!<p>I've spent three days trying to figure out this, any help would be appreciated. I'm trying to open few tables (stored in InnoDB format) within the UDF in MySQL. I'm able to open them if I create a new THD instance and set it to be the "current thd". However, I'm having problem to properly close these tables. The code I used to open the tables looks like this</p> <pre><code>THD *thd = new THD; thd-&gt;thread_stack = (char*) &amp;thd; thd-&gt;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 &lt; 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; } </code></pre> <p>I was able to open all tables using the above code block. However, when I finish using them, I was not able to close these tables since assertion fails. I would appreciate if anyone can help with these. I use the following code block to close the tables,</p> <pre><code>thd-&gt;cleanup_after_query(); close_thread_tables(thd); delete thd; </code></pre> <p>The failed assertion was to do with the thd->transaction.stmt.is_empty(). The is_empty() method simply checks whether ha_list == NULL. I would like to understand how can I properly close these tables??</p> <p>I'm developing on Windows 7 with MySQL 5.6. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload