diff options
-rw-r--r-- | client/mysqlslap.c | 10 | ||||
-rw-r--r-- | man/mysqlslap.1 | 15 | ||||
-rw-r--r-- | mysql-test/r/mysqlslap.result | 4 | ||||
-rw-r--r-- | mysql-test/t/mysqlslap.test | 7 |
4 files changed, 35 insertions, 1 deletions
diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 8e70a2609c3..202fcf7950f 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -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, diff --git a/man/mysqlslap.1 b/man/mysqlslap.1 index 7446c30a839..e795be397a2 100644 --- a/man/mysqlslap.1 +++ b/man/mysqlslap.1 @@ -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, diff --git a/mysql-test/r/mysqlslap.result b/mysql-test/r/mysqlslap.result index 069c9182de2..af78677647f 100644 --- a/mysql-test/r/mysqlslap.result +++ b/mysql-test/r/mysqlslap.result @@ -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; diff --git a/mysql-test/t/mysqlslap.test b/mysql-test/t/mysqlslap.test index 69eaae76409..c49c4ab3d7d 100644 --- a/mysql-test/t/mysqlslap.test +++ b/mysql-test/t/mysqlslap.test @@ -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; |