3457 jonas oreland 2011-09-02 [merge]
ndb - merge 70-spj into 55
modified:
mysql-test/suite/ndb/r/ndb_join_pushdown.result
mysql-test/suite/ndb/t/ndb_join_pushdown.test
sql/ha_ndbcluster_push.cc
3456 jonas oreland 2011-09-02 [merge]
ndb - merge 71 into 5.5
modified:
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_ndb_index_stat.cc
sql/ha_ndb_index_stat.h
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.h
storage/ndb/src/ndbapi/NdbIndexStat.cpp
storage/ndb/src/ndbapi/NdbIndexStatImpl.cpp
storage/ndb/src/ndbapi/ndberror.c
3455 jonas oreland 2011-09-02
ndb - fix ndb_alter_table_error which failed due to different locking in 5.5 than in 5.1...
modified:
sql/ha_ndbcluster.cc
=== modified file 'mysql-test/suite/ndb/r/ndb_index_stat.result'
--- a/mysql-test/suite/ndb/r/ndb_index_stat.result 2011-09-02 07:40:42 +0000
+++ b/mysql-test/suite/ndb/r/ndb_index_stat.result 2011-09-02 09:16:56 +0000
@@ -487,6 +487,67 @@ id select_type table type possible_keys
1 SIMPLE t1 ref PRIMARY,a1 a1 5 const 2 #
1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.b1 50 #
drop table t1, t2;
+CREATE TABLE t1(
+K INT NOT NULL AUTO_INCREMENT,
+I INT,
+J INT,
+L INT,
+PRIMARY KEY(K),
+KEY(I,J),
+KEY(L)
+) ENGINE=ndbcluster
+partition by key (K) partitions 1;
+INSERT INTO t1(I,J,L) VALUES
+(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),
+(6,6,6),(7,7,7),(8,8,8),(9,9,9),(0,0,0);
+INSERT INTO t1(I,J,L) SELECT I,1,I FROM t1;
+INSERT INTO t1(I,J,L) SELECT I,2,I FROM t1;
+INSERT INTO t1(I,J,L) SELECT I,3,I FROM t1;
+INSERT INTO t1(I,J,L) SELECT I,4,I FROM t1;
+INSERT INTO t1(I,J,L) SELECT I,5,I FROM t1;
+INSERT INTO t1(I,J,L) SELECT I,6,I FROM t1;
+INSERT INTO t1(I,J,L) SELECT I,7,I FROM t1;
+INSERT INTO t1(I,J,L) SELECT I,8,I FROM t1;
+select i, count(*) from t1 group by 1 order by 1;
+i count(*)
+0 256
+1 256
+2 256
+3 256
+4 256
+5 256
+6 256
+7 256
+8 256
+9 256
+select l, count(*) from t1 group by 1 order by 1;
+l count(*)
+0 256
+1 256
+2 256
+3 256
+4 256
+5 256
+6 256
+7 256
+8 256
+9 256
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+explain SELECT count(*) as Count FROM t1 WHERE I = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref I I 5 const 256 Using where with pushed condition
+SELECT count(*) as Count FROM t1 WHERE I = 5;
+Count
+256
+explain SELECT count(*) as Count FROM t1 WHERE L = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref L L 5 const 256 Using where with pushed condition
+SELECT count(*) as Count FROM t1 WHERE L = 5;
+Count
+256
+drop table t1;
set @is_enable = @is_enable_default;
set @is_enable = NULL;
# is_enable_on=0 is_enable_off=1
=== modified file 'mysql-test/suite/ndb/r/ndb_join_pushdown.result'
--- a/mysql-test/suite/ndb/r/ndb_join_pushdown.result 2011-08-25 07:17:03 +0000
+++ b/mysql-test/suite/ndb/r/ndb_join_pushdown.result 2011-09-02 09:16:56 +0000
@@ -5178,6 +5178,55 @@ pw 4 4 5
wh 1 1 2
drop table t1;
drop table t2;
+create table t1 (
+a char(10) primary key,
+b char(10) not null,
+c char(10) not null,
+l00 char(255) not null,
+l01 char(255) not null,
+l02 char(255) not null,
+l03 char(255) not null,
+l04 char(255) not null,
+l05 char(255) not null,
+l06 char(255) not null,
+l07 char(255) not null,
+l08 char(255) not null,
+l09 char(255) not null,
+l10 char(255) not null,
+l11 char(255) not null,
+l12 char(255) not null,
+l13 char(255) not null,
+l14 char(255) not null,
+l15 char(255) not null,
+l16 char(255) not null,
+l17 char(255) not null,
+l18 char(255) not null,
+l19 char(255) not null,
+l20 char(255) not null,
+l21 char(255) not null,
+l22 char(255) not null,
+l23 char(255) not null,
+l24 char(255) not null,
+l25 char(255) not null,
+l26 char(255) not null,
+l27 char(255) not null,
+l28 char(255) not null,
+l29 char(255) not null,
+l30 char(255) not null,
+l31 char(255) not null,
+index(c, b)
+) engine=ndb partition by key(a) partitions 8;
+insert into t1 values ('a','a','a','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x');
+insert into t1 values ('b','b','b','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x');
+insert into t1 values ('c','c','c','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x');
+explain select count(*) from t1 as x1 join t1 as x2 on x1.b = x2.c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE x1 ALL NULL NULL NULL NULL 3 Parent of 2 pushed join@1
+1 SIMPLE x2 ref c c 10 test.x1.b 1 Child of 'x1' in pushed join@1
+select count(*) from t1 as x1 join t1 as x2 on x1.b = x2.c;
+count(*)
+3
+drop table t1;
create temporary table spj_counts_at_end
select counter_name, sum(val) as val
from ndbinfo.counters
@@ -5193,13 +5242,13 @@ and spj_counts_at_end.counter_name <> 'L
and spj_counts_at_end.counter_name <> 'SCAN_BATCHES_RETURNED';
counter_name spj_counts_at_end.val - spj_counts_at_startup.val
CONST_PRUNED_RANGE_SCANS_RECEIVED 6
-LOCAL_TABLE_SCANS_SENT 236
+LOCAL_TABLE_SCANS_SENT 244
PRUNED_RANGE_SCANS_RECEIVED 25
RANGE_SCANS_RECEIVED 720
READS_NOT_FOUND 6616
READS_RECEIVED 52
-SCAN_ROWS_RETURNED 76380
-TABLE_SCANS_RECEIVED 236
+SCAN_ROWS_RETURNED 76386
+TABLE_SCANS_RECEIVED 244
select sum(spj_counts_at_end.val - spj_counts_at_startup.val) as 'LOCAL+REMOTE READS_SENT'
from spj_counts_at_end, spj_counts_at_startup
where spj_counts_at_end.counter_name = spj_counts_at_startup.counter_name
@@ -5211,15 +5260,15 @@ drop table spj_save_counts;
drop table spj_counts_at_startup;
drop table spj_counts_at_end;
scan_count
-2520
+2524
pruned_scan_count
8
sorted_scan_count
10
pushed_queries_defined
-383
+385
pushed_queries_dropped
11
pushed_queries_executed
-534
+535
set ndb_join_pushdown = @save_ndb_join_pushdown;
=== modified file 'mysql-test/suite/ndb/r/ndb_statistics1.result'
--- a/mysql-test/suite/ndb/r/ndb_statistics1.result 2011-09-02 07:40:42 +0000
+++ b/mysql-test/suite/ndb/r/ndb_statistics1.result 2011-09-02 09:16:56 +0000
@@ -59,15 +59,15 @@ 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 9959 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
-1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 42 Using where with pushed condition
+1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 41 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
@@ -81,7 +81,7 @@ id select_type table type possible_keys
EXPLAIN
SELECT * FROM t100 WHERE k < 42;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t100 range PRIMARY PRIMARY 4 NULL 42 Using where with pushed condition
+1 SIMPLE t100 range PRIMARY PRIMARY 4 NULL 41 Using where with pushed condition
EXPLAIN
SELECT * FROM t100 WHERE k > 42;
id select_type table type possible_keys key key_len ref rows Extra
@@ -89,7 +89,7 @@ id select_type table type possible_keys
EXPLAIN
SELECT * FROM t10000 WHERE k < 42;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 42 Using where with pushed condition
+1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 41 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
@@ -97,11 +97,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 59 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 9959 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
@@ -129,7 +129,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
@@ -149,7 +149,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 'mysql-test/suite/ndb/t/ndb_index_stat.test'
--- a/mysql-test/suite/ndb/t/ndb_index_stat.test 2011-08-28 13:29:22 +0000
+++ b/mysql-test/suite/ndb/t/ndb_index_stat.test 2011-09-02 06:43:38 +0000
@@ -334,5 +334,45 @@ explain select * from t1, t2 where b2 =
drop table t1, t2;
+# bugXXXXX rule b3.3 fix
+
+CREATE TABLE t1(
+ K INT NOT NULL AUTO_INCREMENT,
+ I INT,
+ J INT,
+ L INT,
+ PRIMARY KEY(K),
+ KEY(I,J),
+ KEY(L)
+) ENGINE=ndbcluster
+ partition by key (K) partitions 1;
+
+INSERT INTO t1(I,J,L) VALUES
+(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),
+(6,6,6),(7,7,7),(8,8,8),(9,9,9),(0,0,0);
+
+INSERT INTO t1(I,J,L) SELECT I,1,I FROM t1;
+INSERT INTO t1(I,J,L) SELECT I,2,I FROM t1;
+INSERT INTO t1(I,J,L) SELECT I,3,I FROM t1;
+INSERT INTO t1(I,J,L) SELECT I,4,I FROM t1;
+INSERT INTO t1(I,J,L) SELECT I,5,I FROM t1;
+INSERT INTO t1(I,J,L) SELECT I,6,I FROM t1;
+INSERT INTO t1(I,J,L) SELECT I,7,I FROM t1;
+INSERT INTO t1(I,J,L) SELECT I,8,I FROM t1;
+
+select i, count(*) from t1 group by 1 order by 1;
+select l, count(*) from t1 group by 1 order by 1;
+
+ANALYZE TABLE t1;
+
+explain SELECT count(*) as Count FROM t1 WHERE I = 5;
+SELECT count(*) as Count FROM t1 WHERE I = 5;
+
+# before fix rows was 128 instead of 256
+explain SELECT count(*) as Count FROM t1 WHERE L = 5;
+SELECT count(*) as Count FROM t1 WHERE L = 5;
+
+drop table t1;
+
set @is_enable = @is_enable_default;
source ndb_index_stat_enable.inc;
=== modified file 'mysql-test/suite/ndb/t/ndb_join_pushdown.test'
--- a/mysql-test/suite/ndb/t/ndb_join_pushdown.test 2011-06-28 14:27:57 +0000
+++ b/mysql-test/suite/ndb/t/ndb_join_pushdown.test 2011-09-01 12:22:14 +0000
@@ -3641,6 +3641,63 @@ drop table t1;
drop table t2;
########################################
+# Test query with very long records.
+connection ddl;
+create table t1 (
+ a char(10) primary key,
+ b char(10) not null,
+ c char(10) not null,
+ l00 char(255) not null,
+ l01 char(255) not null,
+ l02 char(255) not null,
+ l03 char(255) not null,
+ l04 char(255) not null,
+ l05 char(255) not null,
+ l06 char(255) not null,
+ l07 char(255) not null,
+ l08 char(255) not null,
+ l09 char(255) not null,
+ l10 char(255) not null,
+ l11 char(255) not null,
+ l12 char(255) not null,
+ l13 char(255) not null,
+ l14 char(255) not null,
+ l15 char(255) not null,
+ l16 char(255) not null,
+ l17 char(255) not null,
+ l18 char(255) not null,
+ l19 char(255) not null,
+ l20 char(255) not null,
+ l21 char(255) not null,
+ l22 char(255) not null,
+ l23 char(255) not null,
+ l24 char(255) not null,
+ l25 char(255) not null,
+ l26 char(255) not null,
+ l27 char(255) not null,
+ l28 char(255) not null,
+ l29 char(255) not null,
+ l30 char(255) not null,
+ l31 char(255) not null,
+ index(c, b)
+) engine=ndb partition by key(a) partitions 8;
+
+connection spj;
+
+insert into t1 values ('a','a','a','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x');
+
+insert into t1 values ('b','b','b','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x');
+
+insert into t1 values ('c','c','c','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x');
+
+explain select count(*) from t1 as x1 join t1 as x2 on x1.b = x2.c;
+
+select count(*) from t1 as x1 join t1 as x2 on x1.b = x2.c;
+
+connection ddl;
+drop table t1;
+
+########################################
# Verify DBSPJ counters for entire test:
# Note: These tables are 'temporary' withing 'connection spj'
=== modified file 'sql/ha_ndb_index_stat.cc'
--- a/sql/ha_ndb_index_stat.cc 2011-08-17 10:36:01 +0000
+++ b/sql/ha_ndb_index_stat.cc 2011-09-02 09:01:29 +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,18 +2097,21 @@ 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)
rows= 1;
*rows_out= rows;
- DBUG_PRINT("index_stat", ("rir: %u", (uint)rows));
+#ifndef DBUG_OFF
+ char rule[NdbIndexStat::RuleBufferBytes];
+ NdbIndexStat::get_rule(stat, rule);
+#endif
+ DBUG_PRINT("index_stat", ("rir: %u rule: %s", (uint)rows, rule));
DBUG_RETURN(0);
}
DBUG_RETURN(err);
@@ -2125,7 +2129,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;
@@ -2135,7 +2139,11 @@ ha_ndbcluster::ndb_index_stat_set_rpk(ui
NdbIndexStat::get_rpk(stat, k, &rpk);
ulonglong recs= ndb_index_stat_round(rpk);
key_info->rec_per_key[k]= (ulong)recs;
- DBUG_PRINT("index_stat", ("rpk[%u]: %u", k, (uint)recs));
+#ifndef DBUG_OFF
+ char rule[NdbIndexStat::RuleBufferBytes];
+ NdbIndexStat::get_rule(stat, rule);
+#endif
+ DBUG_PRINT("index_stat", ("rpk[%u]: %u rule: %s", k, (uint)recs, rule));
}
DBUG_RETURN(0);
}
=== 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-31 10:53:27 +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-09-02 08:09:35 +0000
+++ b/sql/ha_ndbcluster.cc 2011-09-02 09:16:56 +0000
@@ -4089,11 +4089,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;
@@ -4108,9 +4134,11 @@ 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;
@@ -4140,11 +4168,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;
}
/**
@@ -4194,7 +4225,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;
}
@@ -12229,7 +12261,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;
@@ -13870,7 +13903,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;
const NdbRecord *key_rec= m_index[active_index].ndb_record_key;
=== modified file 'sql/ha_ndbcluster.h'
--- a/sql/ha_ndbcluster.h 2011-08-31 10:39:08 +0000
+++ b/sql/ha_ndbcluster.h 2011-09-02 09:16:56 +0000
@@ -650,7 +650,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 'sql/ha_ndbcluster_push.cc'
--- a/sql/ha_ndbcluster_push.cc 2011-07-04 08:38:03 +0000
+++ b/sql/ha_ndbcluster_push.cc 2011-09-02 09:16:56 +0000
@@ -282,14 +282,15 @@ NdbQuery* ndb_pushed_join::make_query_in
* after the keyFieldParams[].
*/
uint outer_fields= get_field_referrences_count();
+ NdbQueryParamValue* extendedParams = NULL;
if (unlikely(outer_fields > 0))
{
uint size= sizeof(NdbQueryParamValue) * (paramCnt+outer_fields);
- NdbQueryParamValue* extendedParams = reinterpret_cast<NdbQueryParamValue*>(alloca(size));
+ extendedParams = reinterpret_cast<NdbQueryParamValue*>(my_alloca(size));
// Copy specified keyFieldParams[] first
for (uint i= 0; i < paramCnt; i++)
{
- extendedParams[i]= keyFieldParams[i];
+ new (extendedParams + i) NdbQueryParamValue(keyFieldParams[i]);
}
// There may be referrences to Field values from tables outside the scope of
@@ -298,12 +299,20 @@ NdbQuery* ndb_pushed_join::make_query_in
{
Field* field= m_referred_fields[i];
DBUG_ASSERT(!field->is_real_null()); // Checked by ::check_if_pushable()
- extendedParams[paramCnt+i]= NdbQueryParamValue(field->ptr, false);
+ new (extendedParams + paramCnt + i) NdbQueryParamValue(field->ptr, false);
}
paramValues= extendedParams;
}
NdbQuery* query= trans->createQuery(&get_query_def(), paramValues);
+ if (unlikely(extendedParams != NULL))
+ {
+ for (uint i = 0; i < paramCnt + outer_fields; i++)
+ {
+ extendedParams[i].~NdbQueryParamValue();
+ }
+ my_afree(extendedParams);
+ }
DBUG_RETURN(query);
}
=== modified file 'storage/ndb/src/ndbapi/NdbIndexStat.cpp'
--- a/storage/ndb/src/ndbapi/NdbIndexStat.cpp 2011-08-17 10:36:01 +0000
+++ b/storage/ndb/src/ndbapi/NdbIndexStat.cpp 2011-09-02 09:01:29 +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;
}
=== modified file 'storage/ndb/src/ndbapi/NdbIndexStatImpl.cpp'
--- a/storage/ndb/src/ndbapi/NdbIndexStatImpl.cpp 2011-08-17 10:36:01 +0000
+++ b/storage/ndb/src/ndbapi/NdbIndexStatImpl.cpp 2011-09-02 09:01:29 +0000
@@ -1506,16 +1506,32 @@ NdbIndexStatImpl::cache_insert(Con& con)
const Uint8* rir_ptr = &cacheValuePtr[0];
Uint32 rir;
memcpy(&rir, rir_ptr, 4);
- assert(rir != 0);
+ if (!(rir != 0))
+ {
+ setError(InvalidCache, __LINE__);
+ return -1;
+ }
Uint32 unq_prev = 0;
for (uint k = 0; k < c.m_keyAttrs; k++)
{
Uint8* unq_ptr = &cacheValuePtr[4 + k * 4];
Uint32 unq;
memcpy(&unq, unq_ptr, 4);
- assert(unq != 0);
- assert(rir >= unq);
- assert(unq >= unq_prev);
+ if (!(unq != 0))
+ {
+ setError(InvalidCache, __LINE__);
+ return -1;
+ }
+ if (!(rir >= unq))
+ {
+ setError(InvalidCache, __LINE__);
+ return -1;
+ }
+ if (!(unq >= unq_prev))
+ {
+ setError(InvalidCache, __LINE__);
+ return -1;
+ }
unq_prev = unq;
}
}
@@ -1713,6 +1729,34 @@ NdbIndexStatImpl::cache_verify(const Cac
setError(InvalidCache, __LINE__);
return -1;
}
+ const Uint8* ptr1 = c.get_valueptr(pos1);
+ const Uint8* ptr2 = c.get_valueptr(pos2);
+ Uint32 rir1;
+ Uint32 rir2;
+ memcpy(&rir1, &ptr1[0], 4);
+ memcpy(&rir2, &ptr2[0], 4);
+ if (!(rir1 < rir2))
+ {
+ setError(InvalidCache, __LINE__);
+ return -1;
+ }
+ for (uint k = 0; k < c.m_keyAttrs; k++)
+ {
+ Uint32 unq1;
+ Uint32 unq2;
+ memcpy(&unq1, &ptr1[4 + k * 4], 4);
+ memcpy(&unq2, &ptr2[4 + k * 4], 4);
+ if (!(unq1 <= unq2))
+ {
+ setError(InvalidCache, __LINE__);
+ return -1;
+ }
+ if (k == c.m_keyAttrs - 1 && !(unq1 < unq2))
+ {
+ setError(InvalidCache, __LINE__);
+ return -1;
+ }
+ }
}
}
return 0;
@@ -2196,7 +2240,7 @@ NdbIndexStatImpl::query_interpolate(cons
cnt == stat.m_numEqH &&
side == -1) {
stat.m_rule = "b3.3";
- const double u = 1.0 + c.get_unq(posL, posH, keyAttrs - 1);
+ const double u = c.get_unq(posL, posH, keyAttrs - 1);
const double wL = 1.0 / u;
const double wH = 1.0 - wL;
value.m_rir = wL * c.get_rir(posL) + wH * c.get_rir(posH);
=== modified file 'storage/ndb/src/ndbapi/ndberror.c'
--- a/storage/ndb/src/ndbapi/ndberror.c 2011-09-02 07:40:42 +0000
+++ b/storage/ndb/src/ndbapi/ndberror.c 2011-09-02 09:16:56 +0000
@@ -548,7 +548,7 @@ ErrorBundle ErrorCodes[] = {
{ 4715, DMEC, AE, "Index stats for specified index do not exist" },
{ 4716, DMEC, AE, "Index stats methods usage error" },
{ 4717, DMEC, AE, "Index stats cannot allocate memory" },
- { 4718, DMEC, IE, "Index stats memory cache is corrupted" },
+ { 4718, DMEC, IE, "Index stats samples data or memory cache is invalid" },
{ 4719, DMEC, IE, "Index stats internal error" },
{ 4720, DMEC, AE, "Index stats sys tables " NDB_INDEX_STAT_PREFIX " partly missing or invalid" },
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-5.5-cluster branch (jonas.oreland:3455 to 3457) | jonas oreland | 2 Sep |