summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/item_cmpfunc.h2
-rw-r--r--sql/protocol.cc11
-rw-r--r--sql/sql_audit.cc16
-rw-r--r--sql/sql_audit.h1
-rw-r--r--sql/sql_class.cc3
-rw-r--r--sql/sql_class.h1
-rw-r--r--sql/sql_connect.cc3
-rw-r--r--sql/sql_plugin.cc3
-rw-r--r--sql/sql_plugin.h1
-rw-r--r--sql/threadpool_common.cc3
10 files changed, 42 insertions, 2 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 2af7ebdf231..776ac27eb75 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -291,6 +291,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; }
};
@@ -322,6 +323,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 83b4dc80ae2..8c7eeaec90c 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 94e2b518fa4..a5066dd9f54 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -632,6 +632,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 dd9cfbbd1c4..18ccf992d1e 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -3231,6 +3231,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 cb030296eec..b8fff8c864a 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -1399,7 +1399,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 a6672e2be2c..a5f27e2c562 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;
@@ -2225,6 +2226,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);
@@ -2375,6 +2377,7 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_CSTRING *name,
}
reap_plugins();
+ global_plugin_version++;
mysql_mutex_unlock(&LOCK_plugin);
DBUG_RETURN(error);
#ifdef WITH_WSREP
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 4dd0fa35b40..cfb831e2f55 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;