Skip to content

Commit

Permalink
Merge 5.5 into 10.0
Browse files Browse the repository at this point in the history
Also, implement MDEV-11027 a little differently from 5.5:

recv_sys_t::report(ib_time_t): Determine whether progress should
be reported.

recv_apply_hashed_log_recs(): Rename the parameter to last_batch.
  • Loading branch information
dr-m committed Mar 8, 2017
2 parents c4f3e64 + 6860a4b commit 47396dd
Show file tree
Hide file tree
Showing 21 changed files with 501 additions and 579 deletions.
34 changes: 34 additions & 0 deletions mysql-test/r/subselect4.result
Original file line number Diff line number Diff line change
Expand Up @@ -2436,5 +2436,39 @@ EXECUTE stmt;
i
6
drop table t1, t2, t3;
#
# MDEV-11078: NULL NOT IN (non-empty subquery) should never return results
#
create table t1(a int,b int);
create table t2(a int,b int);
insert into t1 value (1,2);
select (NULL) in (select 1 from t1);
(NULL) in (select 1 from t1)
NULL
select (null) in (select 1 from t2);
(null) in (select 1 from t2)
0
select 1 in (select 1 from t1);
1 in (select 1 from t1)
1
select 1 in (select 1 from t2);
1 in (select 1 from t2)
0
select 1 from dual where null in (select 1 from t1);
1
select 1 from dual where null in (select 1 from t2);
1
select (null,null) in (select * from t1);
(null,null) in (select * from t1)
NULL
select (null,null) in (select * from t2);
(null,null) in (select * from t2)
0
select 1 from dual where null not in (select 1 from t1);
1
select 1 from dual where null not in (select 1 from t2);
1
1
drop table t1,t2;
SET optimizer_switch= @@global.optimizer_switch;
set @@tmp_table_size= @@global.tmp_table_size;
15 changes: 15 additions & 0 deletions mysql-test/r/subselect_innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,21 @@ HAVING SQ2_alias1 . col_int_key >= 7
drop table t1;
set optimizer_switch=@subselect_innodb_tmp;
#
# MDEV-9635:Server crashes in part_of_refkey or assertion
# `!created && key_to_save < (int)s->keys' failed in
# TABLE::use_index(int) or with join_cache_level>2
#
SET join_cache_level=3;
CREATE TABLE t1 (f1 VARCHAR(1024)) ENGINE=InnoDB;
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
CREATE TABLE t2 (f2 VARCHAR(4)) ENGINE=InnoDB;
INSERT INTO t2 VALUES ('foo'),('bar');
SELECT * FROM v1, t2 WHERE ( f1, f2 ) IN ( SELECT f1, f1 FROM t1 );
f1 f2
set join_cache_level = default;
drop view v1;
drop table t1,t2;
#
# MDEV-6041: ORDER BY+subqueries: subquery_table.key=outer_table.col is not recongized as binding
#
create table t1(a int) engine=innodb;
Expand Down
12 changes: 4 additions & 8 deletions mysql-test/suite/innodb/r/log_file_size.result
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,24 @@ ERROR 42000: Unknown storage engine 'InnoDB'
FOUND /syntax error in innodb_log_group_home_dir/ in mysqld.1.err
SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB'
FOUND /InnoDB: Starting an apply batch of log records/ in mysqld.1.err
FOUND /InnoDB: Starting crash recovery from checkpoint LSN=/ in mysqld.1.err
SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB'
FOUND /InnoDB: Starting an apply batch of log records/ in mysqld.1.err
SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB'
FOUND /InnoDB: innodb_read_only prevents crash recovery/ in mysqld.1.err
SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB'
FOUND /InnoDB: Starting an apply batch of log records/ in mysqld.1.err
FOUND /InnoDB: Resizing redo log from 3\*[0-9]+ to 2\*[0-9]+ pages/ in mysqld.1.err
FOUND /redo log from 3\*[0-9]+ to 2\*[0-9]+ pages/ in mysqld.1.err
SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB'
FOUND /InnoDB: Starting an apply batch of log records/ in mysqld.1.err
FOUND /InnoDB: Resizing redo log from 3\*[0-9]+ to 2\*[0-9]+ pages/ in mysqld.1.err
FOUND /redo log from 3\*[0-9]+ to 2\*[0-9]+ pages/ in mysqld.1.err
SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB'
FOUND /InnoDB: innodb_read_only prevents crash recovery/ in mysqld.1.err
SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB'
FOUND /InnoDB: Starting an apply batch of log records/ in mysqld.1.err
FOUND /InnoDB: Resizing redo log from 3\*[0-9]+ to 2\*[0-9]+ pages/ in mysqld.1.err
FOUND /redo log from 3\*[0-9]+ to 2\*[0-9]+ pages/ in mysqld.1.err
SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB'
SELECT * FROM t1;
Expand Down
16 changes: 4 additions & 12 deletions mysql-test/suite/innodb/t/log_file_size.test
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,13 @@ let SEARCH_PATTERN= syntax error in innodb_log_group_home_dir;
--source include/restart_mysqld.inc
--error ER_UNKNOWN_STORAGE_ENGINE
SELECT * FROM t1;
let SEARCH_PATTERN= InnoDB: Starting an apply batch of log records;
let SEARCH_PATTERN= InnoDB: Starting crash recovery from checkpoint LSN=;
--source include/search_pattern_in_file.inc

