Commit 0a79eedb authored by unknown's avatar unknown

sql_delete.cc, sql_update.cc, sql_class.h:

  Simplification of the previous fix for multi-update/delete.


sql/sql_class.h:
  Simplification of the previous fix for multi-update/delete.
sql/sql_update.cc:
  Simplification of the previous fix for multi-update/delete.
sql/sql_delete.cc:
  Simplification of the previous fix for multi-update/delete.
parent b196f030
...@@ -844,11 +844,10 @@ class multi_delete : public select_result ...@@ -844,11 +844,10 @@ class multi_delete : public select_result
TABLE_LIST *delete_tables, *table_being_deleted; TABLE_LIST *delete_tables, *table_being_deleted;
Unique **tempfiles; Unique **tempfiles;
THD *thd; THD *thd;
ha_rows deleted; ha_rows deleted, found;
uint num_of_tables; uint num_of_tables;
int error; int error;
bool do_delete, transactional_tables, log_delayed, normal_tables; bool do_delete, transactional_tables, log_delayed, normal_tables;
bool tempfiles_inited;
public: public:
multi_delete(THD *thd, TABLE_LIST *dt, uint num_of_tables); multi_delete(THD *thd, TABLE_LIST *dt, uint num_of_tables);
...@@ -876,7 +875,6 @@ class multi_update : public select_result ...@@ -876,7 +875,6 @@ class multi_update : public select_result
Copy_field *copy_field; Copy_field *copy_field;
enum enum_duplicates handle_duplicates; enum enum_duplicates handle_duplicates;
bool do_update, trans_safe, transactional_tables, log_delayed; bool do_update, trans_safe, transactional_tables, log_delayed;
bool tmp_tables_inited;
public: public:
multi_update(THD *thd_arg, TABLE_LIST *ut, List<Item> *fields, multi_update(THD *thd_arg, TABLE_LIST *ut, List<Item> *fields,
......
...@@ -234,10 +234,9 @@ extern "C" int refposcmp2(void* arg, const void *a,const void *b) ...@@ -234,10 +234,9 @@ extern "C" int refposcmp2(void* arg, const void *a,const void *b)
multi_delete::multi_delete(THD *thd_arg, TABLE_LIST *dt, multi_delete::multi_delete(THD *thd_arg, TABLE_LIST *dt,
uint num_of_tables_arg) uint num_of_tables_arg)
: delete_tables(dt), thd(thd_arg), deleted(0), : delete_tables(dt), thd(thd_arg), deleted(0), found(0),
num_of_tables(num_of_tables_arg), error(0), num_of_tables(num_of_tables_arg), error(0),
do_delete(0), transactional_tables(0), log_delayed(0), normal_tables(0), do_delete(0), transactional_tables(0), log_delayed(0), normal_tables(0)
tempfiles_inited(0)
{ {
tempfiles = (Unique **) sql_calloc(sizeof(Unique *) * (num_of_tables-1)); tempfiles = (Unique **) sql_calloc(sizeof(Unique *) * (num_of_tables-1));
} }
...@@ -298,7 +297,6 @@ multi_delete::initialize_tables(JOIN *join) ...@@ -298,7 +297,6 @@ multi_delete::initialize_tables(JOIN *join)
table->file->ref_length, table->file->ref_length,
MEM_STRIP_BUF_SIZE); MEM_STRIP_BUF_SIZE);
} }
tempfiles_inited= 1;
init_ftfuncs(thd,1); init_ftfuncs(thd,1);
DBUG_RETURN(thd->fatal_error != 0); DBUG_RETURN(thd->fatal_error != 0);
} }
...@@ -339,6 +337,7 @@ bool multi_delete::send_data(List<Item> &values) ...@@ -339,6 +337,7 @@ bool multi_delete::send_data(List<Item> &values)
continue; continue;
table->file->position(table->record[0]); table->file->position(table->record[0]);
found++;
if (secure_counter < 0) if (secure_counter < 0)
{ {
...@@ -414,7 +413,7 @@ int multi_delete::do_deletes(bool from_send_error) ...@@ -414,7 +413,7 @@ int multi_delete::do_deletes(bool from_send_error)
if (from_send_error) if (from_send_error)
{ {
/* Found out table number for 'table_being_deleted' */ /* Found out table number for 'table_being_deleted*/
for (TABLE_LIST *aux=delete_tables; for (TABLE_LIST *aux=delete_tables;
aux != table_being_deleted; aux != table_being_deleted;
aux=aux->next) aux=aux->next)
...@@ -424,7 +423,7 @@ int multi_delete::do_deletes(bool from_send_error) ...@@ -424,7 +423,7 @@ int multi_delete::do_deletes(bool from_send_error)
table_being_deleted = delete_tables; table_being_deleted = delete_tables;
do_delete= 0; do_delete= 0;
if (!tempfiles_inited) if (!found)
DBUG_RETURN(0); DBUG_RETURN(0);
for (table_being_deleted=table_being_deleted->next; for (table_being_deleted=table_being_deleted->next;
table_being_deleted ; table_being_deleted ;
......
...@@ -440,7 +440,7 @@ multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list, ...@@ -440,7 +440,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), :all_tables(table_list), update_tables(0), thd(thd_arg), tmp_tables(0),
updated(0), found(0), fields(field_list), values(value_list), updated(0), found(0), fields(field_list), values(value_list),
table_count(0), copy_field(0), handle_duplicates(handle_duplicates_arg), table_count(0), copy_field(0), handle_duplicates(handle_duplicates_arg),
do_update(1), trans_safe(0), tmp_tables_inited(0) do_update(1), trans_safe(0)
{} {}
...@@ -622,7 +622,6 @@ multi_update::initialize_tables(JOIN *join) ...@@ -622,7 +622,6 @@ multi_update::initialize_tables(JOIN *join)
DBUG_RETURN(1); DBUG_RETURN(1);
tmp_tables[cnt]->file->extra(HA_EXTRA_WRITE_CACHE); tmp_tables[cnt]->file->extra(HA_EXTRA_WRITE_CACHE);
} }
tmp_tables_inited= 1;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -823,7 +822,7 @@ int multi_update::do_updates(bool from_send_error) ...@@ -823,7 +822,7 @@ int multi_update::do_updates(bool from_send_error)
do_update= 0; // Don't retry this function do_update= 0; // Don't retry this function
if (!tmp_tables_inited) if (!found)
DBUG_RETURN(0); DBUG_RETURN(0);
for (cur_table= update_tables; cur_table ; cur_table= cur_table->next) for (cur_table= update_tables; cur_table ; cur_table= cur_table->next)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment