Skip to content

Commit 9161270

Browse files
committed
Merge branch '12.1' into 12.2
2 parents 8abdcba + 7011746 commit 9161270

12 files changed

+82
-49
lines changed

mysql-test/main/delete.result

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,22 @@ id
779779
Warnings:
780780
Warning 4207 Index hints are ignored because they are incompatible with RETURNING clause
781781
drop table t2;
782-
#
783782
# End of 11.4 test
784783
#
784+
# MDEV-38068 Query doesn't delete all data it should after update to 11.8.4
785+
#
786+
create table t1 (id varchar(32), d1 char, key (id), key (d1)) engine=myisam;
787+
insert into t1 values ('1','A'), ('1','B'), ('1','C'), ('2','D'), ('2','E');
788+
select count(*) from t1;
789+
count(*)
790+
5
791+
need "range" below
792+
explain delete from t1 where id = '1';
793+
id select_type table type possible_keys key key_len ref rows Extra
794+
1 SIMPLE t1 range id id 131 NULL 3 Using where
795+
delete from t1 where id = '1';
796+
select count(*) from t1;
797+
count(*)
798+
2
799+
drop table t1;
800+
# End of 11.8 test

mysql-test/main/delete.test

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,18 @@ DELETE FROM t2 ignore index(primary) ORDER BY (id) LIMIT 2 RETURNING id;
825825

826826
drop table t2;
827827

828-
--echo #
829828
--echo # End of 11.4 test
829+
830830
--echo #
831+
--echo # MDEV-38068 Query doesn't delete all data it should after update to 11.8.4
832+
--echo #
833+
create table t1 (id varchar(32), d1 char, key (id), key (d1)) engine=myisam;
834+
insert into t1 values ('1','A'), ('1','B'), ('1','C'), ('2','D'), ('2','E');
835+
select count(*) from t1;
836+
--echo need "range" below
837+
explain delete from t1 where id = '1';
838+
delete from t1 where id = '1';
839+
select count(*) from t1;
840+
drop table t1;
841+
842+
--echo # End of 11.8 test

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;

mysql-test/suite/vcol/r/order_by_group_by_subst.result

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,19 @@ a b
222222
5 4
223223
5 5
224224
drop table t1, t2;
225+
#
226+
# MDEV-37422: SIGSEGV failed in base_list_iterator::replace, Assertion `n < m_size'
227+
# in Baounds_checked_array, ASAN use-after-poison in JOIN::rollup_make_fields
228+
#
229+
CREATE TABLE t1 (
230+
a INT,
231+
b INT,
232+
a1 INT GENERATED ALWAYS AS (a) VIRTUAL,
233+
INDEX (a1)
234+
) ENGINE=INNODB;
235+
SELECT * FROM t1 GROUP BY a WITH ROLLUP;
236+
a b a1
237+
drop table t1;
238+
#
239+
# End of 12.1 tests
240+
#

mysql-test/suite/vcol/t/order_by_group_by_subst.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,22 @@ insert into t1 (a) select seq from seq_1_to_5;
168168
insert into t2 (b) select seq from seq_1_to_5;
169169
SELECT a, b FROM t1, t2 GROUP BY a, b HAVING a>2 and b>2;
170170
drop table t1, t2;
171+
172+
--echo #
173+
--echo # MDEV-37422: SIGSEGV failed in base_list_iterator::replace, Assertion `n < m_size'
174+
--echo # in Baounds_checked_array, ASAN use-after-poison in JOIN::rollup_make_fields
175+
--echo #
176+
--source include/have_innodb.inc
177+
CREATE TABLE t1 (
178+
a INT,
179+
b INT,
180+
a1 INT GENERATED ALWAYS AS (a) VIRTUAL,
181+
INDEX (a1)
182+
) ENGINE=INNODB;
183+
184+
SELECT * FROM t1 GROUP BY a WITH ROLLUP;
185+
drop table t1;
186+
187+
--echo #
188+
--echo # End of 12.1 tests
189+
--echo #

sql/opt_vcol_substitution.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ bool substitute_indexed_vcols_for_join(JOIN *join)
303303
ctx.subst_count= 0;
304304
if (join->order)
305305
subst_vcols_in_order(&ctx, join->order, join, false);
306-
if (join->group_list)
306+
/*
307+
Do not do substitution for WITH ROLLUP as that breaks some of its data
308+
structures.
309+
*/
310+
if (join->group_list && join->rollup.state == st_rollup::STATE_NONE)
307311
subst_vcols_in_order(&ctx, join->group_list, join, true);
308312
if (ctx.subst_count)
309313
{

sql/sql_class.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,6 @@ void old_mode_deprecated_warnings(ulonglong v);
232232
/* Definitions above that have transitioned from new behaviour to default */
233233

234234
#define NOW_DEFAULT -1
235-
#define NEW_MODE_TEST_WARNING1 NOW_DEFAULT
236-
#define NEW_MODE_TEST_WARNING2 NOW_DEFAULT
237-
#define NEW_MODE_FIX_DISK_TMPTABLE_COSTS NOW_DEFAULT
238-
#define NEW_MODE_FIX_INDEX_STATS_FOR_ALL_NULLS NOW_DEFAULT
239235

240236
#define TEST_NEW_MODE_FLAG(thd, flag) \
241237
(flag == NOW_DEFAULT ? TRUE : thd->variables.new_behavior & flag)

sql/sql_delete.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,18 +312,20 @@ template <bool replace>
312312
int TABLE::delete_row(bool treat_versioned)
313313
{
314314
int err= 0;
315+
bool remembered_pos= false;
315316
uchar *del_buf= record[replace ? 1 : 0];
316317
bool delete_row= !treat_versioned
317318
|| in_use->lex->vers_conditions.delete_history
318319
|| versioned(VERS_TRX_ID)
319320
|| !vers_end_field()->is_max(
320321
vers_end_field()->ptr_in_record(del_buf));
321322

322-
if ((err= file->extra(HA_EXTRA_REMEMBER_POS)))
323-
return err;
324-
325323
if (!delete_row)
326324
{
325+
if ((err= file->extra(HA_EXTRA_REMEMBER_POS)))
326+
return err;
327+
remembered_pos= true;
328+
327329
if (replace)
328330
{
329331
store_record(this, record[2]);
@@ -370,7 +372,8 @@ int TABLE::delete_row(bool treat_versioned)
370372
if (delete_row)
371373
err= file->ha_delete_row(del_buf);
372374

373-
(void) file->extra(HA_EXTRA_RESTORE_POS);
375+
if (remembered_pos)
376+
(void) file->extra(HA_EXTRA_RESTORE_POS);
374377

375378
return err;
376379
}

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
{

0 commit comments

Comments
 (0)