From: Pekka Nousiainen Date: August 30 2011 6:47pm Subject: bzr push into mysql-5.1-telco-7.0-wl4124-new2 branch (pekka.nousiainen:4473 to 4474) WL#4124 List-Archive: http://lists.mysql.com/commits/140860 Message-Id: <20110830184728.A6B6A5587A@sama.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 4474 Pekka Nousiainen 2011-08-30 wl#4124 g02_rir.diff optimizer RIR sets weird HA_READ_KEY_EXACT modified: mysql-test/suite/ndb/r/ndb_statistics1.result sql/ha_ndb_index_stat.cc sql/ha_ndb_index_stat.h sql/ha_ndbcluster.cc sql/ha_ndbcluster.h storage/ndb/src/ndbapi/NdbIndexStat.cpp 4473 Pekka Nousiainen 2011-08-29 [merge] merge telco-7.0 to wl4124-new2 added: storage/ndb/src/kernel/vm/mt_thr_config.cpp storage/ndb/src/kernel/vm/mt_thr_config.hpp modified: .bzr-mysql/default.conf mysql-test/suite/ndb/r/ndb_index_stat.result mysql-test/suite/ndb/r/ndb_statistics1.result mysql-test/suite/ndb/t/ndb_index_stat.test sql/ha_ndbcluster.cc sql/ha_ndbcluster_binlog.cc sql/ha_ndbinfo.cc storage/ndb/include/util/SparseBitmask.hpp storage/ndb/src/kernel/SimBlockList.cpp storage/ndb/src/kernel/blocks/dbspj/Dbspj.hpp storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp storage/ndb/src/kernel/vm/Configuration.cpp storage/ndb/src/kernel/vm/Configuration.hpp storage/ndb/src/kernel/vm/Makefile.am storage/ndb/src/kernel/vm/SimulatedBlock.cpp storage/ndb/src/kernel/vm/SimulatedBlock.hpp storage/ndb/src/kernel/vm/dummy_nonmt.cpp storage/ndb/src/kernel/vm/mt.cpp storage/ndb/src/kernel/vm/mt.hpp storage/ndb/src/ndbapi/NdbQueryOperation.cpp storage/ndb/src/ndbapi/NdbQueryOperation.hpp storage/ndb/src/ndbapi/NdbQueryOperationImpl.hpp === modified file 'mysql-test/suite/ndb/r/ndb_statistics1.result' --- a/mysql-test/suite/ndb/r/ndb_statistics1.result 2011-08-29 14:35:32 +0000 +++ b/mysql-test/suite/ndb/r/ndb_statistics1.result 2011-08-30 18:35:08 +0000 @@ -57,11 +57,11 @@ id select_type table type possible_keys EXPLAIN SELECT * FROM t10000 WHERE k >= 42 and k < 10000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 2 Using where with pushed condition +1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 9958 Using where with pushed condition EXPLAIN SELECT * FROM t10000 WHERE k BETWEEN 42 AND 10000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 2 Using where with pushed condition +1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 9958 Using where with pushed condition EXPLAIN SELECT * FROM t10000 WHERE k < 42; id select_type table type possible_keys key key_len ref rows Extra @@ -95,11 +95,11 @@ id select_type table type possible_keys EXPLAIN SELECT * FROM t100 WHERE k BETWEEN 42 AND 10000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t100 range PRIMARY PRIMARY 4 NULL 2 Using where with pushed condition +1 SIMPLE t100 range PRIMARY PRIMARY 4 NULL 58 Using where with pushed condition EXPLAIN SELECT * FROM t10000 WHERE k BETWEEN 42 AND 10000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 2 Using where with pushed condition +1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 9958 Using where with pushed condition EXPLAIN SELECT * FROM t10000 WHERE I = 0; id select_type table type possible_keys key key_len ref rows Extra @@ -127,7 +127,7 @@ id select_type table type possible_keys EXPLAIN SELECT * FROM t10000 WHERE I = 0 AND J BETWEEN 1 AND 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t10000 range J,I J 5 NULL 2 Using where with pushed condition +1 SIMPLE t10000 range J,I I 10 NULL 2 Using where with pushed condition EXPLAIN SELECT * FROM t10000 WHERE I = 0 AND J = 1; id select_type table type possible_keys key key_len ref rows Extra @@ -147,7 +147,7 @@ id select_type table type possible_keys EXPLAIN SELECT * FROM t10000 WHERE J = 0 AND K BETWEEN 1 AND 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t10000 ref PRIMARY,J J 5 const 2 Using where with pushed condition +1 SIMPLE t10000 range PRIMARY,J J 9 NULL 2 Using where with pushed condition EXPLAIN SELECT * FROM t10000 WHERE J = 0 AND K = 1; id select_type table type possible_keys key key_len ref rows Extra === modified file 'sql/ha_ndb_index_stat.cc' --- a/sql/ha_ndb_index_stat.cc 2011-08-16 11:53:13 +0000 +++ b/sql/ha_ndb_index_stat.cc 2011-08-30 18:35:08 +0000 @@ -2030,20 +2030,21 @@ int ha_ndbcluster::ndb_index_stat_query(uint inx, const key_range *min_key, const key_range *max_key, - NdbIndexStat::Stat& stat) + NdbIndexStat::Stat& stat, + int from) { DBUG_ENTER("ha_ndbcluster::ndb_index_stat_query"); const KEY *key_info= table->key_info + inx; const NDB_INDEX_DATA &data= m_index[inx]; const NDBINDEX *index= data.index; - DBUG_PRINT("index_stat", ("index: %s", index->getName())); + DBUG_PRINT("index_stat", ("index: %u name: %s", inx, index->getName())); int err= 0; /* Create an IndexBound struct for the keys */ NdbIndexScanOperation::IndexBound ib; - compute_index_bounds(ib, key_info, min_key, max_key); + compute_index_bounds(ib, key_info, min_key, max_key, from); ib.range_no= 0; Ndb_index_stat *st= @@ -2096,12 +2097,11 @@ ha_ndbcluster::ndb_index_stat_get_rir(ui DBUG_ENTER("ha_ndbcluster::ndb_index_stat_get_rir"); uint8 stat_buffer[NdbIndexStat::StatBufferBytes]; NdbIndexStat::Stat stat(stat_buffer); - int err= ndb_index_stat_query(inx, min_key, max_key, stat); + int err= ndb_index_stat_query(inx, min_key, max_key, stat, 1); if (err == 0) { double rir= -1.0; NdbIndexStat::get_rir(stat, &rir); - DBUG_PRINT("index_stat", ("stat rir: %.2f", rir)); ha_rows rows= ndb_index_stat_round(rir); /* Estimate only so cannot return exact zero */ if (rows == 0) @@ -2125,7 +2125,7 @@ ha_ndbcluster::ndb_index_stat_set_rpk(ui NdbIndexStat::Stat stat(stat_buffer); const key_range *min_key= 0; const key_range *max_key= 0; - err= ndb_index_stat_query(inx, min_key, max_key, stat); + err= ndb_index_stat_query(inx, min_key, max_key, stat, 2); if (err == 0) { uint k; === modified file 'sql/ha_ndb_index_stat.h' --- a/sql/ha_ndb_index_stat.h 2011-08-11 17:11:30 +0000 +++ b/sql/ha_ndb_index_stat.h 2011-08-30 18:35:08 +0000 @@ -40,7 +40,8 @@ extern long g_ndb_status_index_stat_cach void compute_index_bounds(NdbIndexScanOperation::IndexBound & bound, const KEY *key_info, - const key_range *start_key, const key_range *end_key); + const key_range *start_key, const key_range *end_key, + int from); /* error codes local to ha_ndb */ === modified file 'sql/ha_ndbcluster.cc' --- a/sql/ha_ndbcluster.cc 2011-08-28 13:29:22 +0000 +++ b/sql/ha_ndbcluster.cc 2011-08-30 18:35:08 +0000 @@ -3732,11 +3732,37 @@ count_key_columns(const KEY *key_info, c } /* Helper method to compute NDB index bounds. Note: does not set range_no. */ +/* Stats queries may differ so add "from" 0:normal 1:RIR 2:RPK. */ void compute_index_bounds(NdbIndexScanOperation::IndexBound & bound, const KEY *key_info, - const key_range *start_key, const key_range *end_key) + const key_range *start_key, const key_range *end_key, + int from) { + DBUG_ENTER("ha_ndbcluster::compute_index_bounds"); + DBUG_PRINT("info", ("from: %d", from)); + +#ifndef DBUG_OFF + DBUG_PRINT("info", ("key parts: %u length: %u", + key_info->key_parts, key_info->key_length)); + { + for (uint j= 0; j <= 1; j++) + { + const key_range* kr= (j == 0 ? start_key : end_key); + if (kr) + { + DBUG_PRINT("info", ("key range %u: length: %u map: %lx flag: %d", + j, kr->length, kr->keypart_map, kr->flag)); + DBUG_DUMP("key", kr->key, kr->length); + } + else + { + DBUG_PRINT("info", ("key range %u: none", j)); + } + } + } +#endif + if (start_key) { bound.low_key= (const char*)start_key->key; @@ -3751,13 +3777,15 @@ compute_index_bounds(NdbIndexScanOperati bound.low_key_count= 0; } + /* RIR query for x >= 1 inexplicably passes HA_READ_KEY_EXACT. */ if (start_key && (start_key->flag == HA_READ_KEY_EXACT || - start_key->flag == HA_READ_PREFIX_LAST)) + start_key->flag == HA_READ_PREFIX_LAST) && + from != 1) { - bound.high_key= bound.low_key; - bound.high_key_count= bound.low_key_count; - bound.high_inclusive= TRUE; + bound.high_key= bound.low_key; + bound.high_key_count= bound.low_key_count; + bound.high_inclusive= TRUE; } else if (end_key) { @@ -3783,11 +3811,14 @@ compute_index_bounds(NdbIndexScanOperati bound.high_key= NULL; bound.high_key_count= 0; } - DBUG_PRINT("info", ("start_flag=0x%x end_flag=0x%x" + DBUG_PRINT("info", ("start_flag=%d end_flag=%d" " lo_keys=%d lo_incl=%d hi_keys=%d hi_incl=%d", start_key?start_key->flag:0, end_key?end_key->flag:0, - bound.low_key_count, bound.low_inclusive, - bound.high_key_count, bound.high_inclusive)); + bound.low_key_count, + bound.low_key_count?bound.low_inclusive:0, + bound.high_key_count, + bound.high_key_count?bound.high_inclusive:0)); + DBUG_VOID_RETURN; } /** @@ -3853,7 +3884,8 @@ int ha_ndbcluster::ordered_index_scan(co (descending? end_key : start_key), (descending? - start_key : end_key)); + start_key : end_key), + 0); bound.range_no = 0; pbound = &bound; } @@ -11881,7 +11913,8 @@ ha_ndbcluster::records_in_range(uint inx compute_index_bounds(ib, key_info, min_key, - max_key); + max_key, + 0); ib.range_no= 0; @@ -13514,7 +13547,7 @@ ha_ndbcluster::read_multi_range_first(KE /* Include this range in the ordered index scan. */ NdbIndexScanOperation::IndexBound bound; - compute_index_bounds(bound, key_info, &r->start_key, &r->end_key); + compute_index_bounds(bound, key_info, &r->start_key, &r->end_key, 0); bound.range_no= i; if (m_multi_cursor->setBound(m_index[active_index].ndb_record_key, === modified file 'sql/ha_ndbcluster.h' --- a/sql/ha_ndbcluster.h 2011-07-23 14:35:37 +0000 +++ b/sql/ha_ndbcluster.h 2011-08-30 18:35:08 +0000 @@ -861,7 +861,8 @@ private: int ndb_index_stat_query(uint inx, const key_range *min_key, const key_range *max_key, - NdbIndexStat::Stat& stat); + NdbIndexStat::Stat& stat, + int from); int ndb_index_stat_get_rir(uint inx, key_range *min_key, key_range *max_key, === modified file 'storage/ndb/src/ndbapi/NdbIndexStat.cpp' --- a/storage/ndb/src/ndbapi/NdbIndexStat.cpp 2011-08-11 17:11:30 +0000 +++ b/storage/ndb/src/ndbapi/NdbIndexStat.cpp 2011-08-30 18:35:08 +0000 @@ -548,7 +548,7 @@ NdbIndexStat::convert_range(Range& range const NdbRecord* key_record, const NdbIndexScanOperation::IndexBound* ib) { - DBUG_ENTER("NdbIndexStatImpl::convert_range"); + DBUG_ENTER("NdbIndexStat::convert_range"); Bound& bound1_f = range_f.m_bound1; Bound& bound2_f = range_f.m_bound2; NdbIndexStatImpl::Bound& bound1 = @@ -625,7 +625,11 @@ NdbIndexStat::get_rir(const Stat& stat_f x = 1.0; require(rir != 0); *rir = x; - DBUG_PRINT("index_stat", ("rir:%.2f", *rir)); +#ifndef DBUG_OFF + char buf[100]; + sprintf(buf, "%.2f", *rir); +#endif + DBUG_PRINT("index_stat", ("rir:%s", buf)); DBUG_VOID_RETURN; } @@ -640,7 +644,11 @@ NdbIndexStat::get_rpk(const Stat& stat_f x = 1.0; require(rpk != 0); *rpk = x; - DBUG_PRINT("index_stat", ("rpk[%u]:%.2f", k, *rpk)); +#ifndef DBUG_OFF + char buf[100]; + sprintf(buf, "%.2f", *rpk); +#endif + DBUG_PRINT("index_stat", ("rpk[%u]:%s", k, buf)); DBUG_VOID_RETURN; } No bundle (reason: useless for push emails).