--let $restart_parameters= --debug=d,innodb_log_abort_3
--source include/restart_mysqld.inc
--error ER_UNKNOWN_STORAGE_ENGINE
SELECT * FROM t1;
let SEARCH_PATTERN= InnoDB: Starting an apply batch of log records;
--source include/search_pattern_in_file.inc

--let $restart_parameters= --innodb-read-only
--source include/restart_mysqld.inc
Expand All @@ -98,18 +96,14 @@ let SEARCH_PATTERN= InnoDB: innodb_read_only prevents crash recovery;
--source include/restart_mysqld.inc
--error ER_UNKNOWN_STORAGE_ENGINE
SELECT * FROM t1;
let SEARCH_PATTERN= InnoDB: Starting an apply batch of log records;
--source include/search_pattern_in_file.inc
let SEARCH_PATTERN= InnoDB: Resizing redo log from 3\*[0-9]+ to 2\*[0-9]+ pages;
let SEARCH_PATTERN= redo log from 3\*[0-9]+ to 2\*[0-9]+ pages;
--source include/search_pattern_in_file.inc

--let $restart_parameters= --debug=d,innodb_log_abort_5
--source include/restart_mysqld.inc
--error ER_UNKNOWN_STORAGE_ENGINE
SELECT * FROM t1;
let SEARCH_PATTERN= InnoDB: Starting an apply batch of log records;
--source include/search_pattern_in_file.inc
let SEARCH_PATTERN= InnoDB: Resizing redo log from 3\*[0-9]+ to 2\*[0-9]+ pages;
let SEARCH_PATTERN= redo log from 3\*[0-9]+ to 2\*[0-9]+ pages;
--source include/search_pattern_in_file.inc

--let $restart_parameters= --innodb-read-only
Expand All @@ -124,9 +118,7 @@ let SEARCH_PATTERN= InnoDB: innodb_read_only prevents crash recovery;
--error ER_UNKNOWN_STORAGE_ENGINE
SELECT * FROM t1;

let SEARCH_PATTERN= InnoDB: Starting an apply batch of log records;
--source include/search_pattern_in_file.inc
let SEARCH_PATTERN= InnoDB: Resizing redo log from 3\*[0-9]+ to 2\*[0-9]+ pages;
let SEARCH_PATTERN= redo log from 3\*[0-9]+ to 2\*[0-9]+ pages;
--source include/search_pattern_in_file.inc

--let $restart_parameters= --debug=d,innodb_log_abort_7
Expand Down
19 changes: 19 additions & 0 deletions mysql-test/t/subselect4.test
Original file line number Diff line number Diff line change
Expand Up @@ -1997,5 +1997,24 @@ EXECUTE stmt;

drop table t1, t2, t3;

--echo #
--echo # MDEV-11078: NULL NOT IN (non-empty subquery) should never return results
--echo #

create table t1(a int,b int);
create table t2(a int,b int);
insert into t1 value (1,2);
select (NULL) in (select 1 from t1);
select (null) in (select 1 from t2);
select 1 in (select 1 from t1);
select 1 in (select 1 from t2);
select 1 from dual where null in (select 1 from t1);
select 1 from dual where null in (select 1 from t2);
select (null,null) in (select * from t1);
select (null,null) in (select * from t2);
select 1 from dual where null not in (select 1 from t1);
select 1 from dual where null not in (select 1 from t2);
drop table t1,t2;

