Skip to content

Commit 66f1e28

Browse files
committed
Merge 10.3 into 10.4
2 parents 9e6e435 + 38d6218 commit 66f1e28

File tree

7 files changed

+93
-12
lines changed

7 files changed

+93
-12
lines changed

mysql-test/main/custom_aggregate_functions.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,7 @@ common_schema.sum_ints(seq)
11871187
drop database common_schema;
11881188
drop database another_schema;
11891189
USE test;
1190+
# End of 10.3 tests
11901191
#
11911192
# MDEV-18813 PROCEDURE and anonymous blocks silently ignore FETCH GROUP NEXT ROW
11921193
#

mysql-test/main/custom_aggregate_functions.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,8 @@ drop database another_schema;
10011001

10021002
USE test;
10031003

1004+
--echo # End of 10.3 tests
1005+
10041006
--echo #
10051007
--echo # MDEV-18813 PROCEDURE and anonymous blocks silently ignore FETCH GROUP NEXT ROW
10061008
--echo #

mysql-test/main/subselect4.result

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,6 +2535,38 @@ c1
25352535
1
25362536
drop table t1;
25372537
#
2538+
# MDEV-22498: SIGSEGV in Bitmap<64u>::merge on SELECT
2539+
#
2540+
set @save_sql_select_limit= @@sql_select_limit;
2541+
SET sql_select_limit=0;
2542+
CREATE TABLE t1(b INT, c INT);
2543+
CREATE TABLE t2(a INT, b INT);
2544+
INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
2545+
INSERT INTO t2 VALUES (1,1),(2,2),(3,3);
2546+
EXPLAIN EXTENDED SELECT sum(a), t2.a, t2.b FROM t2 HAVING t2.a IN (SELECT t2.b FROM t1);
2547+
id select_type table type possible_keys key key_len ref rows filtered Extra
2548+
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Zero limit
2549+
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00
2550+
Warnings:
2551+
Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1
2552+
Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1
2553+
Note 1003 /* select#1 */ select sum(`test`.`t2`.`a`) AS `sum(a)`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` having <in_optimizer>(`test`.`t2`.`a`,<exists>(/* select#2 */ select `test`.`t2`.`b` from `test`.`t1` where <cache>(`test`.`t2`.`a`) = `test`.`t2`.`b`))
2554+
SELECT sum(a), t2.a, t2.b FROM t2 HAVING t2.a IN (SELECT t2.b FROM t1);
2555+
sum(a) a b
2556+
SET @@sql_select_limit= @save_sql_select_limit;
2557+
EXPLAIN EXTENDED SELECT sum(a), t2.a, t2.b FROM t2 HAVING t2.a IN (SELECT t2.b FROM t1);
2558+
id select_type table type possible_keys key key_len ref rows filtered Extra
2559+
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00
2560+
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00
2561+
Warnings:
2562+
Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1
2563+
Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1
2564+
Note 1003 /* select#1 */ select sum(`test`.`t2`.`a`) AS `sum(a)`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` having <expr_cache><`test`.`t2`.`a`,`test`.`t2`.`b`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(/* select#2 */ select `test`.`t2`.`b` from `test`.`t1` where <cache>(`test`.`t2`.`a`) = `test`.`t2`.`b`)))
2565+
SELECT sum(a), t2.a, t2.b FROM t2 HAVING t2.a IN (SELECT t2.b FROM t1);
2566+
sum(a) a b
2567+
6 1 1
2568+
DROP TABLE t1,t2;
2569+
#
25382570
# MDEV-19134: EXISTS() slower if ORDER BY is defined
25392571
#
25402572
create table t0 (a int);
@@ -2582,3 +2614,4 @@ id select_type table type possible_keys key key_len ref rows Extra
25822614
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
25832615
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 100
25842616
drop table t0, t1, t2;
2617+
# End of 10.4 tests

mysql-test/main/subselect4.test

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,6 +2078,30 @@ select (select c1 from t1 group by c1,c2 order by c1 limit 1) as x;
20782078
(select c1 from t1 group by c1,c2 order by c1 limit 1);
20792079
drop table t1;
20802080

2081+
--echo #
2082+
--echo # MDEV-22498: SIGSEGV in Bitmap<64u>::merge on SELECT
2083+
--echo #
2084+
2085+
set @save_sql_select_limit= @@sql_select_limit;
2086+
SET sql_select_limit=0;
2087+
2088+
CREATE TABLE t1(b INT, c INT);
2089+
CREATE TABLE t2(a INT, b INT);
2090+
INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
2091+
INSERT INTO t2 VALUES (1,1),(2,2),(3,3);
2092+
2093+
let $query=
2094+
SELECT sum(a), t2.a, t2.b FROM t2 HAVING t2.a IN (SELECT t2.b FROM t1);
2095+
2096+
eval EXPLAIN EXTENDED $query;
2097+
eval $query;
2098+
2099+
SET @@sql_select_limit= @save_sql_select_limit;
2100+
2101+
eval EXPLAIN EXTENDED $query;
2102+
eval $query;
2103+
DROP TABLE t1,t2;
2104+
20812105
--echo #
20822106
--echo # MDEV-19134: EXISTS() slower if ORDER BY is defined
20832107
--echo #
@@ -2118,3 +2142,4 @@ select * from t1 where t1.a in (select t2.a from t2 order by t2.b);
21182142

