From 0e47753ffd450d7df9968e6365ec6ad3eca8724b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Jul 2006 13:33:23 +0400 Subject: After merge fixes for patch solving bug#18437 "Wrong values inserted with a before update trigger on NDB table". Two main changes: - We use TABLE::read_set/write_set bitmaps for marking fields used by statement instead of Field::query_id in 5.1. - Now when we mark columns used by statement we take into account columns used by table's triggers instead of marking all columns as used if table has triggers. mysql-test/r/federated.result: Changed test in order to make it work with RBR. RBR changes the way in which we execute "DELETE FROM t1" statement - we don't use handler::delete_all_rows() method if RBR is enabled (see bug#19066). As result federated engine produces different sequences of statements for remote server in non-RBR and in RBR cases. And this changes order of the rows inserted by following INSERT statements. mysql-test/t/federated.test: Changed test in order to make it work with RBR. RBR changes the way in which we execute "DELETE FROM t1" statement - we don't use handler::delete_all_rows() method if RBR is enabled (see bug#19066). As result federated engine produces different sequences of statements for remote server in non-RBR and in RBR cases. And this changes order of the rows inserted by following INSERT statements. sql/ha_partition.cc: Added handling of HA_EXTRA_WRITE_CAN_REPLACE/HA_EXTRA_WRITE_CANNOT_REPLACE to ha_partition::extra(). sql/item.cc: Adjusted comment after merge. In 5.1 we use TABLE::read_set/write_set bitmaps instead of Field::query_id for marking columns used. sql/log_event.cc: Write_rows_log_event::do_before_row_operations(): Now we explicitly inform handler that we want to replace rows so it can promote operation done by write_row() to replace. sql/mysql_priv.h: Removed declaration of mark_fields_used_by_triggers_for_insert_stmt() which is no longer used (we have TABLE::mark_columns_needed_for_insert() instead). sql/sql_insert.cc: Adjusted code after merge. Get rid of mark_fields_used_by_triggers_for_insert_stmt() as now we use TABLE::mark_columns_needed_for_insert() for the same purprose. Aligned places where we call this method with places where we call mark_fields_used_by_triggers_for_insert() in 5.0. Finally we no longer need to call handler::extra(HA_EXTRA_WRITE_CAN_REPLACE) in case of REPLACE statement since in 5.1 write_record() marks all columns as used before doing actual row replacement. sql/sql_load.cc: Adjusted code after merge. In 5.1 we use TABLE::mark_columns_needed_for_insert() instead of mark_fields_used_by_triggers_for_insert_stmt() routine. We also no longer need to call handler::extra(HA_EXTRA_RETRIEVE_ALL_COLS) if we execute LOAD DATA REPLACE since in 5.1 write_record() will mark all columns as used before doing actual row replacement. sql/sql_trigger.cc: Table_triggers_list::mark_fields_used(): We use TABLE::read_set/write_set bitmaps for marking fields used instead of Field::query_id in 5.1. sql/sql_trigger.h: TABLE::mark_columns_needed_for_* methods no longer need to be friends of Table_triggers_list class as intead of dirrectly accessing its private members they can use public Table_triggers_list::mark_fields_used() method. Also Table_triggers)list::mark_fields_used() no longer needs THD argument. sql/table.cc: TABLE::mark_columns_needed_for_*(): Now we mark columns which are really used by table's triggers instead of marking all columns as used if table has triggers. --- sql/sql_load.cc | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'sql/sql_load.cc') diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 07a33d0551d..db6e3422478 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -187,9 +187,6 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, table= table_list->table; transactional_table= table->file->has_transactions(); - if (table->found_next_number_field) - table->mark_auto_increment_column(); - if (!fields_vars.elements) { Field **field; @@ -232,7 +229,7 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, DBUG_RETURN(TRUE); } - mark_fields_used_by_triggers_for_insert_stmt(thd, table, handle_duplicates); + table->mark_columns_needed_for_insert(); uint tot_length=0; bool use_blobs= 0, use_vars= 0; @@ -364,13 +361,10 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, if (ignore || handle_duplicates == DUP_REPLACE) table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); - if (handle_duplicates == DUP_REPLACE) - { - if (!table->triggers || - !table->triggers->has_delete_triggers()) + if (handle_duplicates == DUP_REPLACE && + (!table->triggers || + !table->triggers->has_delete_triggers())) table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE); - table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); - } if (!thd->prelocked_mode) table->file->ha_start_bulk_insert((ha_rows) 0); table->copy_blobs=1; -- cgit v1.2.1