=== modified file 'mysql-test/suite/ndb/r/ndb_partition_range.result' --- mysql-test/suite/ndb/r/ndb_partition_range.result 2008-11-04 07:43:21 +0000 +++ mysql-test/suite/ndb/r/ndb_partition_range.result 2009-01-29 09:56:48 +0000 @@ -113,8 +113,22 @@ a b c select * from t1 where a=1 and b in (1,6,10,21) order by b; a b c 1 1 1 +select * from t1 where b=6; +a b c +2 6 1 DELETE from t1 WHERE b = 6; +select * from t1 where b=6; +a b c +select * from t1 where a=6; +a b c +6 15 1 +UPDATE t1 SET c=1001 WHERE a=6; +select * from t1 where a=6; +a b c +6 15 1001 DELETE from t1 WHERE a = 6; +select * from t1 where a=6; +a b c show create table t1; Table Create Table t1 CREATE TABLE `t1` ( === modified file 'mysql-test/suite/ndb/t/ndb_partition_range.test' --- mysql-test/suite/ndb/t/ndb_partition_range.test 2007-12-18 12:40:35 +0000 +++ mysql-test/suite/ndb/t/ndb_partition_range.test 2009-01-29 10:02:36 +0000 @@ -91,8 +91,15 @@ select * from t1 where b in (1,6,10,21) select * from t1 where a in (1,2,5,6) order by b; select * from t1 where a=1 and b in (1,6,10,21) order by b; +# test for bug#42443 +select * from t1 where b=6; DELETE from t1 WHERE b = 6; +select * from t1 where b=6; +select * from t1 where a=6; +UPDATE t1 SET c=1001 WHERE a=6; +select * from t1 where a=6; DELETE from t1 WHERE a = 6; +select * from t1 where a=6; # # Test that explicit partition info _is_ shown in show create table === modified file 'sql/ha_ndbcluster.cc' --- sql/ha_ndbcluster.cc 2009-01-16 11:01:12 +0000 +++ sql/ha_ndbcluster.cc 2009-01-29 10:01:48 +0000 @@ -2207,7 +2207,7 @@ int ha_ndbcluster::ndb_pk_update_row(THD const NdbRecord *key_rec; const uchar *key_row; - if (m_user_defined_partitioning) + if (old_part_id != ~uint32(0)) { options.optionsPresent |= NdbOperation::OperationOptions::OO_PARTITION_ID; options.partitionId=old_part_id; @@ -3741,7 +3741,7 @@ int ha_ndbcluster::ndb_update_row(const NdbTransaction *trans= thd_ndb->trans; NdbScanOperation* cursor= m_active_cursor; const NdbOperation *op; - uint32 old_part_id= 0, new_part_id= 0; + uint32 old_part_id= ~uint32(0), new_part_id= ~uint32(0); int error; longlong func_value; Uint32 func_value_uint32; @@ -3780,13 +3780,29 @@ int ha_ndbcluster::ndb_update_row(const bitmap_set_bit(table->write_set, table->timestamp_field->field_index); } - if (m_use_partition_pruning && - (error= get_parts_for_update(old_data, new_data, table->record[0], - m_part_info, &old_part_id, &new_part_id, - &func_value))) + while (m_use_partition_pruning) { - m_part_info->err_value= func_value; - DBUG_RETURN(error); + if (!cursor && m_read_before_write_removal_used) + { + ndb_index_type type= get_index_type(active_index); + /* + Ndb unique indexes are global so when + m_read_before_write_removal_used is active + the unique index can be used directly for update + without finding the partitions + */ + if (type == UNIQUE_INDEX || + type == UNIQUE_ORDERED_INDEX) + break; + } + if ((error= get_parts_for_update(old_data, new_data, table->record[0], + m_part_info, &old_part_id, &new_part_id, + &func_value))) + { + m_part_info->err_value= func_value; + DBUG_RETURN(error); + } + break; } /* @@ -3823,7 +3839,7 @@ int ha_ndbcluster::ndb_update_row(const options.optionsPresent=0; /* Need to set the value of any user-defined partitioning function. */ - if (m_user_defined_partitioning) + if (new_part_id != ~uint32(0)) { if (func_value >= INT_MAX32) func_value_uint32= INT_MAX32; @@ -4021,7 +4037,7 @@ int ha_ndbcluster::ndb_delete_row(const NdbTransaction *trans= m_thd_ndb->trans; NdbScanOperation* cursor= m_active_cursor; const NdbOperation *op; - uint32 part_id; + uint32 part_id= ~uint32(0); int error; bool allow_batch= is_bulk_delete || (thd->options & OPTION_ALLOW_BATCH); DBUG_ENTER("ndb_delete_row"); @@ -4030,11 +4046,27 @@ int ha_ndbcluster::ndb_delete_row(const ha_statistic_increment(&SSV::ha_delete_count); m_rows_changed++; - if (m_use_partition_pruning && - (error= get_part_for_delete(record, table->record[0], m_part_info, - &part_id))) + while (m_use_partition_pruning) { - DBUG_RETURN(error); + if (!cursor && m_read_before_write_removal_used) + { + ndb_index_type type= get_index_type(active_index); + /* + Ndb unique indexes are global so when + m_read_before_write_removal_used is active + the unique index can be used directly for deleting + without finding the partitions + */ + if (type == UNIQUE_INDEX || + type == UNIQUE_ORDERED_INDEX) + break; + } + if ((error= get_part_for_delete(record, table->record[0], m_part_info, + &part_id))) + { + DBUG_RETURN(error); + } + break; } NdbOperation::OperationOptions options; @@ -4079,7 +4111,7 @@ int ha_ndbcluster::ndb_delete_row(const const NdbRecord *key_rec; const uchar *key_row; - if (m_user_defined_partitioning) + if (part_id != ~uint32(0)) { options.optionsPresent|= NdbOperation::OperationOptions::OO_PARTITION_ID; options.partitionId= part_id;