summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 38dfcbdaa7a..49c858b7a16 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -497,13 +497,14 @@ void close_temporary_tables(THD *thd)
TABLE *table,*next;
uint init_query_buf_size = 11, query_buf_size; // "drop table "
char* query, *p;
+ bool found_user_tables = 0;
+
LINT_INIT(p);
query_buf_size = init_query_buf_size;
for (table=thd->temporary_tables ; table ; table=table->next)
{
query_buf_size += table->key_length;
-
}
if(query_buf_size == init_query_buf_size)
@@ -519,15 +520,20 @@ void close_temporary_tables(THD *thd)
{
if(query) // we might be out of memory, but this is not fatal
{
- p = strxmov(p,table->table_cache_key,".",
+ // skip temporary tables not created directly by the user
+ if(table->table_name[0] != '#')
+ {
+ p = strxmov(p,table->table_cache_key,".",
table->table_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;
+ }
}
next=table->next;
close_temporary(table);
}
- if (query && mysql_bin_log.is_open())
+ if (query && found_user_tables && mysql_bin_log.is_open())
{
uint save_query_len = thd->query_length;
*--p = 0;