From 5ede7f5b28288ce45ded718cefcbf36d179fed4c Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Tue, 3 Nov 2015 00:11:51 +0300 Subject: [PATCH 1/5] Use `mysql_config --libs_r` instead of `mysql_config --libs | sed`. --- m4/ac_check_mysqlr.m4 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/m4/ac_check_mysqlr.m4 b/m4/ac_check_mysqlr.m4 index c98198c..67715d1 100644 --- a/m4/ac_check_mysqlr.m4 +++ b/m4/ac_check_mysqlr.m4 @@ -86,8 +86,7 @@ ERROR: cannot find MySQL libraries. If you want to compile with MySQL support, if test [ -z "$ac_cv_mysql_libs" ] then AC_MSG_CHECKING(MySQL linker flags) - MYSQL_LIBS=`${mysqlconfig} --libs | sed -e \ - 's/-lmysqlclient /-lmysqlclient_r /' -e 's/-lmysqlclient$/-lmysqlclient_r/'` + MYSQL_LIBS=`${mysqlconfig} --libs_r` AC_MSG_RESULT($MYSQL_LIBS) fi fi From 76c545645d6a5dfe987677df6cbfbeb99c3793c1 Mon Sep 17 00:00:00 2001 From: pfriedenbach Date: Wed, 31 Aug 2016 17:35:19 -0700 Subject: [PATCH 2/5] Add two new controls: oltp-range-selects controls whether to include range selects or not. (Typical practice is to list all range select statements with zero counts. This allows a simple oltp-range-selects=off) oltp-delete-inserts controls the number of delete/insert pairs to be executed (example: oltp-delete-inserts=0 disables the delete/insert pair ) --- sysbench/tests/oltp/sb_oltp.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sysbench/tests/oltp/sb_oltp.c b/sysbench/tests/oltp/sb_oltp.c index 5ecc133..9ead731 100644 --- a/sysbench/tests/oltp/sb_oltp.c +++ b/sysbench/tests/oltp/sb_oltp.c @@ -47,6 +47,7 @@ static sb_arg_t oltp_args[] = {"oltp-sp-name", "name of store procedure to call in SP test mode", SB_ARG_TYPE_STRING, ""}, {"oltp-read-only", "generate only 'read' queries (do not modify database)", SB_ARG_TYPE_FLAG, "off"}, {"oltp-skip-trx", "skip BEGIN/COMMIT statements", SB_ARG_TYPE_FLAG, "off"}, + {"oltp-range-selects", "flag to do range select statements", SB_ARG_TYPE_FLAG, "on"}, {"oltp-range-size", "range size for range queries", SB_ARG_TYPE_INT, "100"}, {"oltp-point-selects", "number of point selects", SB_ARG_TYPE_INT, "10"}, {"oltp-simple-ranges", "number of simple ranges", SB_ARG_TYPE_INT, "1"}, @@ -55,6 +56,8 @@ static sb_arg_t oltp_args[] = {"oltp-distinct-ranges", "number of distinct ranges", SB_ARG_TYPE_INT, "1"}, {"oltp-index-updates", "number of index update", SB_ARG_TYPE_INT, "1"}, {"oltp-non-index-updates", "number of non-index updates", SB_ARG_TYPE_INT, "1"}, + {"oltp-delete-inserts", "number of delete-insert pairs", SB_ARG_TYPE_INT, "1"}, + {"oltp-nontrx-mode", "mode for non-transactional test {select, update_key, update_nokey, insert, delete}", SB_ARG_TYPE_STRING, "select"}, @@ -128,6 +131,7 @@ typedef struct unsigned int read_only; unsigned int skip_trx; unsigned int auto_inc; + unsigned int range_selects; unsigned int range_size; unsigned int point_selects; unsigned int simple_ranges; @@ -136,6 +140,7 @@ typedef struct unsigned int distinct_ranges; unsigned int index_updates; unsigned int non_index_updates; + unsigned int delete_inserts; nontrx_mode_t nontrx_mode; unsigned int connect_delay; unsigned int user_delay_min; @@ -923,6 +928,9 @@ sb_request_t get_request_complex(int tid) add_reconnect_req(sql_req->queries); } + if (!args.range_selects) + goto rangeselectend; + /* Generate range queries */ for(i = 0; i < args.simple_ranges; i++) { @@ -1011,6 +1019,8 @@ sb_request_t get_request_complex(int tid) add_reconnect_req(sql_req->queries); } + rangeselectend: + /* Skip all write queries for read-only test mode */ if (args.read_only) goto readonly; @@ -1045,6 +1055,10 @@ sb_request_t get_request_complex(int tid) add_reconnect_req(sql_req->queries); } + /* Generate delete and insert pair */ + for (i = 0; i < args.delete_inserts; i++) + { + /* FIXME: generate one more UPDATE with the same ID as DELETE/INSERT to make PostgreSQL work */ query = (sb_sql_query_t *)malloc(sizeof(sb_sql_query_t)); @@ -1078,6 +1092,8 @@ sb_request_t get_request_complex(int tid) query->u.insert_query.id = range; SB_LIST_ADD_TAIL(&query->listitem, sql_req->queries); + } + readonly: if (!args.skip_trx) @@ -1558,6 +1574,7 @@ int parse_arguments(void) args.read_only = sb_get_value_flag("oltp-read-only"); args.skip_trx = sb_get_value_flag("oltp-skip-trx"); args.auto_inc = sb_get_value_flag("oltp-auto-inc"); + args.range_selects = sb_get_value_flag("oltp-range-selects"); args.range_size = sb_get_value_int("oltp-range-size"); args.point_selects = sb_get_value_int("oltp-point-selects"); args.simple_ranges = sb_get_value_int("oltp-simple-ranges"); @@ -1566,6 +1583,7 @@ int parse_arguments(void) args.distinct_ranges = sb_get_value_int("oltp-distinct-ranges"); args.index_updates = sb_get_value_int("oltp-index-updates"); args.non_index_updates = sb_get_value_int("oltp-non-index-updates"); + args.delete_inserts = sb_get_value_int("oltp-delete-inserts"); s = sb_get_value_string("oltp-nontrx-mode"); if (!strcmp(s, "select")) args.nontrx_mode = NONTRX_MODE_SELECT; From bab5d4e7887e5ad7a664524bb1987a9ce89212fa Mon Sep 17 00:00:00 2001 From: pfriedenbach Date: Thu, 1 Sep 2016 09:43:05 -0700 Subject: [PATCH 3/5] Added oltp-write-only control oltp-write-only : Specifies a test to include write only statements (insert, update, and deletes). --- sysbench/tests/oltp/sb_oltp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sysbench/tests/oltp/sb_oltp.c b/sysbench/tests/oltp/sb_oltp.c index 9ead731..c6482d9 100644 --- a/sysbench/tests/oltp/sb_oltp.c +++ b/sysbench/tests/oltp/sb_oltp.c @@ -46,6 +46,7 @@ static sb_arg_t oltp_args[] = "session"}, {"oltp-sp-name", "name of store procedure to call in SP test mode", SB_ARG_TYPE_STRING, ""}, {"oltp-read-only", "generate only 'read' queries (do not modify database)", SB_ARG_TYPE_FLAG, "off"}, + {"oltp-write-only", "generate only 'write' queries (insert, update, delete)", SB_ARG_TYPE_FLAG, "off"}, {"oltp-skip-trx", "skip BEGIN/COMMIT statements", SB_ARG_TYPE_FLAG, "off"}, {"oltp-range-selects", "flag to do range select statements", SB_ARG_TYPE_FLAG, "on"}, {"oltp-range-size", "range size for range queries", SB_ARG_TYPE_INT, "100"}, @@ -129,6 +130,7 @@ typedef struct oltp_mode_t test_mode; reconnect_mode_t reconnect_mode; unsigned int read_only; + unsigned int write_only; unsigned int skip_trx; unsigned int auto_inc; unsigned int range_selects; @@ -711,6 +713,9 @@ void oltp_print_mode(void) if (args.read_only) log_text(LOG_NOTICE, "Doing read-only test"); + + if (args.write_only) + log_text(LOG_NOTICE, "Doing write-only test"); switch (args.dist_type) { case DIST_TYPE_UNIFORM: @@ -912,6 +917,10 @@ sb_request_t get_request_complex(int tid) SB_LIST_ADD_TAIL(&query->listitem, sql_req->queries); } + /* Skip all read queries for write-only test mode */ + if (args.write_only) + goto writeonly; + /* Generate set of point selects */ for(i = 0; i < args.point_selects; i++) { @@ -1025,6 +1034,8 @@ sb_request_t get_request_complex(int tid) if (args.read_only) goto readonly; + writeonly: + /* Generate index update */ for (i = 0; i < args.index_updates; i++) { @@ -1572,6 +1583,7 @@ int parse_arguments(void) } args.read_only = sb_get_value_flag("oltp-read-only"); + args.write_only = sb_get_value_flag("oltp-write-only"); args.skip_trx = sb_get_value_flag("oltp-skip-trx"); args.auto_inc = sb_get_value_flag("oltp-auto-inc"); args.range_selects = sb_get_value_flag("oltp-range-selects"); From 1824dbfa9f517ce8593c5646188e3e798c86299e Mon Sep 17 00:00:00 2001 From: pfriedenbach Date: Thu, 1 Sep 2016 10:48:45 -0700 Subject: [PATCH 4/5] Converted PostgreSQL "FIXME" to apply only to PostgreSQL There is a "FIXME" in the file which generates an additional UPDATE with the same ID as DELETE/INSERT pair which appears to have been required just for PostgreSQL. That statement is now added based on the db-driver. --- sysbench/tests/oltp/sb_oltp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sysbench/tests/oltp/sb_oltp.c b/sysbench/tests/oltp/sb_oltp.c index c6482d9..4c177ef 100644 --- a/sysbench/tests/oltp/sb_oltp.c +++ b/sysbench/tests/oltp/sb_oltp.c @@ -1070,6 +1070,10 @@ sb_request_t get_request_complex(int tid) for (i = 0; i < args.delete_inserts; i++) { + range = GET_RANDOM_ID(); + + if (!strcmp(driver->sname, "pgsql")) + { /* FIXME: generate one more UPDATE with the same ID as DELETE/INSERT to make PostgreSQL work */ query = (sb_sql_query_t *)malloc(sizeof(sb_sql_query_t)); @@ -1078,9 +1082,9 @@ sb_request_t get_request_complex(int tid) query->num_times = 1; query->think_time = get_think_time(); query->type = SB_SQL_QUERY_UPDATE_INDEX; - range = GET_RANDOM_ID(); query->u.update_query.id = range; SB_LIST_ADD_TAIL(&query->listitem, sql_req->queries); + } /* Generate delete */ query = (sb_sql_query_t *)malloc(sizeof(sb_sql_query_t)); From ecb0ace49de3e724c3f13d46db1760f7c5fad1ae Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 16 Jan 2017 11:04:41 +0300 Subject: [PATCH 5/5] Fix an incorrect free() in list option handling. --- sysbench/sb_options.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sysbench/sb_options.c b/sysbench/sb_options.c index 3c5092c..8e670c6 100644 --- a/sysbench/sb_options.c +++ b/sysbench/sb_options.c @@ -80,6 +80,7 @@ option_t *sb_find_option(char *name) int set_option(const char *name, const char *value, sb_arg_type_t type) { option_t *opt; + char *tmpbuf; char *tmp; opt = add_option(&options, name); @@ -102,10 +103,14 @@ int set_option(const char *name, const char *value, sb_arg_type_t type) add_value(&opt->values, value); break; case SB_ARG_TYPE_LIST: - tmp = strdup(value); + tmpbuf = strdup(value); + tmp = tmpbuf; + for (tmp = strtok(tmp, ","); tmp != NULL; tmp = strtok(NULL, ",")) add_value(&opt->values, tmp); - free(tmp); + + free(tmpbuf); + break; default: printf("Unknown argument type: %d", type);