diff --git a/mysql-test/main/null_aware_cardinality.result b/mysql-test/main/null_aware_cardinality.result index 97f9cee9080..43aa6d05c1f 100644 --- a/mysql-test/main/null_aware_cardinality.result +++ b/mysql-test/main/null_aware_cardinality.result @@ -1,4 +1,3 @@ -SET @session_start_value = @@new_mode; # Small driving table CREATE TABLE t1 (a INT, b INT); INSERT INTO t1 VALUES (1, 1), (2, 2000),(3,300); @@ -14,9 +13,6 @@ ANALYZE TABLE t2 PERSISTENT FOR ALL; Table Op Msg_type Msg_text test.t2 analyze status Engine-independent statistics collected test.t2 analyze status Table is already up to date -SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS"; -Warnings: -Warning 4200 The setting 'new_mode=FIX_INDEX_STATS_FOR_ALL_NULLS' is ignored. It only exists for compatibility with old installations and will be removed in a future release # NULL-rejecting equality t1.b = t2.b will not return any matches # because all values of t2.b are NULL. So "rows" = 1 for t2 where 1 is # a special value meaning "very few" rows @@ -82,23 +78,12 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t3 ref key_ab key_ab 10 test.t1.a,const 11 100.00 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t3`.`b` is null -# In the old mode (null-aware estimation is not enabled), "rows" > 1 -SET @@new_mode = ""; -EXPLAIN EXTENDED SELECT * FROM t1 JOIN t2 ON t1.a = t2.a AND t1.b = t2.b; -id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where -1 SIMPLE t2 ref key_b key_b 5 test.t1.b 100 100.00 Using where -Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` # Insert some non-NULL values and re-collect the stats INSERT INTO t3 SELECT 1, 1 FROM seq_1_to_100; ANALYZE TABLE t3 PERSISTENT FOR COLUMNS (b) INDEXES (key_ab); Table Op Msg_type Msg_text test.t3 analyze status Engine-independent statistics collected test.t3 analyze status OK -SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS"; -Warnings: -Warning 4200 The setting 'new_mode=FIX_INDEX_STATS_FOR_ALL_NULLS' is ignored. It only exists for compatibility with old installations and will be removed in a future release EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t1.b = t3.b; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where @@ -158,5 +143,4 @@ EXPLAIN SELECT * FROM t1, t2 WHERE t2.a=t1.a AND t2.b=t1.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where 1 SIMPLE t2 ref i1 i1 66 test.t1.a,test.t1.a 1 Using where -SET @@new_mode = @session_start_value; DROP TABLE t1, t2; diff --git a/mysql-test/main/null_aware_cardinality.test b/mysql-test/main/null_aware_cardinality.test index eead918367a..716643a2297 100644 --- a/mysql-test/main/null_aware_cardinality.test +++ b/mysql-test/main/null_aware_cardinality.test @@ -1,7 +1,5 @@ --source include/have_sequence.inc -SET @session_start_value = @@new_mode; - --echo # Small driving table CREATE TABLE t1 (a INT, b INT); INSERT INTO t1 VALUES (1, 1), (2, 2000),(3,300); @@ -15,8 +13,6 @@ INSERT INTO t2 SELECT seq/100, NULL FROM seq_1_to_1000; ANALYZE TABLE t2 PERSISTENT FOR ALL; -SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS"; - --echo # NULL-rejecting equality t1.b = t2.b will not return any matches --echo # because all values of t2.b are NULL. So "rows" = 1 for t2 where 1 is --echo # a special value meaning "very few" rows @@ -52,16 +48,11 @@ EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t1.b <=> t3.b; EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t3.b is NULL; ---echo # In the old mode (null-aware estimation is not enabled), "rows" > 1 -SET @@new_mode = ""; -EXPLAIN EXTENDED SELECT * FROM t1 JOIN t2 ON t1.a = t2.a AND t1.b = t2.b; - --echo # Insert some non-NULL values and re-collect the stats INSERT INTO t3 SELECT 1, 1 FROM seq_1_to_100; ANALYZE TABLE t3 PERSISTENT FOR COLUMNS (b) INDEXES (key_ab); -SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS"; EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t1.b = t3.b; --echo # Test composite index for 3 columns. Key prefix is used for access @@ -99,5 +90,4 @@ ANALYZE TABLE t2 PERSISTENT FOR COLUMNS (b) INDEXES (i1); EXPLAIN SELECT * FROM t1, t2 WHERE t2.a=t1.a AND t2.b=t1.a; -SET @@new_mode = @session_start_value; DROP TABLE t1, t2; \ No newline at end of file diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 74ba27f2649..3a05ab0ad1c 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -4164,11 +4164,10 @@ void set_statistics_for_table(THD *thd, TABLE *table) (check_eits_preferred(thd) && table->stats_is_read && key_info->read_stats->avg_frequency_is_inited() && - key_info->read_stats->has_stats(thd)); + key_info->read_stats->has_stats()); // Fill out `all_nulls_key_parts` bitmap - if (TEST_NEW_MODE_FLAG(thd, NEW_MODE_FIX_INDEX_STATS_FOR_ALL_NULLS) && - key_info->is_statistics_from_stat_tables) + if (key_info->is_statistics_from_stat_tables) { for (uint part_idx= 0; part_idx < key_info->usable_key_parts; part_idx++) { diff --git a/sql/sql_statistics.h b/sql/sql_statistics.h index 9319b50c6f6..c51cfb648cc 100644 --- a/sql/sql_statistics.h +++ b/sql/sql_statistics.h @@ -614,13 +614,7 @@ public: void mark_stats_as_read() { stats_were_read= true; } - bool has_stats(THD *thd) const - { - if (TEST_NEW_MODE_FLAG(thd, NEW_MODE_FIX_INDEX_STATS_FOR_ALL_NULLS)) - return stats_were_read; - else - return get_avg_frequency(0) > 0.5; - } + bool has_stats() const { return stats_were_read; } bool avg_frequency_is_inited() { return avg_frequency != NULL; } diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 0d5dddf8c30..9e00123e1d2 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4174,9 +4174,9 @@ static Sys_var_set Sys_old_behavior( */ static const char *new_mode_all_names[]= { - "FIX_DISK_TMPTABLE_COSTS", + "FIX_DISK_TMPTABLE_COSTS", // Default from here, See NEW_MODE_MAX "FIX_INDEX_STATS_FOR_ALL_NULLS", - "TEST_WARNING1", // Default from here, See NEW_MODE_MAX + "TEST_WARNING1", "TEST_WARNING2", 0 };