===== sql_delete.cc 1.194 vs edited ===== --- 1.194/sql/sql_delete.cc 2007-03-23 17:12:56 +02:00 +++ edited/sql_delete.cc 2007-04-05 11:07:12 +03:00 @@ -211,6 +211,9 @@ bool mysql_delete(THD *thd, TABLE_LIST * init_ftfuncs(thd, select_lex, 1); thd->proc_info="updating"; + if (!thd->in_sub_stmt) + thd->no_trans_update.stmt= FALSE; + if (table->triggers) table->triggers->mark_fields_used(thd, TRG_EVENT_DELETE); @@ -531,9 +534,9 @@ multi_delete::initialize_tables(JOIN *jo tbl->no_cache= 1; tbl->used_keys.clear_all(); if (tbl->file->has_transactions()) - transactional_tables= 1; + transactional_tables= 1; else - normal_tables= 1; + normal_tables= 1; if (tbl->triggers) tbl->triggers->mark_fields_used(thd, TRG_EVENT_DELETE); } @@ -548,6 +551,9 @@ multi_delete::initialize_tables(JOIN *jo delete_while_scanning= 0; } } + if (!thd->in_sub_stmt) + thd->no_trans_update.stmt= FALSE; + walk= delete_tables; tempfiles_ptr= tempfiles; if (delete_while_scanning) @@ -613,20 +619,22 @@ bool multi_delete::send_data(List if (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_DELETE, TRG_ACTION_BEFORE, FALSE)) - DBUG_RETURN(1); + DBUG_RETURN(1); table->status|= STATUS_DELETED; if (!(error=table->file->delete_row(table->record[0]))) { - deleted++; + deleted++; + if (!table->file->has_transactions()) + thd->no_trans_update.stmt= TRUE; if (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_DELETE, TRG_ACTION_AFTER, FALSE)) - DBUG_RETURN(1); + DBUG_RETURN(1); } else { - table->file->print_error(error,MYF(0)); - DBUG_RETURN(1); + table->file->print_error(error,MYF(0)); + DBUG_RETURN(1); } } else @@ -634,8 +642,8 @@ bool multi_delete::send_data(List error=tempfiles[secure_counter]->unique_add((char*) table->file->ref); if (error) { - error= 1; // Fatal error - DBUG_RETURN(1); + error= 1; // Fatal error + DBUG_RETURN(1); } } } @@ -776,6 +784,7 @@ bool multi_delete::send_eof() */ if (deleted) { + DBUG_ASSERT(!thd->no_trans_update.stmt || normal_tables); query_cache_invalidate3(thd, delete_tables, 1); } @@ -788,7 +797,7 @@ bool multi_delete::send_eof() Query_log_event qinfo(thd, thd->query, thd->query_length, transactional_tables, FALSE); if (mysql_bin_log.write(&qinfo) && !normal_tables) - local_error=1; // Log write failed: roll back the SQL statement + local_error=1; // Log write failed: roll back the SQL statement } if (!transactional_tables) thd->no_trans_update.all= TRUE; ===== sql_insert.cc 1.227 vs edited ===== --- 1.227/sql/sql_insert.cc 2007-03-24 17:16:49 +02:00 +++ edited/sql_insert.cc 2007-03-30 21:14:05 +03:00 @@ -584,7 +584,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *t if (lock_type != TL_WRITE_DELAYED && !thd->prelocked_mode) table->file->start_bulk_insert(values_list.elements); - thd->no_trans_update.stmt= FALSE; + if (!thd->in_sub_stmt) + thd->no_trans_update.stmt= FALSE; thd->abort_on_warning= (!ignore && (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))); ===== sql_update.cc 1.213 vs edited ===== --- 1.213/sql/sql_update.cc 2007-03-23 17:12:56 +02:00 +++ edited/sql_update.cc 2007-04-05 22:13:16 +03:00 @@ -429,7 +429,8 @@ int mysql_update(THD *thd, query_id=thd->query_id; transactional_table= table->file->has_transactions(); - thd->no_trans_update.stmt= FALSE; + if (!thd->in_sub_stmt) + thd->no_trans_update.stmt= FALSE; thd->abort_on_warning= test(!ignore && (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES | @@ -474,7 +475,8 @@ int mysql_update(THD *thd, (byte*) table->record[0]))) { updated++; - thd->no_trans_update.stmt= !transactional_table; + if (!transactional_table) + thd->no_trans_update.stmt= TRUE; /* only thru if */ if (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, @@ -910,7 +912,8 @@ bool mysql_multi_update(THD *thd, handle_duplicates, ignore))) DBUG_RETURN(TRUE); - thd->no_trans_update.stmt= FALSE; + if (!thd->in_sub_stmt) + thd->no_trans_update.stmt= FALSE; thd->abort_on_warning= test(thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)); @@ -1268,12 +1271,12 @@ bool multi_update::send_data(List *values_for_table[offset], 0, table->triggers, TRG_EVENT_UPDATE)) - DBUG_RETURN(1); + DBUG_RETURN(1); found++; if (!can_compare_record || compare_record(table, thd->query_id)) { - int error; + int error; if ((error= cur_table->view_check_option(thd, ignore)) != VIEW_CHECK_OK) { @@ -1283,31 +1286,31 @@ bool multi_update::send_data(List else if (error == VIEW_CHECK_ERROR) DBUG_RETURN(1); } - if (!updated++) - { - /* - Inform the main table that we are going to update the table even - while we may be scanning it. This will flush the read cache - if it's used. - */ - main_table->file->extra(HA_EXTRA_PREPARE_FOR_UPDATE); - } - if ((error=table->file->update_row(table->record[1], - table->record[0]))) - { - updated--; + if (!updated++) + { + /* + Inform the main table that we are going to update the table even + while we may be scanning it. This will flush the read cache + if it's used. + */ + main_table->file->extra(HA_EXTRA_PREPARE_FOR_UPDATE); + } + if ((error=table->file->update_row(table->record[1], + table->record[0]))) + { + updated--; if (!ignore || error != HA_ERR_FOUND_DUPP_KEY) - { + { /* If (ignore && error == HA_ERR_FOUND_DUPP_KEY) we don't have to do anything; otherwise... */ if (error != HA_ERR_FOUND_DUPP_KEY) thd->fatal_error(); /* Other handler errors are fatal */ - table->file->print_error(error,MYF(0)); - DBUG_RETURN(1); - } - } + table->file->print_error(error,MYF(0)); + DBUG_RETURN(1); + } + } else { if (!table->file->has_transactions()) @@ -1315,7 +1318,7 @@ bool multi_update::send_data(List if (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, TRG_ACTION_AFTER, TRUE)) - DBUG_RETURN(1); + DBUG_RETURN(1); } } } @@ -1334,10 +1337,10 @@ bool multi_update::send_data(List error != HA_ERR_FOUND_DUPP_UNIQUE && create_myisam_from_heap(thd, tmp_table, tmp_table_param + offset, error, 1)) - { - do_update=0; - DBUG_RETURN(1); // Not a table_is_full error - } + { + do_update=0; + DBUG_RETURN(1); // Not a table_is_full error + } } else found++; @@ -1519,7 +1522,7 @@ bool multi_update::send_eof() thd->proc_info= "end"; /* We must invalidate the query cache before binlog writing and - ha_autocommit_... */ + ha_autocommit_... */x if (updated) {