Commit 45d3ada7 authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-4684 - Enhancement request: --init-command support for mysqlslap

Added --init-command argument to mysqlslap: SQL Command to execute
when connecting to MySQL server. Will automatically be re-executed
when reconnecting.
parent e2d1aaec
......@@ -123,7 +123,8 @@ static char *host= NULL, *opt_password= NULL, *user= NULL,
*default_engine= NULL,
*pre_system= NULL,
*post_system= NULL,
*opt_mysql_unix_port= NULL;
*opt_mysql_unix_port= NULL,
*opt_init_command= NULL;
static char *opt_plugin_dir= 0, *opt_default_auth= 0;
const char *delimiter= "\n";
......@@ -629,6 +630,11 @@ static struct my_option my_long_options[] =
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", &host, &host, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"init-command", OPT_INIT_COMMAND,
"SQL Command to execute when connecting to MySQL server. Will "
"automatically be re-executed when reconnecting.",
&opt_init_command, &opt_init_command, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"iterations", 'i', "Number of times to run the tests.", &iterations,
&iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0},
{"no-drop", OPT_SLAP_NO_DROP, "Do not drop the schema after the test.",
......@@ -2241,6 +2247,8 @@ slap_connect(MYSQL *mysql)
for (x= 0; x < 10; x++)
{
set_mysql_connect_options(mysql);
if (opt_init_command)
mysql_options(mysql, MYSQL_INIT_COMMAND, opt_init_command);
if (mysql_real_connect(mysql, host, user, opt_password,
create_schema_string,
opt_mysql_port,
......
......@@ -578,6 +578,21 @@ Connect to the MySQL server on the given host\&.
.sp -1
.IP \(bu 2.3
.\}
.\" mysqlslap: init-command option
.\" init-command option: mysqlslap
\fB\-\-init\-command=str\fR
.sp
SQL Command to execute when connecting to MySQL server\&. Will automatically be re\-executed when reconnecting\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
.\" mysqlslap: iterations option
.\" iterations option: mysqlslap
\fB\-\-iterations=\fR\fB\fIN\fR\fR,
......
......@@ -251,3 +251,7 @@ Benchmark
Number of clients running queries: 1
Average number of queries per client: 0
#
# MDEV-4684 - Enhancement request: --init-command support for mysqlslap
#
DROP TABLE t1;
......@@ -73,3 +73,10 @@ DROP DATABASE bug58090;
--replace_regex /queries: [0-9]+.[0-9]+/queries: TIME/
--exec $MYSQL_SLAP
--echo #
--echo # MDEV-4684 - Enhancement request: --init-command support for mysqlslap
--echo #
--exec $MYSQL_SLAP --create-schema=test --init-command="CREATE TABLE t1(a INT)" --silent --concurrency=1 --iterations=1
DROP TABLE t1;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment