Skip to content

Commit ecfdc6f

Browse files
author
Guilhem Bichot
committed
fix for Bug#13820776 CRASH IN HANDLER::HA_STATISTIC_INCREMENT IF QUERY IS KILLED
1 parent dceed2e commit ecfdc6f

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

mysql-test/r/kill_debug.result

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
SET @old_debug= @@session.debug;
2+
Bug#13820776 CRASH IN HANDLER::HA_STATISTIC_INCREMENT IF QUERY IS KILLED
3+
CREATE TABLE g9(a INT) ENGINE=INNODB;
4+
SELECT 1 FROM g9
5+
RIGHT JOIN (SELECT 1 FROM g9) AS d1 ON 1 LEFT JOIN
6+
(SELECT 1 FROM g9) AS d2 ON 1;
7+
1
8+
SET debug= '+d,bug13820776_1';
9+
SELECT 1 FROM g9
10+
RIGHT JOIN (SELECT 1 FROM g9) AS d1 ON 1 LEFT JOIN
11+
(SELECT 1 FROM g9) AS d2 ON 1;
12+
ERROR 70100: Query execution was interrupted
13+
SET debug= '-d,bug13820776_1';
14+
SET debug= '+d,bug13820776_2';
15+
SELECT 1 FROM g9
16+
RIGHT JOIN (SELECT 1 FROM g9) AS d1 ON 1 LEFT JOIN
17+
(SELECT 1 FROM g9) AS d2 ON 1;
18+
ERROR 70100: Query execution was interrupted
19+
SET debug= '-d,bug13820776_2';
20+
DROP TABLE g9;
21+
SET debug= @old_debug;

mysql-test/t/kill_debug.test

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--source include/have_debug.inc
2+
3+
SET @old_debug= @@session.debug;
4+
5+
--echo Bug#13820776 CRASH IN HANDLER::HA_STATISTIC_INCREMENT IF QUERY IS KILLED
6+
7+
CREATE TABLE g9(a INT) ENGINE=INNODB;
8+
9+
let $query=SELECT 1 FROM g9
10+
RIGHT JOIN (SELECT 1 FROM g9) AS d1 ON 1 LEFT JOIN
11+
(SELECT 1 FROM g9) AS d2 ON 1;
12+
13+
eval $query;
14+
15+
SET debug= '+d,bug13820776_1';
16+
--error ER_QUERY_INTERRUPTED
17+
eval $query;
18+
SET debug= '-d,bug13820776_1';
19+
20+
SET debug= '+d,bug13820776_2';
21+
--error ER_QUERY_INTERRUPTED
22+
eval $query;
23+
SET debug= '-d,bug13820776_2';
24+
25+
DROP TABLE g9;
26+
SET debug= @old_debug;

sql/sql_optimizer.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ JOIN::optimize()
151151
Run optimize phase for all derived tables/views used in this SELECT,
152152
including those in semi-joins.
153153
*/
154-
select_lex->handle_derived(thd->lex, &mysql_derived_optimize);
154+
if (select_lex->handle_derived(thd->lex, &mysql_derived_optimize))
155+
DBUG_RETURN(1);
155156

156157
/* dump_TABLE_LIST_graph(select_lex, select_lex->leaf_tables); */
157158

@@ -3406,8 +3407,12 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, Item *conds,
34063407
if (optimize_semijoin_nests_for_materialization(join))
34073408
DBUG_RETURN(true);
34083409

3409-
if (Optimize_table_order(thd, join, NULL).choose_table_order() || thd->killed)
3410-
DBUG_RETURN(true);
3410+
if (Optimize_table_order(thd, join, NULL).choose_table_order())
3411+
DBUG_RETURN(true);
3412+
3413+
DBUG_EXECUTE_IF("bug13820776_1", thd->killed= THD::KILL_QUERY;);
3414+
if (thd->killed)
3415+
DBUG_RETURN(true);
34113416

34123417
/* Generate an execution plan from the found optimal join order. */
34133418
if (join->get_best_combination())

sql/sql_planner.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,7 @@ bool Optimize_table_order::best_extension_by_limited_search(
17541754
{
17551755
DBUG_ENTER("Optimize_table_order::best_extension_by_limited_search");
17561756

1757+
DBUG_EXECUTE_IF("bug13820776_2", thd->killed= THD::KILL_QUERY;);
17571758
if (thd->killed) // Abort
17581759
DBUG_RETURN(true);
17591760
Opt_trace_context * const trace= &thd->opt_trace;

0 commit comments

Comments
 (0)