797
static void combine_queries(vector<string> queries)
799
user_supplied_query.erase();
800
for (vector<string>::iterator it= queries.begin();
804
user_supplied_query.append(*it);
805
user_supplied_query.append(delimiter);
809
* commandline_options is the set of all options that can only be called via the command line.
811
* client_options is the set of all options that can be defined via both command line and via
812
* the configuration file client.cnf
814
* slap_options is the set of all drizzleslap specific options which behave in a manner
815
* similar to that of client_options. It's configuration file is drizzleslap.cnf
817
* long_options is the union of commandline_options, slap_options and client_options.
819
* There are two configuration files per set of options, one which is defined by the user
820
* which is found at either $XDG_CONFIG_HOME/drizzle or ~/.config/drizzle directory and the other which
821
* is the system configuration file which is found in the SYSCONFDIR/drizzle directory.
823
* The system configuration file is over ridden by the user's configuration file which
824
* in turn is over ridden by the command line.
826
824
int main(int argc, char **argv)
828
char *password= NULL;
831
po::options_description commandline_options("Options used only in command line");
832
commandline_options.add_options()
833
("help,?","Display this help and exit")
834
("info,i","Gives information and exit")
835
("burnin",po::value<bool>(&opt_burnin)->default_value(false)->zero_tokens(),
836
"Run full test case in infinite loop")
837
("ignore-sql-errors", po::value<bool>(&opt_ignore_sql_errors)->default_value(false)->zero_tokens(),
838
"Ignore SQL errors in query run")
839
("create-schema",po::value<string>(&create_schema_string)->default_value("drizzleslap"),
840
"Schema to run tests in")
841
("create",po::value<string>(&create_string)->default_value(""),
842
"File or string to use to create tables")
843
("detach",po::value<uint32_t>(&detach_rate)->default_value(0),
844
"Detach (close and re open) connections after X number of requests")
845
("iterations,i",po::value<uint32_t>(&iterations)->default_value(1),
846
"Number of times to run the tests")
847
("label",po::value<string>(&opt_label)->default_value(""),
848
"Label to use for print and csv")
849
("number-blob-cols",po::value<string>(&num_blob_cols_opt)->default_value(""),
850
"Number of BLOB columns to create table with if specifying --auto-generate-sql. Example --number-blob-cols=3:1024/2048 would give you 3 blobs with a random size between 1024 and 2048. ")
851
("number-char-cols,x",po::value<string>(&num_char_cols_opt)->default_value(""),
852
"Number of VARCHAR columns to create in table if specifying --auto-generate-sql.")
853
("number-int-cols,y",po::value<string>(&num_int_cols_opt)->default_value(""),
854
"Number of INT columns to create in table if specifying --auto-generate-sql.")
855
("number-of-queries",
856
po::value<uint64_t>(&num_of_query)->default_value(0),
857
"Limit each client to this number of queries(this is not exact)")
858
("only-print",po::value<bool>(&opt_only_print)->default_value(false)->zero_tokens(),
859
"This causes drizzleslap to not connect to the database instead print out what it would have done instead")
860
("post-query", po::value<string>(&user_supplied_post_statements)->default_value(""),
861
"Query to run or file containing query to execute after tests have completed.")
862
("post-system",po::value<string>(&post_system)->default_value(""),
863
"system() string to execute after tests have completed")
865
po::value<string>(&user_supplied_pre_statements)->default_value(""),
866
"Query to run or file containing query to execute before running tests.")
867
("pre-system",po::value<string>(&pre_system)->default_value(""),
868
"system() string to execute before running tests.")
869
("query,q",po::value<vector<string> >(&user_supplied_queries)->composing()->notifier(&combine_queries),
870
"Query to run or file containing query")
871
("verbose,v", po::value<string>(&opt_verbose)->default_value("v"), "Increase verbosity level by one.")
872
("version,V","Output version information and exit")
875
po::options_description slap_options("Options specific to drizzleslap");
876
slap_options.add_options()
877
("auto-generate-sql-select-columns",
878
po::value<string>(&auto_generate_selected_columns_opt)->default_value(""),
879
"Provide a string to use for the select fields used in auto tests")
880
("auto-generate-sql,a",po::value<bool>(&auto_generate_sql)->default_value(false)->zero_tokens(),
881
"Generate SQL where not supplied by file or command line")
882
("auto-generate-sql-add-autoincrement",
883
po::value<bool>(&auto_generate_sql_autoincrement)->default_value(false)->zero_tokens(),
884
"Add an AUTO_INCREMENT column to auto-generated tables")
885
("auto-generate-sql-execute-number",
886
po::value<uint64_t>(&auto_actual_queries)->default_value(0),
887
"See this number and generate a set of queries to run")
888
("auto-generate-sql-guid-primary",
889
po::value<bool>(&auto_generate_sql_guid_primary)->default_value(false)->zero_tokens(),
890
"Add GUID based primary keys to auto-generated tables")
891
("auto-generate-sql-load-type",
892
po::value<string>(&opt_auto_generate_sql_type)->default_value("mixed"),
893
"Specify test load type: mixed, update, write, key or read; default is mixed")
894
("auto-generate-sql-secondary-indexes",
895
po::value<uint32_t>(&auto_generate_sql_secondary_indexes)->default_value(0),
896
"Number of secondary indexes to add to auto-generated tables")
897
("auto-generated-sql-unique-query-number",
898
po::value<uint64_t>(&auto_generate_sql_unique_query_number)->default_value(10),
899
"Number of unique queries to generate for automatic tests")
900
("auto-generate-sql-unique-write-number",
901
po::value<uint64_t>(&auto_generate_sql_unique_write_number)->default_value(10),
902
"Number of unique queries to generate for auto-generate-sql-write-number")
903
("auto-generate-sql-write-number",
904
po::value<uint64_t>(&auto_generate_sql_number)->default_value(100),
905
"Number of row inserts to perform for each thread (default is 100).")
906
("commit",po::value<uint32_t>(&commit_rate)->default_value(0),
907
"Commit records every X number of statements")
908
("concurrency,c",po::value<string>(&concurrency_str)->default_value(""),
909
"Number of clients to simulate for query to run")
910
("csv",po::value<std::string>(&opt_csv_str)->default_value(""),
911
"Generate CSV output to named file or to stdout if no file is name.")
912
("delayed-start",po::value<uint32_t>(&opt_delayed_start)->default_value(0),
913
"Delay the startup of threads by a random number of microsends (the maximum of the delay")
914
("delimiter,F",po::value<string>(&delimiter)->default_value("\n"),
915
"Delimiter to use in SQL statements supplied in file or command line")
916
("engine ,e",po::value<string>(&default_engine)->default_value(""),
917
"Storage engien to use for creating the table")
919
po::value<uint32_t>(&opt_set_random_seed)->default_value(0),
920
"Seed for random number generator (srandom(3)) ")
921
("silent,s",po::value<bool>(&opt_silent)->default_value(false)->zero_tokens(),
922
"Run program in silent mode - no output. ")
923
("timer-length",po::value<uint32_t>(&opt_timer_length)->default_value(0),
924
"Require drizzleslap to run each specific test a certain amount of time in seconds")
927
po::options_description client_options("Options specific to the client");
928
client_options.add_options()
929
("host,h",po::value<string>(&host)->default_value("localhost"),"Connect to the host")
930
("password,P",po::value<char *>(&password),
931
"Password to use when connecting to server. If password is not given it's asked from the tty")
932
("port,p",po::value<uint32_t>(), "Port number to use for connection")
933
("protocol",po::value<string>(&opt_protocol)->default_value("mysql"),
934
"The protocol of connection (mysql or drizzle).")
935
("user,u",po::value<string>(&user)->default_value(""),
936
"User for login if not current user")
939
po::options_description long_options("Allowed Options");
940
long_options.add(commandline_options).add(slap_options).add(client_options);
942
std::string system_config_dir_slap(SYSCONFDIR);
943
system_config_dir_slap.append("/drizzle/drizzleslap.cnf");
945
std::string system_config_dir_client(SYSCONFDIR);
946
system_config_dir_client.append("/drizzle/client.cnf");
948
std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config"));
950
uint64_t temp_drizzle_port= 0;
955
po::variables_map vm;
956
po::store(po::command_line_parser(argc, argv).options(long_options).
957
extra_parser(parse_password_arg).run(), vm);
959
std::string user_config_dir_slap(user_config_dir);
960
user_config_dir_slap.append("/drizzle/drizzleslap.cnf");
962
std::string user_config_dir_client(user_config_dir);
963
user_config_dir_client.append("/drizzle/client.cnf");
965
ifstream user_slap_ifs(user_config_dir_slap.c_str());
966
po::store(parse_config_file(user_slap_ifs, slap_options), vm);
968
ifstream user_client_ifs(user_config_dir_client.c_str());
969
po::store(parse_config_file(user_client_ifs, client_options), vm);
971
ifstream system_slap_ifs(system_config_dir_slap.c_str());
972
store(parse_config_file(system_slap_ifs, slap_options), vm);
974
ifstream system_client_ifs(system_config_dir_client.c_str());
975
store(parse_config_file(system_client_ifs, client_options), vm);
979
if (process_options())
982
if ( vm.count("help") || vm.count("info"))
984
printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION,
985
drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU);
986
puts("Copyright (C) 2008 Sun Microsystems");
987
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\
988
\nand you are welcome to modify and redistribute it under the GPL \
990
puts("Run a query multiple times against the server\n");
991
cout << long_options << endl;
995
if (vm.count("protocol"))
997
std::transform(opt_protocol.begin(), opt_protocol.end(),
998
opt_protocol.begin(), ::tolower);
1000
if (not opt_protocol.compare("mysql"))
1001
use_drizzle_protocol=false;
1002
else if (not opt_protocol.compare("drizzle"))
1003
use_drizzle_protocol=true;
1006
cout << _("Error: Unknown protocol") << " '" << opt_protocol << "'" << endl;
1010
if (vm.count("port"))
1012
temp_drizzle_port= vm["port"].as<uint32_t>();
1014
if ((temp_drizzle_port == 0) || (temp_drizzle_port > 65535))
1016
fprintf(stderr, _("Value supplied for port is not valid.\n"));
1021
opt_drizzle_port= (uint32_t) temp_drizzle_port;
1025
if ( vm.count("password") )
1027
if (!opt_password.empty())
1028
opt_password.erase();
1029
if (password == PASSWORD_SENTINEL)
1035
opt_password= password;
1036
tty_password= false;
1046
if ( vm.count("version") )
1048
printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION,
1049
drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU);
1053
/* Seed the random number generator if we will be using it. */
1054
if (auto_generate_sql)
1056
if (opt_set_random_seed == 0)
1057
opt_set_random_seed= (unsigned int)time(NULL);
1058
srandom(opt_set_random_seed);
1061
/* globals? Yes, so we only have to run strlen once */
1062
delimiter_length= delimiter.length();
1064
slap_connect(&con, false);
1066
pthread_mutex_init(&counter_mutex, NULL);
1067
pthread_cond_init(&count_threshhold, NULL);
1068
pthread_mutex_init(&sleeper_mutex, NULL);
1069
pthread_cond_init(&sleep_threshhold, NULL);
1070
pthread_mutex_init(&timer_alarm_mutex, NULL);
1071
pthread_cond_init(&timer_alarm_threshold, NULL);
1074
/* Main iterations loop */
834
internal::load_defaults("drizzle",load_default_groups,&argc,&argv);
836
if (get_options(&argc,&argv))
838
internal::free_defaults(defaults_argv);
843
/* Seed the random number generator if we will be using it. */
844
if (auto_generate_sql)
846
if (opt_set_random_seed == 0)
847
opt_set_random_seed= (unsigned int)time(NULL);
848
srandom(opt_set_random_seed);
851
/* globals? Yes, so we only have to run strlen once */
852
delimiter_length= strlen(delimiter);
856
fprintf(stderr,"%s: Too many arguments\n",internal::my_progname);
857
internal::free_defaults(defaults_argv);
862
slap_connect(&con, false);
864
pthread_mutex_init(&counter_mutex, NULL);
865
pthread_cond_init(&count_threshhold, NULL);
866
pthread_mutex_init(&sleeper_mutex, NULL);
867
pthread_cond_init(&sleep_threshhold, NULL);
868
pthread_mutex_init(&timer_alarm_mutex, NULL);
869
pthread_cond_init(&timer_alarm_threshold, NULL);
872
/* Main iterations loop */
1076
eptr= engine_options;
1079
/* For the final stage we run whatever queries we were asked to run */
1083
printf("Starting Concurrency Test\n");
1085
if (concurrency.size())
1087
for (current= &concurrency[0]; current && *current; current++)
1088
concurrency_loop(&con, *current, eptr);
1092
uint32_t infinite= 1;
1094
concurrency_loop(&con, infinite, eptr);
1100
drop_schema(&con, create_schema_string.c_str());
1102
} while (eptr ? (eptr= eptr->getNext()) : 0);
1107
pthread_mutex_destroy(&counter_mutex);
1108
pthread_cond_destroy(&count_threshhold);
1109
pthread_mutex_destroy(&sleeper_mutex);
1110
pthread_cond_destroy(&sleep_threshhold);
1111
pthread_mutex_destroy(&timer_alarm_mutex);
1112
pthread_cond_destroy(&timer_alarm_threshold);
1116
/* now free all the strings we created */
1117
if (!opt_password.empty())
1118
opt_password.erase();
1120
concurrency.clear();
1122
statement_cleanup(create_statements);
1123
for (uint32_t x= 0; x < query_statements_count; x++)
1124
statement_cleanup(query_statements[x]);
1125
query_statements.clear();
1126
statement_cleanup(pre_statements);
1127
statement_cleanup(post_statements);
1128
option_cleanup(engine_options);
1129
option_cleanup(query_options);
874
eptr= engine_options;
877
/* For the final stage we run whatever queries we were asked to run */
881
printf("Starting Concurrency Test\n");
885
for (current= concurrency; current && *current; current++)
886
concurrency_loop(&con, *current, eptr);
890
uint32_t infinite= 1;
892
concurrency_loop(&con, infinite, eptr);
898
drop_schema(&con, create_schema_string);
900
} while (eptr ? (eptr= eptr->getNext()) : 0);
905
pthread_mutex_destroy(&counter_mutex);
906
pthread_cond_destroy(&count_threshhold);
907
pthread_mutex_destroy(&sleeper_mutex);
908
pthread_cond_destroy(&sleep_threshhold);
909
pthread_mutex_destroy(&timer_alarm_mutex);
910
pthread_cond_destroy(&timer_alarm_threshold);
914
/* now free all the strings we created */
920
statement_cleanup(create_statements);
921
for (x= 0; x < query_statements_count; x++)
922
statement_cleanup(query_statements[x]);
923
free(query_statements);
924
statement_cleanup(pre_statements);
925
statement_cleanup(post_statements);
926
option_cleanup(engine_options);
927
option_cleanup(query_options);
1131
929
#ifdef HAVE_SMEM
1132
if (shared_memory_base_name)
1133
free(shared_memory_base_name);
930
if (shared_memory_base_name)
931
free(shared_memory_base_name);
1138
catch(std::exception &err)
1140
cerr<<"Error:"<<err.what()<<endl;
1143
if (csv_file != fileno(stdout))
933
internal::free_defaults(defaults_argv);
1149
939
void concurrency_loop(drizzle_con_st *con, uint32_t current, OptionString *eptr)
1151
942
Stats *head_sptr;
1153
944
Conclusions conclusion;
1154
945
uint64_t client_limit;
1156
head_sptr= new Stats[iterations];
947
head_sptr= (Stats *)malloc(sizeof(Stats) * iterations);
1157
948
if (head_sptr == NULL)
1159
950
fprintf(stderr,"Error allocating memory in concurrency_loop\n");
953
memset(head_sptr, 0, sizeof(Stats) * iterations);
955
memset(&conclusion, 0, sizeof(Conclusions));
1163
957
if (auto_actual_queries)
1164
958
client_limit= auto_actual_queries;
1232
1025
if (!opt_silent)
1233
1026
print_conclusions(&conclusion);
1234
if (!opt_csv_str.empty())
1235
1028
print_conclusions_csv(&conclusion);
1237
delete [] head_sptr;
1035
static struct option my_long_options[] =
1037
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG,
1039
{"auto-generate-sql-select-columns", OPT_SLAP_AUTO_GENERATE_SELECT_COLUMNS,
1040
"Provide a string to use for the select fields used in auto tests.",
1041
(char**) &auto_generate_selected_columns_opt,
1042
(char**) &auto_generate_selected_columns_opt,
1043
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1044
{"auto-generate-sql", 'a',
1045
"Generate SQL where not supplied by file or command line.",
1046
(char**) &auto_generate_sql, (char**) &auto_generate_sql,
1047
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1048
{"auto-generate-sql-add-autoincrement", OPT_SLAP_AUTO_GENERATE_ADD_AUTO,
1049
"Add an AUTO_INCREMENT column to auto-generated tables.",
1050
(char**) &auto_generate_sql_autoincrement,
1051
(char**) &auto_generate_sql_autoincrement,
1052
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1053
{"auto-generate-sql-execute-number", OPT_SLAP_AUTO_GENERATE_EXECUTE_QUERIES,
1054
"Set this number to generate a set number of queries to run.",
1055
(char**) &auto_actual_queries, (char**) &auto_actual_queries,
1056
0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1057
{"auto-generate-sql-guid-primary", OPT_SLAP_AUTO_GENERATE_GUID_PRIMARY,
1058
"Add GUID based primary keys to auto-generated tables.",
1059
(char**) &auto_generate_sql_guid_primary,
1060
(char**) &auto_generate_sql_guid_primary,
1061
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1062
{"auto-generate-sql-load-type", OPT_SLAP_AUTO_GENERATE_SQL_LOAD_TYPE,
1063
"Specify test load type: mixed, update, write, key, or read; default is mixed.",
1064
(char**) &opt_auto_generate_sql_type, (char**) &opt_auto_generate_sql_type,
1065
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1066
{"auto-generate-sql-secondary-indexes",
1067
OPT_SLAP_AUTO_GENERATE_SECONDARY_INDEXES,
1068
"Number of secondary indexes to add to auto-generated tables.",
1069
(char**) &auto_generate_sql_secondary_indexes,
1070
(char**) &auto_generate_sql_secondary_indexes, 0,
1071
GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1072
{"auto-generate-sql-unique-query-number",
1073
OPT_SLAP_AUTO_GENERATE_UNIQUE_QUERY_NUM,
1074
"Number of unique queries to generate for automatic tests.",
1075
(char**) &auto_generate_sql_unique_query_number,
1076
(char**) &auto_generate_sql_unique_query_number,
1077
0, GET_ULL, REQUIRED_ARG, 10, 0, 0, 0, 0, 0},
1078
{"auto-generate-sql-unique-write-number",
1079
OPT_SLAP_AUTO_GENERATE_UNIQUE_WRITE_NUM,
1080
"Number of unique queries to generate for auto-generate-sql-write-number.",
1081
(char**) &auto_generate_sql_unique_write_number,
1082
(char**) &auto_generate_sql_unique_write_number,
1083
0, GET_ULL, REQUIRED_ARG, 10, 0, 0, 0, 0, 0},
1084
{"auto-generate-sql-write-number", OPT_SLAP_AUTO_GENERATE_WRITE_NUM,
1085
"Number of row inserts to perform for each thread (default is 100).",
1086
(char**) &auto_generate_sql_number, (char**) &auto_generate_sql_number,
1087
0, GET_ULL, REQUIRED_ARG, 100, 0, 0, 0, 0, 0},
1088
{"burnin", OPT_SLAP_BURNIN, "Run full test case in infinite loop.",
1089
(char**) &opt_burnin, (char**) &opt_burnin, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1091
{"ignore-sql-errors", OPT_SLAP_IGNORE_SQL_ERRORS,
1092
"Ignore SQL erros in query run.",
1093
(char**) &opt_ignore_sql_errors,
1094
(char**) &opt_ignore_sql_errors,
1095
0, GET_BOOL, NO_ARG, 0, 0, 0,
1097
{"commit", OPT_SLAP_COMMIT, "Commit records every X number of statements.",
1098
(char**) &commit_rate, (char**) &commit_rate, 0, GET_UINT, REQUIRED_ARG,
1100
{"concurrency", 'c', "Number of clients to simulate for query to run.",
1101
(char**) &concurrency_str, (char**) &concurrency_str, 0, GET_STR,
1102
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1103
{"create", OPT_SLAP_CREATE_STRING, "File or string to use create tables.",
1104
(char**) &create_string, (char**) &create_string, 0, GET_STR, REQUIRED_ARG,
1106
{"create-schema", OPT_CREATE_SLAP_SCHEMA, "Schema to run tests in.",
1107
(char**) &create_schema_string, (char**) &create_schema_string, 0, GET_STR,
1108
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1109
{"csv", OPT_SLAP_CSV,
1110
"Generate CSV output to named file or to stdout if no file is named.",
1111
(char**) &opt_csv_str, (char**) &opt_csv_str, 0, GET_STR,
1112
OPT_ARG, 0, 0, 0, 0, 0, 0},
1113
{"delayed-start", OPT_SLAP_DELAYED_START,
1114
"Delay the startup of threads by a random number of microsends (the maximum of the delay)",
1115
(char**) &opt_delayed_start, (char**) &opt_delayed_start, 0, GET_UINT,
1116
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1118
"Delimiter to use in SQL statements supplied in file or command line.",
1119
(char**) &delimiter, (char**) &delimiter, 0, GET_STR, REQUIRED_ARG,
1121
{"detach", OPT_SLAP_DETACH,
1122
"Detach (close and reopen) connections after X number of requests.",
1123
(char**) &detach_rate, (char**) &detach_rate, 0, GET_UINT, REQUIRED_ARG,
1125
{"engine", 'e', "Storage engine to use for creating the table.",
1126
(char**) &default_engine, (char**) &default_engine, 0,
1127
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1128
{"host", 'h', "Connect to host.", (char**) &host, (char**) &host, 0, GET_STR,
1129
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1130
{"iterations", 'i', "Number of times to run the tests.", (char**) &iterations,
1131
(char**) &iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0},
1132
{"label", OPT_SLAP_LABEL, "Label to use for print and csv output.",
1133
(char**) &opt_label, (char**) &opt_label, 0,
1134
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1135
{"mysql", 'm', N_("Use MySQL Protocol."),
1136
(char**) &opt_mysql, (char**) &opt_mysql, 0, GET_BOOL, NO_ARG, 1, 0, 0,
1138
{"number-blob-cols", OPT_SLAP_BLOB_COL,
1139
"Number of BLOB columns to create table with if specifying --auto-generate-sql. Example --number-blob-cols=3:1024/2048 would give you 3 blobs with a random size between 1024 and 2048. ",
1140
(char**) &num_blob_cols_opt, (char**) &num_blob_cols_opt, 0, GET_STR, REQUIRED_ARG,
1142
{"number-char-cols", 'x',
1143
"Number of VARCHAR columns to create in table if specifying --auto-generate-sql.",
1144
(char**) &num_char_cols_opt, (char**) &num_char_cols_opt, 0, GET_STR, REQUIRED_ARG,
1146
{"number-int-cols", 'y',
1147
"Number of INT columns to create in table if specifying --auto-generate-sql.",
1148
(char**) &num_int_cols_opt, (char**) &num_int_cols_opt, 0, GET_STR, REQUIRED_ARG,
1150
{"number-of-queries", OPT_DRIZZLE_NUMBER_OF_QUERY,
1151
"Limit each client to this number of queries (this is not exact).",
1152
(char**) &num_of_query, (char**) &num_of_query, 0,
1153
GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1154
{"only-print", OPT_DRIZZLE_ONLY_PRINT,
1155
"This causes drizzleslap to not connect to the databases, but instead print "
1156
"out what it would have done instead.",
1157
(char**) &opt_only_print, (char**) &opt_only_print, 0, GET_BOOL, NO_ARG,
1160
"Password to use when connecting to server. If password is not given it's "
1161
"asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1162
{"port", 'p', "Port number to use for connection.",
1163
0, 0, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1164
{"post-query", OPT_SLAP_POST_QUERY,
1165
"Query to run or file containing query to execute after tests have completed.",
1166
(char**) &user_supplied_post_statements,
1167
(char**) &user_supplied_post_statements,
1168
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1169
{"post-system", OPT_SLAP_POST_SYSTEM,
1170
"system() string to execute after tests have completed.",
1171
(char**) &post_system,
1172
(char**) &post_system,
1173
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1174
{"pre-query", OPT_SLAP_PRE_QUERY,
1175
"Query to run or file containing query to execute before running tests.",
1176
(char**) &user_supplied_pre_statements,
1177
(char**) &user_supplied_pre_statements,
1178
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1179
{"pre-system", OPT_SLAP_PRE_SYSTEM,
1180
"system() string to execute before running tests.",
1181
(char**) &pre_system,
1182
(char**) &pre_system,
1183
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1184
{"protocol", OPT_DRIZZLE_PROTOCOL,
1185
"The protocol of connection (tcp,socket,pipe,memory).",
1186
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1187
{"query", 'q', "Query to run or file containing query to run.",
1188
(char**) &user_supplied_query, (char**) &user_supplied_query,
1189
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1190
{"set-random-seed", OPT_SLAP_SET_RANDOM_SEED,
1191
"Seed for random number generator (srandom(3))",
1192
(char**)&opt_set_random_seed,
1193
(char**)&opt_set_random_seed,0,
1194
GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1195
{"silent", 's', "Run program in silent mode - no output.",
1196
(char**) &opt_silent, (char**) &opt_silent, 0, GET_BOOL, NO_ARG,
1198
{"timer-length", OPT_SLAP_TIMER_LENGTH,
1199
"Require drizzleslap to run each specific test a certain amount of time in seconds.",
1200
(char**) &opt_timer_length, (char**) &opt_timer_length, 0, GET_UINT,
1201
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1202
{"user", 'u', "User for login if not current user.", (char**) &user,
1203
(char**) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1205
"More verbose output; you can use this multiple times to get even more "
1206
"verbose output.", (char**) &verbose, (char**) &verbose, 0,
1207
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1208
{"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
1209
NO_ARG, 0, 0, 0, 0, 0, 0},
1210
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
1214
static void print_version(void)
1216
printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION,
1217
drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU);
1221
static void usage(void)
1224
puts("Copyright (C) 2008 Sun Microsystems");
1225
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\
1226
\nand you are welcome to modify and redistribute it under the GPL \
1228
puts("Run a query multiple times against the server\n");
1229
printf("Usage: %s [OPTIONS]\n",internal::my_progname);
1230
internal::print_defaults("drizzle",load_default_groups);
1231
my_print_help(my_long_options);
1234
static int get_one_option(int optid, const struct option *, char *argument)
1236
char *endchar= NULL;
1237
uint64_t temp_drizzle_port= 0;
1244
temp_drizzle_port= (uint64_t) strtoul(argument, &endchar, 10);
1245
/* if there is an alpha character this is not a valid port */
1246
if (strlen(endchar) != 0)
1248
fprintf(stderr, _("Non-integer value supplied for port. If you are trying to enter a password please use --password instead.\n"));
1251
/* If the port number is > 65535 it is not a valid port
1252
This also helps with potential data loss casting unsigned long to a
1254
if ((temp_drizzle_port == 0) || (temp_drizzle_port > 65535))
1256
fprintf(stderr, _("Value supplied for port is not valid.\n"));
1261
opt_drizzle_port= (uint32_t) temp_drizzle_port;
1267
char *start= argument;
1270
opt_password = strdup(argument);
1271
if (opt_password == NULL)
1273
fprintf(stderr, "Memory allocation error while copying password. "
1279
/* Overwriting password with 'x' */
1284
/* Cut length of argument */
1296
case 'I': /* Info */