diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2013-10-18 13:44:39 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2013-10-18 13:44:39 +0400 |
commit | 60c55522c3afca0e6ee422ea3a98ddc02761c196 (patch) | |
tree | d6c8b7e17d7a9d95a291bb2896c51d84961e0b98 | |
parent | 5258e642ccdae3c6e39054b5e415bdaf80a4509b (diff) | |
download | mariadb-git-60c55522c3afca0e6ee422ea3a98ddc02761c196.tar.gz |
MDEV-5148: Server crashes in print_explain on killing EXPLAIN EXTENDED
- Make mysql_select() return error when the query was killed.
-rw-r--r-- | mysql-test/r/show_explain.result | 18 | ||||
-rw-r--r-- | mysql-test/t/show_explain.test | 30 | ||||
-rw-r--r-- | sql/sql_select.cc | 12 |
3 files changed, 56 insertions, 4 deletions
diff --git a/mysql-test/r/show_explain.result b/mysql-test/r/show_explain.result index 7e0ac0b277c..5d7057a0937 100644 --- a/mysql-test/r/show_explain.result +++ b/mysql-test/r/show_explain.result @@ -1166,6 +1166,22 @@ SUM(b) 0 set debug_dbug=@old_debug; DROP TABLE t1,t2; -# End drop table t0; +# +# MDEV-5148: Server crashes in print_explain on killing EXPLAIN EXTENDED +# +create table t0 (a int not null); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 as select * from t1; +set @show_explain_probe_select_id=2; +set debug_dbug='+d,show_explain_probe_best_ext_lim_search'; +explain +select * from t0 +where not exists ( select 1 from t1, t2 where t1.b=t2.b and t2.a=t0.a) and a is null; +kill query $thr2; +ERROR 70100: Query execution was interrupted +drop table t0,t1,t2; +# End set debug_sync='RESET'; diff --git a/mysql-test/t/show_explain.test b/mysql-test/t/show_explain.test index 2ac4e214dbc..83c05d93007 100644 --- a/mysql-test/t/show_explain.test +++ b/mysql-test/t/show_explain.test @@ -1167,9 +1167,37 @@ reap; set debug_dbug=@old_debug; DROP TABLE t1,t2; +drop table t0; + +--echo # +--echo # MDEV-5148: Server crashes in print_explain on killing EXPLAIN EXTENDED +--echo # +create table t0 (a int not null); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1 (a int, b int); +insert into t1 select a,a from t0; + +create table t2 as select * from t1; + +set @show_explain_probe_select_id=2; +set debug_dbug='+d,show_explain_probe_best_ext_lim_search'; +send +explain +select * from t0 +where not exists ( select 1 from t1, t2 where t1.b=t2.b and t2.a=t0.a) and a is null; + +connection default; +--source include/wait_condition.inc +evalp kill query $thr2; + +connection con1; +--error ER_QUERY_INTERRUPTED +reap; + +drop table t0,t1,t2; --echo # End -drop table t0; connection default; disconnect con1; set debug_sync='RESET'; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2d6b5aa18fd..77205c7ce07 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3200,7 +3200,7 @@ mysql_select(THD *thd, Item ***rref_pointer_array, select_result *result, SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex) { - bool err; + int err= 0; bool free_join= 1; DBUG_ENTER("mysql_select"); @@ -3294,7 +3294,7 @@ err: err|= select_lex->cleanup(); DBUG_RETURN(err || thd->is_error()); } - DBUG_RETURN(join->error); + DBUG_RETURN(join->error ? join->error: err); } @@ -7412,6 +7412,14 @@ best_extension_by_limited_search(JOIN *join, DBUG_ENTER("best_extension_by_limited_search"); THD *thd= join->thd; + + DBUG_EXECUTE_IF("show_explain_probe_best_ext_lim_search", + if (dbug_user_var_equals_int(thd, + "show_explain_probe_select_id", + join->select_lex->select_number)) + dbug_serve_apcs(thd, 1); + ); + if (thd->check_killed()) // Abort DBUG_RETURN(TRUE); |