summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorSergey Glukhov <sergey.glukhov@oracle.com>2011-10-05 13:28:20 +0400
committerSergey Glukhov <sergey.glukhov@oracle.com>2011-10-05 13:28:20 +0400
commitfcd99c156ba85af9af11c41a0ad8c5abe25e2b8e (patch)
tree27192e80c7e7886d1587e695346110e3cec09e9f /sql/sql_select.cc
parent836c3a2378518cf09ef2cf05bc73a947db20770d (diff)
downloadmariadb-git-fcd99c156ba85af9af11c41a0ad8c5abe25e2b8e.tar.gz
Bug#11747970 34660: CRASH WHEN FEDERATED TABLE LOSES CONNECTION DURING INSERT ... SELECT
Problematic query: insert ignore into `t1_federated` (`c1`) select `c1` from `t1_local` a where not exists (select 1 from `t1_federated` b where a.c1 = b.c1); When this query is killed in another connection it could lead to crash. The problem is follwing: An attempt to obtain table statistics for subselect table in killed query fails with an error. So JOIN::optimize() for subquery is failed but it does not prevent further subquery evaluation. At the first subquery execution JOIN::optimize() is called (see subselect_single_select_engine::exec()) and fails with an error. 'executed' flag is set to TRUE and it prevents further subquery evaluation. At the second call JOIN::optimize() does not happen as 'JOIN::optimized' is TRUE and in case of uncacheable subquery the 'executed' flag is set to FALSE before subquery evaluation. So we loose 'optimize stage' error indication (see subselect_single_select_engine::exec()). In other words 'executed' flag is used for two purposes, for error indication at JOIN::optimize() stage and for an indication of subquery execution. And it seems it's wrong as the flag could be reset.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 516c9c37473..bf0cd7c9db8 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2677,6 +2677,16 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
table_vector[i]=s->table=table=tables->table;
table->pos_in_table_list= tables;
error= table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
+
+ DBUG_EXECUTE_IF("bug11747970_raise_error",
+ {
+ if (!error)
+ {
+ my_error(ER_UNKNOWN_ERROR, MYF(0));
+ goto error;
+ }
+ });
+
if (error)
{
table->file->print_error(error, MYF(0));