summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-12-21 21:24:22 +0100
committerSergei Golubchik <serg@mariadb.org>2015-12-21 21:24:22 +0100
commita2bcee626d4ef2836e38e4932305871390164644 (patch)
treeb41e357427318bad8985078b91bbd2b0360defc8 /sql/sql_insert.cc
parent1788bfe93a745582d938a608d5959b7d2e6b2f23 (diff)
parent4fdf25afa8188905653a83e08fc387243e584600 (diff)
downloadmariadb-git-a2bcee626d4ef2836e38e4932305871390164644.tar.gz
Merge branch '10.0' into 10.1
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 7a0a114971d..a04cbb573e1 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -2031,7 +2031,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)
{
@@ -2041,7 +2041,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
@@ -2218,7 +2218,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);
@@ -2870,6 +2870,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);