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/ha_partition.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'sql/ha_partition.cc') diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 7929257d608..2a3589bf65c 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4665,6 +4665,27 @@ int ha_partition::extra(enum ha_extra_function operation) */ break; } + case HA_EXTRA_WRITE_CAN_REPLACE: + case HA_EXTRA_WRITE_CANNOT_REPLACE: + { + /* + Informs handler that write_row() can replace rows which conflict + with row being inserted by PK/unique key without reporting error + to the SQL-layer. + + This optimization is not safe for partitioned table in general case + since we may have to put new version of row into partition which is + different from partition in which old version resides (for example + when we partition by non-PK column or by some column which is not + part of unique key which were violated). + And since NDB which is the only engine at the moment that supports + this optimization handles partitioning on its own we simple disable + it here. (BTW for NDB this optimization is safe since it supports + only KEY partitioning and won't use this optimization for tables + which have additional unique constraints). + */ + break; + } default: { /* Temporary crash to discover what is wrong */ -- cgit v1.2.1