diff options
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 3b46c53f75c..838cf70f08d 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -539,26 +539,20 @@ void close_temporary_tables(THD *thd) { TABLE *table,*next; char *query, *end; - const uint init_query_buf_size = 11; // "drop table " uint query_buf_size; bool found_user_tables = 0; + if (!thd->temporary_tables) + return; + LINT_INIT(end); - query_buf_size = init_query_buf_size; + query_buf_size= 50; // Enough for DROP ... TABLE for (table=thd->temporary_tables ; table ; table=table->next) - { query_buf_size += table->key_length; - } - - if (query_buf_size == init_query_buf_size) - return; // no tables to close if ((query = alloc_root(&thd->mem_root, query_buf_size))) - { - memcpy(query, "drop table ", init_query_buf_size); - end = query + init_query_buf_size; - } + end=strmov(query, "DROP /*!40005 TEMPORARY */ TABLE "); for (table=thd->temporary_tables ; table ; table=next) { @@ -567,12 +561,14 @@ void close_temporary_tables(THD *thd) // skip temporary tables not created directly by the user if (table->real_name[0] != '#') { - end = strxmov(end,table->table_cache_key,".", - table->real_name,",", NullS); - // here we assume table_cache_key always starts - // with \0 terminated db name + /* + Here we assume table_cache_key always starts + with \0 terminated db name + */ found_user_tables = 1; } + end = strxmov(end,table->table_cache_key,".", + table->real_name,",", NullS); } next=table->next; close_temporary(table); @@ -580,7 +576,7 @@ void close_temporary_tables(THD *thd) if (query && found_user_tables && mysql_bin_log.is_open()) { /* The -1 is to remove last ',' */ - Query_log_event qinfo(thd, query, (ulong)(end-query)-1); + Query_log_event qinfo(thd, query, (ulong)(end-query)-1, 0); qinfo.error_code=0; mysql_bin_log.write(&qinfo); } |