diff options
author | unknown <monty@mashka.mysql.fi> | 2003-01-28 06:48:26 +0200 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2003-01-28 06:48:26 +0200 |
commit | 72455300841e1b00c312c3a03ace3bcbd57a4d2f (patch) | |
tree | 9e418865f0fad863fd9f50122562955a2ff1b8e3 /sql | |
parent | c46c1258274f4993e5c5cc30cd0d4137d611db5f (diff) | |
download | mariadb-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')
-rw-r--r-- | sql/log.cc | 2 | ||||
-rw-r--r-- | sql/sql_base.cc | 19 |
2 files changed, 7 insertions, 14 deletions
diff --git a/sql/log.cc b/sql/log.cc index ab3277fe58b..5e5d5b9368e 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -697,7 +697,7 @@ bool MYSQL_LOG::write(Query_log_event* event_info) if (thd->last_insert_id_used) { - Intvar_log_event e((uchar)LAST_INSERT_ID_EVENT, thd->last_insert_id); + Intvar_log_event e((uchar)LAST_INSERT_ID_EVENT, thd->current_insert_id); if(thd->server_id) e.server_id = thd->server_id; if (e.write(file)) 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) { |