Commit 9a2a7071 authored by brian@zim.(none)'s avatar brian@zim.(none)

Added pre and post option to test run (allows me to adjust an engine once all...

Added pre and post option to test run (allows me to adjust an engine once all of the data has been loaded).

Kinda obvious that this was going to come up ;)
parent 34b26587
...@@ -63,6 +63,8 @@ enum options_client ...@@ -63,6 +63,8 @@ enum options_client
OPT_SLAP_AUTO_GENERATE_SECONDARY_INDEXES, OPT_SLAP_AUTO_GENERATE_SECONDARY_INDEXES,
OPT_SLAP_AUTO_GENERATE_UNIQUE_WRITE_NUM, OPT_SLAP_AUTO_GENERATE_UNIQUE_WRITE_NUM,
OPT_SLAP_AUTO_GENERATE_UNIQUE_QUERY_NUM, OPT_SLAP_AUTO_GENERATE_UNIQUE_QUERY_NUM,
OPT_SLAP_PRE_QUERY,
OPT_SLAP_POST_QUERY,
OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT, OPT_SERVER_ID, OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT, OPT_SERVER_ID,
OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT, OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
OPT_DEBUG_INFO, OPT_COLUMN_TYPES OPT_DEBUG_INFO, OPT_COLUMN_TYPES
......
...@@ -122,6 +122,8 @@ unsigned long long primary_keys_number_of; ...@@ -122,6 +122,8 @@ unsigned long long primary_keys_number_of;
static char *host= NULL, *opt_password= NULL, *user= NULL, static char *host= NULL, *opt_password= NULL, *user= NULL,
*user_supplied_query= NULL, *user_supplied_query= NULL,
*user_supplied_pre_statements= NULL,
*user_supplied_post_statements= NULL,
*default_engine= NULL, *default_engine= NULL,
*opt_mysql_unix_port= NULL; *opt_mysql_unix_port= NULL;
...@@ -226,6 +228,8 @@ struct conclusions { ...@@ -226,6 +228,8 @@ struct conclusions {
}; };
static option_string *engine_options= NULL; static option_string *engine_options= NULL;
static statement *pre_statements= NULL;
static statement *post_statements= NULL;
static statement *create_statements= NULL, static statement *create_statements= NULL,
*query_statements= NULL; *query_statements= NULL;
...@@ -252,6 +256,7 @@ pthread_handler_t run_task(void *p); ...@@ -252,6 +256,7 @@ pthread_handler_t run_task(void *p);
void statement_cleanup(statement *stmt); void statement_cleanup(statement *stmt);
void option_cleanup(option_string *stmt); void option_cleanup(option_string *stmt);
void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr); void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr);
static int run_statements(MYSQL *mysql, statement *stmt);
static const char ALPHANUMERICS[]= static const char ALPHANUMERICS[]=
"0123456789ABCDEFGHIJKLMNOPQRSTWXYZabcdefghijklmnopqrstuvwxyz"; "0123456789ABCDEFGHIJKLMNOPQRSTWXYZabcdefghijklmnopqrstuvwxyz";
...@@ -392,6 +397,8 @@ int main(int argc, char **argv) ...@@ -392,6 +397,8 @@ int main(int argc, char **argv)
statement_cleanup(create_statements); statement_cleanup(create_statements);
statement_cleanup(query_statements); statement_cleanup(query_statements);
statement_cleanup(pre_statements);
statement_cleanup(post_statements);
option_cleanup(engine_options); option_cleanup(engine_options);
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
...@@ -447,7 +454,13 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr) ...@@ -447,7 +454,13 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary) if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary)
generate_primary_key_list(mysql, eptr); generate_primary_key_list(mysql, eptr);
if (pre_statements)
run_statements(mysql, pre_statements);
run_scheduler(sptr, query_statements, current, client_limit); run_scheduler(sptr, query_statements, current, client_limit);
if (post_statements)
run_statements(mysql, post_statements);
/* We are finished with this run */ /* We are finished with this run */
if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary) if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary)
...@@ -574,6 +587,16 @@ static struct my_option my_long_options[] = ...@@ -574,6 +587,16 @@ static struct my_option my_long_options[] =
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
0}, 0},
{"post-query", OPT_SLAP_POST_QUERY,
"Query to run or file containing query to run after executing.",
(gptr*) &user_supplied_post_statements,
(gptr*) &user_supplied_post_statements,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"pre-query", OPT_SLAP_PRE_QUERY,
"Query to run or file containing query to run before executing.",
(gptr*) &user_supplied_pre_statements,
(gptr*) &user_supplied_pre_statements,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"preserve-schema", OPT_MYSQL_PRESERVE_SCHEMA, {"preserve-schema", OPT_MYSQL_PRESERVE_SCHEMA,
"Preserve the schema from the mysqlslap run, this happens unless " "Preserve the schema from the mysqlslap run, this happens unless "
"--auto-generate-sql or --create are used.", "--auto-generate-sql or --create are used.",
...@@ -1336,6 +1359,66 @@ get_options(int *argc,char ***argv) ...@@ -1336,6 +1359,66 @@ get_options(int *argc,char ***argv)
} }
} }
if (user_supplied_pre_statements && my_stat(user_supplied_pre_statements, &sbuf, MYF(0)))
{
File data_file;
if (!MY_S_ISREG(sbuf.st_mode))
{
fprintf(stderr,"%s: User query supplied file was not a regular file\n",
my_progname);
exit(1);
}
if ((data_file= my_open(user_supplied_pre_statements, O_RDWR, MYF(0))) == -1)
{
fprintf(stderr,"%s: Could not open query supplied file\n", my_progname);
exit(1);
}
tmp_string= (char *)my_malloc(sbuf.st_size + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
my_read(data_file, tmp_string, sbuf.st_size, MYF(0));
tmp_string[sbuf.st_size]= '\0';
my_close(data_file,MYF(0));
if (user_supplied_pre_statements)
actual_queries= parse_delimiter(tmp_string, &pre_statements,
delimiter[0]);
my_free((gptr)tmp_string, MYF(0));
}
else if (user_supplied_pre_statements)
{
actual_queries= parse_delimiter(user_supplied_pre_statements, &pre_statements,
delimiter[0]);
}
if (user_supplied_post_statements && my_stat(user_supplied_post_statements, &sbuf, MYF(0)))
{
File data_file;
if (!MY_S_ISREG(sbuf.st_mode))
{
fprintf(stderr,"%s: User query supplied file was not a regular file\n",
my_progname);
exit(1);
}
if ((data_file= my_open(user_supplied_post_statements, O_RDWR, MYF(0))) == -1)
{
fprintf(stderr,"%s: Could not open query supplied file\n", my_progname);
exit(1);
}
tmp_string= (char *)my_malloc(sbuf.st_size + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
my_read(data_file, tmp_string, sbuf.st_size, MYF(0));
tmp_string[sbuf.st_size]= '\0';
my_close(data_file,MYF(0));
if (user_supplied_post_statements)
parse_delimiter(tmp_string, &post_statements,
delimiter[0]);
my_free((gptr)tmp_string, MYF(0));
}
else if (user_supplied_post_statements)
{
parse_delimiter(user_supplied_post_statements, &post_statements,
delimiter[0]);
}
if (verbose >= 2) if (verbose >= 2)
printf("Parsing engines to use.\n"); printf("Parsing engines to use.\n");
...@@ -1368,7 +1451,7 @@ generate_primary_key_list(MYSQL *mysql, option_string *engine_stmt) ...@@ -1368,7 +1451,7 @@ generate_primary_key_list(MYSQL *mysql, option_string *engine_stmt)
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
unsigned long long counter; unsigned long long counter;
DBUG_ENTER("create_schema"); DBUG_ENTER("generate_primary_key_list");
/* /*
Blackhole is a special case, this allows us to test the upper end Blackhole is a special case, this allows us to test the upper end
...@@ -1548,6 +1631,25 @@ drop_schema(MYSQL *mysql, const char *db) ...@@ -1548,6 +1631,25 @@ drop_schema(MYSQL *mysql, const char *db)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
static int
run_statements(MYSQL *mysql, statement *stmt)
{
statement *ptr;
DBUG_ENTER("run_statements");
for (ptr= stmt; ptr && ptr->length; ptr= ptr->next)
{
if (run_query(mysql, ptr->string, ptr->length))
{
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
my_progname, (uint)ptr->length, ptr->string, mysql_error(mysql));
exit(1);
}
}
DBUG_RETURN(0);
}
static int static int
run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit) run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
{ {
...@@ -1569,7 +1671,7 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit) ...@@ -1569,7 +1671,7 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
pthread_mutex_unlock(&sleeper_mutex); pthread_mutex_unlock(&sleeper_mutex);
for (x= 0; x < concur; x++) for (x= 0; x < concur; x++)
{ {
/* nowucreate the thread */ /* now you create the thread */
if (pthread_create(&mainthread, NULL, run_task, if (pthread_create(&mainthread, NULL, run_task,
(void *)&con) != 0) (void *)&con) != 0)
{ {
......
...@@ -143,3 +143,27 @@ select * from t1; ...@@ -143,3 +143,27 @@ select * from t1;
select * from t2; select * from t2;
select * from t1; select * from t1;
DROP SCHEMA IF EXISTS `mysqlslap`; DROP SCHEMA IF EXISTS `mysqlslap`;
DROP SCHEMA IF EXISTS `mysqlslap`;
CREATE SCHEMA `mysqlslap`;
use mysqlslap;
set storage_engine=`heap`;
CREATE TABLE t1 (id int, name varchar(64));
create table t2(foo1 varchar(32), foo2 varchar(32));
INSERT INTO t1 VALUES (1, 'This is a test');
insert into t2 values ('test', 'test2');
SHOW TABLES;
select * from t1;
SHOW TABLES;
DROP SCHEMA IF EXISTS `mysqlslap`;
DROP SCHEMA IF EXISTS `mysqlslap`;
CREATE SCHEMA `mysqlslap`;
use mysqlslap;
set storage_engine=`myisam`;
CREATE TABLE t1 (id int, name varchar(64));
create table t2(foo1 varchar(32), foo2 varchar(32));
INSERT INTO t1 VALUES (1, 'This is a test');
insert into t2 values ('test', 'test2');
SHOW TABLES;
select * from t1;
SHOW TABLES;
DROP SCHEMA IF EXISTS `mysqlslap`;
...@@ -34,3 +34,5 @@ ...@@ -34,3 +34,5 @@
--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-guid-primary --auto-generate-sql-load-type=key --auto-generate-sql-execute-number=5 --exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-guid-primary --auto-generate-sql-load-type=key --auto-generate-sql-execute-number=5
--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-guid-primary --auto-generate-sql-load-type=key --auto-generate-sql-execute-number=5 --auto-generate-sql-secondary-indexes=3 --exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-guid-primary --auto-generate-sql-load-type=key --auto-generate-sql-execute-number=5 --auto-generate-sql-secondary-indexes=3
--exec $MYSQL_SLAP --only-print --delimiter=";" --query="select * from t1;select * from t2" --create="CREATE TABLE t1 (id int, name varchar(64)); create table t2(foo1 varchar(32), foo2 varchar(32)); INSERT INTO t1 VALUES (1, 'This is a test'); insert into t2 values ('test', 'test2')" --engine="heap,myisam" --post-query="SHOW TABLES" --pre-query="SHOW TABLES";
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