SET optimizer_switch= @@global.optimizer_switch;
set @@tmp_table_size= @@global.tmp_table_size;
59 changes: 12 additions & 47 deletions mysql-test/t/subselect_innodb.test
Original file line number Diff line number Diff line change
Expand Up @@ -483,56 +483,21 @@ drop table t1;
set optimizer_switch=@subselect_innodb_tmp;

--echo #
--echo # MDEV-6041: ORDER BY+subqueries: subquery_table.key=outer_table.col is not recongized as binding
--echo # MDEV-9635:Server crashes in part_of_refkey or assertion
--echo # `!created && key_to_save < (int)s->keys' failed in
--echo # TABLE::use_index(int) or with join_cache_level>2
--echo #
create table t1(a int) engine=innodb;
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);

create table t2(
id int primary key,
key1 int,
col1 int,
key(key1)
) engine=innodb;

insert into t2
select
A.a + B.a*10 + C.a*100 + D.a* 1000,
A.a + 10*B.a,
123456
from t1 A, t1 B, t1 C, t1 D;

--echo # Table tsubq:
--echo # - must use 'ref' (not 'index'), and must not use 'Using filesort'
--echo # - shows a bad estimate for 'rows' (but I'm not sure if one can do better w/o histograms)
explain select
(SELECT
concat(id, '-', key1, '-', col1)
FROM t2
WHERE t2.key1 = t1.a
ORDER BY t2.id ASC LIMIT 1)
from
t1;
SET join_cache_level=3;

--echo #
--echo # MDEV-6081: ORDER BY+ref(const): selectivity is very incorrect (MySQL Bug#14338686)
--echo #
CREATE TABLE t1 (f1 VARCHAR(1024)) ENGINE=InnoDB;
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;

alter table t2 add key2 int;
update t2 set key2=key1;
alter table t2 add key(key2);
analyze table t2;
flush tables;
--echo # Table tsubq must use 'ref' + Using filesort (not 'index' w/o filesort)
--replace_column 9 #
explain select
(SELECT
concat(id, '-', key1, '-', col1)
FROM t2
WHERE t2.key1 = t1.a
ORDER BY t2.key2 ASC LIMIT 1)
from
t1;
CREATE TABLE t2 (f2 VARCHAR(4)) ENGINE=InnoDB;
INSERT INTO t2 VALUES ('foo'),('bar');

drop table t1,t2;
SELECT * FROM v1, t2 WHERE ( f1, f2 ) IN ( SELECT f1, f1 FROM t1 );

set join_cache_level = default;
drop view v1;
drop table t1,t2;
2 changes: 1 addition & 1 deletion plugin/server_audit/server_audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


#define PLUGIN_VERSION 0x104
#define PLUGIN_STR_VERSION "1.4.0"
#define PLUGIN_STR_VERSION "1.4.1"

#define _my_thread_var loc_thread_var

Expand Down
7 changes: 7 additions & 0 deletions sql/item_subselect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
We can encounter "NULL IN (SELECT ...)". Wrap the added condition
within a trig_cond.
*/
disable_cond_guard_for_const_null_left_expr(0);
item= new Item_func_trig_cond(item, get_cond_guard(0));
}

