diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2019-12-02 14:35:10 +0200 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2019-12-02 14:35:10 +0200 |
commit | 9d9a2253c6b41a70de9314118ac067f1f869ff8d (patch) | |
tree | 06c295ab42075e7985b278273fef5c75845443ec /sql | |
parent | 8d2a57b4b7b9f6c7894ebf285a5c390e40fdc806 (diff) | |
parent | c6ed37b88a36bdadb5dbd47dc5ce84bbe847faba (diff) | |
download | mariadb-git-9d9a2253c6b41a70de9314118ac067f1f869ff8d.tar.gz |
Merge remote-tracking branch 10.2 into 10.3
Conflicts:
mysql-test/suite/galera/t/galera_binlog_event_max_size_max-master.opt
mysql-test/suite/innodb/r/innodb-mdev-7513.result
mysql-test/suite/innodb/t/innodb-mdev-7513.test
mysql-test/suite/wsrep/disabled.def
storage/innobase/ibuf/ibuf0ibuf.cc
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_cmpfunc.h | 2 | ||||
-rw-r--r-- | sql/sql_insert.cc | 81 |
2 files changed, 78 insertions, 5 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 4bb2e0a5dee..24a9991640a 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -2611,7 +2611,6 @@ class Item_func_like :public Item_bool_func2 bool escape_used_in_parsing; bool use_sampling; - bool negated; DTCollation cmp_collation; String cmp_value1, cmp_value2; @@ -2628,6 +2627,7 @@ protected: Item_func::Functype type, Item *value); public: int escape; + bool negated; Item_func_like(THD *thd, Item *a, Item *b, Item *escape_arg, bool escape_used): Item_bool_func2(thd, a, b), canDoTurboBM(FALSE), pattern(0), pattern_len(0), diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index e747b645e9d..0c01bcd4cb2 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2115,11 +2115,15 @@ public: ulong auto_increment_offset; LEX_STRING query; Time_zone *time_zone; + char *user, *host, *ip; + query_id_t query_id; + my_thread_id thread_id; delayed_row(LEX_STRING const query_arg, enum_duplicates dup_arg, bool ignore_arg, bool log_query_arg) : record(0), dup(dup_arg), ignore(ignore_arg), log_query(log_query_arg), - forced_insert_id(0), query(query_arg), time_zone(0) + forced_insert_id(0), query(query_arg), time_zone(0), + user(0), host(0), ip(0) {} ~delayed_row() { @@ -2167,6 +2171,27 @@ 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()), @@ -2174,8 +2199,8 @@ public: status(0), retry(0), handler_thread_initialized(FALSE), group_count(0) { DBUG_ENTER("Delayed_insert constructor"); - thd.security_ctx->user=(char*) delayed_user; - thd.security_ctx->host=(char*) my_localhost; + orig_thread_id= thd.thread_id; + set_default_user(); strmake_buf(thd.security_ctx->priv_user, thd.security_ctx->user); thd.current_tablenr=0; thd.set_command(COM_DELAYED_INSERT); @@ -2682,6 +2707,7 @@ int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic, delayed_row *row= 0; Delayed_insert *di=thd->di; const Discrete_interval *forced_auto_inc; + size_t user_len, host_len, ip_len; DBUG_ENTER("write_delayed"); DBUG_PRINT("enter", ("query = '%s' length %lu", query.str, (ulong) query.length)); @@ -2715,11 +2741,45 @@ int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic, goto err; } + user_len= host_len= ip_len= 0; + row->user= row->host= row->ip= NULL; + if (thd->security_ctx) + { + if (thd->security_ctx->user) + user_len= strlen(thd->security_ctx->user) + 1; + if (thd->security_ctx->host) + host_len= strlen(thd->security_ctx->host) + 1; + if (thd->security_ctx->ip) + ip_len= strlen(thd->security_ctx->ip) + 1; + } /* This can't be THREAD_SPECIFIC as it's freed in delayed thread */ - if (!(row->record= (char*) my_malloc(table->s->reclength, + if (!(row->record= (char*) my_malloc(table->s->reclength + + user_len + host_len + ip_len, MYF(MY_WME)))) goto err; memcpy(row->record, table->record[0], table->s->reclength); + + if (thd->security_ctx) + { + if (thd->security_ctx->user) + { + row->user= row->record + table->s->reclength; + memcpy(row->user, thd->security_ctx->user, user_len); + } + if (thd->security_ctx->host) + { + row->host= row->record + table->s->reclength + user_len; + memcpy(row->host, thd->security_ctx->host, host_len); + } + if (thd->security_ctx->ip) + { + row->ip= row->record + table->s->reclength + user_len + host_len; + memcpy(row->ip, thd->security_ctx->ip, ip_len); + } + } + row->query_id= thd->query_id; + row->thread_id= thd->thread_id; + row->start_time= thd->start_time; row->start_time_sec_part= thd->start_time_sec_part; row->query_start_sec_part_used= thd->query_start_sec_part_used; @@ -3118,6 +3178,7 @@ 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. @@ -3137,6 +3198,18 @@ pthread_handler_t handle_delayed_insert(void *arg) } if (di->stacked_inserts) { + delayed_row *row; + I_List_iterator<delayed_row> it(di->rows); + while ((row= it++)) + { + if (di->thd.thread_id != row->thread_id) + { + di->set_user_from_row(row); + mysql_audit_external_lock(&di->thd, di->table->s, F_WRLCK); + } + } + di->set_default_user(); + if (di->handle_inserts()) { /* Some fatal error */ |