summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-12-27 13:05:06 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-12-27 15:14:48 +0200
commit5ab70e7f68ba9659dbdd8c71759cfe99ee90ebf2 (patch)
treecde569f712505f981e7a43f01e82c600e282c88c /sql/sql_insert.cc
parentee9a19fb054085fcea006a25ec957e0d5cb01ce8 (diff)
parent16bce0f6fe6bcad0091dc45a97a8ac7b33fe9d44 (diff)
downloadmariadb-git-5ab70e7f68ba9659dbdd8c71759cfe99ee90ebf2.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc41
1 files changed, 11 insertions, 30 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 0c01bcd4cb2..bbd639b91d3 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -2171,36 +2171,16 @@ public:
passed from connection thread to the handler thread.
*/
MDL_request grl_protection;
- my_thread_id orig_thread_id;
- void set_default_user()
- {
- thd.security_ctx->user=(char*) delayed_user;
- thd.security_ctx->host=(char*) my_localhost;
- thd.security_ctx->ip= NULL;
- thd.query_id= 0;
- thd.thread_id= orig_thread_id;
- }
-
- void set_user_from_row(const delayed_row *r)
- {
- if (r)
- {
- thd.security_ctx->user= r->user;
- thd.security_ctx->host= r->host;
- thd.security_ctx->ip= r->ip;
- thd.query_id= r->query_id;
- thd.thread_id= r->thread_id;
- }
- }
-
Delayed_insert(SELECT_LEX *current_select)
:locks_in_memory(0), thd(next_thread_id()),
table(0),tables_in_use(0), stacked_inserts(0),
status(0), retry(0), handler_thread_initialized(FALSE), group_count(0)
{
DBUG_ENTER("Delayed_insert constructor");
- orig_thread_id= thd.thread_id;
- set_default_user();
+ thd.security_ctx->user=(char*) delayed_user;
+ thd.security_ctx->host=(char*) my_localhost;
+ thd.security_ctx->ip= NULL;
+ thd.query_id= 0;
strmake_buf(thd.security_ctx->priv_user, thd.security_ctx->user);
thd.current_tablenr=0;
thd.set_command(COM_DELAYED_INSERT);
@@ -3178,7 +3158,6 @@ pthread_handler_t handle_delayed_insert(void *arg)
if (di->tables_in_use && ! thd->lock && !thd->killed)
{
- di->set_user_from_row(di->rows.head());
/*
Request for new delayed insert.
Lock the table, but avoid to be blocked by a global read lock.
@@ -3200,16 +3179,18 @@ pthread_handler_t handle_delayed_insert(void *arg)
{
delayed_row *row;
I_List_iterator<delayed_row> it(di->rows);
+ my_thread_id cur_thd= di->thd.thread_id;
+
while ((row= it++))
{
- if (di->thd.thread_id != row->thread_id)
+ if (cur_thd != row->thread_id)
{
- di->set_user_from_row(row);
- mysql_audit_external_lock(&di->thd, di->table->s, F_WRLCK);
+ mysql_audit_external_lock_ex(&di->thd, row->thread_id,
+ row->user, row->host, row->ip, row->query_id,
+ di->table->s, F_WRLCK);
+ cur_thd= row->thread_id;
}
}
- di->set_default_user();
-
if (di->handle_inserts())
{
/* Some fatal error */