[Commits] 5fb922bea0c: More test coverage
revision-id: 5fb922bea0c7f70b6c912946464c43b8c6a007d5 (mariadb-10.6.1-325-g5fb922bea0c) parent(s): 99e762c7fafea895fcd2dbdd4fcf6cba75d80e5e author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2021-12-03 19:03:42 +0300 message: More test coverage --- mysql-test/main/statistics_json.result | 22 ++++++++++++++++++++++ mysql-test/main/statistics_json.test | 22 ++++++++++++++++++++++ sql/opt_histogram_json.cc | 2 -- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result index 127ac6feb4b..1948d5acb4e 100644 --- a/mysql-test/main/statistics_json.result +++ b/mysql-test/main/statistics_json.result @@ -8146,3 +8146,25 @@ analyze select * from t1 where a >= 0; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 100 100.00 100.00 100.00 Using where drop table t1; +# +# More test coverage +# +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int); +insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C; +create table t2 (a int); +insert into t2 select 1 from t1; +insert into t2 select (a+1)*10 from t0; +insert into t2 values (0); +analyze table t2 persistent for all; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +analyze select * from t2 where a < 1; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1011 1011.00 8.33 0.10 Using where +analyze select * from t2 where a =100; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1011 1011.00 0.10 0.10 Using where +drop table t0,t1,t2; diff --git a/mysql-test/main/statistics_json.test b/mysql-test/main/statistics_json.test index 2b2a93f5465..bcc80093891 100644 --- a/mysql-test/main/statistics_json.test +++ b/mysql-test/main/statistics_json.test @@ -353,3 +353,25 @@ analyze select * from t1 where a < 0; analyze select * from t1 where a > 0; analyze select * from t1 where a >= 0; drop table t1; + + +--echo # +--echo # More test coverage +--echo # +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1(a int); +insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C; + +create table t2 (a int); +insert into t2 select 1 from t1; +insert into t2 select (a+1)*10 from t0; +insert into t2 values (0); + +analyze table t2 persistent for all; +analyze select * from t2 where a < 1; +analyze select * from t2 where a =100; + +drop table t0,t1,t2; + diff --git a/sql/opt_histogram_json.cc b/sql/opt_histogram_json.cc index 572a65bc2ed..023e69b83aa 100644 --- a/sql/opt_histogram_json.cc +++ b/sql/opt_histogram_json.cc @@ -914,7 +914,6 @@ double Histogram_json_hb::range_selectivity(Field *field, key_range *min_endp, /* The range is "col > $CONST" and we've found a bucket that contains only the value $CONST. Move to the next bucket. - TODO: what if the last value in the histogram is a popular one? */ idx++; } @@ -948,7 +947,6 @@ double Histogram_json_hb::range_selectivity(Field *field, key_range *min_endp, /* The range is "col < $CONST" and we've found a bucket starting with $CONST. Move to the previous bucket. - TODO: what if the first value is the popular one? */ idx--; }
participants (1)
-
psergey