diff options
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index d8838b3b03d..16aa59d992e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -833,7 +833,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, info.copied=values_list.elements; end_delayed_insert(thd); } - query_cache_invalidate3(thd, table_list, 1); } else #endif @@ -1548,6 +1547,17 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) } } } + + /* + If more than one iteration of the above while loop is done, from the second + one the row being inserted will have an explicit value in the autoinc field, + which was set at the first call of handler::update_auto_increment(). This + value is saved to avoid thd->insert_id_for_cur_row becoming 0. Use this saved + autoinc value. + */ + if (table->file->insert_id_for_cur_row == 0) + table->file->insert_id_for_cur_row= insert_id_for_cur_row; + thd->record_first_successful_insert_id_in_cur_stmt(table->file->insert_id_for_cur_row); /* Restore column maps if they where replaced during an duplicate key @@ -2538,8 +2548,13 @@ bool Delayed_insert::handle_inserts(void) thd_proc_info(&thd, "upgrading lock"); if (thr_upgrade_write_delay_lock(*thd.lock->locks)) { - /* This can only happen if thread is killed by shutdown */ - sql_print_error(ER(ER_DELAYED_CANT_CHANGE_LOCK),table->s->table_name.str); + /* + This can happen if thread is killed either by a shutdown + or if another thread is removing the current table definition + from the table cache. + */ + my_error(ER_DELAYED_CANT_CHANGE_LOCK,MYF(ME_FATALERROR), + table->s->table_name.str); goto err; } @@ -2694,9 +2709,10 @@ bool Delayed_insert::handle_inserts(void) query_cache_invalidate3(&thd, table, 1); if (thr_reschedule_write_lock(*thd.lock->locks)) { - /* This should never happen */ - sql_print_error(ER(ER_DELAYED_CANT_CHANGE_LOCK), - table->s->table_name.str); + /* This is not known to happen. */ + my_error(ER_DELAYED_CANT_CHANGE_LOCK,MYF(ME_FATALERROR), + table->s->table_name.str); + goto err; } if (!using_bin_log) table->file->extra(HA_EXTRA_WRITE_CACHE); @@ -2743,6 +2759,11 @@ bool Delayed_insert::handle_inserts(void) /* Remove all not used rows */ while ((row=rows.get())) { + if (table->s->blob_fields) + { + memcpy(table->record[0],row->record,table->s->reclength); + free_delayed_insert_blobs(table); + } delete row; thread_safe_increment(delayed_insert_errors,&LOCK_delayed_status); stacked_inserts--; @@ -3624,7 +3645,8 @@ select_create::binlog_show_create_table(TABLE **tables, uint count) tmp_table_list.table = *tables; query.length(0); // Have to zero it since constructor doesn't - result= store_create_info(thd, &tmp_table_list, &query, create_info); + result= store_create_info(thd, &tmp_table_list, &query, create_info, + /* show_database */ TRUE); DBUG_ASSERT(result == 0); /* store_create_info() always return 0 */ if (mysql_bin_log.is_open()) |