diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-07-02 17:46:22 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-07-02 17:46:22 +0300 |
commit | e82fe21e3ac3141c92b7c4fb2d1fc3c083d834e8 (patch) | |
tree | 3ecf4329b6a623165aa6cb392ae71998de50c89e /sql | |
parent | 709f0510e32981c59d7353e55a564073939db770 (diff) | |
parent | 7f1e1309bbd54a7923cf33a37938a29171ca0993 (diff) | |
download | mariadb-git-e82fe21e3ac3141c92b7c4fb2d1fc3c083d834e8.tar.gz |
Merge 10.2 into 10.3
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_cmpfunc.h | 2 | ||||
-rw-r--r-- | sql/protocol.cc | 11 | ||||
-rw-r--r-- | sql/sql_audit.cc | 16 | ||||
-rw-r--r-- | sql/sql_audit.h | 1 | ||||
-rw-r--r-- | sql/sql_class.cc | 3 | ||||
-rw-r--r-- | sql/sql_class.h | 1 | ||||
-rw-r--r-- | sql/sql_connect.cc | 3 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 3 | ||||
-rw-r--r-- | sql/sql_plugin.h | 1 | ||||
-rw-r--r-- | sql/threadpool_common.cc | 3 |
10 files changed, 42 insertions, 2 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 7d99cbdb936..21f4a5ba1e2 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -286,6 +286,7 @@ public: virtual const char* func_name() const { return "isnottrue"; } Item *get_copy(THD *thd) { return get_item_copy<Item_func_isnottrue>(thd, this); } + bool eval_not_null_tables(void *) { not_null_tables_cache= 0; return false; } }; @@ -317,6 +318,7 @@ public: virtual const char* func_name() const { return "isnotfalse"; } Item *get_copy(THD *thd) { return get_item_copy<Item_func_isnotfalse>(thd, this); } + bool eval_not_null_tables(void *) { not_null_tables_cache= 0; return false; } }; diff --git a/sql/protocol.cc b/sql/protocol.cc index 84ca4585a12..02c95a42695 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -461,6 +461,17 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err, */ if ((save_compress= net->compress)) net->compress= 2; + + /* + Sometimes, we send errors "out-of-band", e.g ER_CONNECTION_KILLED + on an idle connection. The current protocol "sequence number" is 0, + however some client drivers would however always expect packets + coming from server to have seq_no > 0, due to missing awareness + of "out-of-band" operations. Make these clients happy. + */ + if (!net->pkt_nr) + net->pkt_nr= 1; + ret= net_write_command(net,(uchar) 255, (uchar*) "", 0, (uchar*) buff, length); net->compress= save_compress; diff --git a/sql/sql_audit.cc b/sql/sql_audit.cc index e8a00abf30b..ed175ae4865 100644 --- a/sql/sql_audit.cc +++ b/sql/sql_audit.cc @@ -119,12 +119,27 @@ void mysql_audit_acquire_plugins(THD *thd, ulong *event_class_mask) { plugin_foreach(thd, acquire_plugins, MYSQL_AUDIT_PLUGIN, event_class_mask); add_audit_mask(thd->audit_class_mask, event_class_mask); + thd->audit_plugin_version= global_plugin_version; } DBUG_VOID_RETURN; } /** + Check if there were changes in the state of plugins + so we need to do the mysql_audit_release asap. + + @param[in] thd + +*/ + +my_bool mysql_audit_release_required(THD *thd) +{ + return thd && (thd->audit_plugin_version != global_plugin_version); +} + + +/** Release any resources associated with the current thd. @param[in] thd @@ -159,6 +174,7 @@ void mysql_audit_release(THD *thd) /* Reset the state of thread values */ reset_dynamic(&thd->audit_class_plugins); bzero(thd->audit_class_mask, sizeof(thd->audit_class_mask)); + thd->audit_plugin_version= -1; } diff --git a/sql/sql_audit.h b/sql/sql_audit.h index 327fe6052ab..59cced13b0a 100644 --- a/sql/sql_audit.h +++ b/sql/sql_audit.h @@ -58,6 +58,7 @@ static inline void mysql_audit_notify(THD *thd, uint event_class, #define mysql_audit_connection_enabled() 0 #define mysql_audit_table_enabled() 0 #endif +extern my_bool mysql_audit_release_required(THD *thd); extern void mysql_audit_release(THD *thd); static inline unsigned int strlen_uint(const char *s) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 32fd2cf5edd..455c5fd47b5 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -629,6 +629,9 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) waiting_on_group_commit(FALSE), has_waiter(FALSE), spcont(NULL), m_parser_state(NULL), +#ifndef EMBEDDED_LIBRARY + audit_plugin_version(-1), +#endif #if defined(ENABLED_DEBUG_SYNC) debug_sync_control(0), #endif /* defined(ENABLED_DEBUG_SYNC) */ diff --git a/sql/sql_class.h b/sql/sql_class.h index fa2fadd598e..acf699f72e3 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3255,6 +3255,7 @@ public: added to the list of audit plugins which are currently in use. */ unsigned long audit_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE]; + int audit_plugin_version; #endif #if defined(ENABLED_DEBUG_SYNC) diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 17aba33a76e..826951f7c9d 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1398,7 +1398,8 @@ void do_handle_one_connection(CONNECT *connect) while (thd_is_connection_alive(thd)) { - mysql_audit_release(thd); + if (mysql_audit_release_required(thd)) + mysql_audit_release(thd); if (do_command(thd)) break; } diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 7ebc0781a7c..b568c5cb229 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -227,6 +227,7 @@ static DYNAMIC_ARRAY plugin_array; static HASH plugin_hash[MYSQL_MAX_PLUGIN_TYPE_NUM]; static MEM_ROOT plugin_mem_root; static bool reap_needed= false; +volatile int global_plugin_version= 1; static bool initialized= 0; ulong dlopen_count; @@ -2217,6 +2218,7 @@ bool mysql_install_plugin(THD *thd, const LEX_CSTRING *name, reap_plugins(); } err: + global_plugin_version++; mysql_mutex_unlock(&LOCK_plugin); if (argv) free_defaults(argv); @@ -2364,6 +2366,7 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_CSTRING *name, } reap_plugins(); + global_plugin_version++; mysql_mutex_unlock(&LOCK_plugin); DBUG_RETURN(error); diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index b60fe0f13eb..352d1e22ac4 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -38,6 +38,7 @@ enum enum_plugin_load_option { PLUGIN_OFF, PLUGIN_ON, PLUGIN_FORCE, PLUGIN_FORCE_PLUS_PERMANENT }; extern const char *global_plugin_typelib_names[]; +extern volatile int global_plugin_version; extern ulong dlopen_count; #include <my_sys.h> diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc index 75b924a7569..6a4139197f9 100644 --- a/sql/threadpool_common.cc +++ b/sql/threadpool_common.cc @@ -353,7 +353,8 @@ static int threadpool_process_request(THD *thd) { Vio *vio; thd->net.reading_or_writing= 0; - mysql_audit_release(thd); + if (mysql_audit_release_required(thd)) + mysql_audit_release(thd); if ((retval= do_command(thd)) != 0) goto end; |