diff options
author | gkodinov/kgeorge@magare.gmz <> | 2007-07-30 18:27:36 +0300 |
---|---|---|
committer | gkodinov/kgeorge@magare.gmz <> | 2007-07-30 18:27:36 +0300 |
commit | 9a0e6ec6d2aadd14badb65aa6e5c313ce72e276e (patch) | |
tree | 3a0bd3810b778a710ddd3bc97e13539062f58cdc /sql/sql_update.cc | |
parent | b6bb988d12f7df7033cbb9cebc58036d264ad26e (diff) | |
download | mariadb-git-9a0e6ec6d2aadd14badb65aa6e5c313ce72e276e.tar.gz |
(pushing for Andrei)
Bug #27417 thd->no_trans_update.stmt lost value inside of SF-exec-stack
Once had been set the flag might later got reset inside of a stored routine
execution stack.
The reason was in that there was no check if a new statement started at time
of resetting.
The artifact affects most of binlogable DML queries. Notice, that multi-update
is wrapped up within
bug@27716 fix, multi-delete bug@29136.
Fixed with saving parent's statement flag of whether the statement modified
non-transactional table, and unioning (merging) the value with that was gained
in mysql_execute_command.
Resettling thd->no_trans_update members into thd->transaction.`member`;
Asserting code;
Effectively the following properties are held.
1. At the end of a substatement thd->transaction.stmt.modified_non_trans_table
reflects the fact if such a table got modified by the substatement.
That also respects THD::really_abort_on_warnin() requirements.
2. Eventually thd->transaction.stmt.modified_non_trans_table will be computed as
the union of the values of all invoked sub-statements.
That fixes this bug#27417;
Computing of thd->transaction.all.modified_non_trans_table is refined to base to
the stmt's value for all the case including insert .. select statement which
before the patch had an extra issue bug@28960.
Minor issues are covered with mysql_load, mysql_delete, and binloggin of insert in
to temp_table select.
The supplied test verifies limitely, mostly asserts. The ultimate testing is defered
for bug@13270, bug@23333.
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r-- | sql/sql_update.cc | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc index f4239afc4cd..e20647dc808 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -430,7 +430,6 @@ int mysql_update(THD *thd, query_id=thd->query_id; transactional_table= table->file->has_transactions(); - thd->no_trans_update.stmt= FALSE; thd->abort_on_warning= test(!ignore && (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES | @@ -487,7 +486,6 @@ int mysql_update(THD *thd, (byte*) table->record[0]))) { updated++; - thd->no_trans_update.stmt= !transactional_table; if (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, @@ -522,6 +520,10 @@ int mysql_update(THD *thd, thd->row_count++; } + if (!transactional_table && updated > 0) + thd->transaction.stmt.modified_non_trans_table= TRUE; + + /* todo bug#27571: to avoid asynchronization of `error' and `error_code' of binlog event constructor @@ -589,9 +591,10 @@ int mysql_update(THD *thd, if (mysql_bin_log.write(&qinfo) && transactional_table) error=1; // Rollback update } - if (!transactional_table) - thd->no_trans_update.all= TRUE; + if (thd->transaction.stmt.modified_non_trans_table) + thd->transaction.all.modified_non_trans_table= TRUE; } + DBUG_ASSERT(transactional_table || !updated || thd->transaction.stmt.modified_non_trans_table); free_underlaid_joins(thd, select_lex); if (transactional_table) { @@ -955,7 +958,6 @@ bool mysql_multi_update(THD *thd, handle_duplicates, ignore))) DBUG_RETURN(TRUE); - thd->no_trans_update.stmt= FALSE; thd->abort_on_warning= test(thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)); @@ -1331,9 +1333,7 @@ multi_update::~multi_update() if (copy_field) delete [] copy_field; thd->count_cuted_fields= CHECK_FIELD_IGNORE; // Restore this setting - if (!trans_safe) // todo: remove since redundant - thd->no_trans_update.all= TRUE; - DBUG_ASSERT(trans_safe || thd->no_trans_update.all); + DBUG_ASSERT(trans_safe || thd->transaction.all.modified_non_trans_table); } @@ -1426,7 +1426,7 @@ bool multi_update::send_data(List<Item> ¬_used_values) else { trans_safe= 0; - thd->no_trans_update.stmt= TRUE; + thd->transaction.stmt.modified_non_trans_table= TRUE; } if (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, @@ -1489,7 +1489,6 @@ void multi_update::send_error(uint errcode,const char *err) /* Something already updated so we have to invalidate cache */ query_cache_invalidate3(thd, update_tables, 1); - /* If all tables that has been updated are trans safe then just do rollback. If not attempt to do remaining updates. @@ -1502,7 +1501,7 @@ void multi_update::send_error(uint errcode,const char *err) } else { - DBUG_ASSERT(thd->no_trans_update.stmt); + DBUG_ASSERT(thd->transaction.stmt.modified_non_trans_table); if (do_update && table_count > 1) { /* Add warning here */ @@ -1513,7 +1512,7 @@ void multi_update::send_error(uint errcode,const char *err) VOID(do_updates(0)); } } - if (thd->no_trans_update.stmt) + if (thd->transaction.stmt.modified_non_trans_table) { /* The query has to binlog because there's a modified non-transactional table @@ -1526,9 +1525,9 @@ void multi_update::send_error(uint errcode,const char *err) mysql_bin_log.write(&qinfo); } if (!trans_safe) - thd->no_trans_update.all= TRUE; + thd->transaction.all.modified_non_trans_table= TRUE; } - DBUG_ASSERT(trans_safe || !updated || thd->no_trans_update.stmt); + DBUG_ASSERT(trans_safe || !updated || thd->transaction.stmt.modified_non_trans_table); if (transactional_tables) { @@ -1664,7 +1663,7 @@ int multi_update::do_updates(bool from_send_error) else { trans_safe= 0; // Can't do safe rollback - thd->no_trans_update.stmt= TRUE; + thd->transaction.stmt.modified_non_trans_table= TRUE; } } (void) table->file->ha_rnd_end(); @@ -1697,7 +1696,7 @@ err2: else { trans_safe= 0; - thd->no_trans_update.stmt= TRUE; + thd->transaction.stmt.modified_non_trans_table= TRUE; } } DBUG_RETURN(1); @@ -1722,7 +1721,6 @@ bool multi_update::send_eof() { query_cache_invalidate3(thd, update_tables, 1); } - /* Write the SQL statement to the binlog if we updated rows and we succeeded or if we updated some non @@ -1732,8 +1730,9 @@ bool multi_update::send_eof() either from the query's list or via a stored routine: bug#13270,23333 */ - DBUG_ASSERT(trans_safe || !updated || thd->no_trans_update.stmt); - if (local_error == 0 || thd->no_trans_update.stmt) + DBUG_ASSERT(trans_safe || !updated || + thd->transaction.stmt.modified_non_trans_table); + if (local_error == 0 || thd->transaction.stmt.modified_non_trans_table) { if (mysql_bin_log.is_open()) { @@ -1746,8 +1745,8 @@ bool multi_update::send_eof() if (mysql_bin_log.write(&qinfo) && trans_safe) local_error= 1; // Rollback update } - if (!trans_safe) - thd->no_trans_update.all= TRUE; + if (thd->transaction.stmt.modified_non_trans_table) + thd->transaction.all.modified_non_trans_table= TRUE; } if (transactional_tables) |