Expand All @@ -2072,6 +2073,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
having= new Item_is_not_null_test(this, having);
if (left_expr->maybe_null)
{
disable_cond_guard_for_const_null_left_expr(0);
if (!(having= new Item_func_trig_cond(having,
get_cond_guard(0))))
DBUG_RETURN(true);
Expand All @@ -2090,6 +2092,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
*/
if (!abort_on_null && left_expr->maybe_null)
{
disable_cond_guard_for_const_null_left_expr(0);
if (!(item= new Item_func_trig_cond(item, get_cond_guard(0))))
DBUG_RETURN(true);
}
Expand All @@ -2116,6 +2119,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
(char *)"<result>"));
if (!abort_on_null && left_expr->maybe_null)
{
disable_cond_guard_for_const_null_left_expr(0);
if (!(new_having= new Item_func_trig_cond(new_having,
get_cond_guard(0))))
DBUG_RETURN(true);
Expand Down Expand Up @@ -2311,6 +2315,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
Item *col_item= new Item_cond_or(item_eq, item_isnull);
if (!abort_on_null && left_expr->element_index(i)->maybe_null)
{
disable_cond_guard_for_const_null_left_expr(i);
if (!(col_item= new Item_func_trig_cond(col_item, get_cond_guard(i))))
DBUG_RETURN(true);
}
Expand All @@ -2325,6 +2330,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
(char *)"<list ref>"));
if (!abort_on_null && left_expr->element_index(i)->maybe_null)
{
disable_cond_guard_for_const_null_left_expr(i);
if (!(item_nnull_test=
new Item_func_trig_cond(item_nnull_test, get_cond_guard(i))))
DBUG_RETURN(true);
Expand Down Expand Up @@ -2381,6 +2387,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
item= new Item_cond_or(item, item_isnull);
if (left_expr->element_index(i)->maybe_null)
{
disable_cond_guard_for_const_null_left_expr(i);
if (!(item= new Item_func_trig_cond(item, get_cond_guard(i))))
DBUG_RETURN(true);
if (!(having_col_item=
Expand Down
9 changes: 9 additions & 0 deletions sql/item_subselect.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,15 @@ class Item_in_subselect :public Item_exists_subselect
bool expr_cache_is_needed(THD *thd);
inline bool left_expr_has_null();

void disable_cond_guard_for_const_null_left_expr(int i)
{
if (left_expr->const_item() && !left_expr->is_expensive())
{
if (left_expr->element_index(i)->is_null())
set_cond_guard_var(i,FALSE);
}
}

int optimize(double *out_rows, double *cost);
/*
Return the identifier that we could use to identify the subquery for the
Expand Down
33 changes: 16 additions & 17 deletions sql/log_slow.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2009 Monty Program Ab
/* Copyright (C) 2009, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -16,23 +16,22 @@
/* Defining what to log to slow log */

#define LOG_SLOW_VERBOSITY_INIT 0
#define LOG_SLOW_VERBOSITY_INNODB (1 << 0)
#define LOG_SLOW_VERBOSITY_QUERY_PLAN (1 << 1)
#define LOG_SLOW_VERBOSITY_EXPLAIN (1 << 2)
#define LOG_SLOW_VERBOSITY_INNODB (1U << 0)
#define LOG_SLOW_VERBOSITY_QUERY_PLAN (1U << 1)
#define LOG_SLOW_VERBOSITY_EXPLAIN (1U << 2)

#define QPLAN_INIT QPLAN_QC_NO

#define QPLAN_ADMIN (1 << 0)
#define QPLAN_FILESORT (1 << 1)
#define QPLAN_FILESORT_DISK (1 << 2)
#define QPLAN_FULL_JOIN (1 << 3)
#define QPLAN_FULL_SCAN (1 << 4)
#define QPLAN_QC (1 << 5)
#define QPLAN_QC_NO (1 << 6)
#define QPLAN_TMP_DISK (1 << 7)
#define QPLAN_TMP_TABLE (1 << 8)
#define QPLAN_FILESORT_PRIORITY_QUEUE (1 << 9)

#define QPLAN_ADMIN (1U << 0)
#define QPLAN_FILESORT (1U << 1)
#define QPLAN_FILESORT_DISK (1U << 2)
#define QPLAN_FULL_JOIN (1U << 3)
#define QPLAN_FULL_SCAN (1U << 4)
#define QPLAN_QC (1U << 5)
#define QPLAN_QC_NO (1U << 6)
#define QPLAN_TMP_DISK (1U << 7)
#define QPLAN_TMP_TABLE (1U << 8)
#define QPLAN_FILESORT_PRIORITY_QUEUE (1U << 9)
/* ... */
#define QPLAN_MAX (((ulong) 1) << 31) /* reserved as placeholder */

#define QPLAN_MAX (1U << 31) /* reserved as placeholder */
2 changes: 1 addition & 1 deletion sql/sql_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10149,7 +10149,7 @@ void JOIN::drop_unused_derived_keys()
continue;
if (!table->pos_in_table_list->is_materialized_derived())
continue;
if (table->max_keys > 1)
if (table->max_keys > 1 && !tab->is_ref_for_hash_join())
table->use_index(tab->ref.key);
if (table->s->keys)
{
Expand Down
Loading

0 comments on commit 47396dd

Please sign in to comment.