diff options
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r-- | sql/sql_update.cc | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 5776cba7e96..6c868b542d1 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -613,10 +613,12 @@ bool multi_update::send_data(List<Item> &values) } else { -// Here I insert into each temporary table - values_by_table.push_front(new Item_string(table->file->ref,table->file->ref_length)); + // Here we insert into each temporary table + values_by_table.push_front(new Item_string((char*) table->file->ref, + table->file->ref_length)); fill_record(tmp_tables[secure_counter]->field,values_by_table); - error= write_record(tmp_tables[secure_counter],&(infos[secure_counter])); + error= write_record(tmp_tables[secure_counter], + &(infos[secure_counter])); if (error) { error=-1; @@ -661,7 +663,8 @@ int multi_update::do_updates (bool from_send_error) { int error = 0, counter = 0; - if (num_updated == 1) return 0; + if (num_updated == 1) + return 0; if (from_send_error) { /* Found out table number for 'table_being_updated' */ @@ -690,7 +693,7 @@ int multi_update::do_updates (bool from_send_error) } List<Item> list; Field **ptr=tmp_table->field,*field; -// This is supposed to be something like insert_fields + // This is supposed to be something like insert_fields thd->used_tables|=tmp_table->map; while ((field = *ptr++)) { @@ -709,12 +712,14 @@ int multi_update::do_updates (bool from_send_error) (!thd->killed || from_send_error || not_trans_safe)) { found++; - error= table->file->rnd_pos(table->record[0], (*(tmp_table->field))->ptr); + error= table->file->rnd_pos(table->record[0], + (byte*) (*(tmp_table->field))->ptr); if (error) return error; table->status|= STATUS_UPDATED; store_record(table,1); - error= fill_record(*fields_by_tables[counter + 1],list) /*|| compare_record(table, query_id)*/ || + error= fill_record(*fields_by_tables[counter + 1],list) || + /* compare_record(table, query_id) || */ table->file->update_row(table->record[1],table->record[0]); if (error) { @@ -731,40 +736,47 @@ int multi_update::do_updates (bool from_send_error) } +/* out: 1 if error, 0 if success */ + bool multi_update::send_eof() { - thd->proc_info="updating the reference tables"; /* out: 1 if error, 0 if success */ + thd->proc_info="updating the reference tables"; /* Does updates for the last n - 1 tables, returns 0 if ok */ int error = do_updates(false); /* do_updates returns 0 if success */ /* reset used flags */ -// update_tables->table->no_keyread=0; - if (error == -1) error = 0; +#ifndef NOT_USED + update_tables->table->no_keyread=0; +#endif + if (error == -1) + error = 0; thd->proc_info="end"; if (error) send_error(error,"An error occured in multi-table update"); - /* Write the SQL statement to the binlog if we updated - rows and we succeeded, or also in an error case when there - was a non-transaction-safe table involved, since - modifications in it cannot be rolled back. */ + /* + Write the SQL statement to the binlog if we updated + rows and we succeeded, or also in an error case when there + was a non-transaction-safe table involved, since + modifications in it cannot be rolled back. + */ if (updated || not_trans_safe) { mysql_update_log.write(thd,thd->query,thd->query_length); Query_log_event qinfo(thd, thd->query); - /* mysql_bin_log is not open if binlogging or replication - is not used */ + /* + mysql_bin_log is not open if binlogging or replication + is not used + */ if (mysql_bin_log.is_open() && mysql_bin_log.write(&qinfo) && !not_trans_safe) - error=1; /* Log write failed: roll back - the SQL statement */ + error=1; /* Log write failed: roll back the SQL statement */ /* Commit or rollback the current SQL statement */ - VOID(ha_autocommit_or_rollback(thd,error > 0)); } else @@ -777,8 +789,8 @@ bool multi_update::send_eof() if (updated) query_cache.invalidate(update_tables); ::send_ok(&thd->net, - (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated, - thd->insert_id_used ? thd->insert_id() : 0L,buff); + (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated, + thd->insert_id_used ? thd->insert_id() : 0L,buff); } thd->count_cuted_fields=0; return 0; |