From 92b14262765992adff64fb03d4676de4f45fc1d7 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 2 Apr 2018 11:17:51 +0300 Subject: [PATCH 1/2] Use --db-driver=mysql by default, if the MySQL driver is available. If the MySQL driver is available and --db-driver option was explicitly specified, assume MySQL and don't compain about multiple DB drivers being available. That was a popular request and is likely what most sysbench users want. --- src/db_driver.c | 8 +++++++- tests/t/help_drv_mysql.t | 3 +++ tests/t/opt_help.t | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/db_driver.c b/src/db_driver.c index 1416e07..3fb843c 100644 --- a/src/db_driver.c +++ b/src/db_driver.c @@ -77,7 +77,13 @@ static int db_free_results_int(db_conn_t *con); static sb_arg_t db_args[] = { SB_OPT("db-driver", "specifies database driver to use " - "('help' to get list of available drivers)", NULL, STRING), + "('help' to get list of available drivers)", +#ifdef USE_MYSQL + "mysql", +#else + NULL, +#endif + STRING), SB_OPT("db-ps-mode", "prepared statements usage mode {auto, disable}", "auto", STRING), SB_OPT("db-debug", "print database-specific debug information", "off", BOOL), diff --git a/tests/t/help_drv_mysql.t b/tests/t/help_drv_mysql.t index 081ae2a..c40c16d 100644 --- a/tests/t/help_drv_mysql.t +++ b/tests/t/help_drv_mysql.t @@ -5,6 +5,9 @@ Skip test if the MySQL driver is not available. > exit 80 > fi + $ sysbench --help | grep -- '--db-driver' + --db-driver=STRING specifies database driver to use ('help' to get list of available drivers) [mysql] + $ sysbench --help | sed -n '/mysql options:/,/^$/p' mysql options: --mysql-host=[LIST,...] MySQL server host [localhost] diff --git a/tests/t/opt_help.t b/tests/t/opt_help.t index 08b8dc1..1c9c7b0 100644 --- a/tests/t/opt_help.t +++ b/tests/t/opt_help.t @@ -46,7 +46,7 @@ separately. General database options: - --db-driver=STRING specifies database driver to use ('help' to get list of available drivers) + --db-driver=STRING specifies database driver to use ('help' to get list of available drivers) * (glob) --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto] --db-debug[=on|off] print database-specific debug information [off] From 86235957bbd435b268e070e1abe6effc353e0840 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 2 Apr 2018 11:42:08 +0300 Subject: [PATCH 2/2] Fix opt_help.t to pass when the binary is not configured with MySQL support. --- tests/t/opt_help.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/t/opt_help.t b/tests/t/opt_help.t index 1c9c7b0..9f549c3 100644 --- a/tests/t/opt_help.t +++ b/tests/t/opt_help.t @@ -46,7 +46,7 @@ separately. General database options: - --db-driver=STRING specifies database driver to use ('help' to get list of available drivers) * (glob) + --db-driver=STRING specifies database driver to use \('help' to get list of available drivers\)( \[mysql\])? (re) --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto] --db-debug[=on|off] print database-specific debug information [off]