Skip to content

Commit

Permalink
Merge 10.5 into 10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Nov 12, 2020
2 parents ef639f1 + 97569d3 commit 254bb1c
Show file tree
Hide file tree
Showing 20 changed files with 278 additions and 149 deletions.
1 change: 1 addition & 0 deletions include/my_atomic_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */

#pragma once
#ifdef __cplusplus
#include <atomic>
/**
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/include/innodb_checksum_algorithm.combinations
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

[strict_crc32]
--innodb-checksum-algorithm=strict_crc32
--innodb-flush-sync=OFF

[full_crc32]
--innodb-checksum-algorithm=full_crc32

[strict_full_crc32]
--innodb-checksum-algorithm=strict_full_crc32
--innodb-flush-sync=OFF
35 changes: 34 additions & 1 deletion mysql-test/main/range.result
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ SELECT * FROM t1 WHERE
25 <= a AND b = 23 OR
23 <= a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 2 Using where; Using index
1 SIMPLE t1 range a a 5 NULL 3 Using where; Using index
SELECT * FROM t1 WHERE
23 <= a AND a <= 25 OR
25 <= a AND b = 23 OR
Expand Down Expand Up @@ -3121,6 +3121,39 @@ a b
set eq_range_index_dive_limit=default;
drop table t1;
#
# MDEV-24117: Memory management problem in statistics state...
# (just the testcase)
#
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 + D.a * 1000
from t0 A, t0 B, t0 C, t0 D
where D.a<4;
create table t2 (
a int,
b int,
key(a)
);
insert into t2 values (1,1),(2,2),(3,3);
set @query=(select group_concat(a) from t1);
set @tmp_24117= @@max_session_mem_used;
#
# On debug build, the usage was
# - 2.8M without the bug
# - 1G with the bug.
set max_session_mem_used=64*1024*1024;
set @query=concat('explain select * from t2 where a=1 or a in (', @query, ')');
prepare s from @query;
# This should not fail with an error:
execute s;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL a NULL NULL NULL 3 Using where
set max_session_mem_used=@tmp_24117;
deallocate prepare s;
drop table t0,t1,t2;
#
# MDEV-23811: Both disjunct of WHERE condition contain range conditions
# for the same index such that the second range condition
# fully covers the first one. Additionally one of the disjuncts
Expand Down
46 changes: 46 additions & 0 deletions mysql-test/main/range.test
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,52 @@ set eq_range_index_dive_limit=default;

drop table t1;

--echo #
--echo # MDEV-24117: Memory management problem in statistics state...
--echo # (just the testcase)
--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);

# 4K rows
insert into t1
select A.a + B.a* 10 + C.a * 100 + D.a * 1000
from t0 A, t0 B, t0 C, t0 D
where D.a<4;

create table t2 (
a int,
b int,
key(a)
);

insert into t2 values (1,1),(2,2),(3,3);

set @query=(select group_concat(a) from t1);

set @tmp_24117= @@max_session_mem_used;

--echo #
--echo # On debug build, the usage was
--echo # - 2.8M without the bug
--echo # - 1G with the bug.

set max_session_mem_used=64*1024*1024;

set @query=concat('explain select * from t2 where a=1 or a in (', @query, ')');

prepare s from @query;

--echo # This should not fail with an error:
execute s;
set max_session_mem_used=@tmp_24117;

deallocate prepare s;

drop table t0,t1,t2;
--echo #
--echo # MDEV-23811: Both disjunct of WHERE condition contain range conditions
--echo # for the same index such that the second range condition
Expand Down
35 changes: 34 additions & 1 deletion mysql-test/main/range_mrr_icp.result
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ SELECT * FROM t1 WHERE
25 <= a AND b = 23 OR
23 <= a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 2 Using where; Using index
1 SIMPLE t1 range a a 5 NULL 3 Using where; Using index
SELECT * FROM t1 WHERE
23 <= a AND a <= 25 OR
25 <= a AND b = 23 OR
Expand Down Expand Up @@ -3110,6 +3110,39 @@ a b
set eq_range_index_dive_limit=default;
drop table t1;
#
# MDEV-24117: Memory management problem in statistics state...
# (just the testcase)
#
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 + D.a * 1000
from t0 A, t0 B, t0 C, t0 D
where D.a<4;
create table t2 (
a int,
b int,
key(a)
);
insert into t2 values (1,1),(2,2),(3,3);
set @query=(select group_concat(a) from t1);
set @tmp_24117= @@max_session_mem_used;
#
# On debug build, the usage was
# - 2.8M without the bug
# - 1G with the bug.
set max_session_mem_used=64*1024*1024;
set @query=concat('explain select * from t2 where a=1 or a in (', @query, ')');
prepare s from @query;
# This should not fail with an error:
execute s;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL a NULL NULL NULL 3 Using where
set max_session_mem_used=@tmp_24117;
deallocate prepare s;
drop table t0,t1,t2;
#
# MDEV-23811: Both disjunct of WHERE condition contain range conditions
# for the same index such that the second range condition
# fully covers the first one. Additionally one of the disjuncts
Expand Down
5 changes: 0 additions & 5 deletions mysql-test/suite/maria/create.test
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ flush tables;
--error 1,ER_TABLE_EXISTS_ERROR
--eval CREATE TABLE MDEV_23222 (i INT) DATA DIRECTORY = '$MYSQL_TMP_DIR', ENGINE=Aria TRANSACTIONAL=1;
DROP TABLE t1;
--disable_warnings
--remove_file $mysqld_datadir/test/MDEV_23222.MAD
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
--remove_file $MYSQL_TMP_DIR/MDEV_23222.MAD
--enable_warnings

--echo #
--echo # End of 10.3 tests
Expand Down
10 changes: 1 addition & 9 deletions mysql-test/suite/sys_vars/r/innodb_flush_sync_basic.result
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
SET @start_global_value = @@global.innodb_flush_sync;
SELECT @start_global_value;
@start_global_value
1
Valid values are 'ON' and 'OFF'
select @@global.innodb_flush_sync in (0, 1);
@@global.innodb_flush_sync in (0, 1)
1
select @@global.innodb_flush_sync;
@@global.innodb_flush_sync
1
select @@session.innodb_flush_sync;
ERROR HY000: Variable 'innodb_flush_sync' is a GLOBAL variable
SET GLOBAL innodb_flush_sync = ON;
show global variables like 'innodb_flush_sync';
Variable_name Value
innodb_flush_sync ON
Expand Down Expand Up @@ -87,6 +82,3 @@ INNODB_FLUSH_SYNC ON
set global innodb_flush_sync='AUTO';
ERROR 42000: Variable 'innodb_flush_sync' can't be set to the value of 'AUTO'
SET @@global.innodb_flush_sync = @start_global_value;
SELECT @@global.innodb_flush_sync;
@@global.innodb_flush_sync
1
7 changes: 1 addition & 6 deletions mysql-test/suite/sys_vars/t/innodb_flush_sync_basic.test
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
--source include/have_innodb.inc

SET @start_global_value = @@global.innodb_flush_sync;
SELECT @start_global_value;

#
# exists as global only
#
--echo Valid values are 'ON' and 'OFF'
select @@global.innodb_flush_sync in (0, 1);
select @@global.innodb_flush_sync;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.innodb_flush_sync;
SET GLOBAL innodb_flush_sync = ON;
show global variables like 'innodb_flush_sync';
show session variables like 'innodb_flush_sync';
--disable_warnings
select * from information_schema.global_variables where variable_name='innodb_flush_sync';
select * from information_schema.session_variables where variable_name='innodb_flush_sync';
--enable_warnings

#
# show that it's writable
#
set global innodb_flush_sync='OFF';
select @@global.innodb_flush_sync;
--disable_warnings
Expand Down Expand Up @@ -74,4 +70,3 @@ set global innodb_flush_sync='AUTO';
#

SET @@global.innodb_flush_sync = @start_global_value;
SELECT @@global.innodb_flush_sync;
14 changes: 7 additions & 7 deletions sql/opt_range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9619,15 +9619,9 @@ tree_or(RANGE_OPT_PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2)
}
bool no_imerge_from_ranges= FALSE;

SEL_TREE *rt1= tree1;
SEL_TREE *rt2= tree2;
/* Build the range part of the tree for the formula (1) */
if (sel_trees_can_be_ored(param, tree1, tree2, &ored_keys))
{
if (no_merges1)
rt1= new SEL_TREE(tree1, TRUE, param);
if (no_merges2)
rt2= new SEL_TREE(tree2, TRUE, param);
bool must_be_ored= sel_trees_must_be_ored(param, tree1, tree2, ored_keys);
no_imerge_from_ranges= must_be_ored;

Expand Down Expand Up @@ -9685,6 +9679,12 @@ tree_or(RANGE_OPT_PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2)
else if (!no_ranges1 && !no_ranges2 && !no_imerge_from_ranges)
{
/* Build the imerge part of the tree for the formula (1) */
SEL_TREE *rt1= tree1;
SEL_TREE *rt2= tree2;
if (no_merges1)
rt1= new SEL_TREE(tree1, TRUE, param);
if (no_merges2)
rt2= new SEL_TREE(tree2, TRUE, param);
if (!rt1 || !rt2 ||
result->merges.push_back(imerge_from_ranges) ||
imerge_from_ranges->or_sel_tree(param, rt1) ||
Expand Down Expand Up @@ -10350,7 +10350,7 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *key1,SEL_ARG *key2)
if (!tmp->next_key_part)
{
SEL_ARG *key2_next= key2->next;
if (key2->use_count)
if (key2_shared)
{
SEL_ARG *key2_cpy= new SEL_ARG(*key2);
if (!key2_cpy)
Expand Down
21 changes: 17 additions & 4 deletions sql/sql_prepare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3252,27 +3252,38 @@ void mysqld_stmt_execute(THD *thd, char *packet_arg, uint packet_length)
void mysqld_stmt_bulk_execute(THD *thd, char *packet_arg, uint packet_length)
{
uchar *packet= (uchar*)packet_arg; // GCC 4.0.1 workaround
DBUG_ENTER("mysqld_stmt_execute_bulk");

const uint packet_header_lenght= 4 + 2; //ID & 2 bytes of flags

if (packet_length < packet_header_lenght)
{
my_error(ER_MALFORMED_PACKET, MYF(0));
DBUG_VOID_RETURN;
}

ulong stmt_id= uint4korr(packet);
uint flags= (uint) uint2korr(packet + 4);
uchar *packet_end= packet + packet_length;
DBUG_ENTER("mysqld_stmt_execute_bulk");

if (!(thd->client_capabilities &
MARIADB_CLIENT_STMT_BULK_OPERATIONS))
{
DBUG_PRINT("error",
("An attempt to execute bulk operation without support"));
my_error(ER_UNSUPPORTED_PS, MYF(0));
DBUG_VOID_RETURN;
}
/* Check for implemented parameters */
if (flags & (~STMT_BULK_FLAG_CLIENT_SEND_TYPES))
{
DBUG_PRINT("error", ("unsupported bulk execute flags %x", flags));
my_error(ER_UNSUPPORTED_PS, MYF(0));
DBUG_VOID_RETURN;
}

/* stmt id and two bytes of flags */
packet+= 4 + 2;
packet+= packet_header_lenght;
mysql_stmt_execute_common(thd, stmt_id, packet, packet_end, 0, TRUE,
(flags & STMT_BULK_FLAG_CLIENT_SEND_TYPES));
DBUG_VOID_RETURN;
Expand Down Expand Up @@ -3349,9 +3360,11 @@ stmt_execute_packet_sanity_check(Prepared_statement *stmt,
{
/*
If there is no parameters, this should be normally already end
of the packet. If it's not - then error
of the packet, but it is not a problem if something left (popular
mistake in protocol implementation) because we will not read anymore
from the buffer.
*/
return (packet_end > packet);
return false;
}
return false;
}
Expand Down
Loading

0 comments on commit 254bb1c

Please sign in to comment.