Details
-
Type:
Task
-
Status: Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Fix Version/s: 5.5.34
-
Component/s: None
-
Labels:None
Description
Hello and thank you for mariadb,
I was not able to create this request with anything other than Bug/Epic/Task.
While testing handlersocket with mysqlslap I came upon the need for mysqlslap to support --init-command, this was because on http://varokism.blogspot.co.uk/2010/12/using-mysql-as-nosql-story-for_27.html it looked like init_connect was at one time supported. I have:
~/.my.cnf [client] init-command = use test;HANDLER table_a OPEN
and am using mysqlslap thus:
mysqlslap --create-schema=test --query="HANDLER table_a READ \`PRIMARY\`=(101)"
These are the changes I made against trunk to get this to work:
bzr diff
=== modified file 'client/mysqlslap.c'
--- client/mysqlslap.c 2012-12-18 14:01:58 +0000
+++ client/mysqlslap.c 2013-06-19 20:32:44 +0000
@@ -123,7 +123,8 @@
*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";
@@ -633,6 +634,11 @@
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.",
@@ -2245,6 +2251,8 @@
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,
=== modified file 'man/mysqlslap.1'
--- man/mysqlslap.1 2010-04-28 13:06:11 +0000
+++ man/mysqlslap.1 2013-06-19 20:55:23 +0000
@@ -546,6 +546,21 @@
.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,
=== modified file 'mysql-test/r/mysqlslap.result'
--- mysql-test/r/mysqlslap.result 2013-04-07 15:17:25 +0000
+++ mysql-test/r/mysqlslap.result 2013-06-19 21:07:38 +0000
@@ -251,3 +251,6 @@
Number of clients running queries: 1
Average number of queries per client: 0
+#
+# Add support for --init-command=str
+#
=== modified file 'mysql-test/t/mysqlslap.test'
--- mysql-test/t/mysqlslap.test 2012-05-07 20:20:42 +0000
+++ mysql-test/t/mysqlslap.test 2013-06-19 21:04:36 +0000
@@ -73,3 +73,9 @@
--replace_regex /queries: [0-9]+.[0-9]+/queries: TIME/
--exec $MYSQL_SLAP
+
+--echo #
+--echo # Add support for --init-command=str
+--echo #
+
+--exec $MYSQL_SLAP --init-command="select 7" --silent --concurrency=1 --iterations=1
Thank you for your consideration.
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
Sergei, please review patch for this task.