summaryrefslogtreecommitdiff
path: root/client/mysqlslap.c
diff options
context:
space:
mode:
Diffstat (limited to 'client/mysqlslap.c')
-rw-r--r--client/mysqlslap.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/client/mysqlslap.c b/client/mysqlslap.c
index ba7b8cea6a9..7b3dcced37d 100644
--- a/client/mysqlslap.c
+++ b/client/mysqlslap.c
@@ -85,9 +85,7 @@ TODO:
#include <mysqld_error.h>
#include <my_dir.h>
#include <signal.h>
-#include <stdarg.h>
#include <sslopt-vars.h>
-#include <sys/types.h>
#ifndef __WIN__
#include <sys/wait.h>
#endif
@@ -170,6 +168,7 @@ static ulonglong auto_generate_sql_number;
const char *concurrency_str= NULL;
static char *create_string;
uint *concurrency;
+static char mysql_charsets_dir[FN_REFLEN+1];
const char *default_dbug_option="d:t:o,/tmp/mysqlslap.trace";
const char *opt_csv_str;
@@ -301,8 +300,12 @@ void set_mysql_connect_options(MYSQL *mysql)
mysql_options(mysql,MYSQL_OPT_COMPRESS,NullS);
#ifdef HAVE_OPENSSL
if (opt_use_ssl)
+ {
mysql_ssl_set(mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath, opt_ssl_cipher);
+ mysql_options(mysql, MYSQL_OPT_SSL_CRL, opt_ssl_crl);
+ mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath);
+ }
#endif
if (opt_protocol)
mysql_options(mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
@@ -359,6 +362,9 @@ int main(int argc, char **argv)
if (opt_default_auth && *opt_default_auth)
mysql_options(&mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
+ mysql_options(&mysql, MYSQL_OPT_CONNECT_ATTR_RESET, 0);
+ mysql_options4(&mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
+ "program_name", "mysqlslap");
if (!opt_only_print)
{
if (!(mysql_real_connect(&mysql, host, user, opt_password,
@@ -367,6 +373,7 @@ int main(int argc, char **argv)
{
fprintf(stderr,"%s: Error when connecting to server: %s\n",
my_progname,mysql_error(&mysql));
+ mysql_close(&mysql);
free_defaults(defaults_argv);
my_end(0);
exit(1);
@@ -412,8 +419,7 @@ int main(int argc, char **argv)
pthread_mutex_destroy(&sleeper_mutex);
pthread_cond_destroy(&sleep_threshhold);
- if (!opt_only_print)
- mysql_close(&mysql); /* Close & free connection */
+ mysql_close(&mysql); /* Close & free connection */
/* now free all the strings we created */
my_free(opt_password);
@@ -580,6 +586,9 @@ static struct my_option my_long_options[] =
"Number of row inserts to perform for each thread (default is 100).",
&auto_generate_sql_number, &auto_generate_sql_number,
0, GET_ULL, REQUIRED_ARG, 100, 0, 0, 0, 0, 0},
+ {"character-sets-dir", OPT_CHARSETS_DIR,
+ "Directory for character set files.", &charsets_dir,
+ &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"commit", OPT_SLAP_COMMIT, "Commit records every X number of statements.",
&commit_rate, &commit_rate, 0, GET_UINT, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
@@ -777,6 +786,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
DBUG_PUSH(argument ? argument : default_dbug_option);
debug_check_flag= 1;
break;
+ case OPT_CHARSETS_DIR:
+ strmake_buf(mysql_charsets_dir, argument);
+ charsets_dir = mysql_charsets_dir;
+ break;
case OPT_SLAP_CSV:
if (!argument)
argument= (char *)"-"; /* use stdout */
@@ -1808,8 +1821,8 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
pthread_mutex_lock(&sleeper_mutex);
master_wakeup= 0;
- pthread_mutex_unlock(&sleeper_mutex);
pthread_cond_broadcast(&sleep_threshhold);
+ pthread_mutex_unlock(&sleeper_mutex);
gettimeofday(&start_time, NULL);
@@ -1858,21 +1871,21 @@ pthread_handler_t run_task(void *p)
}
pthread_mutex_unlock(&sleeper_mutex);
- if (!(mysql= mysql_init(NULL)))
+ if (mysql_thread_init())
{
- fprintf(stderr,"%s: mysql_init() failed ERROR : %s\n",
- my_progname, mysql_error(mysql));
+ fprintf(stderr,"%s: mysql_thread_init() failed\n", my_progname);
exit(0);
}
- set_mysql_connect_options(mysql);
- if (mysql_thread_init())
+ if (!(mysql= mysql_init(NULL)))
{
- fprintf(stderr,"%s: mysql_thread_init() failed ERROR : %s\n",
- my_progname, mysql_error(mysql));
+ fprintf(stderr,"%s: mysql_init() failed\n", my_progname);
+ mysql_thread_end();
exit(0);
}
+ set_mysql_connect_options(mysql);
+
DBUG_PRINT("info", ("trying to connect to host %s as user %s", host, user));
if (!opt_only_print)
@@ -1990,8 +2003,7 @@ end:
if (commit_rate)
run_query(mysql, "COMMIT", strlen("COMMIT"));
- if (!opt_only_print)
- mysql_close(mysql);
+ mysql_close(mysql);
mysql_thread_end();