diff --git a/mysql-test/r/union_crash-714.result b/mysql-test/r/union_crash-714.result new file mode 100644 index 00000000000..2811f8bd7f5 --- /dev/null +++ b/mysql-test/r/union_crash-714.result @@ -0,0 +1,5 @@ +create table t1 (i tinyint); +set debug='+d,bug11747970_raise_error'; +insert into t1 (i) select i from t1 union select i from t1; +ERROR 70100: Query execution was interrupted +drop table t1; diff --git a/mysql-test/t/union_crash-714.test b/mysql-test/t/union_crash-714.test new file mode 100644 index 00000000000..a1fb9c12ec1 --- /dev/null +++ b/mysql-test/t/union_crash-714.test @@ -0,0 +1,9 @@ +# +# MDEV-714 LP:1020645 - crash (sig 11) with union query +# +--source include/have_debug.inc +create table t1 (i tinyint); +set debug='+d,bug11747970_raise_error'; +--error ER_QUERY_INTERRUPTED +insert into t1 (i) select i from t1 union select i from t1; +drop table t1; diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 5ca4af8eb0d..f9fecae38c4 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -629,7 +629,8 @@ bool st_select_lex_unit::exec() if (!(uncacheable & ~UNCACHEABLE_EXPLAIN) && item) item->make_const(); - saved_error= optimize(); + if ((saved_error= optimize())) + DBUG_RETURN(saved_error); if (uncacheable || !item || !item->assigned() || describe) {