diff options
author | unknown <monty@mysql.com> | 2003-12-19 16:34:48 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2003-12-19 16:34:48 +0200 |
commit | 245b1385a10a12a955c95338b08190cac5cfcbd4 (patch) | |
tree | 05b144ca850fc0bb99c1922907bfb2e9ba19fc77 /sql/sql_update.cc | |
parent | 060122db13c995908835ca338aeeab848024e266 (diff) | |
parent | 9c2a63e35eec7a1af94dde1f10331361124a69f4 (diff) | |
download | mariadb-git-245b1385a10a12a955c95338b08190cac5cfcbd4.tar.gz |
merge
client/mysqldump.c:
Auto merged
client/mysqltest.c:
Auto merged
include/my_global.h:
Auto merged
libmysqld/lib_sql.cc:
Auto merged
mysql-test/r/warnings.result:
Auto merged
mysql-test/t/type_enum.test:
Auto merged
sql/field.cc:
Auto merged
sql/lex.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_show.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
sql/table.cc:
Auto merged
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r-- | sql/sql_update.cc | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 95dff107350..7dc537768f3 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -352,6 +352,8 @@ int mysql_update(THD *thd, mysql_update_log.write(thd,thd->query,thd->query_length); if (mysql_bin_log.is_open()) { + if (error <= 0) + thd->clear_error(); Query_log_event qinfo(thd, thd->query, thd->query_length, log_delayed); if (mysql_bin_log.write(&qinfo) && transactional_table) @@ -473,7 +475,7 @@ multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list, :all_tables(table_list), update_tables(0), thd(thd_arg), tmp_tables(0), updated(0), found(0), fields(field_list), values(value_list), table_count(0), copy_field(0), handle_duplicates(handle_duplicates_arg), - do_update(1), trans_safe(0) + do_update(1), trans_safe(0), transactional_tables(1) {} @@ -577,6 +579,27 @@ int multi_update::prepare(List<Item> ¬_used_values, for (i=0 ; i < table_count ; i++) set_if_bigger(max_fields, fields_for_table[i]->elements); copy_field= new Copy_field[max_fields]; + + /* + Mark all copies of tables that are updates to ensure that + init_read_record() will not try to enable a cache on them + + The problem is that for queries like + + UPDATE t1, t1 AS t2 SET t1.b=t2.c WHERE t1.a=t2.a; + + the row buffer may contain things that doesn't match what is on disk + which will cause an error when reading a row. + (This issue is mostly relevent for MyISAM tables) + */ + for (table_ref= all_tables; table_ref; table_ref=table_ref->next) + { + TABLE *table=table_ref->table; + if (!(tables_to_update & table->map) && + find_real_table_in_list(update_tables, table_ref->db, + table_ref->real_name)) + table->no_cache= 1; // Disable row cache + } DBUG_RETURN(thd->is_fatal_error != 0); } @@ -718,7 +741,7 @@ multi_update::~multi_update() { TABLE_LIST *table; for (table= update_tables ; table; table= table->next) - table->table->no_keyread=0; + table->table->no_keyread= table->table->no_cache= 0; if (tmp_tables) { @@ -853,8 +876,11 @@ int multi_update::do_updates(bool from_send_error) ha_rows org_updated; TABLE *table; DBUG_ENTER("do_updates"); + - do_update= 0; // Don't retry this function + do_update= 0; // Don't retry this function + if (!found) + DBUG_RETURN(0); for (cur_table= update_tables; cur_table ; cur_table= cur_table->next) { table = cur_table->table; @@ -981,6 +1007,8 @@ bool multi_update::send_eof() mysql_update_log.write(thd,thd->query,thd->query_length); if (mysql_bin_log.is_open()) { + if (local_error <= 0) + thd->clear_error(); Query_log_event qinfo(thd, thd->query, thd->query_length, log_delayed); if (mysql_bin_log.write(&qinfo) && trans_safe) |