diff options
author | Nirbhay Choubey <nirbhay@mariadb.com> | 2015-12-19 14:24:38 -0500 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2015-12-19 14:24:38 -0500 |
commit | dad555a09c8d590132c77c192a18d7fc1f8fe91e (patch) | |
tree | 38fb545e5df0a24333b8284c816f5bea95d19a03 /sql/sql_insert.cc | |
parent | 18173ddfc4081407832d9a6703d1b8356b7defe9 (diff) | |
parent | 90ea0145856338221803ebb9b446ed2a6e082412 (diff) | |
download | mariadb-git-dad555a09c8d590132c77c192a18d7fc1f8fe91e.tar.gz |
Merge tag 'mariadb-10.0.23' into 10.0-galera
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 4e033f21b25..ef4c4421df0 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2006,7 +2006,7 @@ public: */ MDL_request grl_protection; - Delayed_insert() + Delayed_insert(SELECT_LEX *current_select) :locks_in_memory(0), table(0),tables_in_use(0),stacked_inserts(0), status(0), handler_thread_initialized(FALSE), group_count(0) { @@ -2016,7 +2016,7 @@ public: strmake_buf(thd.security_ctx->priv_user, thd.security_ctx->user); thd.current_tablenr=0; thd.set_command(COM_DELAYED_INSERT); - thd.lex->current_select= 0; // for my_message_sql + thd.lex->current_select= current_select; thd.lex->sql_command= SQLCOM_INSERT; // For innodb::store_lock() /* Prevent changes to global.lock_wait_timeout from affecting @@ -2193,7 +2193,7 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request, */ if (! (di= find_handler(thd, table_list))) { - if (!(di= new Delayed_insert())) + if (!(di= new Delayed_insert(thd->lex->current_select))) goto end_create; thread_safe_increment32(&thread_count, &thread_count_lock); @@ -2836,6 +2836,16 @@ pthread_handler_t handle_delayed_insert(void *arg) if (di->open_and_lock_table()) goto err; + /* + INSERT DELAYED generally expects thd->lex->current_select to be NULL, + since this is not an attribute of the current thread. This can lead to + problems if the thread that spawned the current one disconnects. + current_select will then point to freed memory. But current_select is + required to resolve the partition function. So, after fulfilling that + requirement, we set the current_select to 0. + */ + thd->lex->current_select= NULL; + /* Tell client that the thread is initialized */ mysql_cond_signal(&di->cond_client); |