21192143
drop table t0, t1, t2;
21202144

2145+
--echo # End of 10.4 tests

mysql-test/suite/innodb/t/xa_recovery_debug.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
# Embedded server does not support restarting
55
--source include/not_embedded.inc
66

7+
--disable_query_log
8+
FLUSH TABLES;
9+
--enable_query_log
10+
711
--echo #
812
--echo # Bug#20872655 XA ROLLBACK IS NOT CRASH-SAFE
913
--echo #

sql/item_subselect.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,10 +2190,13 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
21902190
}
21912191
else
21922192
{
2193+
/*
2194+
No need to use real_item for the item, as the ref items that are possible
2195+
in the subquery either belong to views or to the parent select.
2196+
For such case we need to refer to the reference and not to the original
2197+
item.
2198+
*/
21932199
Item *item= (Item*) select_lex->item_list.head();
2194-
if (item->type() != REF_ITEM ||
2195-
((Item_ref*)item)->ref_type() != Item_ref::VIEW_REF)
2196-
item= item->real_item();
21972200

21982201
if (select_lex->table_list.elements)
21992202
{

storage/innobase/sync/sync0rw.cc

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,13 @@ rw_lock_s_lock_spin(
286286

287287
ut_ad(rw_lock_validate(lock));
288288

289+
rw_lock_stats.rw_s_spin_wait_count.inc();
290+
289291
lock_loop:
290292

291293
/* Spin waiting for the writer field to become free */
292294
HMT_low();
295+
ulint j = i;
293296
while (i < srv_n_spin_wait_rounds &&
294297
lock->lock_word <= 0) {
295298
ut_delay(srv_spin_wait_delay);
@@ -301,7 +304,7 @@ rw_lock_s_lock_spin(
301304
os_thread_yield();
302305
}
303306

304-
++spin_count;
307+
spin_count += lint(i - j);
305308

306309
/* We try once again to obtain the lock */
307310
if (rw_lock_s_lock_low(lock, pass, file_name, line)) {
@@ -421,7 +424,7 @@ rw_lock_x_lock_wait_func(
421424
}
422425

423426
/* If there is still a reader, then go to sleep.*/
424-
++n_spins;
427+
n_spins += i;
425428

426429
sync_cell_t* cell;
427430

@@ -651,6 +654,12 @@ rw_lock_x_lock_func(
651654
ut_ad(rw_lock_validate(lock));
652655
ut_ad(!rw_lock_own(lock, RW_LOCK_S));
653656

657+
if (rw_lock_x_lock_low(lock, pass, file_name, line)) {
658+
/* Locking succeeded */
659+
return;
660+
}
661+
rw_lock_stats.rw_x_spin_wait_count.inc();
662+
654663
lock_loop:
655664

656665
if (rw_lock_x_lock_low(lock, pass, file_name, line)) {
@@ -670,14 +679,15 @@ rw_lock_x_lock_func(
670679

671680
/* Spin waiting for the lock_word to become free */
672681
HMT_low();
682+
ulint j = i;
673683
while (i < srv_n_spin_wait_rounds
674684
&& lock->lock_word <= X_LOCK_HALF_DECR) {
675685
ut_delay(srv_spin_wait_delay);
676686
i++;
677687
}
678688

679689
HMT_medium();
680-
spin_count += lint(i);
690+
spin_count += lint(i - j);
681691

682692
if (i >= srv_n_spin_wait_rounds) {
683693

@@ -745,11 +755,17 @@ rw_lock_sx_lock_func(
745755
sync_array_t* sync_arr;
746756
lint spin_count = 0;
747757
int64_t count_os_wait = 0;
748-
lint spin_wait_count = 0;
749758

750759
ut_ad(rw_lock_validate(lock));
751760
ut_ad(!rw_lock_own(lock, RW_LOCK_S));
752761

762+
if (rw_lock_sx_lock_low(lock, pass, file_name, line)) {
763+
/* Locking succeeded */
764+
return;
765+
}
766+
767+
rw_lock_stats.rw_sx_spin_wait_count.inc();
768+
753769
lock_loop:
754770

755771
if (rw_lock_sx_lock_low(lock, pass, file_name, line)) {
@@ -761,23 +777,21 @@ rw_lock_sx_lock_func(
761777
}
762778

763779
rw_lock_stats.rw_sx_spin_round_count.add(spin_count);
764-
rw_lock_stats.rw_sx_spin_wait_count.add(spin_wait_count);
765780

766781
/* Locking succeeded */
767782
return;
768783

769784
} else {
770785

771-
++spin_wait_count;
772-
773786
/* Spin waiting for the lock_word to become free */
787+
ulint j = i;
774788
while (i < srv_n_spin_wait_rounds
775789
&& lock->lock_word <= X_LOCK_HALF_DECR) {
776790
ut_delay(srv_spin_wait_delay);
777791
i++;
778792
}
779793

780-
spin_count += lint(i);
794+
spin_count += lint(i - j);
781795

782796
if (i >= srv_n_spin_wait_rounds) {
783797

@@ -809,7 +823,6 @@ rw_lock_sx_lock_func(
809823
}
810824

811825
rw_lock_stats.rw_sx_spin_round_count.add(spin_count);
812-
rw_lock_stats.rw_sx_spin_wait_count.add(spin_wait_count);
813826

814827
/* Locking succeeded */
815828
return;

0 commit comments

Comments
 (0)