summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'plugin')
-rw-r--r--plugin/feedback/sender_thread.cc2
-rw-r--r--plugin/feedback/url_http.cc2
-rw-r--r--plugin/feedback/utils.cc5
-rw-r--r--plugin/handler_socket/handlersocket/database.cpp2
-rw-r--r--plugin/metadata_lock_info/CMakeLists.txt2
-rw-r--r--plugin/metadata_lock_info/metadata_lock_info.cc188
-rw-r--r--plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/global_read_lock.result10
-rw-r--r--plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/table_metadata_lock.result13
-rw-r--r--plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/user_lock.result13
-rw-r--r--plugin/metadata_lock_info/mysql-test/metadata_lock_info/suite.opt2
-rw-r--r--plugin/metadata_lock_info/mysql-test/metadata_lock_info/suite.pm9
-rw-r--r--plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/global_read_lock.test5
-rw-r--r--plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/table_metadata_lock.test8
-rw-r--r--plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/user_lock.test5
-rw-r--r--plugin/qc_info/qc_info.cc2
-rw-r--r--plugin/query_response_time/query_response_time.cc4
-rw-r--r--plugin/query_response_time/query_response_time.h4
-rw-r--r--plugin/semisync/semisync.h1
-rw-r--r--plugin/semisync/semisync_master.cc10
-rw-r--r--plugin/semisync/semisync_master.h2
-rw-r--r--plugin/semisync/semisync_master_plugin.cc20
21 files changed, 287 insertions, 22 deletions
diff --git a/plugin/feedback/sender_thread.cc b/plugin/feedback/sender_thread.cc
index 4ab45998484..465bdfa8feb 100644
--- a/plugin/feedback/sender_thread.cc
+++ b/plugin/feedback/sender_thread.cc
@@ -100,7 +100,7 @@ static int prepare_for_fill(TABLE_LIST *tables)
thd->mysys_var->current_cond= &sleep_condition;
thd->mysys_var->current_mutex= &sleep_mutex;
thd->proc_info="feedback";
- thd->command=COM_SLEEP;
+ thd->set_command(COM_SLEEP);
thd->system_thread= SYSTEM_THREAD_EVENT_WORKER; // whatever
thd->set_time();
thd->init_for_queries();
diff --git a/plugin/feedback/url_http.cc b/plugin/feedback/url_http.cc
index dd39adbf7a7..f214f7a6ccc 100644
--- a/plugin/feedback/url_http.cc
+++ b/plugin/feedback/url_http.cc
@@ -195,7 +195,7 @@ int Url_http::send(const char* data, size_t data_length)
{
enum enum_ssl_init_error ssl_init_error= SSL_INITERR_NOERROR;
ulong ssl_error= 0;
- if (!(ssl_fd= new_VioSSLConnectorFd(0, 0, 0, 0, 0, &ssl_init_error)) ||
+ if (!(ssl_fd= new_VioSSLConnectorFd(0, 0, 0, 0, 0, &ssl_init_error, 0, 0)) ||
sslconnect(ssl_fd, vio, send_timeout, &ssl_error))
{
const char *err;
diff --git a/plugin/feedback/utils.cc b/plugin/feedback/utils.cc
index f6ed00386f7..0510140aee9 100644
--- a/plugin/feedback/utils.cc
+++ b/plugin/feedback/utils.cc
@@ -393,7 +393,6 @@ int calculate_server_uid(char *dest)
{
uchar rawbuf[2 + 6];
uchar shabuf[SHA1_HASH_SIZE];
- SHA1_CONTEXT ctx;
int2store(rawbuf, mysqld_port);
if (my_gethwaddr(rawbuf + 2))
@@ -402,9 +401,7 @@ int calculate_server_uid(char *dest)
return 1;
}
- mysql_sha1_reset(&ctx);
- mysql_sha1_input(&ctx, rawbuf, sizeof(rawbuf));
- mysql_sha1_result(&ctx, shabuf);
+ compute_sha1_hash((uint8*) shabuf, (char*) rawbuf, sizeof(rawbuf));
assert(base64_needed_encoded_length(sizeof(shabuf)) <= SERVER_UID_SIZE);
base64_encode(shabuf, sizeof(shabuf), dest);
diff --git a/plugin/handler_socket/handlersocket/database.cpp b/plugin/handler_socket/handlersocket/database.cpp
index beb28ef708c..a15c18a4c70 100644
--- a/plugin/handler_socket/handlersocket/database.cpp
+++ b/plugin/handler_socket/handlersocket/database.cpp
@@ -762,7 +762,7 @@ dbcontext::cmd_find_internal(dbcallback_i& cb, const prep_stmt& pst,
return cb.dbcb_resp_short(2, "idxnum");
}
KEY& kinfo = table->key_info[pst.get_idxnum()];
- if (args.kvalslen > kinfo.key_parts) {
+ if (args.kvalslen > kinfo.user_defined_key_parts) {
return cb.dbcb_resp_short(2, "kpnum");
}
uchar *const key_buf = DENA_ALLOCA_ALLOCATE(uchar, kinfo.key_length);
diff --git a/plugin/metadata_lock_info/CMakeLists.txt b/plugin/metadata_lock_info/CMakeLists.txt
new file mode 100644
index 00000000000..44393c09eb6
--- /dev/null
+++ b/plugin/metadata_lock_info/CMakeLists.txt
@@ -0,0 +1,2 @@
+SET(METADATA_LOCK_INFO_SOURCES metadata_lock_info.cc)
+MYSQL_ADD_PLUGIN(metadata_lock_info ${METADATA_LOCK_INFO_SOURCES} MODULE_OUTPUT_NAME "metadata_lock_info")
diff --git a/plugin/metadata_lock_info/metadata_lock_info.cc b/plugin/metadata_lock_info/metadata_lock_info.cc
new file mode 100644
index 00000000000..0ddde226553
--- /dev/null
+++ b/plugin/metadata_lock_info/metadata_lock_info.cc
@@ -0,0 +1,188 @@
+/* Copyright (C) 2013 Kentoku Shiba
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#define MYSQL_SERVER 1
+#include "mysql_version.h"
+#include "mysql/plugin.h"
+#include "sql_class.h"
+#include "sql_show.h"
+
+static const LEX_STRING metadata_lock_info_lock_name[] = {
+ { C_STRING_WITH_LEN("Global read lock") },
+ { C_STRING_WITH_LEN("Schema metadata lock") },
+ { C_STRING_WITH_LEN("Table metadata lock") },
+ { C_STRING_WITH_LEN("Stored function metadata lock") },
+ { C_STRING_WITH_LEN("Stored procedure metadata lock") },
+ { C_STRING_WITH_LEN("Trigger metadata lock") },
+ { C_STRING_WITH_LEN("Event metadata lock") },
+ { C_STRING_WITH_LEN("Commit lock") },
+ { C_STRING_WITH_LEN("User lock") },
+};
+
+static const LEX_STRING metadata_lock_info_lock_mode[] = {
+ { C_STRING_WITH_LEN("MDL_INTENTION_EXCLUSIVE") },
+ { C_STRING_WITH_LEN("MDL_SHARED") },
+ { C_STRING_WITH_LEN("MDL_SHARED_HIGH_PRIO") },
+ { C_STRING_WITH_LEN("MDL_SHARED_READ") },
+ { C_STRING_WITH_LEN("MDL_SHARED_WRITE") },
+ { C_STRING_WITH_LEN("MDL_SHARED_NO_WRITE") },
+ { C_STRING_WITH_LEN("MDL_SHARED_NO_READ_WRITE") },
+ { C_STRING_WITH_LEN("MDL_EXCLUSIVE") },
+};
+
+static const LEX_STRING metadata_lock_info_duration[] = {
+ { C_STRING_WITH_LEN("MDL_STATEMENT") },
+ { C_STRING_WITH_LEN("MDL_TRANSACTION") },
+ { C_STRING_WITH_LEN("MDL_EXPLICIT") },
+};
+
+static ST_FIELD_INFO i_s_metadata_lock_info_fields_info[] =
+{
+ {"THREAD_ID", 20, MYSQL_TYPE_LONGLONG, 0,
+ MY_I_S_UNSIGNED, "thread_id", SKIP_OPEN_TABLE},
+ {"LOCK_MODE", 24, MYSQL_TYPE_STRING, 0,
+ MY_I_S_MAYBE_NULL, "lock_mode", SKIP_OPEN_TABLE},
+ {"LOCK_DURATION", 30, MYSQL_TYPE_STRING, 0,
+ MY_I_S_MAYBE_NULL, "lock_duration", SKIP_OPEN_TABLE},
+ {"LOCK_TYPE", 30, MYSQL_TYPE_STRING, 0,
+ MY_I_S_MAYBE_NULL, "lock_type", SKIP_OPEN_TABLE},
+ {"TABLE_SCHEMA", 64, MYSQL_TYPE_STRING, 0,
+ MY_I_S_MAYBE_NULL, "table_schema", SKIP_OPEN_TABLE},
+ {"TABLE_NAME", 64, MYSQL_TYPE_STRING, 0,
+ MY_I_S_MAYBE_NULL, "table_name", SKIP_OPEN_TABLE},
+ {NULL, 0, MYSQL_TYPE_STRING, 0, 0, NULL, 0}
+};
+
+struct st_i_s_metadata_param
+{
+ THD *thd;
+ TABLE *table;
+};
+
+int i_s_metadata_lock_info_fill_row(
+ MDL_ticket *mdl_ticket,
+ void *arg
+) {
+ st_i_s_metadata_param *param = (st_i_s_metadata_param *) arg;
+ THD *thd = param->thd;
+ TABLE *table = param->table;
+ DBUG_ENTER("i_s_metadata_lock_info_fill_row");
+ MDL_request mdl_request;
+ enum_mdl_duration mdl_duration;
+ MDL_context *mdl_ctx = mdl_ticket->get_ctx();
+ enum_mdl_type mdl_ticket_type = mdl_ticket->get_type();
+ MDL_key *mdl_key = mdl_ticket->get_key();
+ MDL_key::enum_mdl_namespace mdl_namespace = mdl_key->mdl_namespace();
+ mdl_request.init(mdl_key, mdl_ticket_type, MDL_STATEMENT);
+ mdl_ctx->find_ticket(&mdl_request, &mdl_duration);
+ table->field[0]->store((longlong) mdl_ctx->get_thread_id(), TRUE);
+ table->field[1]->set_notnull();
+ table->field[1]->store(
+ metadata_lock_info_lock_mode[(int) mdl_ticket_type].str,
+ metadata_lock_info_lock_mode[(int) mdl_ticket_type].length,
+ system_charset_info);
+ table->field[2]->set_notnull();
+ table->field[2]->store(
+ metadata_lock_info_duration[(int) mdl_duration].str,
+ metadata_lock_info_duration[(int) mdl_duration].length,
+ system_charset_info);
+ table->field[3]->set_notnull();
+ table->field[3]->store(
+ metadata_lock_info_lock_name[(int) mdl_namespace].str,
+ metadata_lock_info_lock_name[(int) mdl_namespace].length,
+ system_charset_info);
+ table->field[4]->set_notnull();
+ table->field[4]->store(mdl_key->db_name(),
+ mdl_key->db_name_length(), system_charset_info);
+ table->field[5]->set_notnull();
+ table->field[5]->store(mdl_key->name(),
+ mdl_key->name_length(), system_charset_info);
+ if (schema_table_store_record(thd, table))
+ DBUG_RETURN(1);
+ DBUG_RETURN(0);
+}
+
+int i_s_metadata_lock_info_fill_table(
+ THD *thd,
+ TABLE_LIST *tables,
+ COND *cond
+) {
+ st_i_s_metadata_param param;
+ DBUG_ENTER("i_s_metadata_lock_info_fill_table");
+ param.table = tables->table;
+ param.thd = thd;
+ DBUG_RETURN(mdl_iterate(i_s_metadata_lock_info_fill_row, &param));
+}
+
+static int i_s_metadata_lock_info_init(
+ void *p
+) {
+ ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p;
+ DBUG_ENTER("i_s_metadata_lock_info_init");
+ schema->fields_info = i_s_metadata_lock_info_fields_info;
+ schema->fill_table = i_s_metadata_lock_info_fill_table;
+ schema->idx_field1 = 0;
+ DBUG_RETURN(0);
+}
+
+static int i_s_metadata_lock_info_deinit(
+ void *p
+) {
+ DBUG_ENTER("i_s_metadata_lock_info_deinit");
+ DBUG_RETURN(0);
+}
+
+static struct st_mysql_information_schema i_s_metadata_lock_info_plugin =
+{ MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION };
+
+#ifdef MARIADB_BASE_VERSION
+maria_declare_plugin(metadata_lock_info)
+{
+ MYSQL_INFORMATION_SCHEMA_PLUGIN,
+ &i_s_metadata_lock_info_plugin,
+ "METADATA_LOCK_INFO",
+ "Kentoku Shiba",
+ "Metadata locking viewer",
+ PLUGIN_LICENSE_GPL,
+ i_s_metadata_lock_info_init,
+ i_s_metadata_lock_info_deinit,
+ 0x0001,
+ NULL,
+ NULL,
+ NULL,
+ MariaDB_PLUGIN_MATURITY_ALPHA,
+}
+maria_declare_plugin_end;
+#else
+mysql_declare_plugin(metadata_lock_info)
+{
+ MYSQL_INFORMATION_SCHEMA_PLUGIN,
+ &i_s_metadata_lock_info_plugin,
+ "METADATA_LOCK_INFO",
+ "Kentoku Shiba",
+ "Metadata locking viewer",
+ PLUGIN_LICENSE_GPL,
+ i_s_metadata_lock_info_init,
+ i_s_metadata_lock_info_deinit,
+ 0x0001,
+ NULL,
+ NULL,
+ NULL,
+#if MYSQL_VERSION_ID >= 50600
+ 0,
+#endif
+}
+mysql_declare_plugin_end;
+#endif
diff --git a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/global_read_lock.result b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/global_read_lock.result
new file mode 100644
index 00000000000..9840aeecf97
--- /dev/null
+++ b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/global_read_lock.result
@@ -0,0 +1,10 @@
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+lock_mode lock_duration lock_type table_schema table_name
+FLUSH TABLES WITH READ LOCK;
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+lock_mode lock_duration lock_type table_schema table_name
+MDL_SHARED MDL_EXPLICIT Global read lock
+MDL_SHARED MDL_EXPLICIT Commit lock
+UNLOCK TABLES;
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+lock_mode lock_duration lock_type table_schema table_name
diff --git a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/table_metadata_lock.result b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/table_metadata_lock.result
new file mode 100644
index 00000000000..280c8284c54
--- /dev/null
+++ b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/table_metadata_lock.result
@@ -0,0 +1,13 @@
+CREATE TABLE IF NOT EXISTS t1(a int);
+BEGIN;
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+lock_mode lock_duration lock_type table_schema table_name
+SELECT * FROM t1;
+a
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+lock_mode lock_duration lock_type table_schema table_name
+MDL_SHARED_READ MDL_TRANSACTION Table metadata lock test t1
+ROLLBACK;
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+lock_mode lock_duration lock_type table_schema table_name
+DROP TABLE t1;
diff --git a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/user_lock.result b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/user_lock.result
new file mode 100644
index 00000000000..9e3779e0336
--- /dev/null
+++ b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/user_lock.result
@@ -0,0 +1,13 @@
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+lock_mode lock_duration lock_type table_schema table_name
+SELECT GET_LOCK('LOCK1',0);
+GET_LOCK('LOCK1',0)
+1
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+lock_mode lock_duration lock_type table_schema table_name
+MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT User lock LOCK1
+SELECT RELEASE_LOCK('LOCK1');
+RELEASE_LOCK('LOCK1')
+1
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+lock_mode lock_duration lock_type table_schema table_name
diff --git a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/suite.opt b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/suite.opt
new file mode 100644
index 00000000000..638f267c166
--- /dev/null
+++ b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/suite.opt
@@ -0,0 +1,2 @@
+--loose-metadata_lock_info
+--plugin-load=$METADATA_LOCK_INFO_SO
diff --git a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/suite.pm b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/suite.pm
new file mode 100644
index 00000000000..0773110821d
--- /dev/null
+++ b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/suite.pm
@@ -0,0 +1,9 @@
+package My::Suite::Metadata_lock_info;
+
+@ISA = qw(My::Suite);
+
+return "No Metadata_lock_info plugin" unless $ENV{METADATA_LOCK_INFO_SO} or
+ $::mysqld_variables{'metadata-lock-info'} eq "ON";;
+
+bless { };
+
diff --git a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/global_read_lock.test b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/global_read_lock.test
new file mode 100644
index 00000000000..f221191255e
--- /dev/null
+++ b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/global_read_lock.test
@@ -0,0 +1,5 @@
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+FLUSH TABLES WITH READ LOCK;
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+UNLOCK TABLES;
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
diff --git a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/table_metadata_lock.test b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/table_metadata_lock.test
new file mode 100644
index 00000000000..3451dff039d
--- /dev/null
+++ b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/table_metadata_lock.test
@@ -0,0 +1,8 @@
+CREATE TABLE IF NOT EXISTS t1(a int);
+BEGIN;
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+SELECT * FROM t1;
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+ROLLBACK;
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+DROP TABLE t1;
diff --git a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/user_lock.test b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/user_lock.test
new file mode 100644
index 00000000000..85dec3dcf75
--- /dev/null
+++ b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/user_lock.test
@@ -0,0 +1,5 @@
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+SELECT GET_LOCK('LOCK1',0);
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+SELECT RELEASE_LOCK('LOCK1');
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
diff --git a/plugin/qc_info/qc_info.cc b/plugin/qc_info/qc_info.cc
index 8489b14c5db..717c54d548b 100644
--- a/plugin/qc_info/qc_info.cc
+++ b/plugin/qc_info/qc_info.cc
@@ -113,7 +113,7 @@ static int qc_info_fill_table(THD *thd, TABLE_LIST *tables,
statement_text_length = strlen(statement_text);
/* We truncate SQL statements up to MAX_STATEMENT_TEXT_LENGTH in our I_S table */
table->field[COLUMN_STATEMENT_TEXT]->store((char*)statement_text,
- min(statement_text_length, MAX_STATEMENT_TEXT_LENGTH), scs);
+ MY_MIN(statement_text_length, MAX_STATEMENT_TEXT_LENGTH), scs);
/* get the entire key that identifies this query cache query */
key = (const char*)query_cache_query_get_key(query_cache_block_raw,
diff --git a/plugin/query_response_time/query_response_time.cc b/plugin/query_response_time/query_response_time.cc
index c8273172205..b28962a5db4 100644
--- a/plugin/query_response_time/query_response_time.cc
+++ b/plugin/query_response_time/query_response_time.cc
@@ -156,14 +156,14 @@ public:
{
my_atomic_rwlock_destroy(&time_collector_lock);
}
- uint32 count(uint index) const
+ uint32 count(uint index)
{
my_atomic_rwlock_rdlock(&time_collector_lock);
uint32 result= my_atomic_load32((int32*)&m_count[index]);
my_atomic_rwlock_rdunlock(&time_collector_lock);
return result;
}
- uint64 total(uint index) const
+ uint64 total(uint index)
{
my_atomic_rwlock_rdlock(&time_collector_lock);
uint64 result= my_atomic_load64((int64*)&m_total[index]);
diff --git a/plugin/query_response_time/query_response_time.h b/plugin/query_response_time/query_response_time.h
index b19833a6570..35b01b0db81 100644
--- a/plugin/query_response_time/query_response_time.h
+++ b/plugin/query_response_time/query_response_time.h
@@ -44,11 +44,11 @@
#define QRT_DEFAULT_BASE 10
#define QRT_TIME_STRING_LENGTH \
- max( (QRT_TIME_STRING_POSITIVE_POWER_LENGTH + 1 /* '.' */ + 6 /*QRT_TIME_STRING_NEGATIVE_POWER_LENGTH*/), \
+ MY_MAX( (QRT_TIME_STRING_POSITIVE_POWER_LENGTH + 1 /* '.' */ + 6 /*QRT_TIME_STRING_NEGATIVE_POWER_LENGTH*/), \
(sizeof(QRT_TIME_OVERFLOW) - 1) )
#define QRT_TOTAL_STRING_LENGTH \
- max( (QRT_TOTAL_STRING_POSITIVE_POWER_LENGTH + 1 /* '.' */ + 6 /*QRT_TOTAL_STRING_NEGATIVE_POWER_LENGTH*/), \
+ MY_MAX( (QRT_TOTAL_STRING_POSITIVE_POWER_LENGTH + 1 /* '.' */ + 6 /*QRT_TOTAL_STRING_NEGATIVE_POWER_LENGTH*/), \
(sizeof(QRT_TIME_OVERFLOW) - 1) )
extern ST_SCHEMA_TABLE query_response_time_table;
diff --git a/plugin/semisync/semisync.h b/plugin/semisync/semisync.h
index 900ce5d8bf9..4208048bacb 100644
--- a/plugin/semisync/semisync.h
+++ b/plugin/semisync/semisync.h
@@ -21,6 +21,7 @@
#define MYSQL_SERVER
#define HAVE_REPLICATION
#include <sql_priv.h>
+#include <sql_class.h>
#include "unireg.h"
#include <my_global.h>
#include <my_pthread.h>
diff --git a/plugin/semisync/semisync_master.cc b/plugin/semisync/semisync_master.cc
index df1bb454527..0c84519fac0 100644
--- a/plugin/semisync/semisync_master.cc
+++ b/plugin/semisync/semisync_master.cc
@@ -605,7 +605,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
struct timespec start_ts;
struct timespec abstime;
int wait_result;
- const char *old_msg= 0;
+ PSI_stage_info old_stage;
set_timespec(start_ts, 0);
@@ -614,8 +614,9 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
lock();
/* This must be called after acquired the lock */
- old_msg= thd_enter_cond(NULL, &COND_binlog_send_, &LOCK_binlog_,
- "Waiting for semi-sync ACK from slave");
+ THD_ENTER_COND(NULL, &COND_binlog_send_, &LOCK_binlog_,
+ & stage_waiting_for_semi_sync_ack_from_slave,
+ & old_stage);
/* This is the real check inside the mutex. */
if (!getMasterEnabled() || !is_on())
@@ -741,7 +742,6 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
must have been removed from ActiveTranx.
*/
assert(thd_killed(NULL) ||
- !getMasterEnabled() ||
!active_tranxs_->is_tranx_end_pos(trx_wait_binlog_name,
trx_wait_binlog_pos));
@@ -754,7 +754,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
/* The lock held will be released by thd_exit_cond, so no need to
call unlock() here */
- thd_exit_cond(NULL, old_msg);
+ THD_EXIT_COND(NULL, & old_stage);
}
return function_exit(kWho, 0);
diff --git a/plugin/semisync/semisync_master.h b/plugin/semisync/semisync_master.h
index 9b266ca6565..66fa176624b 100644
--- a/plugin/semisync/semisync_master.h
+++ b/plugin/semisync/semisync_master.h
@@ -26,6 +26,8 @@ extern PSI_mutex_key key_ss_mutex_LOCK_binlog_;
extern PSI_cond_key key_ss_cond_COND_binlog_send_;
#endif
+extern PSI_stage_info stage_waiting_for_semi_sync_ack_from_slave;
+
struct TranxNode {
char log_name_[FN_REFLEN];
my_off_t log_pos_;
diff --git a/plugin/semisync/semisync_master_plugin.cc b/plugin/semisync/semisync_master_plugin.cc
index 81ed9b55d99..b8240c80ef3 100644
--- a/plugin/semisync/semisync_master_plugin.cc
+++ b/plugin/semisync/semisync_master_plugin.cc
@@ -354,20 +354,30 @@ static PSI_cond_info all_semisync_conds[]=
{
{ &key_ss_cond_COND_binlog_send_, "COND_binlog_send_", 0}
};
+#endif /* HAVE_PSI_INTERFACE */
+
+PSI_stage_info stage_waiting_for_semi_sync_ack_from_slave=
+{ 0, "Waiting for semi-sync ACK from slave", 0};
+
+#ifdef HAVE_PSI_INTERFACE
+PSI_stage_info *all_semisync_stages[]=
+{
+ & stage_waiting_for_semi_sync_ack_from_slave
+};
static void init_semisync_psi_keys(void)
{
const char* category= "semisync";
int count;
- if (PSI_server == NULL)
- return;
-
count= array_elements(all_semisync_mutexes);
- PSI_server->register_mutex(category, all_semisync_mutexes, count);
+ mysql_mutex_register(category, all_semisync_mutexes, count);
count= array_elements(all_semisync_conds);
- PSI_server->register_cond(category, all_semisync_conds, count);
+ mysql_cond_register(category, all_semisync_conds, count);
+
+ count= array_elements(all_semisync_stages);
+ mysql_stage_register(category, all_semisync_stages, count);
}
#endif /* HAVE_PSI_INTERFACE */