summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-01-28 06:48:26 +0200
committerunknown <monty@mashka.mysql.fi>2003-01-28 06:48:26 +0200
commit72455300841e1b00c312c3a03ace3bcbd57a4d2f (patch)
tree9e418865f0fad863fd9f50122562955a2ff1b8e3 /sql/sql_base.cc
parentc46c1258274f4993e5c5cc30cd0d4137d611db5f (diff)
downloadmariadb-git-72455300841e1b00c312c3a03ace3bcbd57a4d2f.tar.gz
Fix when using auto_increment and last_insert_id() in the same insert statement.
sql/sql_base.cc: S
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc19
1 files changed, 6 insertions, 13 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index fb120442385..bab4c151ef3 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -522,26 +522,19 @@ 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;
-
LINT_INIT(end);
- 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)
+ if (!thd->temporary_tables)
return; // no tables to close
+ query_buf_size= 11; // "drop table "
+ for (table=thd->temporary_tables ; table ; table=table->next)
+ query_buf_size+= table->key_length +1;
+
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 table ");
for (table=thd->temporary_tables ; table ; table=next)
{