summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'plugin')
-rw-r--r--plugin/audit_null/audit_null.c11
-rw-r--r--plugin/auth_dialog/CMakeLists.txt2
-rw-r--r--plugin/auth_dialog/dialog.c2
-rw-r--r--plugin/auth_examples/CMakeLists.txt2
-rw-r--r--plugin/auth_pam/auth_pam.c3
-rw-r--r--plugin/auth_socket/CMakeLists.txt2
-rw-r--r--plugin/auth_socket/auth_socket.c21
-rw-r--r--plugin/daemon_example/daemon_example.cc19
-rw-r--r--plugin/feedback/CMakeLists.txt3
-rw-r--r--plugin/feedback/feedback.cc5
-rw-r--r--plugin/feedback/feedback.h1
-rw-r--r--plugin/feedback/sender_thread.cc6
-rw-r--r--plugin/feedback/url_http.cc2
-rw-r--r--plugin/feedback/utils.cc26
-rw-r--r--plugin/fulltext/plugin_example.c18
-rw-r--r--plugin/handler_socket/CMakeLists.txt4
-rw-r--r--plugin/handler_socket/client/hslongrun.cpp6
-rw-r--r--plugin/handler_socket/docs-en/about-handlersocket.en.txt2
-rw-r--r--plugin/handler_socket/docs-en/installation.en.txt9
-rw-r--r--plugin/handler_socket/docs-en/perl-client.en.txt16
-rw-r--r--plugin/handler_socket/docs-en/protocol.en.txt33
-rw-r--r--plugin/handler_socket/docs-ja/installation.ja.txt3
-rw-r--r--plugin/handler_socket/docs-ja/perl-client.ja.txt10
-rw-r--r--plugin/handler_socket/docs-ja/protocol.ja.txt256
-rw-r--r--plugin/handler_socket/handlersocket/database.cpp4
-rw-r--r--plugin/handler_socket/libhsclient/auto_file.hpp5
-rw-r--r--plugin/handler_socket/libhsclient/fatal.cpp8
-rw-r--r--plugin/handler_socket/libhsclient/fatal.hpp1
-rw-r--r--plugin/handler_socket/libhsclient/socket.cpp2
-rw-r--r--plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.xs2
-rwxr-xr-xplugin/handler_socket/regtest/test_01_lib/run.sh2
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test14.pl2
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test17.pl2
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test19.pl2
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test24.expected2
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test24.pl35
-rw-r--r--plugin/locale_info/CMakeLists.txt5
-rw-r--r--plugin/locale_info/locale_info.cc122
-rw-r--r--plugin/metadata_lock_info/CMakeLists.txt2
-rw-r--r--plugin/metadata_lock_info/metadata_lock_info.cc176
-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.pm11
-rw-r--r--plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/global_read_lock.test6
-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/CMakeLists.txt3
-rw-r--r--plugin/qc_info/qc_info.cc4
-rw-r--r--plugin/query_response_time/CMakeLists.txt2
-rw-r--r--plugin/query_response_time/mysql-test/query_response_time/basic.result27
-rw-r--r--plugin/query_response_time/mysql-test/query_response_time/basic.test3
-rw-r--r--plugin/query_response_time/mysql-test/query_response_time/query_response_time-stored.inc36
-rw-r--r--plugin/query_response_time/mysql-test/query_response_time/query_response_time-stored.result392
-rw-r--r--plugin/query_response_time/mysql-test/query_response_time/query_response_time-stored.test44
-rw-r--r--plugin/query_response_time/mysql-test/query_response_time/query_response_time.inc41
-rw-r--r--plugin/query_response_time/mysql-test/query_response_time/query_response_time.result1003
-rw-r--r--plugin/query_response_time/mysql-test/query_response_time/query_response_time.test28
-rw-r--r--plugin/query_response_time/mysql-test/query_response_time/suite.opt1
-rw-r--r--plugin/query_response_time/mysql-test/query_response_time/suite.pm14
-rw-r--r--plugin/query_response_time/plugin.cc163
-rw-r--r--plugin/query_response_time/query_response_time.cc302
-rw-r--r--plugin/query_response_time/query_response_time.h67
-rw-r--r--plugin/semisync/CMakeLists.txt7
-rw-r--r--plugin/semisync/semisync.h5
-rw-r--r--plugin/semisync/semisync_master.cc19
-rw-r--r--plugin/semisync/semisync_master.h12
-rw-r--r--plugin/semisync/semisync_master_plugin.cc50
-rw-r--r--plugin/semisync/semisync_slave_plugin.cc11
-rw-r--r--plugin/server_audit/server_audit.c15
-rw-r--r--plugin/sql_errlog/sql_errlog.c20
-rw-r--r--plugin/win_auth_client/CMakeLists.txt2
73 files changed, 2895 insertions, 278 deletions
diff --git a/plugin/audit_null/audit_null.c b/plugin/audit_null/audit_null.c
index fd4cd1d1e87..2747063670c 100644
--- a/plugin/audit_null/audit_null.c
+++ b/plugin/audit_null/audit_null.c
@@ -1,4 +1,5 @@
-/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2006, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2012, 2013, Monty Program Ab.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -174,10 +175,10 @@ static struct st_mysql_audit audit_null_descriptor=
static struct st_mysql_show_var simple_status[]=
{
- { "Audit_null_called", (char *) &ncalls, SHOW_INT },
- { "Audit_null_general_log", (char *) &ncalls_general_log, SHOW_INT },
- { "Audit_null_general_error", (char *) &ncalls_general_error, SHOW_INT },
- { "Audit_null_general_result", (char *) &ncalls_general_result, SHOW_INT },
+ { "called", (char *) &ncalls, SHOW_INT },
+ { "general_error", (char *) &ncalls_general_error, SHOW_INT },
+ { "general_log", (char *) &ncalls_general_log, SHOW_INT },
+ { "general_result", (char *) &ncalls_general_result, SHOW_INT },
{ 0, 0, 0}
};
diff --git a/plugin/auth_dialog/CMakeLists.txt b/plugin/auth_dialog/CMakeLists.txt
index 9b4dcfd99bf..a23518060be 100644
--- a/plugin/auth_dialog/CMakeLists.txt
+++ b/plugin/auth_dialog/CMakeLists.txt
@@ -15,4 +15,4 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
MYSQL_ADD_PLUGIN(dialog dialog.c ${CMAKE_SOURCE_DIR}/libmysql/get_password.c
- MODULE_ONLY COMPONENT SharedLibraries)
+ MODULE_ONLY COMPONENT ClientPlugins)
diff --git a/plugin/auth_dialog/dialog.c b/plugin/auth_dialog/dialog.c
index 0fa5ab93a35..da937ea6e91 100644
--- a/plugin/auth_dialog/dialog.c
+++ b/plugin/auth_dialog/dialog.c
@@ -25,6 +25,8 @@
the answer back to the server. No encryption is involved,
the answers are sent in clear text.
*/
+#define _GNU_SOURCE 1 /* for RTLD_DEFAULT */
+
#include <my_global.h>
#include <mysql/client_plugin.h>
#include <mysql.h>
diff --git a/plugin/auth_examples/CMakeLists.txt b/plugin/auth_examples/CMakeLists.txt
index f6c2b637067..c7b7e5be62d 100644
--- a/plugin/auth_examples/CMakeLists.txt
+++ b/plugin/auth_examples/CMakeLists.txt
@@ -30,4 +30,4 @@ MYSQL_ADD_PLUGIN(qa_auth_client qa_auth_client.c
MYSQL_ADD_PLUGIN(auth_0x0100 auth_0x0100.c MODULE_ONLY COMPONENT Test)
MYSQL_ADD_PLUGIN(mysql_clear_password clear_password_client.c
- MODULE_ONLY COMPONENT SharedLibraries)
+ MODULE_ONLY COMPONENT ClientPlugins)
diff --git a/plugin/auth_pam/auth_pam.c b/plugin/auth_pam/auth_pam.c
index 2a06b6a01a6..a4d1deb8ada 100644
--- a/plugin/auth_pam/auth_pam.c
+++ b/plugin/auth_pam/auth_pam.c
@@ -141,6 +141,7 @@ static int pam_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info)
if (new_username && strcmp(new_username, info->user_name))
strncpy(info->authenticated_as, new_username,
sizeof(info->authenticated_as));
+ info->authenticated_as[sizeof(info->authenticated_as)-1]= 0;
end:
pam_end(pamh, status);
@@ -189,6 +190,6 @@ maria_declare_plugin(pam)
NULL,
vars,
"1.0",
- MariaDB_PLUGIN_MATURITY_BETA
+ MariaDB_PLUGIN_MATURITY_STABLE
}
maria_declare_plugin_end;
diff --git a/plugin/auth_socket/CMakeLists.txt b/plugin/auth_socket/CMakeLists.txt
index 8137c6b4529..e4a8d1d6efd 100644
--- a/plugin/auth_socket/CMakeLists.txt
+++ b/plugin/auth_socket/CMakeLists.txt
@@ -65,6 +65,6 @@ ENDIF()
ENDIF()
IF(ok)
- MYSQL_ADD_PLUGIN(auth_socket auth_socket.c MODULE_ONLY)
+ MYSQL_ADD_PLUGIN(auth_socket auth_socket.c)
ENDIF()
diff --git a/plugin/auth_socket/auth_socket.c b/plugin/auth_socket/auth_socket.c
index 508cd1ecf5e..f04b1d9d2a1 100644
--- a/plugin/auth_socket/auth_socket.c
+++ b/plugin/auth_socket/auth_socket.c
@@ -105,24 +105,7 @@ static struct st_mysql_auth socket_auth_handler=
socket_auth
};
-mysql_declare_plugin(socket_auth)
-{
- MYSQL_AUTHENTICATION_PLUGIN,
- &socket_auth_handler,
- "unix_socket",
- "Sergei Golubchik",
- "Unix Socket based authentication",
- PLUGIN_LICENSE_GPL,
- NULL,
- NULL,
- 0x0100,
- NULL,
- NULL,
- NULL,
- 0,
-}
-mysql_declare_plugin_end;
-maria_declare_plugin(socket_auth)
+maria_declare_plugin(auth_socket)
{
MYSQL_AUTHENTICATION_PLUGIN,
&socket_auth_handler,
@@ -136,7 +119,7 @@ maria_declare_plugin(socket_auth)
NULL,
NULL,
"1.0",
- MariaDB_PLUGIN_MATURITY_BETA
+ MariaDB_PLUGIN_MATURITY_STABLE
}
maria_declare_plugin_end;
diff --git a/plugin/daemon_example/daemon_example.cc b/plugin/daemon_example/daemon_example.cc
index 35376a8ec32..cdea632c8f4 100644
--- a/plugin/daemon_example/daemon_example.cc
+++ b/plugin/daemon_example/daemon_example.cc
@@ -129,7 +129,7 @@ static int daemon_example_plugin_init(void *p __attribute__ ((unused)))
(void *)con) != 0)
{
fprintf(stderr,"Could not create heartbeat thread!\n");
- exit(0);
+ DBUG_RETURN(1);
}
plugin->data= (void *)con;
@@ -195,23 +195,6 @@ struct st_mysql_daemon daemon_example_plugin=
Plugin library descriptor
*/
-mysql_declare_plugin(daemon_example)
-{
- MYSQL_DAEMON_PLUGIN,
- &daemon_example_plugin,
- "daemon_example",
- "Brian Aker",
- "Daemon example, creates a heartbeat beat file in mysql-heartbeat.log",
- PLUGIN_LICENSE_GPL,
- daemon_example_plugin_init, /* Plugin Init */
- daemon_example_plugin_deinit, /* Plugin Deinit */
- 0x0100 /* 1.0 */,
- NULL, /* status variables */
- NULL, /* system variables */
- NULL, /* config options */
- 0, /* flags */
-}
-mysql_declare_plugin_end;
maria_declare_plugin(daemon_example)
{
MYSQL_DAEMON_PLUGIN,
diff --git a/plugin/feedback/CMakeLists.txt b/plugin/feedback/CMakeLists.txt
index 3e14ef3918b..9807eadbe34 100644
--- a/plugin/feedback/CMakeLists.txt
+++ b/plugin/feedback/CMakeLists.txt
@@ -1,4 +1,5 @@
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/regex
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql
+ ${PCRE_INCLUDES}
${SSL_INCLUDE_DIRS})
SET(FEEDBACK_SOURCES feedback.cc sender_thread.cc
diff --git a/plugin/feedback/feedback.cc b/plugin/feedback/feedback.cc
index 79436bd5268..b9ab3563125 100644
--- a/plugin/feedback/feedback.cc
+++ b/plugin/feedback/feedback.cc
@@ -221,7 +221,8 @@ int fill_feedback(THD *thd, TABLE_LIST *tables, COND *unused)
tables->schema_table= i_s_feedback;
res= res || fill_plugin_version(thd, tables)
|| fill_misc_data(thd, tables)
- || fill_linux_info(thd, tables);
+ || fill_linux_info(thd, tables)
+ || fill_collation_statistics(thd, tables);
return res;
}
@@ -437,7 +438,7 @@ maria_declare_plugin(feedback)
NULL,
feedback::settings,
"1.1",
- MariaDB_PLUGIN_MATURITY_BETA
+ MariaDB_PLUGIN_MATURITY_STABLE
}
maria_declare_plugin_end;
#endif
diff --git a/plugin/feedback/feedback.h b/plugin/feedback/feedback.h
index 0542b7399f1..bb3f896288d 100644
--- a/plugin/feedback/feedback.h
+++ b/plugin/feedback/feedback.h
@@ -22,6 +22,7 @@ int fill_feedback(THD *thd, TABLE_LIST *tables, COND *cond);
int fill_plugin_version(THD *thd, TABLE_LIST *tables);
int fill_misc_data(THD *thd, TABLE_LIST *tables);
int fill_linux_info(THD *thd, TABLE_LIST *tables);
+int fill_collation_statistics(THD *thd, TABLE_LIST *tables);
static const int SERVER_UID_SIZE= 29;
extern char server_uid_buf[SERVER_UID_SIZE+1], *user_info;
diff --git a/plugin/feedback/sender_thread.cc b/plugin/feedback/sender_thread.cc
index da7628ef895..4a7da3000ca 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();
@@ -204,7 +204,7 @@ static void send_report(const char *when)
/*
otherwise, prepare the THD and TABLE_LIST,
create and fill the temporary table with data just like
- SELECT * FROM IFROEMATION_SCHEMA.feedback is doing,
+ SELECT * FROM INFORMATION_SCHEMA.FEEDBACK is doing,
read and concatenate table data into a String.
*/
if (!(thd= new THD()))
@@ -261,7 +261,7 @@ ret:
the effect of the background thread on SHOW STATUS.
*/
mysql_mutex_lock(&LOCK_thread_count);
- bzero(&thd->status_var, sizeof(thd->status_var));
+ thd->set_status_var_init();
thread_count--;
thd->killed= KILL_CONNECTION;
mysql_cond_broadcast(&COND_thread_count);
diff --git a/plugin/feedback/url_http.cc b/plugin/feedback/url_http.cc
index fbea38c07eb..cec3f60505c 100644
--- a/plugin/feedback/url_http.cc
+++ b/plugin/feedback/url_http.cc
@@ -217,7 +217,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 cff19c93ed2..dad3d59e76d 100644
--- a/plugin/feedback/utils.cc
+++ b/plugin/feedback/utils.cc
@@ -353,8 +353,10 @@ int prepare_linux_info()
*/
int fill_linux_info(THD *thd, TABLE_LIST *tables)
{
+#if defined(HAVE_SYS_UTSNAME_H) || defined(TARGET_OS_LINUX)
TABLE *table= tables->table;
CHARSET_INFO *cs= system_charset_info;
+#endif
#ifdef HAVE_SYS_UTSNAME_H
if (have_ubuf)
@@ -390,6 +392,25 @@ int fill_misc_data(THD *thd, TABLE_LIST *tables)
return 0;
}
+int fill_collation_statistics(THD *thd, TABLE_LIST *tables)
+{
+ TABLE *table= tables->table;
+ for (uint id= 1; id < MY_ALL_CHARSETS_SIZE; id++)
+ {
+ ulonglong count;
+ if (my_collation_is_known_id(id) &&
+ (count= my_collation_statistics_get_use_count(id)))
+ {
+ char name[MY_CS_NAME_SIZE + 32];
+ size_t namelen= my_snprintf(name, sizeof(name),
+ "Collation used %s",
+ get_charset_name(id));
+ INSERT2(name, namelen, (count, UNSIGNED));
+ }
+ }
+ return 0;
+};
+
/**
calculates the server unique identifier
@@ -400,7 +421,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))
@@ -409,9 +429,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/fulltext/plugin_example.c b/plugin/fulltext/plugin_example.c
index 53a321b473e..778918cb439 100644
--- a/plugin/fulltext/plugin_example.c
+++ b/plugin/fulltext/plugin_example.c
@@ -254,24 +254,6 @@ static struct st_mysql_sys_var* simple_system_variables[]= {
Plugin library descriptor
*/
-mysql_declare_plugin(ftexample)
-{
- MYSQL_FTPARSER_PLUGIN, /* type */
- &simple_parser_descriptor, /* descriptor */
- "simple_parser", /* name */
- "Sergei Golubchik", /* author */
- "Simple Full-Text Parser", /* description */
- PLUGIN_LICENSE_GPL,
- simple_parser_plugin_init, /* init function (when loaded) */
- simple_parser_plugin_deinit,/* deinit function (when unloaded) */
- 0x0001, /* version */
- simple_status, /* status variables */
- simple_system_variables, /* system variables */
- NULL,
- 0,
-}
-mysql_declare_plugin_end;
-
maria_declare_plugin(ftexample)
{
MYSQL_FTPARSER_PLUGIN, /* type */
diff --git a/plugin/handler_socket/CMakeLists.txt b/plugin/handler_socket/CMakeLists.txt
index a0cac0015d0..655a1fe955a 100644
--- a/plugin/handler_socket/CMakeLists.txt
+++ b/plugin/handler_socket/CMakeLists.txt
@@ -6,9 +6,7 @@ IF(WIN32)
ENDIF()
#Remove -fno-implicit-templates from compiler flags(handlersocket would not work with it)
-IF(CMAKE_COMPILER_IS_GNUCXX)
- STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
-ENDIF()
+STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(" -Wdeprecated-declarations" HAVE_CXX_WDEPRECATED_DECLARATIONS)
diff --git a/plugin/handler_socket/client/hslongrun.cpp b/plugin/handler_socket/client/hslongrun.cpp
index e82c12b166b..b7c02951340 100644
--- a/plugin/handler_socket/client/hslongrun.cpp
+++ b/plugin/handler_socket/client/hslongrun.cpp
@@ -39,7 +39,7 @@ struct auto_mysql : private noncopyable {
mysql_close(db);
}
if ((db = mysql_init(0)) == 0) {
- fatal_exit("failed to initialize mysql client");
+ fatal_abort("failed to initialize mysql client");
}
}
operator MYSQL *() const { return db; }
@@ -870,7 +870,7 @@ mysql_do(MYSQL *db, const char *query)
{
if (mysql_real_query(db, query, strlen(query)) != 0) {
fprintf(stderr, "mysql: e=[%s] q=[%s]\n", mysql_error(db), query);
- fatal_exit("mysql_do");
+ fatal_abort("mysql_do");
}
}
@@ -886,7 +886,7 @@ hs_longrun_init_table(const config& conf, int num_prepare,
if (!mysql_real_connect(db, mysql_host.c_str(), mysql_user.c_str(),
mysql_passwd.c_str(), mysql_dbname.c_str(), mysql_port, 0, 0)) {
fprintf(stderr, "mysql: error=[%s]\n", mysql_error(db));
- fatal_exit("hs_longrun_init_table");
+ fatal_abort("hs_longrun_init_table");
}
mysql_do(db, "drop database if exists hstestdb");
mysql_do(db, "create database hstestdb");
diff --git a/plugin/handler_socket/docs-en/about-handlersocket.en.txt b/plugin/handler_socket/docs-en/about-handlersocket.en.txt
index 0a13a2713d6..73b9cab556b 100644
--- a/plugin/handler_socket/docs-en/about-handlersocket.en.txt
+++ b/plugin/handler_socket/docs-en/about-handlersocket.en.txt
@@ -66,7 +66,7 @@ Here is a list of other language bindings:
https://github.com/koichik/node-handlersocket
The home of HandlerSocket is here:
- https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL
+ https://github.com/DeNADev/HandlerSocket-Plugin-for-MySQL
More documents are available in docs-en/ and docs-ja/ directories.
diff --git a/plugin/handler_socket/docs-en/installation.en.txt b/plugin/handler_socket/docs-en/installation.en.txt
index 8e680ed35f1..0a0616fa5c8 100644
--- a/plugin/handler_socket/docs-en/installation.en.txt
+++ b/plugin/handler_socket/docs-en/installation.en.txt
@@ -17,10 +17,11 @@ crash, etc).
$ ./autogen.sh
$ ./configure --with-mysql-source=/work/mysql-5.1.50 --with-mysql-bindir=/work/mysql-5.1.50-linux-x86_64-glibc23/bin --with-mysql-plugindir=/work/mysql-5.1.50-linux-x86_64-glibc23/lib/plugin
- --with-mysql-source refers to the top of MySQL source directory,
---with-mysql-bindir refers to where MySQL binary executables (i.e.
-mysql_config) are located, and --with-mysql-plugindir refers to a plugin
-directory where plugin libraries (*.so) are installed.
+ --with-mysql-source refers to the top of MySQL source directory (which
+contains the VERSION file or the configure.in file), --with-mysql-bindir
+refers to where MySQL binary executables (i.e. mysql_config) are located,
+and --with-mysql-plugindir refers to a plugin directory where plugin
+libraries (*.so) are installed.
$ make
$ sudo make install
diff --git a/plugin/handler_socket/docs-en/perl-client.en.txt b/plugin/handler_socket/docs-en/perl-client.en.txt
index 2b863c638f0..cc9138518ee 100644
--- a/plugin/handler_socket/docs-en/perl-client.en.txt
+++ b/plugin/handler_socket/docs-en/perl-client.en.txt
@@ -42,7 +42,7 @@ to be retrieved are specified by the 5th argument for the
corresponding open_index call.
The execute_single method always returns an arrayref. The first
-element is the error code, which is 0 when no error is occured.
+element is the error code, which is 0 when no error is occurred.
The remaining are the field values. If more than one record is
returned, it is flatten to an 1-dimensional array. For example,
when 5 records that have 3 columns are returned, you can retrieve
@@ -93,7 +93,6 @@ The execute_single method can be used for inserting records also.
my $res = $hs->execute_single(3, '+', [ 'foo', 'bar', 'baz' ]);
die $hs->get_error() if $res->[0] != 0;
- my $num_inserted_rows = $res->[1];
The 3rd argument must be an arrayref whose elements correspond to
the 5th argument for the corresponding open_index call. If there
@@ -117,9 +116,18 @@ executing them separatedly.
}
-----------------------------------------------------------------
-When an error is occured, the first element of the returned
+If handlersocket is configured to authenticate client connections
+(ie., handlersocket_plain_secret or handlersocket_plain_secret_wr
+is set), a client must call 'auth' method before any other
+methods.
+
+ my $res = $hs->auth('password');
+ die $hs->get_error() if $res->[0] != 0;
+
+-----------------------------------------------------------------
+When an error is occurred, the first element of the returned
arrayref becomes a non-zero value. A negative value indicates
-that an I/O error is occured and the Net::HandlerSocket object
+that an I/O error is occurred and the Net::HandlerSocket object
should be disposed. A positive value means that the connection is
still active and the Net::HandlerSocket object can be reused
later.
diff --git a/plugin/handler_socket/docs-en/protocol.en.txt b/plugin/handler_socket/docs-en/protocol.en.txt
index afde231df7d..e36f17444ae 100644
--- a/plugin/handler_socket/docs-en/protocol.en.txt
+++ b/plugin/handler_socket/docs-en/protocol.en.txt
@@ -29,7 +29,7 @@ Request and Response
lines) at one time, and receive responses for them at one time.
----------------------------------------------------------------------------
-'open_index' request
+Opening index
The 'open_index' request has the following syntax.
@@ -74,23 +74,21 @@ FILETER is a sequence of the following parameters.
HandlerSocket supports '=', '>', '>=', '<', and '<='.
- <vlen> indicates the length of the trailing parameters <v1> ... <vn>. This
must be smaller than or equal to the number of index columns specified by
- the <columns> parameter of the corresponding 'open_index' request.
+ the <indexname> parameter of the corresponding 'open_index' request.
- <v1> ... <vn> specify the index column values to fetch.
- LIM is optional. <limit> and <offset> are numbers. When omitted, it works
as if 1 and 0 are specified. These parameter works like LIMIT of SQL.
These values don't include the number of records skipped by a filter.
- IN is optional. It works like WHERE ... IN syntax of SQL. <icol> must be
- smaller than or equal to the number of index columns specified by the
- <columns> parameter of the corresponding 'open_index' request. If IN is
- specified in a find request, the <icol>-th parameter value of <v1> ...
- <vn> is ignored.
- smaller than or equal to the number of index columns specified by the
+ smaller than the number of index columns specified by the <indexname>
+ parameter of the corresponding 'open_index' request. If IN is specified in
+ a find request, the <icol>-th parameter value of <v1> ... <vn> is ignored.
- FILTERs are optional. A FILTER specifies a filter. <ftyp> is either 'F'
(filter) or 'W' (while). <fop> specifies the comparison operation to use.
- <fcol> must be smaller than or equal to the number of columns specified by
- the <fcolumns> parameter of the corresponding 'open_index' request.
- Multiple filters can be specified, and work as the logical AND of them.
- The difference of 'F' and 'W' is that, when a record does not meet the
+ <fcol> must be smaller than the number of columns specified by the
+ <fcolumns> parameter of the corresponding 'open_index' request. Multiple
+ filters can be specified, and work as the logical AND of them. The
+ difference of 'F' and 'W' is that, when a record does not meet the
specified condition, 'F' simply skips the record, and 'W' stops the loop.
----------------------------------------------------------------------------
@@ -112,8 +110,8 @@ MOD is a sequence of the following parameters.
<mk> must be smaller than or equal to the length of <columns> specified by
the corresponding 'open_index' request. If <mop> is 'D', these parameters
are ignored. If <mop> is '+' or '-', values must be numeric. If <mop> is
- '-' and it attempts to change column values from negative to positive or
- positive to negative, it is not modified.
+ '-' and it attempts to change a column value from negative to positive or
+ positive to negative, the column value is not modified.
----------------------------------------------------------------------------
Inserting data
@@ -187,6 +185,8 @@ syntax.
0 1 <nummod>
- <nummod> is the number of modified rows.
+- As an exception, if the '?' suffix is specified in <mop>, a response has
+ the syntax of a response for 'find' instead.
----------------------------------------------------------------------------
Response for 'insert'
@@ -196,3 +196,10 @@ syntax.
0 1
+----------------------------------------------------------------------------
+Response for 'auth'
+
+If 'auth' is succeeded, HanderSocket returns a line of the following syntax.
+
+ 0 1
+
diff --git a/plugin/handler_socket/docs-ja/installation.ja.txt b/plugin/handler_socket/docs-ja/installation.ja.txt
index c14f47f6c02..0e8f3513712 100644
--- a/plugin/handler_socket/docs-ja/installation.ja.txt
+++ b/plugin/handler_socket/docs-ja/installation.ja.txt
@@ -8,7 +8,8 @@ HandlerSocketプラグインã®ãƒ“ルド方法(RPMを使ã‚ãªã„方法)
$ ./configure --with-mysql-source=/work/mysql-5.1.50 --with-mysql-bindir=/work/mysql-5.1.50-linux-x86_64-glibc23/bin --with-mysql-plugindir=/work/mysql-5.1.50-linux-x86_64-glibc23/lib/plugin
ã“ã“ã§--with-mysql-sourceã«ã¯MySQLã®ã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ã®ãƒˆãƒƒãƒ—ディレク
-トリを指定ã—ã¾ã™ã€‚--with-mysql-bindirã«ã¯ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«æ¸ˆã¿ã®MySQL
+トリを指定ã—ã¾ã™(ãã“ã«VERSIONファイルã‹configure.inファイルãŒãªã
+ã¦ã¯ãªã‚Šã¾ã›ã‚“)。--with-mysql-bindirã«ã¯ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«æ¸ˆã¿ã®MySQL
ã®mysql_configコマンドãŒæœ‰ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’指定ã—ã¾ã™ã€‚
ãã®å¾Œä»¥ä¸‹ã®ã‚ˆã†ã«ãƒ“ルド・インストールã—ã¾ã™ã€‚
diff --git a/plugin/handler_socket/docs-ja/perl-client.ja.txt b/plugin/handler_socket/docs-ja/perl-client.ja.txt
index 5d3adfa3301..90b7e4d6fd8 100644
--- a/plugin/handler_socket/docs-ja/perl-client.ja.txt
+++ b/plugin/handler_socket/docs-ja/perl-client.ja.txt
@@ -86,7 +86,6 @@ execute_singleメソッドã¯åˆ—ã®æŒ¿å…¥ã«ã‚‚使用ã§ãã¾ã™ã€‚
my $res = $hs->execute_single(3, '+', [ 'foo', 'bar', 'baz' ]);
die $hs->get_error() if $res->[0] != 0;
- my $num_inserted_rows = $res->[1];
第3引数ã¯ã€å¯¾å¿œã™ã‚‹open_index呼ã³å‡ºã—ã®ç¬¬5引数ã®åˆ—リストã¨åŒã˜ã 
ã‘ã®é•·ã•ã®é…列ã¸ã®å‚ç…§ã§ãªã‘ã‚Œã°ãªã‚Šã¾ã›ã‚“。open_index呼ã³å‡ºã—ã®
@@ -110,6 +109,15 @@ execute_multiメソッドを使ãˆã°ã€è¤‡æ•°ã®ãƒªã‚¯ã‚¨ã‚¹ãƒˆã‚’一ã¤ã®å‘¼ã
}
-----------------------------------------------------------------
+ã‚‚ã—handlersocketãŒæŽ¥ç¶šã‚’èªè¨¼ã™ã‚‹ã‚ˆã†ã«è¨­å®šã•ã‚Œã¦ã„ã‚‹
+(handlersocket_plain_secretåˆã¯handlersocket_plain_secret_wrãŒã‚»ãƒƒ
+トã•ã‚Œã¦ã„ã‚‹)ãªã‚‰ã°ã€ã‚¯ãƒ©ã‚¤ã‚¢ãƒ³ãƒˆã¯ä»–ã®ãƒ¡ã‚½ãƒƒãƒ‰å‘¼ã³å‡ºã—ã®å‰ã«auth
+メソッドを呼ã³å‡ºã™å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚
+
+ my $res = $hs->auth('password');
+ die $hs->get_error() if $res->[0] != 0;
+
+-----------------------------------------------------------------
エラーãŒèµ·ã“ã‚‹ã¨è¿”値ã®é…列å‚ç…§ã®æœ€åˆã®è¦ç´ ãŒ0以外ã«ãªã‚Šã¾ã™ã€‚è² ã®
æ•°ã®å ´åˆã¯I/OエラーãŒèµ·ã“ã£ãŸã“ã¨ã‚’示ã—ã€ãã®å ´åˆã¯ãã®
Net::HandlerSocketオブジェクトã¯ç ´æ£„ã™ã‚‹ã¹ãã§ã™ã€‚æ­£ã®å€¤ã®å ´åˆã¯
diff --git a/plugin/handler_socket/docs-ja/protocol.ja.txt b/plugin/handler_socket/docs-ja/protocol.ja.txt
index 01c9d39f71f..46cc9932e60 100644
--- a/plugin/handler_socket/docs-ja/protocol.ja.txt
+++ b/plugin/handler_socket/docs-ja/protocol.ja.txt
@@ -1,94 +1,180 @@
------------------------------------------------------------------
+----------------------------------------------------------------------------
handlersocketã®é€šä¿¡ãƒ—ロトコル
------------------------------------------------------------------
-構文
+----------------------------------------------------------------------------
+基本的ãªæ§‹æ–‡
-・コマンド行ã¯æ”¹è¡Œ(LF)ã§çµ‚ã‚る。
-・コマンド行ã¯è¤‡æ•°ã®ãƒˆãƒ¼ã‚¯ãƒ³ã‹ã‚‰ãªã‚Šã€ãƒˆãƒ¼ã‚¯ãƒ³é–“ã¯TABã§åŒºåˆ‡ã‚‰ã‚Œã‚‹ã€‚
+・HandlerSocketã®ãƒ—ロトコルã¯è¡Œãƒ™ãƒ¼ã‚¹ã€‚å„è¡Œã¯æ”¹è¡Œæ–‡å­—(0x0a)ã§çµ‚ã‚る。
+・å„è¡Œã¯è¤‡æ•°ã®ãƒˆãƒ¼ã‚¯ãƒ³ã‹ã‚‰ãªã‚Šã€ãƒˆãƒ¼ã‚¯ãƒ³é–“ã¯TAB文字(0x09)ã§åŒºåˆ‡ã‚‰ã‚Œã‚‹ã€‚
・トークンã¯NULLトークンã‹ã€æ–‡å­—列トークンã®ã„ãšã‚Œã‹ã€‚
-・NULLトークンã¯å˜ä¸€ã®NUL文字ã§ã‚らã‚ã•ã‚Œã‚‹ã€‚
-・文字列トークンã¯ã€0ãƒã‚¤ãƒˆä»¥ä¸Šã®æ–‡å­—列ã§ã‚らã‚ã•ã‚Œã‚‹ã€‚ãŸã ã—0x10
- 未満ã®æ–‡å­—ã«ã¤ã„ã¦ã¯0x01ã‚’å‰ç½®ã—ã€0x40を加ãˆãŸã‚³ãƒ¼ãƒ‰ã§ã‚らã‚ã•
- れる。ãれ以外ã®æ–‡å­—ã¯ãã®æ–‡å­—自身ã®ã‚³ãƒ¼ãƒ‰ã§ã‚らã‚ã•ã‚Œã‚‹ã€‚
+・NULLトークンã¯å˜ä¸€ã®NUL文字(0x00)ã§ã‚らã‚ã•ã‚Œã‚‹ã€‚
+・文字列トークンã¯ã€0ãƒã‚¤ãƒˆä»¥ä¸Šã®æ–‡å­—列ã§ã‚らã‚ã•ã‚Œã‚‹ã€‚ãŸã ã—0x10未満ã®æ–‡å­—
+ ã«ã¤ã„ã¦ã¯0x01ã‚’å‰ç½®ã—ã€0x40を加ãˆãŸã‚³ãƒ¼ãƒ‰ã§ã‚らã‚ã•ã‚Œã‚‹ã€‚ãれ以外ã®æ–‡å­—ã¯
+ ãã®æ–‡å­—自身ã®ã‚³ãƒ¼ãƒ‰ã§ã‚らã‚ã•ã‚Œã‚‹ã€‚
------------------------------------------------------------------
+----------------------------------------------------------------------------
リクエストã¨ãƒ¬ã‚¹ãƒãƒ³ã‚¹
-・接続ãŒç¢ºç«‹ã—ãŸç›´å¾Œã®çŠ¶æ…‹ã§ã¯ã€ã¾ãšã‚¯ãƒ©ã‚¤ã‚¢ãƒ³ãƒˆãŒã‚³ãƒžãƒ³ãƒ‰è¡Œã‚’é€
- る。(リクエスト)
-・サーãƒã¯ã‚¯ãƒ©ã‚¤ã‚¢ãƒ³ãƒˆãŒé€ã£ãŸãƒªã‚¯ã‚¨ã‚¹ãƒˆã¨ä¸åº¦åŒã˜æ•°ã®ã‚³ãƒžãƒ³ãƒ‰è¡Œ
- ã‚’è¿”ã™ã€‚(レスãƒãƒ³ã‚¹)
-・リクエストã¯ãƒ‘イプライン化ã—ã¦ã‚ˆã„。ã¤ã¾ã‚Šã‚¯ãƒ©ã‚¤ã‚¢ãƒ³ãƒˆã¯å‰ã«
- é€ã£ãŸãƒªã‚¯ã‚¨ã‚¹ãƒˆã«å¯¾ã™ã‚‹è¿”事を待ãŸãšã«æ¬¡ã®ãƒªã‚¯ã‚¨ã‚¹ãƒˆã‚’é€ã£ã¦ã‚‚
- よã„。
-
------------------------------------------------------------------
-リクエスト
-
-・open_index命令ã¯æ¬¡ã®ã‚ˆã†ãªæ§‹æ–‡ã‚’æŒã¤ã€‚
- 'P' indexid dbname tablename indexname fieldlist
- indexidã¯é–‹ã„ã¦ã„る索引ã«ä»˜ã‘られる番å·ã§ã€åŒä¸€æŽ¥ç¶šä¸Šã§å¾Œã«å®Ÿè¡Œ
- ã™ã‚‹å‘½ä»¤ã®ã€å¯¾è±¡ç´¢å¼•ã‚’指定ã™ã‚‹ãŸã‚ã«ä½¿ã‚れる。dbnameã€tablenameã€
- indexnameã¯ãã‚Œãžã‚Œé–‹ããŸã„DBã€ãƒ†ãƒ¼ãƒ–ルã€ç´¢å¼•ã®åå‰ã€‚索引ã®åå‰
- ã¨ã—ã¦"PRIMARY"を指定ã™ã‚‹ã¨ãƒ—ライマリキーãŒé–‹ã‹ã‚Œã‚‹ã€‚fieldlist
- ã¯ã‚«ãƒ³ãƒžåŒºåˆ‡ã‚Šã®åˆ—åã®ãƒªã‚¹ãƒˆã€‚
-・find命令ã¯æ¬¡ã®ã‚ˆã†ãªæ§‹æ–‡ã‚’æŒã¤ã€‚
- indexid op nflds v1 ... vn limit offset
- indexidã¯å®Ÿè¡Œå¯¾è±¡ã®ç´¢å¼•ã‚’指定ã™ã‚‹ã€‚opã¯ç´¢å¼•æ¤œç´¢ã®æ¼”ç®—å­(後述)。
- v1ã‹ã‚‰vnã¯å¯å¤‰é•·ã§ã€ãã®å€‹æ•°ã¯nflds。nfldsã¯indexidã§æŒ‡å®šã•ã‚ŒãŸ
- open_index命令ã®indexnameã®ç´¢å¼•ã®fieldlistã®ãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰æ•°ã«ç­‰ã—
- ã„ã‹å°ã•ããªãã¦ã¯ãªã‚‰ãªã„。m2ã‹ã‚‰mkã¯å¯å¤‰é•·ã§ã€ãã®å€‹æ•°ã¯
- indexidã§æŒ‡å®šã•ã‚ŒãŸopen_index命令ãŒç™ºè¡Œã•ã‚ŒãŸéš›ã®fieldlistã«ä¸€
- 致ã—ãªã‘ã‚Œã°ãªã‚‰ãªã„。コマンド行ã®limit以é™ã¯çœç•¥ã§ãる。limit
- ã¨offsetã¯ã€æ¤œç´¢æ¡ä»¶ã«åˆè‡´ã™ã‚‹åˆ—ã®ã†ã¡ãƒ¬ã‚¹ãƒãƒ³ã‚¹ã«è¿”ã™åˆ—æ•°ã®ä¸Š
- é™ã¨ã€ã‚¹ã‚­ãƒƒãƒ—ã™ã‚‹åˆ—数。limitã¨offsetã‚’çœç•¥ã—ãŸå ´åˆã¯ãã‚Œãžã‚Œ1
- ã¨0ãŒæŒ‡å®šã•ã‚ŒãŸã¨ãã¨åŒã˜å‹•ä½œã‚’ã™ã‚‹ã€‚find命令ã¯ãƒ¬ã‚¹ãƒãƒ³ã‚¹ã¨ã—ã¦ã€
- æ¡ä»¶ã«åˆè‡´ã—ãŸåˆ—ã®ãƒªã‚¹ãƒˆã‚’è¿”ã™ã€‚opã¨ã—ã¦æŒ‡å®šã§ãる演算å­ã¯æ¬¡ã®
- ã¨ãŠã‚Šã€‚
- '=' - v1 ... vnã¨ä¸€è‡´ã™ã‚‹ã‚‚ã®ã‚’å–å¾—
- '>' - v1 ... vnより大ãã„ã‚‚ã®ã‚’昇順ã«å–å¾—
- '>=' - v1 ... vnã«ä¸€è‡´ã™ã‚‹ã‹å¤§ãã„ã‚‚ã®ã‚’昇順ã«å–å¾—
- '<' - v1 ... vnよりå°ã•ã„ã‚‚ã®ã‚’é™é †ã«å–å¾—
- '<=' - v1 ... vnã«ä¸€è‡´ã™ã‚‹ã‹ç­‰ã—ã„ã‚‚ã®ã‚’é™é †ã«å–å¾—
- nfldsãŒ1より大ãã„(v1 ... vnãŒ2個以上)ã¨ãã¯è¾žæ›¸å¼é †åºã§æ¯”較ã•
- れる。
-・find_modify命令ã¯æ¬¡ã®ã‚ˆã†ãªæ§‹æ–‡ã‚’æŒã¤ã€‚
- indexid op nflds v1 ... vn limit offset modop m1 ... mk
- modopよりå‰ã®éƒ¨åˆ†ã¯find命令ã¨åŒç­‰ã§ã€ã“ã‚Œã«ã‚ˆã£ã¦æ“作対象ã®è¡Œã‚’
- 指定ã™ã‚‹ã€‚ãã®æ“作対象ã®è¡Œã«å¯¾ã—modopã§æŒ‡å®šã•ã‚ŒãŸå¤‰æ›´å‡¦ç†ã‚’実行
- ã™ã‚‹ã€‚m1 ... mkã¯å¯å¤‰é•·ã§ã€çœç•¥ã§ãる。modopã¯æ¬¡ã„ãšã‚Œã‹ã€‚
- 'U' - indexidã§æŒ‡å®šã•ã‚ŒãŸopen_index命令ã®fieldlist列
- ã®å†…容をã€m1 ... mkã®å€¤ã§æ›´æ–°ã™ã‚‹ã€‚
- 'D' - 対象ã®è¡Œã‚’削除ã™ã‚‹ã€‚m1 ... mkã®å€¤ã¯ç„¡è¦–ã•ã‚Œã‚‹ã€‚
-・insert命令ã¯ã®ã‚ˆã†ãªæ§‹æ–‡ã‚’æŒã¤ã€‚
- indexid '+' nflds v1 ... vn
- indexidã§æŒ‡å®šã•ã‚ŒãŸãƒ†ãƒ¼ãƒ–ルã«ã€åˆ—を挿入ã™ã‚‹ã€‚v1 ... vnã¯å¯å¤‰é•·
- ã§ã€ãã®å€‹æ•°ã¯nflds。nfldsã¯indexidã§æŒ‡å®šã•ã‚ŒãŸopen_index命令ã®
- indexnameã®ç´¢å¼•ã®fieldlistã®ãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰æ•°ã«ç­‰ã—ã„ã‹å°ã•ããªãã¦
- ã¯ãªã‚‰ãªã„。
-
------------------------------------------------------------------
-レスãƒãƒ³ã‚¹
-
-・open_index命令ãŒæˆåŠŸã—ãŸã¨ãã€ãƒ¬ã‚¹ãƒãƒ³ã‚¹ã¯æ¬¡ã®æ§‹æ–‡ã‚’æŒã¤ã€‚
- '0' '1'
-・find命令ãŒæˆåŠŸã—ãŸã¨ãã€ãƒ¬ã‚¹ãƒãƒ³ã‚¹ã¯æ¬¡ã®æ§‹æ–‡ã‚’æŒã¤ã€‚
- '0' nflds v1 ... vn
- nfldsã¯çµæžœã‚»ãƒƒãƒˆã®åˆ—ã®æ•°ã‚’ã‚らã‚ã™ã€‚v1 ... vnã¯å¯å¤‰é•·ã§ã€ãã®
- é•·ã•ã¯nfldsã®æ•´æ•°å€ã€‚v1 ... vnã¯ç©ºã®ã“ã¨ã‚‚ã‚ã‚Šã€ãã‚Œã¯æ¡ä»¶ã«åˆ
- 致ã™ã‚‹ãƒ¬ã‚³ãƒ¼ãƒ‰ãŒå­˜åœ¨ã—ãªã‹ã£ãŸã“ã¨ã‚’ã‚らã‚ã™ã€‚çµæžœã‚»ãƒƒãƒˆãŒè¤‡æ•°
- è¡Œã«ãªã£ãŸã¨ãã¯v1 ... vnã®é•·ã•ãŒnfldsã®2å€ä»¥ä¸Šã¨ãªã‚Šã€æœ€åˆã®
- è¡Œã‹ã‚‰é †ã«v1 ... vnã«ã‚»ãƒƒãƒˆã•ã‚Œã‚‹ã€‚
-・modify命令ãŒæˆåŠŸã—ãŸã¨ãã€ãƒ¬ã‚¹ãƒãƒ³ã‚¹ã¯æ¬¡ã®æ§‹æ–‡ã‚’æŒã¤ã€‚
- '0' '1' nummod
- nummodã¯å¤‰æ›´ãŒæ–½ã•ã‚ŒãŸè¡Œæ•°ã€‚nummodãŒ0ã®ã¨ãã¯å¤‰æ›´ã•ã‚ŒãŸè¡ŒãŒç„¡
- ã‹ã£ãŸã“ã¨ã‚’ã‚らã‚ã™ã€‚
-・insert命令ãŒæˆåŠŸã—ãŸã¨ãã€ãƒ¬ã‚¹ãƒãƒ³ã‚¹ã¯æ¬¡ã®æ§‹æ–‡ã‚’æŒã¤ã€‚
- '0' '1'
-・命令ãŒå¤±æ•—ã—ãŸã¨ãã€ãƒ¬ã‚¹ãƒãƒ³ã‚¹ã¯å‘½ä»¤ã«é–¢ã‚らãšæ¬¡ã®æ§‹æ–‡ã‚’æŒã¤ã€‚
- err '1' message
- errã¯0以外ã®æ•°å€¤ã§ã€ã‚¨ãƒ©ãƒ¼ã‚³ãƒ¼ãƒ‰ã‚’ã‚らã‚ã™ã€‚messageã¯äººé–“å¯èª­ãª
- エラーメッセージ。ãŸã ã—messageãŒç„¡ã„ã“ã¨ã‚‚ã‚る。
+・HandlerSocketã®ãƒ—ロトコルã¯å˜ç´”ãªãƒªã‚¯ã‚¨ã‚¹ãƒˆãƒ»ãƒ¬ã‚¹ãƒãƒ³ã‚¹ãƒ—ロトコルã«ãªã£ã¦
+ ã„る。接続ãŒç¢ºç«‹ã—ãŸå¾Œã¯ã€ã¾ãšã‚¯ãƒ©ã‚¤ã‚¢ãƒ³ãƒˆãŒãƒªã‚¯ã‚¨ã‚¹ãƒˆã‚’é€ã‚‹ã€‚
+・サーãƒã¯ã€ã‚¯ãƒ©ã‚¤ã‚¢ãƒ³ãƒˆãŒé€ã£ãŸãƒªã‚¯ã‚¨ã‚¹ãƒˆã¨ä¸åº¦åŒã˜æ•°ã®è¡Œ(レスãƒãƒ³ã‚¹)ã‚’è¿”
+ ã™ã€‚
+・リクエストã¯ãƒ‘イプライン化ã—ã¦ã‚ˆã„。ã¤ã¾ã‚Šã‚¯ãƒ©ã‚¤ã‚¢ãƒ³ãƒˆã¯å‰ã«é€ã£ãŸãƒªã‚¯ã‚¨ã‚¹
+ トã«å¯¾ã™ã‚‹è¿”事(レスãƒãƒ³ã‚¹)ã‚’å¾…ãŸãšã«æ¬¡ã®ãƒªã‚¯ã‚¨ã‚¹ãƒˆã‚’é€ã£ã¦ã‚‚よã„。
+
+----------------------------------------------------------------------------
+インデックスを開ã
+
+open_index命令ã¯æ¬¡ã®ã‚ˆã†ãªæ§‹æ–‡ã‚’æŒã¤ã€‚
+
+ P <indexid> <dbname> <tablename> <indexname> <columns> [<fcolumns>]
+
+- <indexid>ã¯æ•°å­—ã§ã€åŒä¸€æŽ¥ç¶šä¸Šã§å¾Œã«å®Ÿè¡Œã™ã‚‹å‘½ä»¤ã®ã€å¯¾è±¡ç´¢å¼•ã‚’指定ã™ã‚‹ãŸã‚
+ ã«ä½¿ã‚れる。
+- <dbname>, <tablename>, <indexname>ã¯æ–‡å­—列ã§ã€ãã‚Œãžã‚ŒDBåã€ãƒ†ãƒ¼ãƒ–ルåã€
+ 索引ã®åå‰ã‚’指定ã™ã‚‹ã€‚<indexname>ã¨ã—ã¦ã€ŒPRIMARYã€ã‚’指定ã™ã‚‹ã¨ãƒ—ライマリ
+ キーãŒé–‹ã‹ã‚Œã‚‹ã€‚
+- <columns>ã¯ã‚«ãƒ³ãƒžåŒºåˆ‡ã‚Šã®åˆ—åã®ãƒªã‚¹ãƒˆã€‚
+- <fcolumns>ã¯ã‚«ãƒ³ãƒžåŒºåˆ‡ã‚Šã®åˆ—åã®ãƒªã‚¹ãƒˆã€‚ã“ã‚Œã¯çœç•¥ã™ã‚‹ã“ã¨ãŒã§ãる。
+
+ã“ã®open_index命令ãŒå®Ÿè¡Œã•ã‚Œã‚‹ã¨ã€HandlerSocketプラグインã¯æŒ‡å®šã•ã‚ŒãŸDBã€
+テーブルã€ç´¢å¼•ã‚’é–‹ã。開ã‹ã‚ŒãŸç´¢å¼•ã¯æŽ¥ç¶šãŒé–‰ã˜ã‚‰ã‚Œã‚‹ã¾ã§é–‹ã‹ã‚ŒãŸã¾ã¾ã«ãªã‚‹ã€‚
+é–‹ã‹ã‚ŒãŸç´¢å¼•ã¯<indexid>ã®æ•°å­—ã§è­˜åˆ¥ã•ã‚Œã‚‹ã€‚ã‚‚ã—æ—¢ã«<indexid>ã«æŒ‡å®šã•ã‚ŒãŸç•ªå·
+ã®ç´¢å¼•ãŒæ—¢ã«é–‹ã‹ã‚Œã¦ã„ã‚‹å ´åˆã¯å¤ã„ã»ã†ãŒé–‰ã˜ã‚‰ã‚Œã‚‹ã€‚ã“ã®<indexid>ã¯ãªã‚‹ã¹ã
+å°ã•ãªæ•°å­—を使ã£ãŸã»ã†ãŒåŠ¹çŽ‡ãŒè‰¯ã„。
+
+----------------------------------------------------------------------------
+データå–å¾—
+
+find命令ã¯æ¬¡ã®ã‚ˆã†ãªæ§‹æ–‡ã‚’æŒã¤ã€‚
+
+ <indexid> <op> <vlen> <v1> ... <vn> [LIM] [IN] [FILTER ...]
+
+LIMã¯æ¬¡ã®ã‚ˆã†ãªãƒ‘ラメータã®ä¸¦ã³
+
+ <limit> <offset>
+
+INã¯æ¬¡ã®ã‚ˆã†ãªãƒ‘ラメータã®ä¸¦ã³
+
+ @ <icol> <ivlen> <iv1> ... <ivn>
+
+FILTERã¯æ¬¡ã®ã‚ˆã†ãªãƒ‘ラメータã®ä¸¦ã³
+
+ <ftyp> <fop> <fcol> <fval>
+
+- <indexid>ã¯æ•°å­—ã§ã€ã“ã‚Œã¯åŒã˜æŽ¥ç¶šä¸Šã§éŽåŽ»ã«å®Ÿè¡Œã—ãŸopen_index命令ã«æŒ‡å®šã•
+ ã‚ŒãŸæ•°å­—ã§ãªã‘ã‚Œã°ãªã‚‰ãªã„。
+- <op>ã¯æ¯”較演算å­ã§ã€ç¾åœ¨ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã§ã¯ '=', '>', '>=', '<', '<=' をサ
+ ãƒãƒ¼ãƒˆã—ã¦ã„る。
+- <vlen>ã¯å¾Œã«ç¶šãパラメータ<v1> ... <vn>ã®é•·ã•ã€‚ã“ã®å€¤ã¯å¯¾å¿œã™ã‚‹open_index
+ 命令ã®<indexname>パラメータã§æŒ‡å®šã•ã‚ŒãŸç´¢å¼•ã®ã‚­ãƒ¼åˆ—ã®æ•°ã¨åŒã˜ã‹å°ã•ã„ã‚‚ã®
+ ã§ãªã‘ã‚Œã°ãªã‚‰ãªã„。
+- <v1> ... <vn>ã¯å–å¾—ã™ã‚‹ã¹ãキーã®å€¤ã‚’指定ã™ã‚‹ãƒ‘ラメータ。
+- LIMã¯çœç•¥ã§ãる。<limit>ã¨<offset>ã¯æ•°å­—ã§ã€ã“ã‚Œã¯SQLã®LIMITã¨åŒã˜ã‚ˆã†ã«
+ ã¯ãŸã‚‰ã。çœç•¥ã—ãŸå ´åˆã¯1ã¨0を指定ã—ãŸå ´åˆã¨åŒã˜å‹•ä½œã‚’ã™ã‚‹ã€‚FILTERã«ã‚ˆã£
+ ã¦èª­ã¿é£›ã°ã•ã‚ŒãŸãƒ¬ã‚³ãƒ¼ãƒ‰ã¯<limit>ã¨<offset>ã«ã‚«ã‚¦ãƒ³ãƒˆã•ã‚Œãªã„。
+- INã¯çœç•¥ã§ãる。指定ã•ã‚Œã‚‹ã¨ã€ã“ã‚Œã¯SQLã® WHERE ... IN ã®ã‚ˆã†ã«å‹•ä½œã™ã‚‹ã€‚
+ <icol>ã¯å¯¾å¿œã™ã‚‹open_index命令ã®<indexname>パラメータã§æŒ‡å®šã•ã‚ŒãŸç´¢å¼•ã®
+ キー列ã®æ•°ã‚ˆã‚Šå°ã•ã„ã‚‚ã®ã§ãªã‘ã‚Œã°ãªã‚‰ãªã„。INãŒæŒ‡å®šã•ã‚ŒãŸã¨ãã¯ã€find命
+ 令ã®<v1> ... <vn>ã®ã†ã¡<icol>番目ã®å€¤ã¯ç„¡è¦–ã•ã‚Œã‚‹ã€‚
+- FILTERã¯çœç•¥ã§ãる。ã“ã‚Œã¯è¡Œå–å¾—ã®éš›ã®ãƒ•ã‚£ãƒ«ã‚¿ã‚’指定ã™ã‚‹ã€‚<ftyp>ã¯
+ 'F'(filter)ã‹'W'(while)ã®ã„ãšã‚Œã‹ã§ãªã‘ã‚Œã°ãªã‚‰ãªã„。<fop>ã¯æ¯”較演算å­ã€‚
+ <fcol>ã¯æ•°å­—ã§ã€ã“ã‚Œã¯å¯¾å¿œã™ã‚‹open_index命令ã®<fcolumns>ã§æŒ‡å®šã•ã‚ŒãŸåˆ—ã®
+ 数よりå°ã•ã„ã‚‚ã®ã§ãªã‘ã‚Œã°ãªã‚‰ãªã„。複数ã®ãƒ•ã‚£ãƒ«ã‚¿ã‚’指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã€
+ ãã®å ´åˆã¯å„フィルタã®ANDã¨è§£é‡ˆã•ã‚Œã‚‹ã€‚'F'ã¨'W'ã®é•ã„ã¯ã€æ¡ä»¶ã«ã‚ã¦ã¯ã¾
+ らãªã„è¡ŒãŒã‚ã£ãŸã¨ãã«'F'ã¯å˜ã«ãれをスキップã™ã‚‹ãŒã€'W'ã¯ãã®æ™‚点ã§ãƒ«ãƒ¼
+ プを抜ã‘ã‚‹ã¨ã„ã†ç‚¹ã€‚
+
+----------------------------------------------------------------------------
+æ›´æ–°ã¨å‰Šé™¤
+
+find_modify命令ã¯æ¬¡ã®ã‚ˆã†ãªæ§‹æ–‡ã‚’æŒã¤ã€‚
+
+ <indexid> <op> <vlen> <v1> ... <vn> [LIM] [IN] [FILTER ...] MOD
+
+MODã¯æ¬¡ã®ã‚ˆã†ãªãƒ‘ラメータã®ä¸¦ã³
+
+ <mop> <m1> ... <mk>
+
+- <mop>ã¯'U', '+', '-', 'D', 'U?', '+?', '-?', 'D?'ã®ã„ãšã‚Œã‹ã€‚'?'ãŒä»˜ã„ãŸ
+ ã‚‚ã®ã¯ä»˜ã„ã¦ã„ãªã„ã‚‚ã®ã¨ã»ã¼åŒã˜å‹•ä½œã‚’ã™ã‚‹ãŒã€ä»˜ã„ã¦ã„ãªã„ã‚‚ã®ãŒãƒ¬ã‚¹ãƒãƒ³
+ スã¨ã—ã¦æ›´æ–°ã•ã‚ŒãŸè¡Œã®æ•°ã‚’è¿”ã™ã®ã«å¯¾ã—ã€ä»˜ã„ã¦ã„ã‚‹ã‚‚ã®ã¯æ›´æ–°ã•ã‚Œã‚‹å‰ã®è¡Œ
+ ã®å†…容を返ã™ç‚¹ã®ã¿ãŒç•°ãªã‚‹ã€‚'U'ã¯æ›´æ–°ã€'D'ã¯å‰Šé™¤ã€'+'ã¯ã‚¤ãƒ³ã‚¯ãƒªãƒ¡ãƒ³ãƒˆã€
+ '-'ã¯ãƒ‡ã‚¯ãƒªãƒ¡ãƒ³ãƒˆã‚’実行ã™ã‚‹ã€‚
+- <m1> ... <mk>ã¯ã‚»ãƒƒãƒˆã•ã‚Œã‚‹å„列ã®å€¤ã€‚<m1> ... <mk>ã®é•·ã•ã¯å¯¾å¿œã™ã‚‹
+ open_index命令ã®<columns>ã®é•·ã•ã¨ç­‰ã—ã„ã‹å°ã•ããªã‘ã‚Œã°ãªã‚‰ãªã„。<mop>ãŒ
+ 'D'ã®ã¨ãã¯ã“れらã®ãƒ‘ラメータã¯ç„¡è¦–ã•ã‚Œã‚‹ã€‚<mop>ãŒ'+'ã‹'-'ã®ã¨ãã¯ã€ã“れら
+ ã®å€¤ã¯æ•°å€¤ã§ãªã‘ã‚Œã°ãªã‚‰ãªã„。<mop>ãŒ'-'ã§ã€ãã‚ŒãŒè² æ•°ã‹ã‚‰æ­£æ•°ã€ã¾ãŸã¯æ­£æ•°
+ ã‹ã‚‰è² æ•°ã¸åˆ—ã®å€¤ã‚’変更ã™ã‚‹ã‚ˆã†ãªã‚‚ã®ã§ã‚ã£ãŸå ´åˆã¯ã€å€¤ã¯å¤‰æ›´ã•ã‚Œãªã„。
+
+----------------------------------------------------------------------------
+è¡Œã®æŒ¿å…¥
+
+insert命令ã¯æ¬¡ã®ã‚ˆã†ãªæ§‹æ–‡ã‚’æŒã¤ã€‚
+
+ <indexid> + <vlen> <v1> ... <vn>
+
+- <vlen>ã¯å¾Œã«ç¶šãパラメータ<v1> ... <vn>ã®é•·ã•ã€‚ã“ã‚Œã¯å¯¾å¿œã™ã‚‹open_indexã®
+ <columns>ã®é•·ã•ã«ç­‰ã—ã„ã‹å°ã•ããªã‘ã‚Œã°ãªã‚‰ãªã„。
+- <v1> ... <vn>ã¯ã‚»ãƒƒãƒˆã•ã‚Œã‚‹å„列ã®å€¤ã€‚指定ã•ã‚Œãªã„ã‹ã£ãŸåˆ—ã«ã¤ã„ã¦ã¯ãã®åˆ—
+ ã®ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆå€¤ãŒã‚»ãƒƒãƒˆã•ã‚Œã‚‹ã€‚
+
+----------------------------------------------------------------------------
+èªè¨¼
+
+auth命令ã¯æ¬¡ã®ã‚ˆã†ãªæ§‹æ–‡ã‚’æŒã¤ã€‚
+
+ A <atyp> <akey>
+
+- <atyp>ã¯ç¾åœ¨ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã§ã¯'1'ã®ã¿ãŒæœ‰åŠ¹ã€‚
+- 指定ã•ã‚ŒãŸ<akey>ãŒã€ã‚µãƒ¼ãƒã®è¨­å®šã®'handlersocket_plain_secret'ã‚„
+ 'handlersocket_plain_secret_wr'ã«æŒ‡å®šã•ã‚ŒãŸæ–‡å­—列ã¨ä¸€è‡´ã—ãŸå ´åˆã«ã®ã¿èªè¨¼
+ ã¯æˆåŠŸã™ã‚‹ã€‚
+- HandlerSocketã®èªè¨¼ãŒæœ‰åŠ¹ã«ãªã£ã¦ã„ã‚‹ã¨ãã¯ã€ã“ã®'auth'ãŒæˆåŠŸã—ãªã„é™ã‚Šã
+ れ以外ã®å‘½ä»¤ã¯å…¨ã¦å¤±æ•—ã™ã‚‹ã€‚
+
+----------------------------------------------------------------------------
+open_indexã«å¯¾ã™ã‚‹ãƒ¬ã‚¹ãƒãƒ³ã‚¹
+
+open_index命令ãŒæˆåŠŸã—ãŸã¨ãã€ãƒ¬ã‚¹ãƒãƒ³ã‚¹ã¯æ¬¡ã®æ§‹æ–‡ã‚’æŒã¤ã€‚
+
+ 0 1
+
+----------------------------------------------------------------------------
+findã«å¯¾ã™ã‚‹ãƒ¬ã‚¹ãƒãƒ³ã‚¹
+
+find命令ãŒæˆåŠŸã—ãŸã¨ãã€ãƒ¬ã‚¹ãƒãƒ³ã‚¹ã¯æ¬¡ã®æ§‹æ–‡ã‚’æŒã¤ã€‚
+
+ 0 <numcolumns> <r1> ... <rn>
+
+- <numcolumns>ã¯find命令ã®å¯¾å¿œã™ã‚‹open_index命令ã«æŒ‡å®šã—ãŸ<columns>ã®é•·ã•ã«
+ 一致ã™ã‚‹ã€‚
+- <r1> ... <rn>ã¯çµæžœã‚»ãƒƒãƒˆã€‚ã‚‚ã—Nè¡ŒãŒfind命令ã§è¦‹ã¤ã‹ã£ãŸãªã‚‰ã€<r1> ...
+ <rn>ã®é•·ã•ã¯ ( <numcolumns> * N )ã«ãªã‚‹ã€‚
+
+----------------------------------------------------------------------------
+find_modifyã«å¯¾ã™ã‚‹ãƒ¬ã‚¹ãƒãƒ³ã‚¹
+
+find_modify命令ãŒæˆåŠŸã—ãŸã¨ãã€ãƒ¬ã‚¹ãƒãƒ³ã‚¹ã¯æ¬¡ã®æ§‹æ–‡ã‚’æŒã¤ã€‚
+
+ 0 1 <nummod>
+
+- <nummod>ã¯å¤‰æ›´ã•ã‚ŒãŸè¡Œã®æ•°ã€‚
+- 例外ã¨ã—ã¦ã€<mop>ãŒ'?'ã®ä»˜ã„ãŸã‚‚ã®ã§ã‚ã£ãŸå ´åˆã«ã¯ã€find命令ã«å¯¾ã™ã‚‹ãƒ¬ã‚¹ãƒ
+ ンスã¨åŒã˜æ§‹æ–‡ã®ãƒ¬ã‚¹ãƒãƒ³ã‚¹ã‚’è¿”ã™ã€‚
+
+----------------------------------------------------------------------------
+insertã«å¯¾ã™ã‚‹ãƒ¬ã‚¹ãƒãƒ³ã‚¹
+
+insert命令ãŒæˆåŠŸã—ãŸã¨ãã€ãƒ¬ã‚¹ãƒãƒ³ã‚¹ã¯æ¬¡ã®æ§‹æ–‡ã‚’æŒã¤ã€‚
+
+ 0 1
+
+----------------------------------------------------------------------------
+authã«å¯¾ã™ã‚‹ãƒ¬ã‚¹ãƒãƒ³ã‚¹
+
+auth命令ãŒæˆåŠŸã—ãŸã¨ãã€ãƒ¬ã‚¹ãƒãƒ³ã‚¹ã¯æ¬¡ã®æ§‹æ–‡ã‚’æŒã¤ã€‚
+
+ 0 1
diff --git a/plugin/handler_socket/handlersocket/database.cpp b/plugin/handler_socket/handlersocket/database.cpp
index da55113a179..2d9785df6e2 100644
--- a/plugin/handler_socket/handlersocket/database.cpp
+++ b/plugin/handler_socket/handlersocket/database.cpp
@@ -660,7 +660,7 @@ dbcontext::cmd_insert_internal(dbcallback_i& cb, const prep_stmt& pst,
empty_record(table);
memset(buf, 0, table->s->null_bytes); /* clear null flags */
const prep_stmt::fields_type& rf = pst.get_ret_fields();
- const size_t n = rf.size();
+ const size_t n = std::min(rf.size(), fvalslen);
for (size_t i = 0; i < n; ++i) {
uint32_t fn = rf[i];
Field *const fld = table->field[fn];
@@ -764,7 +764,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/handler_socket/libhsclient/auto_file.hpp b/plugin/handler_socket/libhsclient/auto_file.hpp
index 841351e54cd..03c357f4d4e 100644
--- a/plugin/handler_socket/libhsclient/auto_file.hpp
+++ b/plugin/handler_socket/libhsclient/auto_file.hpp
@@ -9,6 +9,11 @@
#ifndef DENA_AUTO_FILE_HPP
#define DENA_AUTO_FILE_HPP
+/* Workaround for _LARGE_FILES and _LARGE_FILE_API incompatibility on AIX */
+#if defined(_AIX) && defined(_LARGE_FILE_API)
+#undef _LARGE_FILE_API
+#endif
+
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
diff --git a/plugin/handler_socket/libhsclient/fatal.cpp b/plugin/handler_socket/libhsclient/fatal.cpp
index 5cdd8879ab1..8e109cf13ba 100644
--- a/plugin/handler_socket/libhsclient/fatal.cpp
+++ b/plugin/handler_socket/libhsclient/fatal.cpp
@@ -18,14 +18,6 @@ namespace dena {
const int opt_syslog = LOG_ERR | LOG_PID | LOG_CONS;
void
-fatal_exit(const std::string& message)
-{
- fprintf(stderr, "FATAL_EXIT: %s\n", message.c_str());
- syslog(opt_syslog, "FATAL_EXIT: %s", message.c_str());
- _exit(1);
-}
-
-void
fatal_abort(const std::string& message)
{
fprintf(stderr, "FATAL_COREDUMP: %s\n", message.c_str());
diff --git a/plugin/handler_socket/libhsclient/fatal.hpp b/plugin/handler_socket/libhsclient/fatal.hpp
index 8a630fab1cb..5eaa3db8687 100644
--- a/plugin/handler_socket/libhsclient/fatal.hpp
+++ b/plugin/handler_socket/libhsclient/fatal.hpp
@@ -13,7 +13,6 @@
namespace dena {
-void fatal_exit(const std::string& message);
void fatal_abort(const std::string& message);
};
diff --git a/plugin/handler_socket/libhsclient/socket.cpp b/plugin/handler_socket/libhsclient/socket.cpp
index cf19d4bbe14..2c93a3b4846 100644
--- a/plugin/handler_socket/libhsclient/socket.cpp
+++ b/plugin/handler_socket/libhsclient/socket.cpp
@@ -43,7 +43,7 @@ socket_args::set(const config& conf)
} else {
const char *nd = node.empty() ? 0 : node.c_str();
if (resolve(nd, port.c_str()) != 0) {
- fatal_exit("getaddrinfo failed: " + node + ":" + port);
+ fatal_abort("getaddrinfo failed: " + node + ":" + port);
}
}
}
diff --git a/plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.xs b/plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.xs
index 899941df7ff..8169b3e52a9 100644
--- a/plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.xs
+++ b/plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.xs
@@ -148,7 +148,7 @@ sv_get_string_ref(SV *sv)
static IV
sv_get_iv(SV *sv)
{
- if (sv == 0 || !SvIOK(sv)) {
+ if (sv == 0 || ( !SvIOK(sv) && !SvPOK(sv) ) ) {
return 0;
}
return SvIV(sv);
diff --git a/plugin/handler_socket/regtest/test_01_lib/run.sh b/plugin/handler_socket/regtest/test_01_lib/run.sh
index 8514612832f..84603d65a57 100755
--- a/plugin/handler_socket/regtest/test_01_lib/run.sh
+++ b/plugin/handler_socket/regtest/test_01_lib/run.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-TESTS="01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23";
+TESTS="01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24";
source ../common/compat.sh
diff --git a/plugin/handler_socket/regtest/test_01_lib/test14.pl b/plugin/handler_socket/regtest/test_01_lib/test14.pl
index 68ce87bdd63..ff4e433ae8f 100644
--- a/plugin/handler_socket/regtest/test_01_lib/test14.pl
+++ b/plugin/handler_socket/regtest/test_01_lib/test14.pl
@@ -27,7 +27,7 @@ srand(999);
my %valmap = ();
-my $sth = $dbh->prepare("insert into $table values (?,?,?)");
+my $sth = $dbh->prepare("insert ignore into $table values (?,?,?)");
for (my $i = 0; $i < $tablesize; ++$i) {
my $k = $i;
my ($s1, $s2) = ("", "");
diff --git a/plugin/handler_socket/regtest/test_01_lib/test17.pl b/plugin/handler_socket/regtest/test_01_lib/test17.pl
index b7861b880f5..1ffd7fa1242 100644
--- a/plugin/handler_socket/regtest/test_01_lib/test17.pl
+++ b/plugin/handler_socket/regtest/test_01_lib/test17.pl
@@ -60,7 +60,7 @@ sub test_one {
$dbh->do(
"create table $table (" .
"k $typ, " .
- "v1 varchar(2047), " .
+ "v1 varchar(1000), " .
"v2 $typ, " .
"primary key(k$keylen_str), " .
"index i1(v1), index i2(v2$keylen_str, v1(300))) " .
diff --git a/plugin/handler_socket/regtest/test_01_lib/test19.pl b/plugin/handler_socket/regtest/test_01_lib/test19.pl
index 6c43267c927..9870199c1a7 100644
--- a/plugin/handler_socket/regtest/test_01_lib/test19.pl
+++ b/plugin/handler_socket/regtest/test_01_lib/test19.pl
@@ -113,7 +113,7 @@ sub test_one {
"(k1 int not null, k2 int not null, " .
"v1 int not null, v2 $typ default null, " .
"primary key (k1, k2) ) engine = innodb");
- my $sth = $dbh->prepare("insert into $table values (?,?,?,?)");
+ my $sth = $dbh->prepare("insert ignore into $table values (?,?,?,?)");
for (my $i = 0; $i < $tablesize; ++$i) {
my $j = 0;
for my $v (@$values) {
diff --git a/plugin/handler_socket/regtest/test_01_lib/test24.expected b/plugin/handler_socket/regtest/test_01_lib/test24.expected
new file mode 100644
index 00000000000..5d07e01bb92
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test24.expected
@@ -0,0 +1,2 @@
+HS
+0 0
diff --git a/plugin/handler_socket/regtest/test_01_lib/test24.pl b/plugin/handler_socket/regtest/test_01_lib/test24.pl
new file mode 100644
index 00000000000..6cd95a995e5
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test24.pl
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+
+# vim:sw=2:ai
+
+# test for issue #78
+
+BEGIN {
+ push @INC, "../common/";
+};
+
+use strict;
+use warnings;
+use hstest;
+
+my $dbh = hstest::init_testdb();
+my $table = 'hstesttbl';
+my $tablesize = 100;
+$dbh->do(
+ "create table $table (" .
+ "id bigint(20) not null auto_increment, " .
+ "t1 timestamp not null default current_timestamp, " .
+ "primary key (id)" .
+ ") engine = innodb");
+srand(999);
+
+my %valmap = ();
+
+my $hs = hstest::get_hs_connection(undef, 9999);
+my $dbname = $hstest::conf{dbname};
+$hs->open_index(0, $dbname, $table, 'PRIMARY', 'id,t1');
+my $res = $hs->execute_single(0, '+', [ 321 ], 0, 0);
+die $hs->get_error() if $res->[0] != 0;
+print "HS\n";
+print join(' ', @$res) . "\n";
+
diff --git a/plugin/locale_info/CMakeLists.txt b/plugin/locale_info/CMakeLists.txt
new file mode 100644
index 00000000000..1ace6619041
--- /dev/null
+++ b/plugin/locale_info/CMakeLists.txt
@@ -0,0 +1,5 @@
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/regex
+ ${CMAKE_SOURCE_DIR}/extra/yassl/include)
+
+MYSQL_ADD_PLUGIN(LOCALES locale_info.cc)
+
diff --git a/plugin/locale_info/locale_info.cc b/plugin/locale_info/locale_info.cc
new file mode 100644
index 00000000000..2d998b5c880
--- /dev/null
+++ b/plugin/locale_info/locale_info.cc
@@ -0,0 +1,122 @@
+/*
+ Copyright (c) 2013, Spaempresarial - Brazil, Roberto Spadim
+ http://www.spadim.com.br/
+ roberto@spadim.com.br
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the Roberto Spadim nor the
+ names of the contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ROBERTO SPADIM BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sql_class.h> // THD
+#include <table.h> // ST_SCHEMA_TABLE
+#include <mysql/plugin.h>
+#include <m_ctype.h>
+#include "sql_locale.h"
+
+bool schema_table_store_record(THD *thd, TABLE *table);
+static MY_LOCALE **locale_list;
+
+/* LOCALES */
+static ST_FIELD_INFO locale_info_locale_fields_info[]=
+{
+ {"ID", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0, 0},
+ {"NAME", 255, MYSQL_TYPE_STRING, 0, 0, 0, 0},
+ {"DESCRIPTION", 255, MYSQL_TYPE_STRING, 0, 0, 0, 0},
+ {"MAX_MONTH_NAME_LENGTH", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0, 0},
+ {"MAX_DAY_NAME_LENGTH", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0, 0},
+ {"DECIMAL_POINT", 2, MYSQL_TYPE_STRING, 0, 0, 0, 0},
+ {"THOUSAND_SEP", 2, MYSQL_TYPE_STRING, 0, 0, 0, 0},
+ {"ERROR_MESSAGE_LANGUAGE", 64, MYSQL_TYPE_STRING, 0, 0, 0, 0},
+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}
+};
+static int locale_info_fill_table_locale(THD* thd, TABLE_LIST* tables, COND* cond)
+{
+ TABLE *table= tables->table;
+ CHARSET_INFO *cs= system_charset_info;
+
+ for (MY_LOCALE **loc= locale_list; *loc; loc++)
+ {
+ /* ID */
+ table->field[0]->store((longlong) (*loc)->number, TRUE);
+ /* NAME */
+ table->field[1]->store((*loc)->name, strlen((*loc)->name), cs);
+ /* DESCRIPTION */
+ table->field[2]->store((*loc)->description, strlen((*loc)->description), cs);
+ /* MAX_MONTH_NAME_LENGTH */
+ table->field[3]->store((longlong) (*loc)->max_month_name_length, TRUE);
+ /* MAX_DAY_NAME_LENGTH */
+ table->field[4]->store((longlong) (*loc)->max_day_name_length, TRUE);
+ /* DECIMAL_POINT */
+ char decimal= (*loc)->decimal_point;
+ table->field[5]->store(&decimal, decimal ? 1 : 0, cs);
+ /* THOUSAND_SEP */
+ char thousand= (*loc)->thousand_sep;
+ table->field[6]->store(&thousand, thousand ? 1 : 0, cs);
+ /* ERROR_MESSAGE_LANGUAGE */
+ table->field[7]->store((*loc)->errmsgs->language,
+ strlen((*loc)->errmsgs->language), cs);
+ if (schema_table_store_record(thd, table))
+ return 1;
+ }
+ return 0;
+}
+
+static int locale_info_plugin_init_locales(void *p)
+{
+ ST_SCHEMA_TABLE *schema= (ST_SCHEMA_TABLE *)p;
+ schema->fields_info= locale_info_locale_fields_info;
+ schema->fill_table= locale_info_fill_table_locale;
+
+#if defined(_WIN64)
+ locale_list = (MY_LOCALE **)GetProcAddress(GetModuleHandle(NULL), "?my_locales@@3PAPEAVMY_LOCALE@@A");
+#elif defined(_WIN32)
+ locale_list = (MY_LOCALE **)GetProcAddress(GetModuleHandle(NULL), "?my_locales@@3PAPAVMY_LOCALE@@A");
+#else
+ locale_list = my_locales;
+#endif
+
+ return 0;
+}
+static struct st_mysql_information_schema locale_info_plugin=
+{ MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION };
+
+/*
+ Plugin library descriptor
+*/
+
+maria_declare_plugin(locales)
+{
+ MYSQL_INFORMATION_SCHEMA_PLUGIN, /* the plugin type (see include/mysql/plugin.h) */
+ &locale_info_plugin, /* pointer to type-specific plugin descriptor */
+ "LOCALES", /* plugin name */
+ "Roberto Spadim, Spaempresarial - Brazil", /* plugin author */
+ "Lists all locales from server.", /* the plugin description */
+ PLUGIN_LICENSE_BSD, /* the plugin license (see include/mysql/plugin.h) */
+ locale_info_plugin_init_locales, /* Pointer to plugin initialization function */
+ 0, /* Pointer to plugin deinitialization function */
+ 0x0100, /* Numeric version 0xAABB means AA.BB veriosn */
+ NULL, /* Status variables */
+ NULL, /* System variables */
+ "1.0", /* String version representation */
+ MariaDB_PLUGIN_MATURITY_GAMMA /* Maturity (see include/mysql/plugin.h)*/
+}
+maria_declare_plugin_end;
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..48001a9e527
--- /dev/null
+++ b/plugin/metadata_lock_info/metadata_lock_info.cc
@@ -0,0 +1,176 @@
+/* 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 "my_config.h"
+#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_UPGRADABLE") },
+ { C_STRING_WITH_LEN("MDL_SHARED_NO_WRITE") },
+ { C_STRING_WITH_LEN("MDL_SHARED_NO_READ_WRITE") },
+ { C_STRING_WITH_LEN("MDL_EXCLUSIVE") },
+};
+
+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_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();
+ 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_null();
+ 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_GAMMA,
+}
+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..5803d7d1290
--- /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 NULL Commit lock
+MDL_SHARED NULL Global read 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..1b76b9e8222
--- /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 NULL 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..34d238cb43b
--- /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_WRITE NULL 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..47a7881bf33
--- /dev/null
+++ b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/suite.opt
@@ -0,0 +1,2 @@
+--loose-metadata_lock_info
+--plugin-load-add=$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..a1c6d00343c
--- /dev/null
+++ b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/suite.pm
@@ -0,0 +1,11 @@
+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";;
+
+sub is_default { 1 }
+
+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..103050e3fb8
--- /dev/null
+++ b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/global_read_lock.test
@@ -0,0 +1,6 @@
+SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info;
+FLUSH TABLES WITH READ LOCK;
+--sorted_result
+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/CMakeLists.txt b/plugin/qc_info/CMakeLists.txt
index f9c58f77466..d10f4547227 100644
--- a/plugin/qc_info/CMakeLists.txt
+++ b/plugin/qc_info/CMakeLists.txt
@@ -1,4 +1,5 @@
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/regex
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql
+ ${PCRE_INCLUDES}
${CMAKE_SOURCE_DIR}/extra/yassl/include)
MYSQL_ADD_PLUGIN(QUERY_CACHE_INFO qc_info.cc)
diff --git a/plugin/qc_info/qc_info.cc b/plugin/qc_info/qc_info.cc
index 8489b14c5db..796fa0fbd9a 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,
@@ -207,7 +207,7 @@ maria_declare_plugin(query_cache_info)
NULL, /* status variables */
NULL, /* system variables */
"1.0", /* version as a string */
- MariaDB_PLUGIN_MATURITY_ALPHA
+ MariaDB_PLUGIN_MATURITY_GAMMA
}
maria_declare_plugin_end;
diff --git a/plugin/query_response_time/CMakeLists.txt b/plugin/query_response_time/CMakeLists.txt
new file mode 100644
index 00000000000..f008d0256fc
--- /dev/null
+++ b/plugin/query_response_time/CMakeLists.txt
@@ -0,0 +1,2 @@
+ADD_DEFINITIONS(-DHAVE_RESPONSE_TIME_DISTRIBUTION)
+MYSQL_ADD_PLUGIN(QUERY_RESPONSE_TIME query_response_time.cc plugin.cc)
diff --git a/plugin/query_response_time/mysql-test/query_response_time/basic.result b/plugin/query_response_time/mysql-test/query_response_time/basic.result
new file mode 100644
index 00000000000..15746424b1d
--- /dev/null
+++ b/plugin/query_response_time/mysql-test/query_response_time/basic.result
@@ -0,0 +1,27 @@
+SHOW VARIABLES WHERE VARIABLE_NAME LIKE 'query_response_time%' AND VARIABLE_NAME!='query_response_time_exec_time_debug';
+Variable_name Value
+query_response_time_flush OFF
+query_response_time_range_base 10
+query_response_time_stats OFF
+SHOW CREATE TABLE INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+Table Create Table
+QUERY_RESPONSE_TIME CREATE TEMPORARY TABLE `QUERY_RESPONSE_TIME` (
+ `TIME` varchar(14) NOT NULL DEFAULT '',
+ `COUNT` int(11) unsigned NOT NULL DEFAULT '0',
+ `TOTAL` varchar(14) NOT NULL DEFAULT ''
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SELECT PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_TYPE, PLUGIN_AUTHOR, PLUGIN_DESCRIPTION, PLUGIN_LICENSE, PLUGIN_MATURITY FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE 'query_response_time%';;
+PLUGIN_NAME QUERY_RESPONSE_TIME
+PLUGIN_VERSION 1.0
+PLUGIN_TYPE INFORMATION SCHEMA
+PLUGIN_AUTHOR Percona and Sergey Vojtovich
+PLUGIN_DESCRIPTION Query Response Time Distribution INFORMATION_SCHEMA Plugin
+PLUGIN_LICENSE GPL
+PLUGIN_MATURITY Gamma
+PLUGIN_NAME QUERY_RESPONSE_TIME_AUDIT
+PLUGIN_VERSION 1.0
+PLUGIN_TYPE AUDIT
+PLUGIN_AUTHOR Percona and Sergey Vojtovich
+PLUGIN_DESCRIPTION Query Response Time Distribution Audit Plugin
+PLUGIN_LICENSE GPL
+PLUGIN_MATURITY Gamma
diff --git a/plugin/query_response_time/mysql-test/query_response_time/basic.test b/plugin/query_response_time/mysql-test/query_response_time/basic.test
new file mode 100644
index 00000000000..e46c8035d24
--- /dev/null
+++ b/plugin/query_response_time/mysql-test/query_response_time/basic.test
@@ -0,0 +1,3 @@
+SHOW VARIABLES WHERE VARIABLE_NAME LIKE 'query_response_time%' AND VARIABLE_NAME!='query_response_time_exec_time_debug';
+SHOW CREATE TABLE INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+--query_vertical SELECT PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_TYPE, PLUGIN_AUTHOR, PLUGIN_DESCRIPTION, PLUGIN_LICENSE, PLUGIN_MATURITY FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE 'query_response_time%';
diff --git a/plugin/query_response_time/mysql-test/query_response_time/query_response_time-stored.inc b/plugin/query_response_time/mysql-test/query_response_time/query_response_time-stored.inc
new file mode 100644
index 00000000000..e86594d6fac
--- /dev/null
+++ b/plugin/query_response_time/mysql-test/query_response_time/query_response_time-stored.inc
@@ -0,0 +1,36 @@
+SET SESSION query_response_time_exec_time_debug=100000;
+
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+EVAL SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=$base;
+SET GLOBAL query_response_time_flush=1;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+
+CALL test_f(310000);
+CALL test_f(320000);
+CALL test_f(330000);
+CALL test_f(340000);
+CALL test_f(350000);
+CALL test_f(360000);
+CALL test_f(370000);
+CALL test_f(380000);
+CALL test_f(390000);
+CALL test_f(400000);
+CALL test_f(1100000);
+CALL test_f(1200000);
+CALL test_f(1300000);
+CALL test_f(1500000);
+CALL test_f(1400000);
+CALL test_f(500000);
+CALL test_f(2100000);
+CALL test_f(2300000);
+CALL test_f(2500000);
+CALL test_f(3100000);
+CALL test_f(4100000);
+CALL test_f(5100000);
+
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+
+SET SESSION query_response_time_exec_time_debug=default;
diff --git a/plugin/query_response_time/mysql-test/query_response_time/query_response_time-stored.result b/plugin/query_response_time/mysql-test/query_response_time/query_response_time-stored.result
new file mode 100644
index 00000000000..bec7007d2d0
--- /dev/null
+++ b/plugin/query_response_time/mysql-test/query_response_time/query_response_time-stored.result
@@ -0,0 +1,392 @@
+CREATE TABLE t(a INT);
+CREATE PROCEDURE test_f(t INT)
+BEGIN
+SET SESSION query_response_time_exec_time_debug=t;
+INSERT INTO t VALUES(1);
+SET SESSION query_response_time_exec_time_debug=100000;
+DELETE FROM t;
+END^
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=1;
+Warnings:
+Warning 1292 Truncated incorrect query_response_time_range_base value: '1'
+SET GLOBAL query_response_time_flush=1;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+CALL test_f(310000);
+CALL test_f(320000);
+CALL test_f(330000);
+CALL test_f(340000);
+CALL test_f(350000);
+CALL test_f(360000);
+CALL test_f(370000);
+CALL test_f(380000);
+CALL test_f(390000);
+CALL test_f(400000);
+CALL test_f(1100000);
+CALL test_f(1200000);
+CALL test_f(1300000);
+CALL test_f(1500000);
+CALL test_f(1400000);
+CALL test_f(500000);
+CALL test_f(2100000);
+CALL test_f(2300000);
+CALL test_f(2500000);
+CALL test_f(3100000);
+CALL test_f(4100000);
+CALL test_f(5100000);
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+Variable_name Value
+query_response_time_range_base 2
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 45 0.000000
+ 0.000003 0 0.000000
+ 0.000007 0 0.000000
+ 0.000015 0 0.000000
+ 0.000030 0 0.000000
+ 0.000061 0 0.000000
+ 0.000122 0 0.000000
+ 0.000244 0 0.000000
+ 0.000488 0 0.000000
+ 0.000976 0 0.000000
+ 0.001953 0 0.000000
+ 0.003906 0 0.000000
+ 0.007812 0 0.000000
+ 0.015625 0 0.000000
+ 0.031250 0 0.000000
+ 0.062500 0 0.000000
+ 0.125000 44 4.400000
+ 0.250000 0 0.000000
+ 0.500000 10 3.550000
+ 1.000000 1 0.500000
+ 2.000000 5 6.500000
+ 4.000000 4 10.000000
+ 8.000000 2 9.200000
+ 16.000000 0 0.000000
+ 32.000000 0 0.000000
+ 64.000000 0 0.000000
+ 128.000000 0 0.000000
+ 256.000000 0 0.000000
+ 512.000000 0 0.000000
+ 1024.000000 0 0.000000
+ 2048.000000 0 0.000000
+ 4096.000000 0 0.000000
+ 8192.000000 0 0.000000
+ 16384.000000 0 0.000000
+ 32768.000000 0 0.000000
+ 65536.000000 0 0.000000
+ 131072.000000 0 0.000000
+ 262144.000000 0 0.000000
+ 524288.000000 0 0.000000
+1048576.000000 0 0.000000
+2097152.000000 0 0.000000
+4194304.000000 0 0.000000
+8388608.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET SESSION query_response_time_exec_time_debug=default;
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=2;
+SET GLOBAL query_response_time_flush=1;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+CALL test_f(310000);
+CALL test_f(320000);
+CALL test_f(330000);
+CALL test_f(340000);
+CALL test_f(350000);
+CALL test_f(360000);
+CALL test_f(370000);
+CALL test_f(380000);
+CALL test_f(390000);
+CALL test_f(400000);
+CALL test_f(1100000);
+CALL test_f(1200000);
+CALL test_f(1300000);
+CALL test_f(1500000);
+CALL test_f(1400000);
+CALL test_f(500000);
+CALL test_f(2100000);
+CALL test_f(2300000);
+CALL test_f(2500000);
+CALL test_f(3100000);
+CALL test_f(4100000);
+CALL test_f(5100000);
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+Variable_name Value
+query_response_time_range_base 2
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 45 0.000000
+ 0.000003 0 0.000000
+ 0.000007 0 0.000000
+ 0.000015 0 0.000000
+ 0.000030 0 0.000000
+ 0.000061 0 0.000000
+ 0.000122 0 0.000000
+ 0.000244 0 0.000000
+ 0.000488 0 0.000000
+ 0.000976 0 0.000000
+ 0.001953 0 0.000000
+ 0.003906 0 0.000000
+ 0.007812 0 0.000000
+ 0.015625 0 0.000000
+ 0.031250 0 0.000000
+ 0.062500 0 0.000000
+ 0.125000 44 4.400000
+ 0.250000 0 0.000000
+ 0.500000 10 3.550000
+ 1.000000 1 0.500000
+ 2.000000 5 6.500000
+ 4.000000 4 10.000000
+ 8.000000 2 9.200000
+ 16.000000 0 0.000000
+ 32.000000 0 0.000000
+ 64.000000 0 0.000000
+ 128.000000 0 0.000000
+ 256.000000 0 0.000000
+ 512.000000 0 0.000000
+ 1024.000000 0 0.000000
+ 2048.000000 0 0.000000
+ 4096.000000 0 0.000000
+ 8192.000000 0 0.000000
+ 16384.000000 0 0.000000
+ 32768.000000 0 0.000000
+ 65536.000000 0 0.000000
+ 131072.000000 0 0.000000
+ 262144.000000 0 0.000000
+ 524288.000000 0 0.000000
+1048576.000000 0 0.000000
+2097152.000000 0 0.000000
+4194304.000000 0 0.000000
+8388608.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET SESSION query_response_time_exec_time_debug=default;
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=10;
+SET GLOBAL query_response_time_flush=1;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+CALL test_f(310000);
+CALL test_f(320000);
+CALL test_f(330000);
+CALL test_f(340000);
+CALL test_f(350000);
+CALL test_f(360000);
+CALL test_f(370000);
+CALL test_f(380000);
+CALL test_f(390000);
+CALL test_f(400000);
+CALL test_f(1100000);
+CALL test_f(1200000);
+CALL test_f(1300000);
+CALL test_f(1500000);
+CALL test_f(1400000);
+CALL test_f(500000);
+CALL test_f(2100000);
+CALL test_f(2300000);
+CALL test_f(2500000);
+CALL test_f(3100000);
+CALL test_f(4100000);
+CALL test_f(5100000);
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+Variable_name Value
+query_response_time_range_base 10
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 45 0.000000
+ 0.000010 0 0.000000
+ 0.000100 0 0.000000
+ 0.001000 0 0.000000
+ 0.010000 0 0.000000
+ 0.100000 0 0.000000
+ 1.000000 55 8.450000
+ 10.000000 11 25.700000
+ 100.000000 0 0.000000
+ 1000.000000 0 0.000000
+ 10000.000000 0 0.000000
+ 100000.000000 0 0.000000
+1000000.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET SESSION query_response_time_exec_time_debug=default;
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=7;
+SET GLOBAL query_response_time_flush=1;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+CALL test_f(310000);
+CALL test_f(320000);
+CALL test_f(330000);
+CALL test_f(340000);
+CALL test_f(350000);
+CALL test_f(360000);
+CALL test_f(370000);
+CALL test_f(380000);
+CALL test_f(390000);
+CALL test_f(400000);
+CALL test_f(1100000);
+CALL test_f(1200000);
+CALL test_f(1300000);
+CALL test_f(1500000);
+CALL test_f(1400000);
+CALL test_f(500000);
+CALL test_f(2100000);
+CALL test_f(2300000);
+CALL test_f(2500000);
+CALL test_f(3100000);
+CALL test_f(4100000);
+CALL test_f(5100000);
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+Variable_name Value
+query_response_time_range_base 7
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 45 0.000000
+ 0.000008 0 0.000000
+ 0.000059 0 0.000000
+ 0.000416 0 0.000000
+ 0.002915 0 0.000000
+ 0.020408 0 0.000000
+ 0.142857 44 4.400000
+ 1.000000 11 4.050000
+ 7.000000 11 25.700000
+ 49.000000 0 0.000000
+ 343.000000 0 0.000000
+ 2401.000000 0 0.000000
+ 16807.000000 0 0.000000
+ 117649.000000 0 0.000000
+ 823543.000000 0 0.000000
+5764801.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET SESSION query_response_time_exec_time_debug=default;
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=156;
+SET GLOBAL query_response_time_flush=1;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+CALL test_f(310000);
+CALL test_f(320000);
+CALL test_f(330000);
+CALL test_f(340000);
+CALL test_f(350000);
+CALL test_f(360000);
+CALL test_f(370000);
+CALL test_f(380000);
+CALL test_f(390000);
+CALL test_f(400000);
+CALL test_f(1100000);
+CALL test_f(1200000);
+CALL test_f(1300000);
+CALL test_f(1500000);
+CALL test_f(1400000);
+CALL test_f(500000);
+CALL test_f(2100000);
+CALL test_f(2300000);
+CALL test_f(2500000);
+CALL test_f(3100000);
+CALL test_f(4100000);
+CALL test_f(5100000);
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+Variable_name Value
+query_response_time_range_base 156
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000041 45 0.000000
+ 0.006410 0 0.000000
+ 1.000000 55 8.450000
+ 156.000000 11 25.700000
+ 24336.000000 0 0.000000
+3796416.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET SESSION query_response_time_exec_time_debug=default;
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=1000;
+SET GLOBAL query_response_time_flush=1;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+CALL test_f(310000);
+CALL test_f(320000);
+CALL test_f(330000);
+CALL test_f(340000);
+CALL test_f(350000);
+CALL test_f(360000);
+CALL test_f(370000);
+CALL test_f(380000);
+CALL test_f(390000);
+CALL test_f(400000);
+CALL test_f(1100000);
+CALL test_f(1200000);
+CALL test_f(1300000);
+CALL test_f(1500000);
+CALL test_f(1400000);
+CALL test_f(500000);
+CALL test_f(2100000);
+CALL test_f(2300000);
+CALL test_f(2500000);
+CALL test_f(3100000);
+CALL test_f(4100000);
+CALL test_f(5100000);
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+Variable_name Value
+query_response_time_range_base 1000
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 45 0.000000
+ 0.001000 0 0.000000
+ 1.000000 55 8.450000
+ 1000.000000 11 25.700000
+1000000.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET SESSION query_response_time_exec_time_debug=default;
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=1001;
+Warnings:
+Warning 1292 Truncated incorrect query_response_time_range_base value: '1001'
+SET GLOBAL query_response_time_flush=1;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+CALL test_f(310000);
+CALL test_f(320000);
+CALL test_f(330000);
+CALL test_f(340000);
+CALL test_f(350000);
+CALL test_f(360000);
+CALL test_f(370000);
+CALL test_f(380000);
+CALL test_f(390000);
+CALL test_f(400000);
+CALL test_f(1100000);
+CALL test_f(1200000);
+CALL test_f(1300000);
+CALL test_f(1500000);
+CALL test_f(1400000);
+CALL test_f(500000);
+CALL test_f(2100000);
+CALL test_f(2300000);
+CALL test_f(2500000);
+CALL test_f(3100000);
+CALL test_f(4100000);
+CALL test_f(5100000);
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+Variable_name Value
+query_response_time_range_base 1000
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 45 0.000000
+ 0.001000 0 0.000000
+ 1.000000 55 8.450000
+ 1000.000000 11 25.700000
+1000000.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET SESSION query_response_time_exec_time_debug=default;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=default;
+DROP PROCEDURE test_f;
+DROP TABLE t;
diff --git a/plugin/query_response_time/mysql-test/query_response_time/query_response_time-stored.test b/plugin/query_response_time/mysql-test/query_response_time/query_response_time-stored.test
new file mode 100644
index 00000000000..e281bd352f1
--- /dev/null
+++ b/plugin/query_response_time/mysql-test/query_response_time/query_response_time-stored.test
@@ -0,0 +1,44 @@
+--source include/have_debug.inc
+
+# The file with expected results fits only to a run without
+# ps-protocol/sp-protocol/cursor-protocol/view-protocol.
+if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL
+ + $VIEW_PROTOCOL > 0`)
+{
+ --skip Test requires: ps-protocol/sp-protocol/cursor-protocol/view-protocol disabled
+}
+
+
+CREATE TABLE t(a INT);
+
+delimiter ^;
+CREATE PROCEDURE test_f(t INT)
+BEGIN
+ SET SESSION query_response_time_exec_time_debug=t;
+ INSERT INTO t VALUES(1);
+ SET SESSION query_response_time_exec_time_debug=100000;
+ DELETE FROM t;
+END^
+delimiter ;^
+
+--let base=1
+--source query_response_time-stored.inc
+--let base=2
+--source query_response_time-stored.inc
+--let base=10
+--source query_response_time-stored.inc
+--let base=7
+--source query_response_time-stored.inc
+--let base=156
+--source query_response_time-stored.inc
+--let base=1000
+--source query_response_time-stored.inc
+--let base=1001
+--source query_response_time-stored.inc
+
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=default;
+
+DROP PROCEDURE test_f;
+
+DROP TABLE t;
diff --git a/plugin/query_response_time/mysql-test/query_response_time/query_response_time.inc b/plugin/query_response_time/mysql-test/query_response_time/query_response_time.inc
new file mode 100644
index 00000000000..28ef3d8cd2a
--- /dev/null
+++ b/plugin/query_response_time/mysql-test/query_response_time/query_response_time.inc
@@ -0,0 +1,41 @@
+SET SESSION query_response_time_exec_time_debug=100000;
+
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+EVAL SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=$base;
+SET GLOBAL query_response_time_flush=1;
+# Following two queries check works of FLUSH and
+# respecting of "QUERY_RESPONSE_TIME_STATS" variable (see launchpad bug #855312)
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+
+SET SESSION query_response_time_exec_time_debug=310000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=320000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=330000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=340000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=350000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=360000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=370000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=380000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=390000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=400000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=1100000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=1200000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=1300000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=1500000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=1400000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=500000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=2100000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=2300000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=2500000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=3100000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=4100000; SELECT 1;
+SET SESSION query_response_time_exec_time_debug=5100000; SELECT 1;
+
+SET SESSION query_response_time_exec_time_debug=100000;
+
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+
+SET SESSION query_response_time_exec_time_debug=default;
diff --git a/plugin/query_response_time/mysql-test/query_response_time/query_response_time.result b/plugin/query_response_time/mysql-test/query_response_time/query_response_time.result
new file mode 100644
index 00000000000..eac4888c76c
--- /dev/null
+++ b/plugin/query_response_time/mysql-test/query_response_time/query_response_time.result
@@ -0,0 +1,1003 @@
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=1;
+Warnings:
+Warning 1292 Truncated incorrect query_response_time_range_base value: '1'
+SET GLOBAL query_response_time_flush=1;
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 0 0.000000
+ 0.000003 0 0.000000
+ 0.000007 0 0.000000
+ 0.000015 0 0.000000
+ 0.000030 0 0.000000
+ 0.000061 0 0.000000
+ 0.000122 0 0.000000
+ 0.000244 0 0.000000
+ 0.000488 0 0.000000
+ 0.000976 0 0.000000
+ 0.001953 0 0.000000
+ 0.003906 0 0.000000
+ 0.007812 0 0.000000
+ 0.015625 0 0.000000
+ 0.031250 0 0.000000
+ 0.062500 0 0.000000
+ 0.125000 0 0.000000
+ 0.250000 0 0.000000
+ 0.500000 0 0.000000
+ 1.000000 0 0.000000
+ 2.000000 0 0.000000
+ 4.000000 0 0.000000
+ 8.000000 0 0.000000
+ 16.000000 0 0.000000
+ 32.000000 0 0.000000
+ 64.000000 0 0.000000
+ 128.000000 0 0.000000
+ 256.000000 0 0.000000
+ 512.000000 0 0.000000
+ 1024.000000 0 0.000000
+ 2048.000000 0 0.000000
+ 4096.000000 0 0.000000
+ 8192.000000 0 0.000000
+ 16384.000000 0 0.000000
+ 32768.000000 0 0.000000
+ 65536.000000 0 0.000000
+ 131072.000000 0 0.000000
+ 262144.000000 0 0.000000
+ 524288.000000 0 0.000000
+1048576.000000 0 0.000000
+2097152.000000 0 0.000000
+4194304.000000 0 0.000000
+8388608.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+SET SESSION query_response_time_exec_time_debug=310000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=320000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=330000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=340000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=350000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=360000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=370000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=380000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=390000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=400000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1200000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1300000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1400000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2300000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=3100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=4100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=5100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+Variable_name Value
+query_response_time_range_base 2
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 24 0.000000
+ 0.000003 0 0.000000
+ 0.000007 0 0.000000
+ 0.000015 0 0.000000
+ 0.000030 0 0.000000
+ 0.000061 0 0.000000
+ 0.000122 0 0.000000
+ 0.000244 0 0.000000
+ 0.000488 0 0.000000
+ 0.000976 0 0.000000
+ 0.001953 0 0.000000
+ 0.003906 0 0.000000
+ 0.007812 0 0.000000
+ 0.015625 0 0.000000
+ 0.031250 0 0.000000
+ 0.062500 0 0.000000
+ 0.125000 0 0.000000
+ 0.250000 0 0.000000
+ 0.500000 10 3.550000
+ 1.000000 1 0.500000
+ 2.000000 5 6.500000
+ 4.000000 4 10.000000
+ 8.000000 2 9.200000
+ 16.000000 0 0.000000
+ 32.000000 0 0.000000
+ 64.000000 0 0.000000
+ 128.000000 0 0.000000
+ 256.000000 0 0.000000
+ 512.000000 0 0.000000
+ 1024.000000 0 0.000000
+ 2048.000000 0 0.000000
+ 4096.000000 0 0.000000
+ 8192.000000 0 0.000000
+ 16384.000000 0 0.000000
+ 32768.000000 0 0.000000
+ 65536.000000 0 0.000000
+ 131072.000000 0 0.000000
+ 262144.000000 0 0.000000
+ 524288.000000 0 0.000000
+1048576.000000 0 0.000000
+2097152.000000 0 0.000000
+4194304.000000 0 0.000000
+8388608.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET SESSION query_response_time_exec_time_debug=default;
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=2;
+SET GLOBAL query_response_time_flush=1;
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 0 0.000000
+ 0.000003 0 0.000000
+ 0.000007 0 0.000000
+ 0.000015 0 0.000000
+ 0.000030 0 0.000000
+ 0.000061 0 0.000000
+ 0.000122 0 0.000000
+ 0.000244 0 0.000000
+ 0.000488 0 0.000000
+ 0.000976 0 0.000000
+ 0.001953 0 0.000000
+ 0.003906 0 0.000000
+ 0.007812 0 0.000000
+ 0.015625 0 0.000000
+ 0.031250 0 0.000000
+ 0.062500 0 0.000000
+ 0.125000 0 0.000000
+ 0.250000 0 0.000000
+ 0.500000 0 0.000000
+ 1.000000 0 0.000000
+ 2.000000 0 0.000000
+ 4.000000 0 0.000000
+ 8.000000 0 0.000000
+ 16.000000 0 0.000000
+ 32.000000 0 0.000000
+ 64.000000 0 0.000000
+ 128.000000 0 0.000000
+ 256.000000 0 0.000000
+ 512.000000 0 0.000000
+ 1024.000000 0 0.000000
+ 2048.000000 0 0.000000
+ 4096.000000 0 0.000000
+ 8192.000000 0 0.000000
+ 16384.000000 0 0.000000
+ 32768.000000 0 0.000000
+ 65536.000000 0 0.000000
+ 131072.000000 0 0.000000
+ 262144.000000 0 0.000000
+ 524288.000000 0 0.000000
+1048576.000000 0 0.000000
+2097152.000000 0 0.000000
+4194304.000000 0 0.000000
+8388608.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+SET SESSION query_response_time_exec_time_debug=310000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=320000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=330000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=340000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=350000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=360000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=370000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=380000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=390000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=400000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1200000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1300000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1400000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2300000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=3100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=4100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=5100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+Variable_name Value
+query_response_time_range_base 2
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 24 0.000000
+ 0.000003 0 0.000000
+ 0.000007 0 0.000000
+ 0.000015 0 0.000000
+ 0.000030 0 0.000000
+ 0.000061 0 0.000000
+ 0.000122 0 0.000000
+ 0.000244 0 0.000000
+ 0.000488 0 0.000000
+ 0.000976 0 0.000000
+ 0.001953 0 0.000000
+ 0.003906 0 0.000000
+ 0.007812 0 0.000000
+ 0.015625 0 0.000000
+ 0.031250 0 0.000000
+ 0.062500 0 0.000000
+ 0.125000 0 0.000000
+ 0.250000 0 0.000000
+ 0.500000 10 3.550000
+ 1.000000 1 0.500000
+ 2.000000 5 6.500000
+ 4.000000 4 10.000000
+ 8.000000 2 9.200000
+ 16.000000 0 0.000000
+ 32.000000 0 0.000000
+ 64.000000 0 0.000000
+ 128.000000 0 0.000000
+ 256.000000 0 0.000000
+ 512.000000 0 0.000000
+ 1024.000000 0 0.000000
+ 2048.000000 0 0.000000
+ 4096.000000 0 0.000000
+ 8192.000000 0 0.000000
+ 16384.000000 0 0.000000
+ 32768.000000 0 0.000000
+ 65536.000000 0 0.000000
+ 131072.000000 0 0.000000
+ 262144.000000 0 0.000000
+ 524288.000000 0 0.000000
+1048576.000000 0 0.000000
+2097152.000000 0 0.000000
+4194304.000000 0 0.000000
+8388608.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET SESSION query_response_time_exec_time_debug=default;
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=10;
+SET GLOBAL query_response_time_flush=1;
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 0 0.000000
+ 0.000010 0 0.000000
+ 0.000100 0 0.000000
+ 0.001000 0 0.000000
+ 0.010000 0 0.000000
+ 0.100000 0 0.000000
+ 1.000000 0 0.000000
+ 10.000000 0 0.000000
+ 100.000000 0 0.000000
+ 1000.000000 0 0.000000
+ 10000.000000 0 0.000000
+ 100000.000000 0 0.000000
+1000000.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+SET SESSION query_response_time_exec_time_debug=310000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=320000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=330000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=340000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=350000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=360000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=370000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=380000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=390000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=400000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1200000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1300000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1400000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2300000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=3100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=4100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=5100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+Variable_name Value
+query_response_time_range_base 10
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 24 0.000000
+ 0.000010 0 0.000000
+ 0.000100 0 0.000000
+ 0.001000 0 0.000000
+ 0.010000 0 0.000000
+ 0.100000 0 0.000000
+ 1.000000 11 4.050000
+ 10.000000 11 25.700000
+ 100.000000 0 0.000000
+ 1000.000000 0 0.000000
+ 10000.000000 0 0.000000
+ 100000.000000 0 0.000000
+1000000.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET SESSION query_response_time_exec_time_debug=default;
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=7;
+SET GLOBAL query_response_time_flush=1;
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 0 0.000000
+ 0.000008 0 0.000000
+ 0.000059 0 0.000000
+ 0.000416 0 0.000000
+ 0.002915 0 0.000000
+ 0.020408 0 0.000000
+ 0.142857 0 0.000000
+ 1.000000 0 0.000000
+ 7.000000 0 0.000000
+ 49.000000 0 0.000000
+ 343.000000 0 0.000000
+ 2401.000000 0 0.000000
+ 16807.000000 0 0.000000
+ 117649.000000 0 0.000000
+ 823543.000000 0 0.000000
+5764801.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+SET SESSION query_response_time_exec_time_debug=310000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=320000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=330000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=340000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=350000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=360000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=370000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=380000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=390000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=400000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1200000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1300000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1400000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2300000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=3100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=4100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=5100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+Variable_name Value
+query_response_time_range_base 7
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 24 0.000000
+ 0.000008 0 0.000000
+ 0.000059 0 0.000000
+ 0.000416 0 0.000000
+ 0.002915 0 0.000000
+ 0.020408 0 0.000000
+ 0.142857 0 0.000000
+ 1.000000 11 4.050000
+ 7.000000 11 25.700000
+ 49.000000 0 0.000000
+ 343.000000 0 0.000000
+ 2401.000000 0 0.000000
+ 16807.000000 0 0.000000
+ 117649.000000 0 0.000000
+ 823543.000000 0 0.000000
+5764801.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET SESSION query_response_time_exec_time_debug=default;
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=156;
+SET GLOBAL query_response_time_flush=1;
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000041 0 0.000000
+ 0.006410 0 0.000000
+ 1.000000 0 0.000000
+ 156.000000 0 0.000000
+ 24336.000000 0 0.000000
+3796416.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+SET SESSION query_response_time_exec_time_debug=310000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=320000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=330000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=340000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=350000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=360000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=370000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=380000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=390000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=400000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1200000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1300000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1400000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2300000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=3100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=4100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=5100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+Variable_name Value
+query_response_time_range_base 156
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000041 24 0.000000
+ 0.006410 0 0.000000
+ 1.000000 11 4.050000
+ 156.000000 11 25.700000
+ 24336.000000 0 0.000000
+3796416.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET SESSION query_response_time_exec_time_debug=default;
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=1000;
+SET GLOBAL query_response_time_flush=1;
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 0 0.000000
+ 0.001000 0 0.000000
+ 1.000000 0 0.000000
+ 1000.000000 0 0.000000
+1000000.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+SET SESSION query_response_time_exec_time_debug=310000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=320000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=330000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=340000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=350000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=360000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=370000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=380000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=390000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=400000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1200000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1300000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1400000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2300000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=3100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=4100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=5100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+Variable_name Value
+query_response_time_range_base 1000
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 24 0.000000
+ 0.001000 0 0.000000
+ 1.000000 11 4.050000
+ 1000.000000 11 25.700000
+1000000.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET SESSION query_response_time_exec_time_debug=default;
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=1001;
+Warnings:
+Warning 1292 Truncated incorrect query_response_time_range_base value: '1001'
+SET GLOBAL query_response_time_flush=1;
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 0 0.000000
+ 0.001000 0 0.000000
+ 1.000000 0 0.000000
+ 1000.000000 0 0.000000
+1000000.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
+SET SESSION query_response_time_exec_time_debug=310000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=320000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=330000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=340000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=350000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=360000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=370000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=380000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=390000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=400000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1200000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1300000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=1400000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2300000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=2500000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=3100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=4100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=5100000;
+SELECT 1;
+1
+1
+SET SESSION query_response_time_exec_time_debug=100000;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=0;
+SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE';
+Variable_name Value
+query_response_time_range_base 1000
+SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+TIME COUNT TOTAL
+ 0.000001 24 0.000000
+ 0.001000 0 0.000000
+ 1.000000 11 4.050000
+ 1000.000000 11 25.700000
+1000000.000000 0 0.000000
+TOO LONG 0 TOO LONG
+SET SESSION query_response_time_exec_time_debug=default;
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=default;
diff --git a/plugin/query_response_time/mysql-test/query_response_time/query_response_time.test b/plugin/query_response_time/mysql-test/query_response_time/query_response_time.test
new file mode 100644
index 00000000000..5caec36fa96
--- /dev/null
+++ b/plugin/query_response_time/mysql-test/query_response_time/query_response_time.test
@@ -0,0 +1,28 @@
+--source include/have_debug.inc
+
+# The file with expected results fits only to a run without
+# ps-protocol/sp-protocol/cursor-protocol/view-protocol.
+if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL
+ + $VIEW_PROTOCOL > 0`)
+{
+ --skip Test requires: ps-protocol/sp-protocol/cursor-protocol/view-protocol disabled
+}
+
+
+--let base=1
+--source query_response_time.inc
+--let base=2
+--source query_response_time.inc
+--let base=10
+--source query_response_time.inc
+--let base=7
+--source query_response_time.inc
+--let base=156
+--source query_response_time.inc
+--let base=1000
+--source query_response_time.inc
+--let base=1001
+--source query_response_time.inc
+
+SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default;
+SET GLOBAL QUERY_RESPONSE_TIME_STATS=default;
diff --git a/plugin/query_response_time/mysql-test/query_response_time/suite.opt b/plugin/query_response_time/mysql-test/query_response_time/suite.opt
new file mode 100644
index 00000000000..7283ce84e33
--- /dev/null
+++ b/plugin/query_response_time/mysql-test/query_response_time/suite.opt
@@ -0,0 +1 @@
+--plugin-load-add=$QUERY_RESPONSE_TIME_SO --plugin-query-response-time=ON --plugin-query-response-time-audit=ON
diff --git a/plugin/query_response_time/mysql-test/query_response_time/suite.pm b/plugin/query_response_time/mysql-test/query_response_time/suite.pm
new file mode 100644
index 00000000000..5b4983bc1f6
--- /dev/null
+++ b/plugin/query_response_time/mysql-test/query_response_time/suite.pm
@@ -0,0 +1,14 @@
+package My::Suite::Query_response_time;
+
+@ISA = qw(My::Suite);
+
+return "No QUERY_RESPONSE_TIME plugin" unless
+ $ENV{QUERY_RESPONSE_TIME_SO} or
+ $::mysqld_variables{'query-response-time'} eq "ON";
+
+return "Not run for embedded server" if $::opt_embedded_server;
+
+sub is_default { 1 }
+
+bless { };
+
diff --git a/plugin/query_response_time/plugin.cc b/plugin/query_response_time/plugin.cc
new file mode 100644
index 00000000000..4012ad09d2b
--- /dev/null
+++ b/plugin/query_response_time/plugin.cc
@@ -0,0 +1,163 @@
+/* Copyright (C) 2013 Percona and Sergey Vojtovich
+
+ 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
+#include <sql_class.h>
+#include <table.h>
+#include <sql_show.h>
+#include <mysql/plugin_audit.h>
+#include "query_response_time.h"
+
+
+ulong opt_query_response_time_range_base= QRT_DEFAULT_BASE;
+my_bool opt_query_response_time_stats= 0;
+static my_bool opt_query_response_time_flush= 0;
+
+
+static void query_response_time_flush_update(
+ MYSQL_THD thd __attribute__((unused)),
+ struct st_mysql_sys_var *var __attribute__((unused)),
+ void *tgt __attribute__((unused)),
+ const void *save __attribute__((unused)))
+{
+ query_response_time_flush();
+}
+
+
+static MYSQL_SYSVAR_ULONG(range_base, opt_query_response_time_range_base,
+ PLUGIN_VAR_RQCMDARG,
+ "Select base of log for query_response_time ranges. WARNING: variable "
+ "change affect only after flush",
+ NULL, NULL, QRT_DEFAULT_BASE, 2, QRT_MAXIMUM_BASE, 1);
+static MYSQL_SYSVAR_BOOL(stats, opt_query_response_time_stats,
+ PLUGIN_VAR_OPCMDARG,
+ "Enable or disable query response time statisics collecting",
+ NULL, NULL, FALSE);
+static MYSQL_SYSVAR_BOOL(flush, opt_query_response_time_flush,
+ PLUGIN_VAR_NOCMDOPT,
+ "Update of this variable flushes statistics and re-reads "
+ "query_response_time_range_base",
+ NULL, query_response_time_flush_update, FALSE);
+#ifndef DBUG_OFF
+static MYSQL_THDVAR_ULONGLONG(exec_time_debug, PLUGIN_VAR_NOCMDOPT,
+ "Pretend queries take this many microseconds. When 0 (the default) use "
+ "the actual execution time. Used only for debugging.",
+ NULL, NULL, 0, 0, LONG_TIMEOUT, 1);
+#endif
+
+
+static struct st_mysql_sys_var *query_response_time_info_vars[]=
+{
+ MYSQL_SYSVAR(range_base),
+ MYSQL_SYSVAR(stats),
+ MYSQL_SYSVAR(flush),
+#ifndef DBUG_OFF
+ MYSQL_SYSVAR(exec_time_debug),
+#endif
+ NULL
+};
+
+
+ST_FIELD_INFO query_response_time_fields_info[] =
+{
+ { "TIME", QRT_TIME_STRING_LENGTH, MYSQL_TYPE_STRING, 0, 0, "", SKIP_OPEN_TABLE },
+ { "COUNT", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, MY_I_S_UNSIGNED, "", SKIP_OPEN_TABLE },
+ { "TOTAL", QRT_TIME_STRING_LENGTH, MYSQL_TYPE_STRING, 0, 0, "", SKIP_OPEN_TABLE },
+ { 0, 0, MYSQL_TYPE_NULL, 0, 0, 0, 0 }
+};
+
+
+static int query_response_time_info_init(void *p)
+{
+ ST_SCHEMA_TABLE *i_s_query_response_time= (ST_SCHEMA_TABLE *) p;
+ i_s_query_response_time->fields_info= query_response_time_fields_info;
+ i_s_query_response_time->fill_table= query_response_time_fill;
+ query_response_time_init();
+ return 0;
+}
+
+
+static int query_response_time_info_deinit(void *arg __attribute__((unused)))
+{
+ opt_query_response_time_stats= 0;
+ query_response_time_free();
+ return 0;
+}
+
+
+static struct st_mysql_information_schema query_response_time_info_descriptor=
+{ MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION };
+
+
+static void query_response_time_audit_notify(MYSQL_THD thd,
+ unsigned int event_class,
+ const void *event)
+{
+ const struct mysql_event_general *event_general=
+ (const struct mysql_event_general *) event;
+ DBUG_ASSERT(event_class == MYSQL_AUDIT_GENERAL_CLASS);
+ if (event_general->event_subclass == MYSQL_AUDIT_GENERAL_STATUS &&
+ opt_query_response_time_stats)
+ {
+#ifndef DBUG_OFF
+ if (THDVAR(thd, exec_time_debug))
+ query_response_time_collect(thd->lex->sql_command != SQLCOM_SET_OPTION ?
+ THDVAR(thd, exec_time_debug) : 0);
+ else
+#endif
+ query_response_time_collect(thd->utime_after_query - thd->utime_after_lock);
+ }
+}
+
+
+static struct st_mysql_audit query_response_time_audit_descriptor=
+{
+ MYSQL_AUDIT_INTERFACE_VERSION, NULL, query_response_time_audit_notify,
+ { (unsigned long) MYSQL_AUDIT_GENERAL_CLASSMASK }
+};
+
+
+maria_declare_plugin(query_response_time)
+{
+ MYSQL_INFORMATION_SCHEMA_PLUGIN,
+ &query_response_time_info_descriptor,
+ "QUERY_RESPONSE_TIME",
+ "Percona and Sergey Vojtovich",
+ "Query Response Time Distribution INFORMATION_SCHEMA Plugin",
+ PLUGIN_LICENSE_GPL,
+ query_response_time_info_init,
+ query_response_time_info_deinit,
+ 0x0100,
+ NULL,
+ query_response_time_info_vars,
+ "1.0",
+ MariaDB_PLUGIN_MATURITY_GAMMA
+},
+{
+ MYSQL_AUDIT_PLUGIN,
+ &query_response_time_audit_descriptor,
+ "QUERY_RESPONSE_TIME_AUDIT",
+ "Percona and Sergey Vojtovich",
+ "Query Response Time Distribution Audit Plugin",
+ PLUGIN_LICENSE_GPL,
+ NULL,
+ NULL,
+ 0x0100,
+ NULL,
+ NULL,
+ "1.0",
+ MariaDB_PLUGIN_MATURITY_GAMMA
+}
+maria_declare_plugin_end;
diff --git a/plugin/query_response_time/query_response_time.cc b/plugin/query_response_time/query_response_time.cc
new file mode 100644
index 00000000000..47d42f6fc88
--- /dev/null
+++ b/plugin/query_response_time/query_response_time.cc
@@ -0,0 +1,302 @@
+#include "mysql_version.h"
+#include "my_global.h"
+#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
+#include "mysql_com.h"
+#include "rpl_tblmap.h"
+#include "table.h"
+#include "field.h"
+#include "sql_show.h"
+#include "query_response_time.h"
+
+#define TIME_STRING_POSITIVE_POWER_LENGTH QRT_TIME_STRING_POSITIVE_POWER_LENGTH
+#define TIME_STRING_NEGATIVE_POWER_LENGTH 6
+#define TOTAL_STRING_POSITIVE_POWER_LENGTH QRT_TOTAL_STRING_POSITIVE_POWER_LENGTH
+#define TOTAL_STRING_NEGATIVE_POWER_LENGTH 6
+#define MINIMUM_BASE 2
+#define MAXIMUM_BASE QRT_MAXIMUM_BASE
+#define POSITIVE_POWER_FILLER QRT_POSITIVE_POWER_FILLER
+#define NEGATIVE_POWER_FILLER QRT_NEGATIVE_POWER_FILLER
+#define TIME_OVERFLOW QRT_TIME_OVERFLOW
+#define DEFAULT_BASE QRT_DEFAULT_BASE
+
+#define do_xstr(s) do_str(s)
+#define do_str(s) #s
+#define do_format(filler,width) "%" filler width "lld"
+/*
+ Format strings for snprintf. Generate from:
+ POSITIVE_POWER_FILLER and TIME_STRING_POSITIVE_POWER_LENGTH
+ NEFATIVE_POWER_FILLER and TIME_STRING_NEGATIVE_POWER_LENGTH
+*/
+#define TIME_STRING_POSITIVE_POWER_FORMAT do_format(POSITIVE_POWER_FILLER,do_xstr(TIME_STRING_POSITIVE_POWER_LENGTH))
+#define TIME_STRING_NEGATIVE_POWER_FORMAT do_format(NEGATIVE_POWER_FILLER,do_xstr(TIME_STRING_NEGATIVE_POWER_LENGTH))
+#define TIME_STRING_FORMAT TIME_STRING_POSITIVE_POWER_FORMAT "." TIME_STRING_NEGATIVE_POWER_FORMAT
+
+#define TOTAL_STRING_POSITIVE_POWER_FORMAT do_format(POSITIVE_POWER_FILLER,do_xstr(TOTAL_STRING_POSITIVE_POWER_LENGTH))
+#define TOTAL_STRING_NEGATIVE_POWER_FORMAT do_format(NEGATIVE_POWER_FILLER,do_xstr(TOTAL_STRING_NEGATIVE_POWER_LENGTH))
+#define TOTAL_STRING_FORMAT TOTAL_STRING_POSITIVE_POWER_FORMAT "." TOTAL_STRING_NEGATIVE_POWER_FORMAT
+
+#define TIME_STRING_LENGTH QRT_TIME_STRING_LENGTH
+#define TIME_STRING_BUFFER_LENGTH (TIME_STRING_LENGTH + 1 /* '\0' */)
+
+#define TOTAL_STRING_LENGTH QRT_TOTAL_STRING_LENGTH
+#define TOTAL_STRING_BUFFER_LENGTH (TOTAL_STRING_LENGTH + 1 /* '\0' */)
+
+/*
+ Calculate length of "log linear"
+ 1)
+ (MINIMUM_BASE ^ result) <= (10 ^ STRING_POWER_LENGTH) < (MINIMUM_BASE ^ (result + 1))
+
+ 2)
+ (MINIMUM_BASE ^ result) <= (10 ^ STRING_POWER_LENGTH)
+ and
+ (MINIMUM_BASE ^ (result + 1)) > (10 ^ STRING_POWER_LENGTH)
+
+ 3)
+ result <= LOG(MINIMUM_BASE, 10 ^ STRING_POWER_LENGTH)= STRING_POWER_LENGTH * LOG(MINIMUM_BASE,10)
+ result + 1 > LOG(MINIMUM_BASE, 10 ^ STRING_POWER_LENGTH)= STRING_POWER_LENGTH * LOG(MINIMUM_BASE,10)
+
+ 4) STRING_POWER_LENGTH * LOG(MINIMUM_BASE,10) - 1 < result <= STRING_POWER_LENGTH * LOG(MINIMUM_BASE,10)
+
+ MINIMUM_BASE= 2 always, LOG(MINIMUM_BASE,10)= 3.3219280948873626, result= (int)3.3219280948873626 * STRING_POWER_LENGTH
+
+ Last counter always use for time overflow
+*/
+#define POSITIVE_POWER_COUNT ((int)(3.32192809 * TIME_STRING_POSITIVE_POWER_LENGTH))
+#define NEGATIVE_POWER_COUNT ((int)(3.32192809 * TIME_STRING_NEGATIVE_POWER_LENGTH))
+#define OVERALL_POWER_COUNT (NEGATIVE_POWER_COUNT + 1 + POSITIVE_POWER_COUNT)
+
+#define MILLION ((unsigned long)1000 * 1000)
+
+namespace query_response_time
+{
+
+class utility
+{
+public:
+ utility() : m_base(0)
+ {
+ m_max_dec_value= MILLION;
+ for(int i= 0; TIME_STRING_POSITIVE_POWER_LENGTH > i; ++i)
+ m_max_dec_value *= 10;
+ setup(DEFAULT_BASE);
+ }
+public:
+ uint base() const { return m_base; }
+ uint negative_count() const { return m_negative_count; }
+ uint positive_count() const { return m_positive_count; }
+ uint bound_count() const { return m_bound_count; }
+ ulonglong max_dec_value() const { return m_max_dec_value; }
+ ulonglong bound(uint index) const { return m_bound[ index ]; }
+public:
+ void setup(uint base)
+ {
+ if(base != m_base)
+ {
+ m_base= base;
+
+ const ulonglong million= 1000 * 1000;
+ ulonglong value= million;
+ m_negative_count= 0;
+ while(value > 0)
+ {
+ m_negative_count += 1;
+ value /= m_base;
+ }
+ m_negative_count -= 1;
+
+ value= million;
+ m_positive_count= 0;
+ while(value < m_max_dec_value)
+ {
+ m_positive_count += 1;
+ value *= m_base;
+ }
+ m_bound_count= m_negative_count + m_positive_count;
+
+ value= million;
+ for(uint i= 0; i < m_negative_count; ++i)
+ {
+ value /= m_base;
+ m_bound[m_negative_count - i - 1]= value;
+ }
+ value= million;
+ for(uint i= 0; i < m_positive_count; ++i)
+ {
+ m_bound[m_negative_count + i]= value;
+ value *= m_base;
+ }
+ }
+ }
+private:
+ uint m_base;
+ uint m_negative_count;
+ uint m_positive_count;
+ uint m_bound_count;
+ ulonglong m_max_dec_value; /* for TIME_STRING_POSITIVE_POWER_LENGTH=7 is 10000000 */
+ ulonglong m_bound[OVERALL_POWER_COUNT];
+};
+
+static
+void print_time(char* buffer, std::size_t buffer_size, const char* format,
+ uint64 value)
+{
+ ulonglong second= (value / MILLION);
+ ulonglong microsecond= (value % MILLION);
+ my_snprintf(buffer, buffer_size, format, second, microsecond);
+}
+
+class time_collector
+{
+public:
+ time_collector(utility& u) : m_utility(&u)
+ {
+ my_atomic_rwlock_init(&time_collector_lock);
+ }
+ ~time_collector()
+ {
+ my_atomic_rwlock_destroy(&time_collector_lock);
+ }
+ 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)
+ {
+ my_atomic_rwlock_rdlock(&time_collector_lock);
+ uint64 result= my_atomic_load64((int64*)&m_total[index]);
+ my_atomic_rwlock_rdunlock(&time_collector_lock);
+ return result;
+ }
+public:
+ void flush()
+ {
+ my_atomic_rwlock_wrlock(&time_collector_lock);
+ memset((void*)&m_count,0,sizeof(m_count));
+ memset((void*)&m_total,0,sizeof(m_total));
+ my_atomic_rwlock_wrunlock(&time_collector_lock);
+ }
+ void collect(uint64 time)
+ {
+ int i= 0;
+ for(int count= m_utility->bound_count(); count > i; ++i)
+ {
+ if(m_utility->bound(i) > time)
+ {
+ my_atomic_rwlock_wrlock(&time_collector_lock);
+ my_atomic_add32((int32*)(&m_count[i]), 1);
+ my_atomic_add64((int64*)(&m_total[i]), time);
+ my_atomic_rwlock_wrunlock(&time_collector_lock);
+ break;
+ }
+ }
+ }
+private:
+ utility* m_utility;
+ /* The lock for atomic operations on m_count and m_total. Only actually
+ used on architectures that do not have atomic implementation of atomic
+ operations. */
+ my_atomic_rwlock_t time_collector_lock;
+ uint32 m_count[OVERALL_POWER_COUNT + 1];
+ uint64 m_total[OVERALL_POWER_COUNT + 1];
+};
+
+class collector
+{
+public:
+ collector() : m_time(m_utility)
+ {
+ m_utility.setup(DEFAULT_BASE);
+ m_time.flush();
+ }
+public:
+ void flush()
+ {
+ m_utility.setup(opt_query_response_time_range_base);
+ m_time.flush();
+ }
+ int fill(THD* thd, TABLE_LIST *tables, COND *cond)
+ {
+ DBUG_ENTER("fill_schema_query_response_time");
+ TABLE *table= static_cast<TABLE*>(tables->table);
+ Field **fields= table->field;
+ for(uint i= 0, count= bound_count() + 1 /* with overflow */; count > i; ++i)
+ {
+ char time[TIME_STRING_BUFFER_LENGTH];
+ char total[TOTAL_STRING_BUFFER_LENGTH];
+ if(i == bound_count())
+ {
+ assert(sizeof(TIME_OVERFLOW) <= TIME_STRING_BUFFER_LENGTH);
+ assert(sizeof(TIME_OVERFLOW) <= TOTAL_STRING_BUFFER_LENGTH);
+ memcpy(time,TIME_OVERFLOW,sizeof(TIME_OVERFLOW));
+ memcpy(total,TIME_OVERFLOW,sizeof(TIME_OVERFLOW));
+ }
+ else
+ {
+ print_time(time, sizeof(time), TIME_STRING_FORMAT, this->bound(i));
+ print_time(total, sizeof(total), TOTAL_STRING_FORMAT, this->total(i));
+ }
+ fields[0]->store(time,strlen(time),system_charset_info);
+ fields[1]->store(this->count(i));
+ fields[2]->store(total,strlen(total),system_charset_info);
+ if (schema_table_store_record(thd, table))
+ {
+ DBUG_RETURN(1);
+ }
+ }
+ DBUG_RETURN(0);
+ }
+ void collect(ulonglong time)
+ {
+ m_time.collect(time);
+ }
+ uint bound_count() const
+ {
+ return m_utility.bound_count();
+ }
+ ulonglong bound(uint index)
+ {
+ return m_utility.bound(index);
+ }
+ ulonglong count(uint index)
+ {
+ return m_time.count(index);
+ }
+ ulonglong total(uint index)
+ {
+ return m_time.total(index);
+ }
+private:
+ utility m_utility;
+ time_collector m_time;
+};
+
+static collector g_collector;
+
+} // namespace query_response_time
+
+void query_response_time_init()
+{
+}
+
+void query_response_time_free()
+{
+ query_response_time::g_collector.flush();
+}
+
+void query_response_time_flush()
+{
+ query_response_time::g_collector.flush();
+}
+void query_response_time_collect(ulonglong query_time)
+{
+ query_response_time::g_collector.collect(query_time);
+}
+
+int query_response_time_fill(THD* thd, TABLE_LIST *tables, COND *cond)
+{
+ return query_response_time::g_collector.fill(thd,tables,cond);
+}
+#endif // HAVE_RESPONSE_TIME_DISTRIBUTION
diff --git a/plugin/query_response_time/query_response_time.h b/plugin/query_response_time/query_response_time.h
new file mode 100644
index 00000000000..35b01b0db81
--- /dev/null
+++ b/plugin/query_response_time/query_response_time.h
@@ -0,0 +1,67 @@
+#ifndef QUERY_RESPONSE_TIME_H
+#define QUERY_RESPONSE_TIME_H
+
+/*
+ Settings for query response time
+*/
+
+/*
+ Maximum string length for (10 ^ (-1 * QRT_STRING_NEGATIVE_POWER_LENGTH)) in text representation.
+ Example: for 6 is 0.000001
+ Always 2
+
+ Maximum string length for (10 ^ (QRT_STRING_POSITIVE_POWER_LENGTH + 1) - 1) in text representation.
+ Example: for 7 is 9999999.0
+*/
+#define QRT_TIME_STRING_POSITIVE_POWER_LENGTH 7
+#define QRT_TOTAL_STRING_POSITIVE_POWER_LENGTH 7
+
+/*
+ Minimum base for log - ALWAYS 2
+ Maximum base for log:
+*/
+#define QRT_MAXIMUM_BASE 1000
+
+/*
+ Filler for whole number (positive power)
+ Example: for
+ QRT_POSITIVE_POWER_FILLER ' '
+ QRT_POSITIVE_POWER_LENGTH 7
+ and number 7234 result is:
+ ' 7234'
+*/
+#define QRT_POSITIVE_POWER_FILLER ""
+/*
+ Filler for fractional number. Similiary to whole number
+*/
+#define QRT_NEGATIVE_POWER_FILLER "0"
+
+/*
+ Message if time too big for statistic collecting (very long query)
+*/
+#define QRT_TIME_OVERFLOW "TOO LONG"
+
+#define QRT_DEFAULT_BASE 10
+
+#define QRT_TIME_STRING_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 \
+ 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;
+
+#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
+extern void query_response_time_init ();
+extern void query_response_time_free ();
+extern void query_response_time_flush ();
+extern void query_response_time_collect(ulonglong query_time);
+extern int query_response_time_fill (THD* thd, TABLE_LIST *tables, COND *cond);
+
+extern ulong opt_query_response_time_range_base;
+extern my_bool opt_query_response_time_stats;
+#endif // HAVE_RESPONSE_TIME_DISTRIBUTION
+
+#endif // QUERY_RESPONSE_TIME_H
diff --git a/plugin/semisync/CMakeLists.txt b/plugin/semisync/CMakeLists.txt
index f1ada507f4f..33c0895e5e1 100644
--- a/plugin/semisync/CMakeLists.txt
+++ b/plugin/semisync/CMakeLists.txt
@@ -17,11 +17,10 @@ SET(SEMISYNC_MASTER_SOURCES
semisync.cc semisync_master.cc semisync_master_plugin.cc
semisync.h semisync_master.h)
-MYSQL_ADD_PLUGIN(semisync_master ${SEMISYNC_MASTER_SOURCES}
- MODULE_ONLY MODULE_OUTPUT_NAME "semisync_master")
+MYSQL_ADD_PLUGIN(semisync_master ${SEMISYNC_MASTER_SOURCES})
SET(SEMISYNC_SLAVE_SOURCES semisync.cc semisync_slave.cc
semisync_slave_plugin.cc semisync.h semisync_slave.h )
-MYSQL_ADD_PLUGIN(semisync_slave ${SEMISYNC_SLAVE_SOURCES}
- MODULE_ONLY MODULE_OUTPUT_NAME "semisync_slave")
+
+MYSQL_ADD_PLUGIN(semisync_slave ${SEMISYNC_SLAVE_SOURCES})
diff --git a/plugin/semisync/semisync.h b/plugin/semisync/semisync.h
index 5d8753d0a93..28577296817 100644
--- a/plugin/semisync/semisync.h
+++ b/plugin/semisync/semisync.h
@@ -21,11 +21,10 @@
#define MYSQL_SERVER
#define HAVE_REPLICATION
+#include <my_pthread.h>
#include <sql_priv.h>
+#include <sql_class.h>
#include "unireg.h"
-#include <my_global.h>
-#include <my_pthread.h>
-#include <mysql/plugin.h>
#include <replication.h>
#include "log.h" /* sql_print_information */
diff --git a/plugin/semisync/semisync_master.cc b/plugin/semisync/semisync_master.cc
index 16e6b091ca8..d577bd6848f 100644
--- a/plugin/semisync/semisync_master.cc
+++ b/plugin/semisync/semisync_master.cc
@@ -429,12 +429,13 @@ int ReplSemiSyncMaster::disableMaster()
return 0;
}
-ReplSemiSyncMaster::~ReplSemiSyncMaster()
+void ReplSemiSyncMaster::cleanup()
{
if (init_done_)
{
mysql_mutex_destroy(&LOCK_binlog_);
mysql_cond_destroy(&COND_binlog_send_);
+ init_done_= 0;
}
delete active_tranxs_;
@@ -476,6 +477,7 @@ void ReplSemiSyncMaster::add_slave()
void ReplSemiSyncMaster::remove_slave()
{
lock();
+ assert(rpl_semi_sync_master_clients > 0);
rpl_semi_sync_master_clients--;
/* Only switch off if semi-sync is enabled and is on */
@@ -608,7 +610,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);
@@ -617,8 +619,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())
@@ -742,9 +745,10 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
/*
At this point, the binlog file and position of this transaction
must have been removed from ActiveTranx.
+ active_tranxs_ may be NULL if someone disabled semi sync during
+ cond_timewait()
*/
- assert(thd_killed(NULL) ||
- !getMasterEnabled() ||
+ assert(thd_killed(NULL) || !active_tranxs_ ||
!active_tranxs_->is_tranx_end_pos(trx_wait_binlog_name,
trx_wait_binlog_pos));
@@ -757,7 +761,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);
@@ -1045,6 +1049,7 @@ int ReplSemiSyncMaster::readSlaveReply(NET *net, uint32 server_id,
int result = -1;
struct timespec start_ts;
ulong trc_level = trace_level_;
+ LINT_INIT_STRUCT(start_ts);
LINT_INIT_STRUCT(start_ts);
diff --git a/plugin/semisync/semisync_master.h b/plugin/semisync/semisync_master.h
index 841c24197fc..e68795bcab4 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_;
@@ -100,7 +102,7 @@ public:
it are in use. A new Block is allocated and is put into the rear of the
Block link table if no Block is free.
- @return Return a TranxNode *, or NULL if an error occured.
+ @return Return a TranxNode *, or NULL if an error occurred.
*/
TranxNode *allocate_node()
{
@@ -132,7 +134,7 @@ public:
/**
All nodes are freed.
- @return Return 0, or 1 if an error occured.
+ @return Return 0, or 1 if an error occurred.
*/
int free_all_nodes()
{
@@ -148,7 +150,7 @@ public:
@param node All nodes before 'node' will be freed
- @return Return 0, or 1 if an error occured.
+ @return Return 0, or 1 if an error occurred.
*/
int free_nodes_before(TranxNode* node)
{
@@ -453,7 +455,9 @@ class ReplSemiSyncMaster
public:
ReplSemiSyncMaster();
- ~ReplSemiSyncMaster();
+ ~ReplSemiSyncMaster() {}
+
+ void cleanup();
bool getMasterEnabled() {
return master_enabled_;
diff --git a/plugin/semisync/semisync_master_plugin.cc b/plugin/semisync/semisync_master_plugin.cc
index b6ff23cd1ad..9eae7f03c34 100644
--- a/plugin/semisync/semisync_master_plugin.cc
+++ b/plugin/semisync/semisync_master_plugin.cc
@@ -19,7 +19,7 @@
#include "semisync_master.h"
#include "sql_class.h" // THD
-ReplSemiSyncMaster repl_semisync;
+static ReplSemiSyncMaster repl_semisync;
C_MODE_START
@@ -297,10 +297,10 @@ DEF_SHOW_FUNC(avg_trx_wait_time, SHOW_LONG)
static SHOW_VAR semi_sync_master_status_vars[]= {
{"Rpl_semi_sync_master_status",
(char*) &SHOW_FNAME(status),
- SHOW_FUNC},
+ SHOW_SIMPLE_FUNC},
{"Rpl_semi_sync_master_clients",
(char*) &SHOW_FNAME(clients),
- SHOW_FUNC},
+ SHOW_SIMPLE_FUNC},
{"Rpl_semi_sync_master_yes_tx",
(char*) &rpl_semi_sync_master_yes_transactions,
SHOW_LONG},
@@ -309,7 +309,7 @@ static SHOW_VAR semi_sync_master_status_vars[]= {
SHOW_LONG},
{"Rpl_semi_sync_master_wait_sessions",
(char*) &SHOW_FNAME(wait_sessions),
- SHOW_FUNC},
+ SHOW_SIMPLE_FUNC},
{"Rpl_semi_sync_master_no_times",
(char*) &rpl_semi_sync_master_off_times,
SHOW_LONG},
@@ -321,22 +321,22 @@ static SHOW_VAR semi_sync_master_status_vars[]= {
SHOW_LONG},
{"Rpl_semi_sync_master_tx_wait_time",
(char*) &SHOW_FNAME(trx_wait_time),
- SHOW_FUNC},
+ SHOW_SIMPLE_FUNC},
{"Rpl_semi_sync_master_tx_waits",
(char*) &SHOW_FNAME(trx_wait_num),
- SHOW_FUNC},
+ SHOW_SIMPLE_FUNC},
{"Rpl_semi_sync_master_tx_avg_wait_time",
(char*) &SHOW_FNAME(avg_trx_wait_time),
- SHOW_FUNC},
+ SHOW_SIMPLE_FUNC},
{"Rpl_semi_sync_master_net_wait_time",
(char*) &SHOW_FNAME(net_wait_time),
- SHOW_FUNC},
+ SHOW_SIMPLE_FUNC},
{"Rpl_semi_sync_master_net_waits",
(char*) &SHOW_FNAME(net_wait_num),
- SHOW_FUNC},
+ SHOW_SIMPLE_FUNC},
{"Rpl_semi_sync_master_net_avg_wait_time",
(char*) &SHOW_FNAME(avg_net_wait_time),
- SHOW_FUNC},
+ SHOW_SIMPLE_FUNC},
{NULL, NULL, SHOW_LONG},
};
@@ -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 */
@@ -405,6 +415,7 @@ static int semi_sync_master_plugin_deinit(void *p)
sql_print_error("unregister_binlog_transmit_observer failed");
return 1;
}
+ repl_semisync.cleanup();
sql_print_information("unregister_replicator OK");
return 0;
}
@@ -416,7 +427,7 @@ struct Mysql_replication semi_sync_master_plugin= {
/*
Plugin library descriptor
*/
-mysql_declare_plugin(semi_sync_master)
+maria_declare_plugin(semisync_master)
{
MYSQL_REPLICATION_PLUGIN,
&semi_sync_master_plugin,
@@ -429,7 +440,8 @@ mysql_declare_plugin(semi_sync_master)
0x0100 /* 1.0 */,
semi_sync_master_status_vars, /* status variables */
semi_sync_master_system_vars, /* system variables */
- NULL, /* config options */
- 0, /* flags */
+ "1.0",
+ MariaDB_PLUGIN_MATURITY_GAMMA
}
-mysql_declare_plugin_end;
+maria_declare_plugin_end;
+
diff --git a/plugin/semisync/semisync_slave_plugin.cc b/plugin/semisync/semisync_slave_plugin.cc
index f96116eba4f..572ead214de 100644
--- a/plugin/semisync/semisync_slave_plugin.cc
+++ b/plugin/semisync/semisync_slave_plugin.cc
@@ -19,7 +19,7 @@
#include "semisync_slave.h"
#include <mysql.h>
-ReplSemiSyncSlave repl_semisync;
+static ReplSemiSyncSlave repl_semisync;
/*
indicate whether or not the slave should send a reply to the master.
@@ -213,7 +213,7 @@ struct Mysql_replication semi_sync_slave_plugin= {
/*
Plugin library descriptor
*/
-mysql_declare_plugin(semi_sync_slave)
+maria_declare_plugin(semisync_slave)
{
MYSQL_REPLICATION_PLUGIN,
&semi_sync_slave_plugin,
@@ -226,7 +226,8 @@ mysql_declare_plugin(semi_sync_slave)
0x0100 /* 1.0 */,
semi_sync_slave_status_vars, /* status variables */
semi_sync_slave_system_vars, /* system variables */
- NULL, /* config options */
- 0, /* flags */
+ "1.0",
+ MariaDB_PLUGIN_MATURITY_GAMMA
}
-mysql_declare_plugin_end;
+maria_declare_plugin_end;
+
diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c
index ad2a4618514..6a2ed16cb00 100644
--- a/plugin/server_audit/server_audit.c
+++ b/plugin/server_audit/server_audit.c
@@ -97,13 +97,11 @@ static void closelog() {}
#define FLOGGER_NO_PSI
/* How to access the pthread_mutex in mysql_mutex_t */
-//#ifdef SAFE_MUTEX
-//#define mysql_mutex_real_mutex(A) &(A)->m_mutex.mutex
-//#elif defined(MY_PTHREAD_FASTMUTEX)
-//#define mysql_mutex_real_mutex(A) &(A)->m_mutex.mutex
-//#else
+#if defined(SAFE_MUTEX) || defined(MY_PTHREAD_FASTMUTEX)
+#define mysql_mutex_real_mutex(A) &(A)->m_mutex.mutex
+#else
#define mysql_mutex_real_mutex(A) &(A)->m_mutex
-//#endif
+#endif
#define flogger_mutex_init(A,B,C) do{}while(0)
#define flogger_mutex_destroy(A) do{}while(0)
@@ -1043,6 +1041,7 @@ static int start_logging()
error_header();
fprintf(stderr, "logging started to the file %s.\n", alt_fname);
strncpy(current_log_buf, alt_fname, sizeof(current_log_buf));
+ current_log_buf[sizeof(current_log_buf)-1]= 0;
}
else if (output_type == OUTPUT_SYSLOG)
{
@@ -2578,6 +2577,7 @@ static void update_file_path(MYSQL_THD thd,
}
strncpy(path_buffer, new_name, sizeof(path_buffer));
+ path_buffer[sizeof(path_buffer)-1]= 0;
file_path= path_buffer;
exit_func:
internal_stop_logging= 0;
@@ -2630,6 +2630,7 @@ static void update_incl_users(MYSQL_THD thd,
flogger_mutex_lock(&lock_operations);
mark_always_logged(thd);
strncpy(incl_user_buffer, new_users, sizeof(incl_user_buffer));
+ incl_user_buffer[sizeof(incl_user_buffer)-1]= 0;
incl_users= incl_user_buffer;
user_coll_fill(&incl_user_coll, incl_users, &excl_user_coll, 1);
error_header();
@@ -2648,6 +2649,7 @@ static void update_excl_users(MYSQL_THD thd __attribute__((unused)),
flogger_mutex_lock(&lock_operations);
mark_always_logged(thd);
strncpy(excl_user_buffer, new_users, sizeof(excl_user_buffer));
+ excl_user_buffer[sizeof(excl_user_buffer)-1]= 0;
excl_users= excl_user_buffer;
user_coll_fill(&excl_user_coll, excl_users, &incl_user_coll, 0);
error_header();
@@ -2779,6 +2781,7 @@ static void update_syslog_ident(MYSQL_THD thd __attribute__((unused)),
{
char *new_ident= (*(char **) save) ? *(char **) save : empty_str;
strncpy(syslog_ident_buffer, new_ident, sizeof(syslog_ident_buffer));
+ syslog_ident_buffer[sizeof(syslog_ident_buffer)-1]= 0;
syslog_ident= syslog_ident_buffer;
error_header();
fprintf(stderr, "SYSYLOG ident was changed to '%s'\n", syslog_ident);
diff --git a/plugin/sql_errlog/sql_errlog.c b/plugin/sql_errlog/sql_errlog.c
index ae21a032479..1c7e141c022 100644
--- a/plugin/sql_errlog/sql_errlog.c
+++ b/plugin/sql_errlog/sql_errlog.c
@@ -144,24 +144,6 @@ static struct st_mysql_audit descriptor =
{ MYSQL_AUDIT_GENERAL_CLASSMASK }
};
-mysql_declare_plugin(sql_errlog)
-{
- MYSQL_AUDIT_PLUGIN,
- &descriptor,
- "SQL_ERROR_LOG",
- "Alexey Botchkov",
- "Log SQL level errors to a file with rotation",
- PLUGIN_LICENSE_GPL,
- sql_error_log_init,
- sql_error_log_deinit,
- 0x0100,
- NULL,
- vars,
- NULL,
- 0
-}
-mysql_declare_plugin_end;
-
maria_declare_plugin(sql_errlog)
{
MYSQL_AUDIT_PLUGIN,
@@ -176,6 +158,6 @@ maria_declare_plugin(sql_errlog)
NULL,
vars,
"1.0",
- MariaDB_PLUGIN_MATURITY_ALPHA
+ MariaDB_PLUGIN_MATURITY_GAMMA
}
maria_declare_plugin_end;
diff --git a/plugin/win_auth_client/CMakeLists.txt b/plugin/win_auth_client/CMakeLists.txt
index 75ee55117bd..5d72d24d6ad 100644
--- a/plugin/win_auth_client/CMakeLists.txt
+++ b/plugin/win_auth_client/CMakeLists.txt
@@ -29,7 +29,7 @@ IF(WIN32)
MYSQL_ADD_PLUGIN(authentication_windows_client ${PLUGIN_SOURCES} ${HEADERS}
LINK_LIBRARIES Secur32
- MODULE_ONLY COMPONENT SharedLibraries)
+ MODULE_ONLY COMPONENT ClientPlugins)
#IF(MSVC)
# INSTALL_DEBUG_TARGET(auth_win_client DESTINATION ${INSTALL_LIBDIR}/debug)