diff options
author | Monty <monty@mariadb.org> | 2015-11-29 17:51:23 +0200 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2015-11-29 17:51:23 +0200 |
commit | c3018b0ff4fb02c029787d03867adf0530607bab (patch) | |
tree | c3497838c222af9445a16312ecbd0e78ebc62f66 /client | |
parent | 654547b5b4b21aec719a84149595464364c96eea (diff) | |
download | mariadb-git-c3018b0ff4fb02c029787d03867adf0530607bab.tar.gz |
Fixes to get all test to run on MacosX Lion 10.7
This includes fixing all utilities to not have any memory leaks,
as safemalloc warnings stopped tests from passing on MacOSX.
- Ensure that all clients takes character-set-dir, as the
libmysqlclient library will use it.
- mysql-test-run now passes character-set-dir to all external clients.
- Changed dynstr_free() so that it can be called twice (made freeing code easier)
- Changed rpl_global_gtid_slave_state to be allocated dynamicly as it
includes a mutex that needs to be initizlied/destroyed before my_end() is called.
- Removed rpl_slave_state::init() and rpl_slave_stage::deinit() as
their job are better handling by constructor and delete.
- Print alias instead of table_name in check_duplicate_key as
table_name may have been converted to lower case.
Other things:
- Fixed a case in time_to_datetime_with_warn() where we where
using && instead of & in tests
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqlbinlog.cc | 38 | ||||
-rw-r--r-- | client/mysqldump.c | 189 | ||||
-rw-r--r-- | client/mysqlshow.c | 8 | ||||
-rw-r--r-- | client/mysqlslap.c | 29 |
4 files changed, 178 insertions, 86 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 7a54a693cb4..315fdcd22dc 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1533,6 +1533,8 @@ static void cleanup() my_free(host); my_free(user); my_free(const_cast<char*>(dirname_for_local_load)); + my_free(start_datetime_str); + my_free(stop_datetime_str); delete binlog_filter; delete glob_description_event; @@ -1719,7 +1721,7 @@ static int parse_args(int *argc, char*** argv) exit(ho_error); if (debug_info_flag) my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; - if (debug_check_flag) + else if (debug_check_flag) my_end_arg= MY_CHECK_ERROR; return 0; } @@ -2044,6 +2046,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, if ((rev->ident_len != logname_len) || memcmp(rev->new_log_ident, logname, logname_len)) { + delete ev; DBUG_RETURN(OK_CONTINUE); } /* @@ -2052,6 +2055,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, log. If we are running with to_last_remote_log, we print it, because it serves as a useful marker between binlogs then. */ + delete ev; continue; } len= 1; // fake Rotate, so don't increment old_off @@ -2082,7 +2086,9 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, Exit_status retval; if ((file= load_processor.prepare_new_file_for_old_format(le,fname)) < 0) + { DBUG_RETURN(ERROR_STOP); + } retval= process_event(print_event_info, ev, old_off, logname); if (retval != OK_CONTINUE) @@ -2450,23 +2456,23 @@ int main(int argc, char** argv) if (load_defaults("my", load_groups, &argc, &argv)) exit(1); + defaults_argv= argv; + if (!(binlog_filter= new Rpl_filter)) { error("Failed to create Rpl_filter"); - exit(1); + goto err; } - defaults_argv= argv; parse_args(&argc, (char***)&argv); if (!argc || opt_version) { if (!argc) usage(); - cleanup(); - free_defaults(defaults_argv); - my_end(my_end_arg); - exit(!opt_version); + if (!opt_version) + retval= ERROR_STOP; + goto err; } if (opt_base64_output_mode == BASE64_OUTPUT_UNSPEC) @@ -2486,12 +2492,18 @@ int main(int argc, char** argv) if (!dirname_for_local_load) { if (init_tmpdir(&tmpdir, 0)) - exit(1); + { + retval= ERROR_STOP; + goto err; + } dirname_for_local_load= my_strdup(my_tmpdir(&tmpdir), MY_WME); } if (load_processor.init()) - exit(1); + { + retval= ERROR_STOP; + goto err; + } if (dirname_for_local_load) load_processor.init_by_dir_name(dirname_for_local_load); else @@ -2561,12 +2573,20 @@ int main(int argc, char** argv) free_defaults(defaults_argv); my_free_open_file_info(); load_processor.destroy(); + mysql_server_end(); /* We cannot free DBUG, it is used in global destructors after exit(). */ my_end(my_end_arg | MY_DONT_FREE_DBUG); exit(retval == ERROR_STOP ? 1 : 0); /* Keep compilers happy. */ DBUG_RETURN(retval == ERROR_STOP ? 1 : 0); + +err: + cleanup(); + free_defaults(defaults_argv); + my_end(my_end_arg); + exit(retval == ERROR_STOP ? 1 : 0); + DBUG_RETURN(retval == ERROR_STOP ? 1 : 0); } diff --git a/client/mysqldump.c b/client/mysqldump.c index e4683ab79c4..e55da773f29 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -148,6 +148,12 @@ static int first_error=0; */ static uint multi_source= 0; static DYNAMIC_STRING extended_row; +static DYNAMIC_STRING dynamic_where; +static MYSQL_RES *get_table_name_result= NULL; +static MEM_ROOT glob_root; +static MYSQL_RES *routine_res, *routine_list_res; + + #include <sslopt-vars.h> FILE *md_result_file= 0; FILE *stderror_file=0; @@ -1585,14 +1591,26 @@ static void free_resources() { if (md_result_file && md_result_file != stdout) my_fclose(md_result_file, MYF(0)); + if (get_table_name_result) + mysql_free_result(get_table_name_result); + if (routine_res) + mysql_free_result(routine_res); + if (routine_list_res) + mysql_free_result(routine_list_res); + if (mysql) + { + mysql_close(mysql); + mysql= 0; + } + my_free(order_by); my_free(opt_password); my_free(current_host); + free_root(&glob_root, MYF(0)); if (my_hash_inited(&ignore_table)) my_hash_free(&ignore_table); - if (extended_insert) - dynstr_free(&extended_row); - if (insert_pat_inited) - dynstr_free(&insert_pat); + dynstr_free(&extended_row); + dynstr_free(&dynamic_where); + dynstr_free(&insert_pat); if (defaults_argv) free_defaults(defaults_argv); mysql_library_end(); @@ -1609,8 +1627,6 @@ static void maybe_exit(int error) ignore_errors= 1; /* don't want to recurse, if something fails below */ if (opt_slave_data) do_start_slave_sql(mysql); - if (mysql) - mysql_close(mysql); free_resources(); exit(error); } @@ -1703,6 +1719,7 @@ static void dbDisconnect(char *host) { verbose_msg("-- Disconnecting from %s...\n", host ? host : "localhost"); mysql_close(mysql); + mysql= 0; } /* dbDisconnect */ @@ -2324,6 +2341,8 @@ static uint dump_events_for_db(char *db) (const char *) (query_str != NULL ? query_str : row[3]), (const char *) delimiter); + my_free(query_str); + restore_time_zone(sql_file, delimiter); restore_sql_mode(sql_file, delimiter); @@ -2408,7 +2427,6 @@ static uint dump_routines_for_db(char *db) char *routine_name; int i; FILE *sql_file= md_result_file; - MYSQL_RES *routine_res, *routine_list_res; MYSQL_ROW row, routine_list_row; char db_cl_name[MY_CS_NAME_SIZE]; @@ -2463,7 +2481,11 @@ static uint dump_routines_for_db(char *db) routine_type[i], routine_name); if (mysql_query_with_error_report(mysql, &routine_res, query_buff)) + { + mysql_free_result(routine_list_res); + routine_list_res= 0; DBUG_RETURN(1); + } while ((row= mysql_fetch_row(routine_res))) { @@ -2481,7 +2503,8 @@ static uint dump_routines_for_db(char *db) print_comment(sql_file, 1, "-- does %s have permissions on mysql.proc?\n\n", current_user); - maybe_die(EX_MYSQLERR,"%s has insufficent privileges to %s!", current_user, query_buff); + maybe_die(EX_MYSQLERR,"%s has insufficent privileges to %s!", + current_user, query_buff); } else if (strlen(row[2])) { @@ -2504,6 +2527,9 @@ static uint dump_routines_for_db(char *db) if (switch_db_collation(sql_file, db_name_buff, ";", db_cl_name, row[5], &db_cl_altered)) { + mysql_free_result(routine_res); + mysql_free_result(routine_list_res); + routine_res= routine_list_res= 0; DBUG_RETURN(1); } @@ -2548,18 +2574,26 @@ static uint dump_routines_for_db(char *db) if (db_cl_altered) { - if (restore_db_collation(sql_file, db_name_buff, ";", db_cl_name)) + if (restore_db_collation(sql_file, db_name_buff, ";", + db_cl_name)) + { + mysql_free_result(routine_res); + mysql_free_result(routine_list_res); + routine_res= routine_list_res= 0; DBUG_RETURN(1); + } } } } } /* end of routine printing */ mysql_free_result(routine_res); + routine_res= 0; } /* end of list of routines */ } mysql_free_result(routine_list_res); + routine_list_res= 0; } /* end of for i (0 .. 1) */ if (opt_xml) @@ -2681,13 +2715,20 @@ static uint get_table_structure(char *table, char *db, char *table_type, if (switch_character_set_results(mysql, "binary") || mysql_query_with_error_report(mysql, &result, buff) || switch_character_set_results(mysql, default_charset)) + { + my_free(order_by); + order_by= 0; DBUG_RETURN(0); + } if (path) { if (!(sql_file= open_sql_file_for_table(table, O_WRONLY))) + { + my_free(order_by); + order_by= 0; DBUG_RETURN(0); - + } write_header(sql_file, db); } @@ -3257,10 +3298,6 @@ static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs, continue; } - query_str= cover_definer_clause(row[2], strlen(row[2]), - C_STRING_WITH_LEN("50017"), - C_STRING_WITH_LEN("50003"), - C_STRING_WITH_LEN(" TRIGGER")); if (switch_db_collation(sql_file, db_name, ";", db_cl_name, row[5], &db_cl_altered)) DBUG_RETURN(TRUE); @@ -3272,12 +3309,18 @@ static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs, switch_sql_mode(sql_file, ";", row[1]); + query_str= cover_definer_clause(row[2], strlen(row[2]), + C_STRING_WITH_LEN("50017"), + C_STRING_WITH_LEN("50003"), + C_STRING_WITH_LEN(" TRIGGER")); fprintf(sql_file, "DELIMITER ;;\n" "/*!50003 %s */;;\n" "DELIMITER ;\n", (const char *) (query_str != NULL ? query_str : row[2])); + my_free(query_str); + restore_sql_mode(sql_file, ";"); restore_cs_variables(sql_file, ";"); @@ -3286,8 +3329,6 @@ static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs, if (restore_db_collation(sql_file, db_name, ";", db_cl_name)) DBUG_RETURN(TRUE); } - - my_free(query_str); } DBUG_RETURN(FALSE); @@ -3378,13 +3419,14 @@ static int dump_triggers_for_table(char *table_name, char *db_name) { MYSQL_RES *show_create_trigger_rs= mysql_store_result(mysql); - if (!show_create_trigger_rs || - dump_trigger(sql_file, show_create_trigger_rs, db_name, db_cl_name)) - goto done; - + int error= (!show_create_trigger_rs || + dump_trigger(sql_file, show_create_trigger_rs, db_name, + db_cl_name)); mysql_free_result(show_create_trigger_rs); + if (error) + goto done; } - + } if (opt_xml) @@ -3631,12 +3673,14 @@ static void dump_table(char *table, char *db) { dynstr_append_checked(&query_string, " ORDER BY "); dynstr_append_checked(&query_string, order_by); + my_free(order_by); + order_by= 0; } if (mysql_real_query(mysql, query_string.str, query_string.length)) { - DB_error(mysql, "when executing 'SELECT INTO OUTFILE'"); dynstr_free(&query_string); + DB_error(mysql, "when executing 'SELECT INTO OUTFILE'"); DBUG_VOID_RETURN; } } @@ -3662,6 +3706,8 @@ static void dump_table(char *table, char *db) dynstr_append_checked(&query_string, " ORDER BY "); dynstr_append_checked(&query_string, order_by); + my_free(order_by); + order_by= 0; } if (!opt_xml && !opt_compact) @@ -3671,6 +3717,7 @@ static void dump_table(char *table, char *db) } if (mysql_query_with_error_report(mysql, 0, query_string.str)) { + dynstr_free(&query_string); DB_error(mysql, "when retrieving data from server"); goto err; } @@ -3680,6 +3727,7 @@ static void dump_table(char *table, char *db) res=mysql_store_result(mysql); if (!res) { + dynstr_free(&query_string); DB_error(mysql, "when retrieving data from server"); goto err; } @@ -3995,23 +4043,22 @@ err: static char *getTableName(int reset) { - static MYSQL_RES *res= NULL; - MYSQL_ROW row; + MYSQL_ROW row; - if (!res) + if (!get_table_name_result) { - if (!(res= mysql_list_tables(mysql,NullS))) + if (!(get_table_name_result= mysql_list_tables(mysql,NullS))) return(NULL); } - if ((row= mysql_fetch_row(res))) + if ((row= mysql_fetch_row(get_table_name_result))) return((char*) row[0]); if (reset) - mysql_data_seek(res,0); /* We want to read again */ + mysql_data_seek(get_table_name_result,0); /* We want to read again */ else { - mysql_free_result(res); - res= NULL; + mysql_free_result(get_table_name_result); + get_table_name_result= NULL; } return(NULL); } /* getTableName */ @@ -4028,46 +4075,44 @@ static int dump_all_tablespaces() static int dump_tablespaces_for_tables(char *db, char **table_names, int tables) { - DYNAMIC_STRING where; int r; int i; char name_buff[NAME_LEN*2+3]; mysql_real_escape_string(mysql, name_buff, db, strlen(db)); - init_dynamic_string_checked(&where, " AND TABLESPACE_NAME IN (" + init_dynamic_string_checked(&dynamic_where, " AND TABLESPACE_NAME IN (" "SELECT DISTINCT TABLESPACE_NAME FROM" " INFORMATION_SCHEMA.PARTITIONS" " WHERE" " TABLE_SCHEMA='", 256, 1024); - dynstr_append_checked(&where, name_buff); - dynstr_append_checked(&where, "' AND TABLE_NAME IN ("); + dynstr_append_checked(&dynamic_where, name_buff); + dynstr_append_checked(&dynamic_where, "' AND TABLE_NAME IN ("); for (i=0 ; i<tables ; i++) { mysql_real_escape_string(mysql, name_buff, table_names[i], strlen(table_names[i])); - dynstr_append_checked(&where, "'"); - dynstr_append_checked(&where, name_buff); - dynstr_append_checked(&where, "',"); + dynstr_append_checked(&dynamic_where, "'"); + dynstr_append_checked(&dynamic_where, name_buff); + dynstr_append_checked(&dynamic_where, "',"); } - dynstr_trunc(&where, 1); - dynstr_append_checked(&where,"))"); + dynstr_trunc(&dynamic_where, 1); + dynstr_append_checked(&dynamic_where,"))"); - DBUG_PRINT("info",("Dump TS for Tables where: %s",where.str)); - r= dump_tablespaces(where.str); - dynstr_free(&where); + DBUG_PRINT("info",("Dump TS for Tables where: %s",dynamic_where.str)); + r= dump_tablespaces(dynamic_where.str); + dynstr_free(&dynamic_where); return r; } static int dump_tablespaces_for_databases(char** databases) { - DYNAMIC_STRING where; int r; int i; - init_dynamic_string_checked(&where, " AND TABLESPACE_NAME IN (" + init_dynamic_string_checked(&dynamic_where, " AND TABLESPACE_NAME IN (" "SELECT DISTINCT TABLESPACE_NAME FROM" " INFORMATION_SCHEMA.PARTITIONS" " WHERE" @@ -4078,16 +4123,16 @@ static int dump_tablespaces_for_databases(char** databases) char db_name_buff[NAME_LEN*2+3]; mysql_real_escape_string(mysql, db_name_buff, databases[i], strlen(databases[i])); - dynstr_append_checked(&where, "'"); - dynstr_append_checked(&where, db_name_buff); - dynstr_append_checked(&where, "',"); + dynstr_append_checked(&dynamic_where, "'"); + dynstr_append_checked(&dynamic_where, db_name_buff); + dynstr_append_checked(&dynamic_where, "',"); } - dynstr_trunc(&where, 1); - dynstr_append_checked(&where,"))"); + dynstr_trunc(&dynamic_where, 1); + dynstr_append_checked(&dynamic_where,"))"); - DBUG_PRINT("info",("Dump TS for DBs where: %s",where.str)); - r= dump_tablespaces(where.str); - dynstr_free(&where); + DBUG_PRINT("info",("Dump TS for DBs where: %s",dynamic_where.str)); + r= dump_tablespaces(dynamic_where.str); + dynstr_free(&dynamic_where); return r; } @@ -4495,9 +4540,12 @@ static int dump_all_tables_in_db(char *database) } } if (numrows && mysql_real_query(mysql, query.str, query.length-1)) + { + dynstr_free(&query); DB_error(mysql, "when using LOCK TABLES"); - /* We shall continue here, if --force was given */ - dynstr_free(&query); + /* We shall continue here, if --force was given */ + } + dynstr_free(&query); /* Safe to call twice */ } if (flush_logs) { @@ -4511,7 +4559,9 @@ static int dump_all_tables_in_db(char *database) { verbose_msg("-- Setting savepoint...\n"); if (mysql_query_with_error_report(mysql, 0, "SAVEPOINT sp")) + { DBUG_RETURN(1); + } } while ((table= getTableName(0))) { @@ -4746,22 +4796,22 @@ static int dump_selected_tables(char *db, char **table_names, int tables) { char table_buff[NAME_LEN*2+3]; DYNAMIC_STRING lock_tables_query; - MEM_ROOT root; char **dump_tables, **pos, **end; DBUG_ENTER("dump_selected_tables"); if (init_dumping(db, init_dumping_tables)) DBUG_RETURN(1); - init_alloc_root(&root, 8192, 0, MYF(0)); - if (!(dump_tables= pos= (char**) alloc_root(&root, tables * sizeof(char *)))) + init_alloc_root(&glob_root, 8192, 0, MYF(0)); + if (!(dump_tables= pos= (char**) alloc_root(&glob_root, + tables * sizeof(char *)))) die(EX_EOM, "alloc_root failure."); init_dynamic_string_checked(&lock_tables_query, "LOCK TABLES ", 256, 1024); for (; tables > 0 ; tables-- , table_names++) { /* the table name passed on commandline may be wrong case */ - if ((*pos= get_actual_table_name(*table_names, &root))) + if ((*pos= get_actual_table_name(*table_names, &glob_root))) { /* Add found table name to lock_tables_query */ if (lock_tables) @@ -4776,7 +4826,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) if (!ignore_errors) { dynstr_free(&lock_tables_query); - free_root(&root, MYF(0)); + free_root(&glob_root, MYF(0)); } maybe_die(EX_ILLEGAL_TABLE, "Couldn't find table: \"%s\"", *table_names); /* We shall countinue here, if --force was given */ @@ -4797,7 +4847,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) if (!ignore_errors) { dynstr_free(&lock_tables_query); - free_root(&root, MYF(0)); + free_root(&glob_root, MYF(0)); } DB_error(mysql, "when doing LOCK TABLES"); /* We shall countinue here, if --force was given */ @@ -4809,7 +4859,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) if (mysql_refresh(mysql, REFRESH_LOG)) { if (!ignore_errors) - free_root(&root, MYF(0)); + free_root(&glob_root, MYF(0)); DB_error(mysql, "when doing refresh"); } /* We shall countinue here, if --force was given */ @@ -4823,7 +4873,10 @@ static int dump_selected_tables(char *db, char **table_names, int tables) { verbose_msg("-- Setting savepoint...\n"); if (mysql_query_with_error_report(mysql, 0, "SAVEPOINT sp")) + { + free_root(&glob_root, MYF(0)); DBUG_RETURN(1); + } } /* Dump each selected table */ @@ -4838,6 +4891,8 @@ static int dump_selected_tables(char *db, char **table_names, int tables) { if (path) my_fclose(md_result_file, MYF(MY_WME)); + if (!ignore_errors) + free_root(&glob_root, MYF(0)); maybe_exit(EX_MYSQLERR); } } @@ -4856,7 +4911,11 @@ static int dump_selected_tables(char *db, char **table_names, int tables) { verbose_msg("-- Rolling back to savepoint sp...\n"); if (mysql_query_with_error_report(mysql, 0, "ROLLBACK TO SAVEPOINT sp")) + { + if (!ignore_errors) + free_root(&glob_root, MYF(0)); maybe_exit(EX_MYSQLERR); + } } } @@ -4864,8 +4923,10 @@ static int dump_selected_tables(char *db, char **table_names, int tables) { verbose_msg("-- Releasing savepoint...\n"); if (mysql_query_with_error_report(mysql, 0, "RELEASE SAVEPOINT sp")) + { + free_root(&glob_root, MYF(0)); DBUG_RETURN(1); - + } } /* Dump each selected view */ @@ -4885,9 +4946,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) DBUG_PRINT("info", ("Dumping routines for database %s", db)); dump_routines_for_db(db); } - free_root(&root, MYF(0)); - my_free(order_by); - order_by= 0; + free_root(&glob_root, MYF(0)); if (opt_xml) { fputs("</database>\n", md_result_file); diff --git a/client/mysqlshow.c b/client/mysqlshow.c index d1ffb6a4876..48643452b53 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -68,10 +68,12 @@ int main(int argc, char **argv) my_bool first_argument_uses_wildcards=0; char *wild; MYSQL mysql; + static char **defaults_argv; MY_INIT(argv[0]); sf_leaking_memory=1; /* don't report memory leaks on early exits */ if (load_defaults("my",load_default_groups,&argc,&argv)) exit(1); + defaults_argv=argv; get_options(&argc,&argv); @@ -150,7 +152,8 @@ int main(int argc, char **argv) 0))) { fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql)); - exit(1); + error= 1; + goto error; } mysql.reconnect= 1; @@ -169,11 +172,14 @@ int main(int argc, char **argv) error=list_fields(&mysql,argv[0],argv[1],wild); break; } +error: mysql_close(&mysql); /* Close & free connection */ my_free(opt_password); + mysql_server_end(); #ifdef HAVE_SMEM my_free(shared_memory_base_name); #endif + free_defaults(defaults_argv); my_end(my_end_arg); exit(error ? 1 : 0); return 0; /* No compiler warnings */ diff --git a/client/mysqlslap.c b/client/mysqlslap.c index f12ea4c2086..29919f3028d 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -168,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; @@ -372,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); @@ -417,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); @@ -585,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}, @@ -782,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 */ @@ -1863,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) @@ -1995,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(); |