From 226700ee51a827bf1271225394628a3d65a0dc79 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Dec 2007 22:15:02 +0300 Subject: Make handler::{write,delete,update}_row private. It's critical that the entire server uses their public ha_* counterparts instead, since only then we can ensure proper tracing of these calls that is necessary for Bug#12713. A pre-requisite for Bug#12713 "Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem" sql/ha_partition.cc: Use ha_write_row, ha_update_row, ha_delete_row instead of now-private write_row, update_row, delete_row. In future ha_* calls will contain more than just a call to the binary log, so it's essential they are used consistently everywhere in the server. Disable the undesired effect of double binary logging of changes to partitioned tables with tmp_disable_binlog. sql/handler.h: Make write_row, update_row, delete_row private. It's critical that the entire code base uses ha_write_row, ha_update_row, ha_delete_row instead -- in future, ha_* counterparts will have more common functionality than just a call to the binary log. sql/sql_select.cc: Use ha_write_row, ha_update_row, ha_delete_row instead of write_row, update_row, delete_row respectively. The change affects the join execution code that works with an intermediate internal temporary table. Do not disable binary logging, since it's unnecessary - temporary tables are not replicated by row level replication. sql/sql_table.cc: Use ha_write_row in copy_data_between_tables - the function that writes data from the original table to a temporary copy when executing ALTER TABLE. Do not disable binary logging since temporary tables are not replicated by row level replication anyway. --- sql/sql_select.cc | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'sql/sql_select.cc') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 93486aa7b65..cde9d501f83 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -10554,13 +10554,13 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, */ while (!table->file->rnd_next(new_table.record[1])) { - write_err= new_table.file->write_row(new_table.record[1]); + write_err= new_table.file->ha_write_row(new_table.record[1]); DBUG_EXECUTE_IF("raise_error", write_err= HA_ERR_FOUND_DUPP_KEY ;); if (write_err) goto err; } /* copy row that filled HEAP table */ - if ((write_err=new_table.file->write_row(table->record[0]))) + if ((write_err=new_table.file->ha_write_row(table->record[0]))) { if (new_table.file->is_fatal_error(write_err, HA_CHECK_DUP) || !ignore_last_dupp_key_error) @@ -12023,7 +12023,7 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), { int error; join->found_records++; - if ((error=table->file->write_row(table->record[0]))) + if ((error=table->file->ha_write_row(table->record[0]))) { if (!table->file->is_fatal_error(error, HA_CHECK_DUP)) goto end; @@ -12085,8 +12085,8 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), { /* Update old record */ restore_record(table,record[1]); update_tmptable_sum_func(join->sum_funcs,table); - if ((error=table->file->update_row(table->record[1], - table->record[0]))) + if ((error=table->file->ha_update_row(table->record[1], + table->record[0]))) { table->file->print_error(error,MYF(0)); /* purecov: inspected */ DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */ @@ -12109,7 +12109,7 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), } init_tmptable_sum_functions(join->sum_funcs); copy_funcs(join->tmp_table_param.items_to_copy); - if ((error=table->file->write_row(table->record[0]))) + if ((error=table->file->ha_write_row(table->record[0]))) { if (create_myisam_from_heap(join->thd, table, &join->tmp_table_param, error, 0)) @@ -12145,7 +12145,7 @@ end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), copy_fields(&join->tmp_table_param); // Groups are copied twice. copy_funcs(join->tmp_table_param.items_to_copy); - if (!(error=table->file->write_row(table->record[0]))) + if (!(error=table->file->ha_write_row(table->record[0]))) join->send_records++; // New group else { @@ -12161,8 +12161,8 @@ end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), } restore_record(table,record[1]); update_tmptable_sum_func(join->sum_funcs,table); - if ((error=table->file->update_row(table->record[1], - table->record[0]))) + if ((error=table->file->ha_update_row(table->record[1], + table->record[0]))) { table->file->print_error(error,MYF(0)); /* purecov: inspected */ DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */ @@ -12205,7 +12205,7 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), join->sum_funcs_end[send_group_parts]); if (!join->having || join->having->val_int()) { - int error= table->file->write_row(table->record[0]); + int error= table->file->ha_write_row(table->record[0]); if (error && create_myisam_from_heap(join->thd, table, &join->tmp_table_param, error, 0)) @@ -13433,7 +13433,7 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field, } if (having && !having->val_int()) { - if ((error=file->delete_row(record))) + if ((error=file->ha_delete_row(record))) goto err; error=file->rnd_next(record); continue; @@ -13460,7 +13460,7 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field, } if (compare_record(table, first_field) == 0) { - if ((error=file->delete_row(record))) + if ((error=file->ha_delete_row(record))) goto err; } else if (!found) @@ -13557,7 +13557,7 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table, } if (having && !having->val_int()) { - if ((error=file->delete_row(record))) + if ((error=file->ha_delete_row(record))) goto err; continue; } @@ -13574,7 +13574,7 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table, if (hash_search(&hash, org_key_pos, key_length)) { /* Duplicated found ; Remove the row */ - if ((error=file->delete_row(record))) + if ((error=file->ha_delete_row(record))) goto err; } else @@ -15582,7 +15582,7 @@ int JOIN::rollup_write_data(uint idx, TABLE *table_arg) item->save_in_result_field(1); } copy_sum_funcs(sum_funcs_end[i+1], sum_funcs_end[i]); - if ((write_error= table_arg->file->write_row(table_arg->record[0]))) + if ((write_error= table_arg->file->ha_write_row(table_arg->record[0]))) { if (create_myisam_from_heap(thd, table_arg, &tmp_table_param, write_error, 0)) -- cgit v1.2.1 From 0fbc29c197d931fdcf99c071e3ac1e31bf8761ee Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Dec 2007 21:16:55 +0300 Subject: A pre-requisite for the fix for Bug#12713 "Error in a stored function called from a SELECT doesn't cause ROLLBACK of state" Make private all class handler methods (PSEA API) that may modify data. Introduce and deploy public ha_* wrappers for these methods in all sql/. This necessary to keep track of all data modifications in sql/, which is in turn necessary to be able to optimize two-phase commit of those transactions that do not modify data. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sql/ha_partition.cc: Class ha_partition is no longer a friend of class handler. Use the public handler interface (handler::ha_ methods) for partition operations. Remove unnecessary casts from char[] to const char *.ppзи выафвыаafa sql/handler.cc: Function ha_create_table() is no longer a friend of class handler. Use public handler::change_table_ptr() to access private members. This fixes a subtle bug (no test case in the test suite) when a deletion error occurs inside one partition of a partitioned engine. The old code would crash in handler::print_error() in this case. Implement the newly introduced public ha_* wrappers of the private virtual handler methods. sql/handler.h: Introduce ha_* wrappers to all class handler methods that may modify data. This is necessary to be able to keep track of data modifying operations of class handler and optimize read-only transactions. sql/item_sum.cc: delete_all_rows -> ha_delete_all_rows sql/sql_base.cc: Use the new public wrappers. sql/sql_delete.cc: delete_all_rows -> ha_delete_all_rows sql/sql_partition.cc: Use the new public wrappers. sql/sql_select.cc: delete_all_rows -> ha_delete_all_rows delete_table -> ha_delete_table disabe_indexes -> ha_disable_idnexes sql/sql_show.cc: delete_all_rows -> ha_delete_all_rows sql/sql_table.cc: Use the public wrappers for class handler DDL methods. All methods which may change handler data are now accessed via a public wrapper. sql/sql_union.cc: delete_all_rows -> ha_delete_all_rows {enable,disable}_indexes -> ha_{enable,disable}_indexes sql/sql_update.cc: bulk_update_row -> ha_bulk_update_row sql/unireg.cc: create_handler_files -> ha_create_handler_files --- sql/sql_select.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sql/sql_select.cc') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index cde9d501f83..7421bdabcdb 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1534,14 +1534,14 @@ JOIN::reinit() if (exec_tmp_table1) { exec_tmp_table1->file->extra(HA_EXTRA_RESET_STATE); - exec_tmp_table1->file->delete_all_rows(); + exec_tmp_table1->file->ha_delete_all_rows(); free_io_cache(exec_tmp_table1); filesort_free_buffers(exec_tmp_table1,0); } if (exec_tmp_table2) { exec_tmp_table2->file->extra(HA_EXTRA_RESET_STATE); - exec_tmp_table2->file->delete_all_rows(); + exec_tmp_table2->file->ha_delete_all_rows(); free_io_cache(exec_tmp_table2); filesort_free_buffers(exec_tmp_table2,0); } @@ -10467,9 +10467,9 @@ free_tmp_table(THD *thd, TABLE *entry) if (entry->file) { if (entry->db_stat) - entry->file->drop_table(entry->s->table_name.str); + entry->file->ha_drop_table(entry->s->table_name.str); else - entry->file->delete_table(entry->s->table_name.str); + entry->file->ha_delete_table(entry->s->table_name.str); delete entry->file; } @@ -10525,7 +10525,7 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, if (open_tmp_table(&new_table)) goto err1; if (table->file->indexes_are_disabled()) - new_table.file->disable_indexes(HA_KEY_SWITCH_ALL); + new_table.file->ha_disable_indexes(HA_KEY_SWITCH_ALL); table->file->ha_index_or_rnd_end(); table->file->ha_rnd_init(1); if (table->no_rows) @@ -10591,7 +10591,7 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, (void) table->file->ha_rnd_end(); (void) new_table.file->close(); err1: - new_table.file->delete_table(new_table.s->table_name.str); + new_table.file->ha_delete_table(new_table.s->table_name.str); err2: delete new_table.file; thd->proc_info=save_proc_info; -- cgit v1.2.1