Skip to content

Commit 5f84585

Browse files
committed
MDEV-36761 Remove @@new_mode=FIX_INDEX_STATS_FOR_ALL_NULLS in 12.1
Remove the FIX_INDEX_STATS_FOR_ALL_NULLS flag from @@new_mode. The new behavior is now always on.
1 parent ba00960 commit 5f84585

File tree

5 files changed

+5
-38
lines changed

5 files changed

+5
-38
lines changed

mysql-test/main/null_aware_cardinality.result

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
SET @session_start_value = @@new_mode;
21
# Small driving table
32
CREATE TABLE t1 (a INT, b INT);
43
INSERT INTO t1 VALUES (1, 1), (2, 2000),(3,300);
@@ -14,9 +13,6 @@ ANALYZE TABLE t2 PERSISTENT FOR ALL;
1413
Table Op Msg_type Msg_text
1514
test.t2 analyze status Engine-independent statistics collected
1615
test.t2 analyze status Table is already up to date
17-
SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS";
18-
Warnings:
19-
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
2016
# NULL-rejecting equality t1.b = t2.b will not return any matches
2117
# because all values of t2.b are NULL. So "rows" = 1 for t2 where 1 is
2218
# 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
8278
1 SIMPLE t3 ref key_ab key_ab 10 test.t1.a,const 11 100.00 Using where; Using index
8379
Warnings:
8480
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
85-
# In the old mode (null-aware estimation is not enabled), "rows" > 1
86-
SET @@new_mode = "";
87-
EXPLAIN EXTENDED SELECT * FROM t1 JOIN t2 ON t1.a = t2.a AND t1.b = t2.b;
88-
id select_type table type possible_keys key key_len ref rows filtered Extra
89-
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
90-
1 SIMPLE t2 ref key_b key_b 5 test.t1.b 100 100.00 Using where
91-
Warnings:
92-
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`
9381
# Insert some non-NULL values and re-collect the stats
9482
INSERT INTO t3 SELECT 1, 1 FROM seq_1_to_100;
9583
ANALYZE TABLE t3 PERSISTENT FOR COLUMNS (b) INDEXES (key_ab);
9684
Table Op Msg_type Msg_text
9785
test.t3 analyze status Engine-independent statistics collected
9886
test.t3 analyze status OK
99-
SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS";
100-
Warnings:
101-
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
10287
EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t1.b = t3.b;
10388
id select_type table type possible_keys key key_len ref rows filtered Extra
10489
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;
158143
id select_type table type possible_keys key key_len ref rows Extra
159144
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
160145
1 SIMPLE t2 ref i1 i1 66 test.t1.a,test.t1.a 1 Using where
161-
SET @@new_mode = @session_start_value;
162146
DROP TABLE t1, t2;

mysql-test/main/null_aware_cardinality.test

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--source include/have_sequence.inc
22

3-
SET @session_start_value = @@new_mode;
4-
53
--echo # Small driving table
64
CREATE TABLE t1 (a INT, b INT);
75
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;
1513

1614
ANALYZE TABLE t2 PERSISTENT FOR ALL;
1715

18-
SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS";
19-
2016
--echo # NULL-rejecting equality t1.b = t2.b will not return any matches
2117
--echo # because all values of t2.b are NULL. So "rows" = 1 for t2 where 1 is
2218
--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;
5248

5349
EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t3.b is NULL;
5450

55-
--echo # In the old mode (null-aware estimation is not enabled), "rows" > 1
56-
SET @@new_mode = "";
57-
EXPLAIN EXTENDED SELECT * FROM t1 JOIN t2 ON t1.a = t2.a AND t1.b = t2.b;
58-
5951
--echo # Insert some non-NULL values and re-collect the stats
6052
INSERT INTO t3 SELECT 1, 1 FROM seq_1_to_100;
6153

6254
ANALYZE TABLE t3 PERSISTENT FOR COLUMNS (b) INDEXES (key_ab);
6355

64-
SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS";
6556
EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t1.b = t3.b;
6657

6758
--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);
9990

10091
EXPLAIN SELECT * FROM t1, t2 WHERE t2.a=t1.a AND t2.b=t1.a;
10192

102-
SET @@new_mode = @session_start_value;
10393
DROP TABLE t1, t2;

sql/sql_statistics.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4164,11 +4164,10 @@ void set_statistics_for_table(THD *thd, TABLE *table)
41644164
(check_eits_preferred(thd) &&
41654165
table->stats_is_read &&
41664166
key_info->read_stats->avg_frequency_is_inited() &&
4167-
key_info->read_stats->has_stats(thd));
4167+
key_info->read_stats->has_stats());
41684168

41694169
// Fill out `all_nulls_key_parts` bitmap
4170-
if (TEST_NEW_MODE_FLAG(thd, NEW_MODE_FIX_INDEX_STATS_FOR_ALL_NULLS) &&
4171-
key_info->is_statistics_from_stat_tables)
4170+
if (key_info->is_statistics_from_stat_tables)
41724171
{
41734172
for (uint part_idx= 0; part_idx < key_info->usable_key_parts; part_idx++)
41744173
{

sql/sql_statistics.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,7 @@ class Index_statistics
614614

615615
void mark_stats_as_read() { stats_were_read= true; }
616616

617-
bool has_stats(THD *thd) const
618-
{
619-
if (TEST_NEW_MODE_FLAG(thd, NEW_MODE_FIX_INDEX_STATS_FOR_ALL_NULLS))
620-
return stats_were_read;
621-
else
622-
return get_avg_frequency(0) > 0.5;
623-
}
617+
bool has_stats() const { return stats_were_read; }
624618

625619
bool avg_frequency_is_inited() { return avg_frequency != NULL; }
626620

sql/sys_vars.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4174,9 +4174,9 @@ static Sys_var_set Sys_old_behavior(
41744174
*/
41754175
static const char *new_mode_all_names[]=
41764176
{
4177-
"FIX_DISK_TMPTABLE_COSTS",
4177+
"FIX_DISK_TMPTABLE_COSTS", // Default from here, See NEW_MODE_MAX
41784178
"FIX_INDEX_STATS_FOR_ALL_NULLS",
4179-
"TEST_WARNING1", // Default from here, See NEW_MODE_MAX
4179+
"TEST_WARNING1",
41804180
"TEST_WARNING2",
41814181
0
41824182
};

0 commit comments

Comments
 (0)