Merge lp:~vjsamuel/drizzle/refactor-drizzleslap into lp:~drizzle-trunk/drizzle/development
- refactor-drizzleslap
- Merge into development
Proposed by
Monty Taylor
Status: | Merged |
---|---|
Merged at revision: | 1581 |
Proposed branch: | lp:~vjsamuel/drizzle/refactor-drizzleslap |
Merge into: | lp:~drizzle-trunk/drizzle/development |
Diff against target: |
1208 lines (+380/-411) 4 files modified
client/drizzleslap.cc (+363/-406) client/include.am (+12/-2) m4/pandora_warnings.m4 (+4/-2) tests/t/drizzleslap.test (+1/-1) |
To merge this branch: | bzr merge lp:~vjsamuel/drizzle/refactor-drizzleslap |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Monty Taylor | Pending | ||
Brian Aker | Pending | ||
Review via email:
|
This proposal supersedes a proposal from 2010-06-02.
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Brian Aker (brianaker) wrote : Posted in a previous version of this proposal | # |
review:
Needs Fixing
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Monty Taylor (mordred) wrote : Posted in a previous version of this proposal | # |
Re-merge this with trunk now - the code you need for modern boost and forcing gcc44 where possible is in trunk now. (Find us if you need help with doing the merge)
review:
Needs Fixing
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Brian Aker (brianaker) wrote : Posted in a previous version of this proposal | # |
- ifstream system_
+ ifstream system_
store(
ifstream user_client_
po::
- ifstream system_
+ ifstream system_
ifstream() takes a C-style string, not std::string.
Cheers,
-Brian
review:
Needs Fixing
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'client/drizzleslap.cc' | |||
2 | --- client/drizzleslap.cc 2010-04-07 14:15:05 +0000 | |||
3 | +++ client/drizzleslap.cc 2010-06-02 21:23:22 +0000 | |||
4 | @@ -70,11 +70,7 @@ | |||
5 | 70 | 70 | ||
6 | 71 | */ | 71 | */ |
7 | 72 | 72 | ||
13 | 73 | #define SLAP_VERSION "1.5" | 73 | #include "config.h" |
9 | 74 | |||
10 | 75 | #define HUGE_STRING_LENGTH 8196 | ||
11 | 76 | #define RAND_STRING_SIZE 126 | ||
12 | 77 | #define DEFAULT_BLOB_SIZE 1024 | ||
14 | 78 | 74 | ||
15 | 79 | #include "client_priv.h" | 75 | #include "client_priv.h" |
16 | 80 | #include <signal.h> | 76 | #include <signal.h> |
17 | @@ -86,18 +82,26 @@ | |||
18 | 86 | #endif | 82 | #endif |
19 | 87 | #include <fcntl.h> | 83 | #include <fcntl.h> |
20 | 88 | #include <math.h> | 84 | #include <math.h> |
21 | 89 | #include <ctype.h> | ||
22 | 90 | #include <cassert> | 85 | #include <cassert> |
23 | 91 | #include <cstdlib> | 86 | #include <cstdlib> |
24 | 92 | #include <string> | 87 | #include <string> |
26 | 93 | 88 | #include <iostream> | |
27 | 89 | #include <fstream> | ||
28 | 94 | #include <pthread.h> | 90 | #include <pthread.h> |
30 | 95 | 91 | #include <drizzled/configmake.h> | |
31 | 96 | /* Added this for string translation. */ | 92 | /* Added this for string translation. */ |
32 | 97 | #include <drizzled/gettext.h> | 93 | #include <drizzled/gettext.h> |
33 | 94 | #include <boost/program_options.hpp> | ||
34 | 95 | |||
35 | 96 | #define SLAP_VERSION "1.5" | ||
36 | 97 | |||
37 | 98 | #define HUGE_STRING_LENGTH 8196 | ||
38 | 99 | #define RAND_STRING_SIZE 126 | ||
39 | 100 | #define DEFAULT_BLOB_SIZE 1024 | ||
40 | 98 | 101 | ||
41 | 99 | using namespace std; | 102 | using namespace std; |
42 | 100 | using namespace drizzled; | 103 | using namespace drizzled; |
43 | 104 | namespace po= boost::program_options; | ||
44 | 101 | 105 | ||
45 | 102 | #ifdef HAVE_SMEM | 106 | #ifdef HAVE_SMEM |
46 | 103 | static char *shared_memory_base_name=0; | 107 | static char *shared_memory_base_name=0; |
47 | @@ -116,48 +120,51 @@ | |||
48 | 116 | pthread_mutex_t timer_alarm_mutex; | 120 | pthread_mutex_t timer_alarm_mutex; |
49 | 117 | pthread_cond_t timer_alarm_threshold; | 121 | pthread_cond_t timer_alarm_threshold; |
50 | 118 | 122 | ||
51 | 119 | static char **defaults_argv; | ||
52 | 120 | |||
53 | 121 | char **primary_keys; | 123 | char **primary_keys; |
54 | 122 | /* This gets passed to malloc, so lets set it to an arch-dependant size */ | 124 | /* This gets passed to malloc, so lets set it to an arch-dependant size */ |
55 | 123 | size_t primary_keys_number_of; | 125 | size_t primary_keys_number_of; |
56 | 124 | 126 | ||
70 | 125 | static char *host= NULL, *opt_password= NULL, *user= NULL, | 127 | static string host, |
71 | 126 | *user_supplied_query= NULL, | 128 | opt_password, |
72 | 127 | *user_supplied_pre_statements= NULL, | 129 | user, |
73 | 128 | *user_supplied_post_statements= NULL, | 130 | user_supplied_query, |
74 | 129 | *default_engine= NULL, | 131 | user_supplied_pre_statements, |
75 | 130 | *pre_system= NULL, | 132 | user_supplied_post_statements, |
76 | 131 | *post_system= NULL; | 133 | default_engine, |
77 | 132 | 134 | pre_system, | |
78 | 133 | const char *delimiter= "\n"; | 135 | post_system; |
79 | 134 | 136 | ||
80 | 135 | const char *create_schema_string= "drizzleslap"; | 137 | static vector<string> user_supplied_queries; |
81 | 136 | 138 | static string opt_verbose; | |
82 | 137 | static bool opt_mysql= false; | 139 | string delimiter; |
83 | 140 | |||
84 | 141 | string create_schema_string; | ||
85 | 142 | |||
86 | 143 | static bool opt_mysql; | ||
87 | 138 | static bool opt_preserve= true; | 144 | static bool opt_preserve= true; |
90 | 139 | static bool opt_only_print= false; | 145 | static bool opt_only_print; |
91 | 140 | static bool opt_burnin= false; | 146 | static bool opt_burnin; |
92 | 141 | static bool opt_ignore_sql_errors= false; | 147 | static bool opt_ignore_sql_errors= false; |
93 | 142 | static bool tty_password= false, | 148 | static bool tty_password= false, |
99 | 143 | opt_silent= false, | 149 | opt_silent, |
100 | 144 | auto_generate_sql_autoincrement= false, | 150 | auto_generate_sql_autoincrement, |
101 | 145 | auto_generate_sql_guid_primary= false, | 151 | auto_generate_sql_guid_primary, |
102 | 146 | auto_generate_sql= false; | 152 | auto_generate_sql; |
103 | 147 | const char *opt_auto_generate_sql_type= "mixed"; | 153 | std::string opt_auto_generate_sql_type; |
104 | 148 | 154 | ||
106 | 149 | static int verbose, delimiter_length; | 155 | static int32_t verbose= 0; |
107 | 156 | static uint32_t delimiter_length; | ||
108 | 150 | static uint32_t commit_rate; | 157 | static uint32_t commit_rate; |
109 | 151 | static uint32_t detach_rate; | 158 | static uint32_t detach_rate; |
110 | 152 | static uint32_t opt_timer_length; | 159 | static uint32_t opt_timer_length; |
111 | 153 | static uint32_t opt_delayed_start; | 160 | static uint32_t opt_delayed_start; |
116 | 154 | const char *num_int_cols_opt; | 161 | string num_blob_cols_opt, |
117 | 155 | const char *num_char_cols_opt; | 162 | num_char_cols_opt, |
118 | 156 | const char *num_blob_cols_opt; | 163 | num_int_cols_opt; |
119 | 157 | const char *opt_label; | 164 | string opt_label; |
120 | 158 | static unsigned int opt_set_random_seed; | 165 | static unsigned int opt_set_random_seed; |
121 | 159 | 166 | ||
123 | 160 | const char *auto_generate_selected_columns_opt; | 167 | string auto_generate_selected_columns_opt; |
124 | 161 | 168 | ||
125 | 162 | /* Yes, we do set defaults here */ | 169 | /* Yes, we do set defaults here */ |
126 | 163 | static unsigned int num_int_cols= 1; | 170 | static unsigned int num_int_cols= 1; |
127 | @@ -167,26 +174,25 @@ | |||
128 | 167 | static unsigned int num_blob_cols_size_min; | 174 | static unsigned int num_blob_cols_size_min; |
129 | 168 | static unsigned int num_int_cols_index= 0; | 175 | static unsigned int num_int_cols_index= 0; |
130 | 169 | static unsigned int num_char_cols_index= 0; | 176 | static unsigned int num_char_cols_index= 0; |
132 | 170 | static unsigned int iterations; | 177 | static uint32_t iterations; |
133 | 171 | static uint64_t actual_queries= 0; | 178 | static uint64_t actual_queries= 0; |
134 | 172 | static uint64_t auto_actual_queries; | 179 | static uint64_t auto_actual_queries; |
135 | 173 | static uint64_t auto_generate_sql_unique_write_number; | 180 | static uint64_t auto_generate_sql_unique_write_number; |
136 | 174 | static uint64_t auto_generate_sql_unique_query_number; | 181 | static uint64_t auto_generate_sql_unique_query_number; |
138 | 175 | static unsigned int auto_generate_sql_secondary_indexes; | 182 | static uint32_t auto_generate_sql_secondary_indexes; |
139 | 176 | static uint64_t num_of_query; | 183 | static uint64_t num_of_query; |
140 | 177 | static uint64_t auto_generate_sql_number; | 184 | static uint64_t auto_generate_sql_number; |
143 | 178 | const char *concurrency_str= NULL; | 185 | string concurrency_str; |
144 | 179 | static char *create_string; | 186 | string create_string; |
145 | 180 | uint32_t *concurrency; | 187 | uint32_t *concurrency; |
146 | 181 | 188 | ||
147 | 182 | const char *default_dbug_option= "d:t:o,/tmp/drizzleslap.trace"; | 189 | const char *default_dbug_option= "d:t:o,/tmp/drizzleslap.trace"; |
149 | 183 | const char *opt_csv_str; | 190 | std::string opt_csv_str; |
150 | 184 | int csv_file; | 191 | int csv_file; |
151 | 185 | 192 | ||
153 | 186 | static int get_options(int *argc,char ***argv); | 193 | static int process_options(void); |
154 | 187 | static uint32_t opt_drizzle_port= 0; | 194 | static uint32_t opt_drizzle_port= 0; |
155 | 188 | 195 | ||
156 | 189 | static const char *load_default_groups[]= { "drizzleslap","client",0 }; | ||
157 | 190 | 196 | ||
158 | 191 | /* Types */ | 197 | /* Types */ |
159 | 192 | typedef enum { | 198 | typedef enum { |
160 | @@ -821,23 +827,248 @@ | |||
161 | 821 | return s + us; | 827 | return s + us; |
162 | 822 | } | 828 | } |
163 | 823 | 829 | ||
164 | 830 | static void combine_queries(vector<string> queries) | ||
165 | 831 | { | ||
166 | 832 | user_supplied_query.erase(); | ||
167 | 833 | for (vector<string>::iterator it= queries.begin(); | ||
168 | 834 | it != queries.end(); | ||
169 | 835 | ++it) | ||
170 | 836 | { | ||
171 | 837 | user_supplied_query.append(*it); | ||
172 | 838 | user_supplied_query.append(delimiter); | ||
173 | 839 | } | ||
174 | 840 | } | ||
175 | 841 | /** | ||
176 | 842 | * commandline_options is the set of all options that can only be called via the command line. | ||
177 | 843 | |||
178 | 844 | * client_options is the set of all options that can be defined via both command line and via | ||
179 | 845 | * the configuration file client.cnf | ||
180 | 846 | |||
181 | 847 | * slap_options is the set of all drizzleslap specific options which behave in a manner | ||
182 | 848 | * similar to that of client_options. It's configuration file is drizzleslap.cnf | ||
183 | 849 | |||
184 | 850 | * long_options is the union of commandline_options, slap_options and client_options. | ||
185 | 851 | |||
186 | 852 | * There are two configuration files per set of options, one which is defined by the user and | ||
187 | 853 | * which is found at ~/.drizzle directory and the other which is the system configuration | ||
188 | 854 | * file which is found in the SYSCONFDIR/drizzle directory. | ||
189 | 855 | |||
190 | 856 | * The system configuration file is over ridden by the user's configuration file which | ||
191 | 857 | * in turn is over ridden by the command line. | ||
192 | 858 | */ | ||
193 | 824 | int main(int argc, char **argv) | 859 | int main(int argc, char **argv) |
194 | 825 | { | 860 | { |
195 | 861 | char *password= NULL; | ||
196 | 862 | try | ||
197 | 863 | { | ||
198 | 864 | po::options_description commandline_options("Options used only in command line"); | ||
199 | 865 | commandline_options.add_options() | ||
200 | 866 | ("help,?","Display this help and exit") | ||
201 | 867 | ("info,i","Gives information and exit") | ||
202 | 868 | ("burnin",po::value<bool>(&opt_burnin)->default_value(false)->zero_tokens(), | ||
203 | 869 | "Run full test case in infinite loop") | ||
204 | 870 | ("ignore-sql-errors", po::value<bool>(&opt_ignore_sql_errors)->default_value(false)->zero_tokens(), | ||
205 | 871 | "Ignore SQL errors in query run") | ||
206 | 872 | ("create-schema",po::value<string>(&create_schema_string)->default_value("drizzleslap"), | ||
207 | 873 | "Schema to run tests in") | ||
208 | 874 | ("create",po::value<string>(&create_string)->default_value(""), | ||
209 | 875 | "File or string to use to create tables") | ||
210 | 876 | ("detach",po::value<uint32_t>(&detach_rate)->default_value(0), | ||
211 | 877 | "Detach (close and re open) connections after X number of requests") | ||
212 | 878 | ("iterations,i",po::value<uint32_t>(&iterations)->default_value(1), | ||
213 | 879 | "Number of times to run the tests") | ||
214 | 880 | ("label",po::value<string>(&opt_label)->default_value(""), | ||
215 | 881 | "Label to use for print and csv") | ||
216 | 882 | ("number-blob-cols",po::value<string>(&num_blob_cols_opt)->default_value(""), | ||
217 | 883 | "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. ") | ||
218 | 884 | ("number-char-cols,x",po::value<string>(&num_char_cols_opt)->default_value(""), | ||
219 | 885 | "Number of VARCHAR columns to create in table if specifying --auto-generate-sql.") | ||
220 | 886 | ("number-int-cols,y",po::value<string>(&num_int_cols_opt)->default_value(""), | ||
221 | 887 | "Number of INT columns to create in table if specifying --auto-generate-sql.") | ||
222 | 888 | ("number-of-queries", | ||
223 | 889 | po::value<uint64_t>(&num_of_query)->default_value(0), | ||
224 | 890 | "Limit each client to this number of queries(this is not exact)") | ||
225 | 891 | ("only-print",po::value<bool>(&opt_only_print)->default_value(false)->zero_tokens(), | ||
226 | 892 | "This causes drizzleslap to not connect to the database instead print out what it would have done instead") | ||
227 | 893 | ("post-query", po::value<string>(&user_supplied_post_statements)->default_value(""), | ||
228 | 894 | "Query to run or file containing query to execute after tests have completed.") | ||
229 | 895 | ("post-system",po::value<string>(&post_system)->default_value(""), | ||
230 | 896 | "system() string to execute after tests have completed") | ||
231 | 897 | ("pre-query", | ||
232 | 898 | po::value<string>(&user_supplied_pre_statements)->default_value(""), | ||
233 | 899 | "Query to run or file containing query to execute before running tests.") | ||
234 | 900 | ("pre-system",po::value<string>(&pre_system)->default_value(""), | ||
235 | 901 | "system() string to execute before running tests.") | ||
236 | 902 | ("query,q",po::value<vector<string> >(&user_supplied_queries)->composing()->notifier(&combine_queries), | ||
237 | 903 | "Query to run or file containing query") | ||
238 | 904 | ("verbose,v", po::value<string>(&opt_verbose)->default_value("v"), "Increase verbosity level by one.") | ||
239 | 905 | ("version,V","Output version information and exit") | ||
240 | 906 | ; | ||
241 | 907 | |||
242 | 908 | po::options_description slap_options("Options specific to drizzleslap"); | ||
243 | 909 | slap_options.add_options() | ||
244 | 910 | ("auto-generate-sql-select-columns", | ||
245 | 911 | po::value<string>(&auto_generate_selected_columns_opt)->default_value(""), | ||
246 | 912 | "Provide a string to use for the select fields used in auto tests") | ||
247 | 913 | ("auto-generate-sql,a",po::value<bool>(&auto_generate_sql)->default_value(false)->zero_tokens(), | ||
248 | 914 | "Generate SQL where not supplied by file or command line") | ||
249 | 915 | ("auto-generate-sql-add-autoincrement", | ||
250 | 916 | po::value<bool>(&auto_generate_sql_autoincrement)->default_value(false)->zero_tokens(), | ||
251 | 917 | "Add an AUTO_INCREMENT column to auto-generated tables") | ||
252 | 918 | ("auto-generate-sql-execute-number", | ||
253 | 919 | po::value<uint64_t>(&auto_actual_queries)->default_value(0), | ||
254 | 920 | "See this number and generate a set of queries to run") | ||
255 | 921 | ("auto-generate-sql-guid-primary", | ||
256 | 922 | po::value<bool>(&auto_generate_sql_guid_primary)->default_value(false)->zero_tokens(), | ||
257 | 923 | "Add GUID based primary keys to auto-generated tables") | ||
258 | 924 | ("auto-generate-sql-load-type", | ||
259 | 925 | po::value<string>(&opt_auto_generate_sql_type)->default_value("mixed"), | ||
260 | 926 | "Specify test load type: mixed, update, write, key or read; default is mixed") | ||
261 | 927 | ("auto-generate-sql-secondary-indexes", | ||
262 | 928 | po::value<uint32_t>(&auto_generate_sql_secondary_indexes)->default_value(0), | ||
263 | 929 | "Number of secondary indexes to add to auto-generated tables") | ||
264 | 930 | ("auto-generated-sql-unique-query-number", | ||
265 | 931 | po::value<uint64_t>(&auto_generate_sql_unique_query_number)->default_value(10), | ||
266 | 932 | "Number of unique queries to generate for automatic tests") | ||
267 | 933 | ("auto-generate-sql-unique-write-number", | ||
268 | 934 | po::value<uint64_t>(&auto_generate_sql_unique_write_number)->default_value(10), | ||
269 | 935 | "Number of unique queries to generate for auto-generate-sql-write-number") | ||
270 | 936 | ("auto-generate-sql-write-number", | ||
271 | 937 | po::value<uint64_t>(&auto_generate_sql_number)->default_value(100), | ||
272 | 938 | "Number of row inserts to perform for each thread (default is 100).") | ||
273 | 939 | ("commit",po::value<uint32_t>(&commit_rate)->default_value(0), | ||
274 | 940 | "Commit records every X number of statements") | ||
275 | 941 | ("concurrency,c",po::value<string>(&concurrency_str)->default_value(""), | ||
276 | 942 | "Number of clients to simulate for query to run") | ||
277 | 943 | ("csv",po::value<std::string>(&opt_csv_str)->default_value(""), | ||
278 | 944 | "Generate CSV output to named file or to stdout if no file is name.") | ||
279 | 945 | ("delayed-start",po::value<uint32_t>(&opt_delayed_start)->default_value(0), | ||
280 | 946 | "Delay the startup of threads by a random number of microsends (the maximum of the delay") | ||
281 | 947 | ("delimiter,F",po::value<string>(&delimiter)->default_value("\n"), | ||
282 | 948 | "Delimiter to use in SQL statements supplied in file or command line") | ||
283 | 949 | ("engine ,e",po::value<string>(&default_engine)->default_value(""), | ||
284 | 950 | "Storage engien to use for creating the table") | ||
285 | 951 | ("set-random-seed", | ||
286 | 952 | po::value<uint32_t>(&opt_set_random_seed)->default_value(0), | ||
287 | 953 | "Seed for random number generator (srandom(3)) ") | ||
288 | 954 | ("silent,s",po::value<bool>(&opt_silent)->default_value(false)->zero_tokens(), | ||
289 | 955 | "Run program in silent mode - no output. ") | ||
290 | 956 | ("timer-length",po::value<uint32_t>(&opt_timer_length)->default_value(0), | ||
291 | 957 | "Require drizzleslap to run each specific test a certain amount of time in seconds") | ||
292 | 958 | ; | ||
293 | 959 | |||
294 | 960 | po::options_description client_options("Options specific to the client"); | ||
295 | 961 | client_options.add_options() | ||
296 | 962 | ("mysql,m", po::value<bool>(&opt_mysql)->default_value(true)->zero_tokens(), | ||
297 | 963 | N_("Use MySQL Protocol.")) | ||
298 | 964 | ("host,h",po::value<string>(&host)->default_value("localhost"),"Connect to the host") | ||
299 | 965 | ("password,P",po::value<char *>(&password), | ||
300 | 966 | "Password to use when connecting to server. If password is not given it's asked from the tty") | ||
301 | 967 | ("port,p",po::value<uint32_t>(), "Port number to use for connection") | ||
302 | 968 | ("protocol",po::value<string>(), | ||
303 | 969 | "The protocol of connection (tcp,socket,pipe,memory).") | ||
304 | 970 | ("user,u",po::value<string>(&user)->default_value(""), | ||
305 | 971 | "User for login if not current user") | ||
306 | 972 | ; | ||
307 | 973 | |||
308 | 974 | po::options_description long_options("Allowed Options"); | ||
309 | 975 | long_options.add(commandline_options).add(slap_options).add(client_options); | ||
310 | 976 | |||
311 | 977 | std::string system_config_dir_slap(SYSCONFDIR); | ||
312 | 978 | system_config_dir_slap.append("/drizzle/drizzleslap.cnf"); | ||
313 | 979 | |||
314 | 980 | std::string system_config_dir_client(SYSCONFDIR); | ||
315 | 981 | system_config_dir_client.append("/drizzle/client.cnf"); | ||
316 | 982 | |||
317 | 983 | uint64_t temp_drizzle_port= 0; | ||
318 | 826 | drizzle_con_st con; | 984 | drizzle_con_st con; |
319 | 827 | OptionString *eptr; | 985 | OptionString *eptr; |
332 | 828 | unsigned int x; | 986 | uint32_t x; |
333 | 829 | 987 | ||
334 | 830 | internal::my_init(); | 988 | |
335 | 831 | 989 | po::variables_map vm; | |
336 | 832 | MY_INIT(argv[0]); | 990 | po::store(po::parse_command_line(argc,argv,long_options),vm); |
337 | 833 | 991 | ||
338 | 834 | internal::load_defaults("drizzle",load_default_groups,&argc,&argv); | 992 | ifstream user_slap_ifs("~/.drizzle/drizzleslap.cnf"); |
339 | 835 | defaults_argv=argv; | 993 | po::store(parse_config_file(user_slap_ifs, slap_options), vm); |
340 | 836 | if (get_options(&argc,&argv)) | 994 | |
341 | 837 | { | 995 | ifstream system_slap_ifs(system_config_dir_slap.c_str()); |
342 | 838 | internal::free_defaults(defaults_argv); | 996 | store(parse_config_file(system_slap_ifs, slap_options), vm); |
343 | 839 | internal::my_end(); | 997 | |
344 | 998 | ifstream user_client_ifs("~/.drizzle/client.cnf"); | ||
345 | 999 | po::store(parse_config_file(user_client_ifs, client_options), vm); | ||
346 | 1000 | |||
347 | 1001 | ifstream system_client_ifs(system_config_dir_client.c_str()); | ||
348 | 1002 | store(parse_config_file(system_client_ifs, client_options), vm); | ||
349 | 1003 | |||
350 | 1004 | po::notify(vm); | ||
351 | 1005 | |||
352 | 1006 | if (process_options()) | ||
353 | 840 | exit(1); | 1007 | exit(1); |
354 | 1008 | |||
355 | 1009 | if( vm.count("help") || vm.count("info")) | ||
356 | 1010 | { | ||
357 | 1011 | printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION, | ||
358 | 1012 | drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU); | ||
359 | 1013 | puts("Copyright (C) 2008 Sun Microsystems"); | ||
360 | 1014 | puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\ | ||
361 | 1015 | \nand you are welcome to modify and redistribute it under the GPL \ | ||
362 | 1016 | license\n"); | ||
363 | 1017 | puts("Run a query multiple times against the server\n"); | ||
364 | 1018 | cout<<long_options<<endl; | ||
365 | 1019 | exit(0); | ||
366 | 1020 | } | ||
367 | 1021 | |||
368 | 1022 | if(vm.count("port")) | ||
369 | 1023 | { | ||
370 | 1024 | temp_drizzle_port= vm["port"].as<uint32_t>(); | ||
371 | 1025 | |||
372 | 1026 | if ((temp_drizzle_port == 0) || (temp_drizzle_port > 65535)) | ||
373 | 1027 | { | ||
374 | 1028 | fprintf(stderr, _("Value supplied for port is not valid.\n")); | ||
375 | 1029 | exit(1); | ||
376 | 1030 | } | ||
377 | 1031 | else | ||
378 | 1032 | { | ||
379 | 1033 | opt_drizzle_port= (uint32_t) temp_drizzle_port; | ||
380 | 1034 | } | ||
381 | 1035 | } | ||
382 | 1036 | |||
383 | 1037 | if( vm.count("password") ) | ||
384 | 1038 | { | ||
385 | 1039 | char *start= vm["password"].as<char *>(); | ||
386 | 1040 | if (!opt_password.empty()) | ||
387 | 1041 | opt_password.erase(); | ||
388 | 1042 | opt_password = strdup(vm["password"].as<char *>()); | ||
389 | 1043 | if (opt_password.c_str() == NULL) | ||
390 | 1044 | { | ||
391 | 1045 | fprintf(stderr, "Memory allocation error while copying password. " | ||
392 | 1046 | "Aborting.\n"); | ||
393 | 1047 | exit(ENOMEM); | ||
394 | 1048 | } | ||
395 | 1049 | |||
396 | 1050 | while (*password) | ||
397 | 1051 | { | ||
398 | 1052 | /* Overwriting password with 'x' */ | ||
399 | 1053 | *password++= 'x'; | ||
400 | 1054 | } | ||
401 | 1055 | |||
402 | 1056 | if (*start) | ||
403 | 1057 | { | ||
404 | 1058 | /* Cut length of argument */ | ||
405 | 1059 | start[1]= 0; | ||
406 | 1060 | } | ||
407 | 1061 | tty_password= 0; | ||
408 | 1062 | } | ||
409 | 1063 | else | ||
410 | 1064 | tty_password= 1; | ||
411 | 1065 | |||
412 | 1066 | |||
413 | 1067 | if( vm.count("version") ) | ||
414 | 1068 | { | ||
415 | 1069 | printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION, | ||
416 | 1070 | drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU); | ||
417 | 1071 | exit(0); | ||
418 | 841 | } | 1072 | } |
419 | 842 | 1073 | ||
420 | 843 | /* Seed the random number generator if we will be using it. */ | 1074 | /* Seed the random number generator if we will be using it. */ |
421 | @@ -849,15 +1080,7 @@ | |||
422 | 849 | } | 1080 | } |
423 | 850 | 1081 | ||
424 | 851 | /* globals? Yes, so we only have to run strlen once */ | 1082 | /* globals? Yes, so we only have to run strlen once */ |
434 | 852 | delimiter_length= strlen(delimiter); | 1083 | delimiter_length= delimiter.length(); |
426 | 853 | |||
427 | 854 | if (argc > 2) | ||
428 | 855 | { | ||
429 | 856 | fprintf(stderr,"%s: Too many arguments\n",internal::my_progname); | ||
430 | 857 | internal::free_defaults(defaults_argv); | ||
431 | 858 | internal::my_end(); | ||
432 | 859 | exit(1); | ||
433 | 860 | } | ||
435 | 861 | 1084 | ||
436 | 862 | slap_connect(&con, false); | 1085 | slap_connect(&con, false); |
437 | 863 | 1086 | ||
438 | @@ -895,7 +1118,7 @@ | |||
439 | 895 | } | 1118 | } |
440 | 896 | 1119 | ||
441 | 897 | if (!opt_preserve) | 1120 | if (!opt_preserve) |
443 | 898 | drop_schema(&con, create_schema_string); | 1121 | drop_schema(&con, create_schema_string.c_str()); |
444 | 899 | 1122 | ||
445 | 900 | } while (eptr ? (eptr= eptr->getNext()) : 0); | 1123 | } while (eptr ? (eptr= eptr->getNext()) : 0); |
446 | 901 | 1124 | ||
447 | @@ -912,8 +1135,8 @@ | |||
448 | 912 | slap_close(&con); | 1135 | slap_close(&con); |
449 | 913 | 1136 | ||
450 | 914 | /* now free all the strings we created */ | 1137 | /* now free all the strings we created */ |
453 | 915 | if (opt_password) | 1138 | if (!opt_password.empty()) |
454 | 916 | free(opt_password); | 1139 | opt_password.erase(); |
455 | 917 | 1140 | ||
456 | 918 | free(concurrency); | 1141 | free(concurrency); |
457 | 919 | 1142 | ||
458 | @@ -930,9 +1153,13 @@ | |||
459 | 930 | if (shared_memory_base_name) | 1153 | if (shared_memory_base_name) |
460 | 931 | free(shared_memory_base_name); | 1154 | free(shared_memory_base_name); |
461 | 932 | #endif | 1155 | #endif |
465 | 933 | internal::free_defaults(defaults_argv); | 1156 | |
466 | 934 | internal::my_end(); | 1157 | } |
467 | 935 | 1158 | ||
468 | 1159 | catch(exception &err) | ||
469 | 1160 | { | ||
470 | 1161 | cerr<<"Error:"<<err.what()<<endl; | ||
471 | 1162 | } | ||
472 | 936 | return 0; | 1163 | return 0; |
473 | 937 | } | 1164 | } |
474 | 938 | 1165 | ||
475 | @@ -969,11 +1196,11 @@ | |||
476 | 969 | data in the table. | 1196 | data in the table. |
477 | 970 | */ | 1197 | */ |
478 | 971 | if (opt_preserve == false) | 1198 | if (opt_preserve == false) |
480 | 972 | drop_schema(con, create_schema_string); | 1199 | drop_schema(con, create_schema_string.c_str()); |
481 | 973 | 1200 | ||
482 | 974 | /* First we create */ | 1201 | /* First we create */ |
483 | 975 | if (create_statements) | 1202 | if (create_statements) |
485 | 976 | create_schema(con, create_schema_string, create_statements, eptr, sptr); | 1203 | create_schema(con, create_schema_string.c_str(), create_statements, eptr, sptr); |
486 | 977 | 1204 | ||
487 | 978 | /* | 1205 | /* |
488 | 979 | If we generated GUID we need to build a list of them from creation that | 1206 | If we generated GUID we need to build a list of them from creation that |
489 | @@ -987,9 +1214,9 @@ | |||
490 | 987 | if (commit_rate) | 1214 | if (commit_rate) |
491 | 988 | run_query(con, NULL, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0")); | 1215 | run_query(con, NULL, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0")); |
492 | 989 | 1216 | ||
494 | 990 | if (pre_system) | 1217 | if (!pre_system.empty()) |
495 | 991 | { | 1218 | { |
497 | 992 | int ret= system(pre_system); | 1219 | int ret= system(pre_system.c_str()); |
498 | 993 | assert(ret != -1); | 1220 | assert(ret != -1); |
499 | 994 | } | 1221 | } |
500 | 995 | 1222 | ||
501 | @@ -1006,9 +1233,9 @@ | |||
502 | 1006 | if (post_statements) | 1233 | if (post_statements) |
503 | 1007 | run_statements(con, post_statements); | 1234 | run_statements(con, post_statements); |
504 | 1008 | 1235 | ||
506 | 1009 | if (post_system) | 1236 | if (!post_system.empty()) |
507 | 1010 | { | 1237 | { |
509 | 1011 | int ret= system(post_system); | 1238 | int ret= system(post_system.c_str()); |
510 | 1012 | assert(ret !=-1); | 1239 | assert(ret !=-1); |
511 | 1013 | } | 1240 | } |
512 | 1014 | 1241 | ||
513 | @@ -1024,7 +1251,7 @@ | |||
514 | 1024 | 1251 | ||
515 | 1025 | if (!opt_silent) | 1252 | if (!opt_silent) |
516 | 1026 | print_conclusions(&conclusion); | 1253 | print_conclusions(&conclusion); |
518 | 1027 | if (opt_csv_str) | 1254 | if (!opt_csv_str.empty()) |
519 | 1028 | print_conclusions_csv(&conclusion); | 1255 | print_conclusions_csv(&conclusion); |
520 | 1029 | 1256 | ||
521 | 1030 | free(head_sptr); | 1257 | free(head_sptr); |
522 | @@ -1032,274 +1259,6 @@ | |||
523 | 1032 | } | 1259 | } |
524 | 1033 | 1260 | ||
525 | 1034 | 1261 | ||
526 | 1035 | static struct option my_long_options[] = | ||
527 | 1036 | { | ||
528 | 1037 | {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, | ||
529 | 1038 | 0, 0, 0, 0, 0, 0}, | ||
530 | 1039 | {"auto-generate-sql-select-columns", OPT_SLAP_AUTO_GENERATE_SELECT_COLUMNS, | ||
531 | 1040 | "Provide a string to use for the select fields used in auto tests.", | ||
532 | 1041 | (char**) &auto_generate_selected_columns_opt, | ||
533 | 1042 | (char**) &auto_generate_selected_columns_opt, | ||
534 | 1043 | 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
535 | 1044 | {"auto-generate-sql", 'a', | ||
536 | 1045 | "Generate SQL where not supplied by file or command line.", | ||
537 | 1046 | (char**) &auto_generate_sql, (char**) &auto_generate_sql, | ||
538 | 1047 | 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, | ||
539 | 1048 | {"auto-generate-sql-add-autoincrement", OPT_SLAP_AUTO_GENERATE_ADD_AUTO, | ||
540 | 1049 | "Add an AUTO_INCREMENT column to auto-generated tables.", | ||
541 | 1050 | (char**) &auto_generate_sql_autoincrement, | ||
542 | 1051 | (char**) &auto_generate_sql_autoincrement, | ||
543 | 1052 | 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, | ||
544 | 1053 | {"auto-generate-sql-execute-number", OPT_SLAP_AUTO_GENERATE_EXECUTE_QUERIES, | ||
545 | 1054 | "Set this number to generate a set number of queries to run.", | ||
546 | 1055 | (char**) &auto_actual_queries, (char**) &auto_actual_queries, | ||
547 | 1056 | 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
548 | 1057 | {"auto-generate-sql-guid-primary", OPT_SLAP_AUTO_GENERATE_GUID_PRIMARY, | ||
549 | 1058 | "Add GUID based primary keys to auto-generated tables.", | ||
550 | 1059 | (char**) &auto_generate_sql_guid_primary, | ||
551 | 1060 | (char**) &auto_generate_sql_guid_primary, | ||
552 | 1061 | 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, | ||
553 | 1062 | {"auto-generate-sql-load-type", OPT_SLAP_AUTO_GENERATE_SQL_LOAD_TYPE, | ||
554 | 1063 | "Specify test load type: mixed, update, write, key, or read; default is mixed.", | ||
555 | 1064 | (char**) &opt_auto_generate_sql_type, (char**) &opt_auto_generate_sql_type, | ||
556 | 1065 | 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
557 | 1066 | {"auto-generate-sql-secondary-indexes", | ||
558 | 1067 | OPT_SLAP_AUTO_GENERATE_SECONDARY_INDEXES, | ||
559 | 1068 | "Number of secondary indexes to add to auto-generated tables.", | ||
560 | 1069 | (char**) &auto_generate_sql_secondary_indexes, | ||
561 | 1070 | (char**) &auto_generate_sql_secondary_indexes, 0, | ||
562 | 1071 | GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
563 | 1072 | {"auto-generate-sql-unique-query-number", | ||
564 | 1073 | OPT_SLAP_AUTO_GENERATE_UNIQUE_QUERY_NUM, | ||
565 | 1074 | "Number of unique queries to generate for automatic tests.", | ||
566 | 1075 | (char**) &auto_generate_sql_unique_query_number, | ||
567 | 1076 | (char**) &auto_generate_sql_unique_query_number, | ||
568 | 1077 | 0, GET_ULL, REQUIRED_ARG, 10, 0, 0, 0, 0, 0}, | ||
569 | 1078 | {"auto-generate-sql-unique-write-number", | ||
570 | 1079 | OPT_SLAP_AUTO_GENERATE_UNIQUE_WRITE_NUM, | ||
571 | 1080 | "Number of unique queries to generate for auto-generate-sql-write-number.", | ||
572 | 1081 | (char**) &auto_generate_sql_unique_write_number, | ||
573 | 1082 | (char**) &auto_generate_sql_unique_write_number, | ||
574 | 1083 | 0, GET_ULL, REQUIRED_ARG, 10, 0, 0, 0, 0, 0}, | ||
575 | 1084 | {"auto-generate-sql-write-number", OPT_SLAP_AUTO_GENERATE_WRITE_NUM, | ||
576 | 1085 | "Number of row inserts to perform for each thread (default is 100).", | ||
577 | 1086 | (char**) &auto_generate_sql_number, (char**) &auto_generate_sql_number, | ||
578 | 1087 | 0, GET_ULL, REQUIRED_ARG, 100, 0, 0, 0, 0, 0}, | ||
579 | 1088 | {"burnin", OPT_SLAP_BURNIN, "Run full test case in infinite loop.", | ||
580 | 1089 | (char**) &opt_burnin, (char**) &opt_burnin, 0, GET_BOOL, NO_ARG, 0, 0, 0, | ||
581 | 1090 | 0, 0, 0}, | ||
582 | 1091 | {"ignore-sql-errors", OPT_SLAP_IGNORE_SQL_ERRORS, | ||
583 | 1092 | "Ignore SQL erros in query run.", | ||
584 | 1093 | (char**) &opt_ignore_sql_errors, | ||
585 | 1094 | (char**) &opt_ignore_sql_errors, | ||
586 | 1095 | 0, GET_BOOL, NO_ARG, 0, 0, 0, | ||
587 | 1096 | 0, 0, 0}, | ||
588 | 1097 | {"commit", OPT_SLAP_COMMIT, "Commit records every X number of statements.", | ||
589 | 1098 | (char**) &commit_rate, (char**) &commit_rate, 0, GET_UINT, REQUIRED_ARG, | ||
590 | 1099 | 0, 0, 0, 0, 0, 0}, | ||
591 | 1100 | {"concurrency", 'c', "Number of clients to simulate for query to run.", | ||
592 | 1101 | (char**) &concurrency_str, (char**) &concurrency_str, 0, GET_STR, | ||
593 | 1102 | REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
594 | 1103 | {"create", OPT_SLAP_CREATE_STRING, "File or string to use create tables.", | ||
595 | 1104 | (char**) &create_string, (char**) &create_string, 0, GET_STR, REQUIRED_ARG, | ||
596 | 1105 | 0, 0, 0, 0, 0, 0}, | ||
597 | 1106 | {"create-schema", OPT_CREATE_SLAP_SCHEMA, "Schema to run tests in.", | ||
598 | 1107 | (char**) &create_schema_string, (char**) &create_schema_string, 0, GET_STR, | ||
599 | 1108 | REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
600 | 1109 | {"csv", OPT_SLAP_CSV, | ||
601 | 1110 | "Generate CSV output to named file or to stdout if no file is named.", | ||
602 | 1111 | (char**) &opt_csv_str, (char**) &opt_csv_str, 0, GET_STR, | ||
603 | 1112 | OPT_ARG, 0, 0, 0, 0, 0, 0}, | ||
604 | 1113 | {"delayed-start", OPT_SLAP_DELAYED_START, | ||
605 | 1114 | "Delay the startup of threads by a random number of microsends (the maximum of the delay)", | ||
606 | 1115 | (char**) &opt_delayed_start, (char**) &opt_delayed_start, 0, GET_UINT, | ||
607 | 1116 | REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
608 | 1117 | {"delimiter", 'F', | ||
609 | 1118 | "Delimiter to use in SQL statements supplied in file or command line.", | ||
610 | 1119 | (char**) &delimiter, (char**) &delimiter, 0, GET_STR, REQUIRED_ARG, | ||
611 | 1120 | 0, 0, 0, 0, 0, 0}, | ||
612 | 1121 | {"detach", OPT_SLAP_DETACH, | ||
613 | 1122 | "Detach (close and reopen) connections after X number of requests.", | ||
614 | 1123 | (char**) &detach_rate, (char**) &detach_rate, 0, GET_UINT, REQUIRED_ARG, | ||
615 | 1124 | 0, 0, 0, 0, 0, 0}, | ||
616 | 1125 | {"engine", 'e', "Storage engine to use for creating the table.", | ||
617 | 1126 | (char**) &default_engine, (char**) &default_engine, 0, | ||
618 | 1127 | GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
619 | 1128 | {"host", 'h', "Connect to host.", (char**) &host, (char**) &host, 0, GET_STR, | ||
620 | 1129 | REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
621 | 1130 | {"iterations", 'i', "Number of times to run the tests.", (char**) &iterations, | ||
622 | 1131 | (char**) &iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0}, | ||
623 | 1132 | {"label", OPT_SLAP_LABEL, "Label to use for print and csv output.", | ||
624 | 1133 | (char**) &opt_label, (char**) &opt_label, 0, | ||
625 | 1134 | GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
626 | 1135 | {"mysql", 'm', N_("Use MySQL Protocol."), | ||
627 | 1136 | (char**) &opt_mysql, (char**) &opt_mysql, 0, GET_BOOL, NO_ARG, 1, 0, 0, | ||
628 | 1137 | 0, 0, 0}, | ||
629 | 1138 | {"number-blob-cols", OPT_SLAP_BLOB_COL, | ||
630 | 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. ", | ||
631 | 1140 | (char**) &num_blob_cols_opt, (char**) &num_blob_cols_opt, 0, GET_STR, REQUIRED_ARG, | ||
632 | 1141 | 0, 0, 0, 0, 0, 0}, | ||
633 | 1142 | {"number-char-cols", 'x', | ||
634 | 1143 | "Number of VARCHAR columns to create in table if specifying --auto-generate-sql.", | ||
635 | 1144 | (char**) &num_char_cols_opt, (char**) &num_char_cols_opt, 0, GET_STR, REQUIRED_ARG, | ||
636 | 1145 | 0, 0, 0, 0, 0, 0}, | ||
637 | 1146 | {"number-int-cols", 'y', | ||
638 | 1147 | "Number of INT columns to create in table if specifying --auto-generate-sql.", | ||
639 | 1148 | (char**) &num_int_cols_opt, (char**) &num_int_cols_opt, 0, GET_STR, REQUIRED_ARG, | ||
640 | 1149 | 0, 0, 0, 0, 0, 0}, | ||
641 | 1150 | {"number-of-queries", OPT_DRIZZLE_NUMBER_OF_QUERY, | ||
642 | 1151 | "Limit each client to this number of queries (this is not exact).", | ||
643 | 1152 | (char**) &num_of_query, (char**) &num_of_query, 0, | ||
644 | 1153 | GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
645 | 1154 | {"only-print", OPT_DRIZZLE_ONLY_PRINT, | ||
646 | 1155 | "This causes drizzleslap to not connect to the databases, but instead print " | ||
647 | 1156 | "out what it would have done instead.", | ||
648 | 1157 | (char**) &opt_only_print, (char**) &opt_only_print, 0, GET_BOOL, NO_ARG, | ||
649 | 1158 | 0, 0, 0, 0, 0, 0}, | ||
650 | 1159 | {"password", 'P', | ||
651 | 1160 | "Password to use when connecting to server. If password is not given it's " | ||
652 | 1161 | "asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, | ||
653 | 1162 | {"port", 'p', "Port number to use for connection.", | ||
654 | 1163 | 0, 0, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
655 | 1164 | {"post-query", OPT_SLAP_POST_QUERY, | ||
656 | 1165 | "Query to run or file containing query to execute after tests have completed.", | ||
657 | 1166 | (char**) &user_supplied_post_statements, | ||
658 | 1167 | (char**) &user_supplied_post_statements, | ||
659 | 1168 | 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
660 | 1169 | {"post-system", OPT_SLAP_POST_SYSTEM, | ||
661 | 1170 | "system() string to execute after tests have completed.", | ||
662 | 1171 | (char**) &post_system, | ||
663 | 1172 | (char**) &post_system, | ||
664 | 1173 | 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
665 | 1174 | {"pre-query", OPT_SLAP_PRE_QUERY, | ||
666 | 1175 | "Query to run or file containing query to execute before running tests.", | ||
667 | 1176 | (char**) &user_supplied_pre_statements, | ||
668 | 1177 | (char**) &user_supplied_pre_statements, | ||
669 | 1178 | 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
670 | 1179 | {"pre-system", OPT_SLAP_PRE_SYSTEM, | ||
671 | 1180 | "system() string to execute before running tests.", | ||
672 | 1181 | (char**) &pre_system, | ||
673 | 1182 | (char**) &pre_system, | ||
674 | 1183 | 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
675 | 1184 | {"protocol", OPT_DRIZZLE_PROTOCOL, | ||
676 | 1185 | "The protocol of connection (tcp,socket,pipe,memory).", | ||
677 | 1186 | 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
678 | 1187 | {"query", 'q', "Query to run or file containing query to run.", | ||
679 | 1188 | (char**) &user_supplied_query, (char**) &user_supplied_query, | ||
680 | 1189 | 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
681 | 1190 | {"set-random-seed", OPT_SLAP_SET_RANDOM_SEED, | ||
682 | 1191 | "Seed for random number generator (srandom(3))", | ||
683 | 1192 | (char**)&opt_set_random_seed, | ||
684 | 1193 | (char**)&opt_set_random_seed,0, | ||
685 | 1194 | GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
686 | 1195 | {"silent", 's', "Run program in silent mode - no output.", | ||
687 | 1196 | (char**) &opt_silent, (char**) &opt_silent, 0, GET_BOOL, NO_ARG, | ||
688 | 1197 | 0, 0, 0, 0, 0, 0}, | ||
689 | 1198 | {"timer-length", OPT_SLAP_TIMER_LENGTH, | ||
690 | 1199 | "Require drizzleslap to run each specific test a certain amount of time in seconds.", | ||
691 | 1200 | (char**) &opt_timer_length, (char**) &opt_timer_length, 0, GET_UINT, | ||
692 | 1201 | REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
693 | 1202 | {"user", 'u', "User for login if not current user.", (char**) &user, | ||
694 | 1203 | (char**) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
695 | 1204 | {"verbose", 'v', | ||
696 | 1205 | "More verbose output; you can use this multiple times to get even more " | ||
697 | 1206 | "verbose output.", (char**) &verbose, (char**) &verbose, 0, | ||
698 | 1207 | GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, | ||
699 | 1208 | {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, | ||
700 | 1209 | NO_ARG, 0, 0, 0, 0, 0, 0}, | ||
701 | 1210 | {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} | ||
702 | 1211 | }; | ||
703 | 1212 | |||
704 | 1213 | |||
705 | 1214 | static void print_version(void) | ||
706 | 1215 | { | ||
707 | 1216 | printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION, | ||
708 | 1217 | drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU); | ||
709 | 1218 | } | ||
710 | 1219 | |||
711 | 1220 | |||
712 | 1221 | static void usage(void) | ||
713 | 1222 | { | ||
714 | 1223 | print_version(); | ||
715 | 1224 | puts("Copyright (C) 2008 Sun Microsystems"); | ||
716 | 1225 | puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\ | ||
717 | 1226 | \nand you are welcome to modify and redistribute it under the GPL \ | ||
718 | 1227 | license\n"); | ||
719 | 1228 | puts("Run a query multiple times against the server\n"); | ||
720 | 1229 | printf("Usage: %s [OPTIONS]\n",internal::my_progname); | ||
721 | 1230 | internal::print_defaults("drizzle",load_default_groups); | ||
722 | 1231 | my_print_help(my_long_options); | ||
723 | 1232 | } | ||
724 | 1233 | |||
725 | 1234 | static int get_one_option(int optid, const struct option *, char *argument) | ||
726 | 1235 | { | ||
727 | 1236 | char *endchar= NULL; | ||
728 | 1237 | uint64_t temp_drizzle_port= 0; | ||
729 | 1238 | |||
730 | 1239 | switch(optid) { | ||
731 | 1240 | case 'v': | ||
732 | 1241 | verbose++; | ||
733 | 1242 | break; | ||
734 | 1243 | case 'p': | ||
735 | 1244 | temp_drizzle_port= (uint64_t) strtoul(argument, &endchar, 10); | ||
736 | 1245 | /* if there is an alpha character this is not a valid port */ | ||
737 | 1246 | if (strlen(endchar) != 0) | ||
738 | 1247 | { | ||
739 | 1248 | fprintf(stderr, _("Non-integer value supplied for port. If you are trying to enter a password please use --password instead.\n")); | ||
740 | 1249 | exit(1); | ||
741 | 1250 | } | ||
742 | 1251 | /* If the port number is > 65535 it is not a valid port | ||
743 | 1252 | This also helps with potential data loss casting unsigned long to a | ||
744 | 1253 | uint32_t. */ | ||
745 | 1254 | if ((temp_drizzle_port == 0) || (temp_drizzle_port > 65535)) | ||
746 | 1255 | { | ||
747 | 1256 | fprintf(stderr, _("Value supplied for port is not valid.\n")); | ||
748 | 1257 | exit(1); | ||
749 | 1258 | } | ||
750 | 1259 | else | ||
751 | 1260 | { | ||
752 | 1261 | opt_drizzle_port= (uint32_t) temp_drizzle_port; | ||
753 | 1262 | } | ||
754 | 1263 | break; | ||
755 | 1264 | case 'P': | ||
756 | 1265 | if (argument) | ||
757 | 1266 | { | ||
758 | 1267 | char *start= argument; | ||
759 | 1268 | if (opt_password) | ||
760 | 1269 | free(opt_password); | ||
761 | 1270 | opt_password = strdup(argument); | ||
762 | 1271 | if (opt_password == NULL) | ||
763 | 1272 | { | ||
764 | 1273 | fprintf(stderr, "Memory allocation error while copying password. " | ||
765 | 1274 | "Aborting.\n"); | ||
766 | 1275 | exit(ENOMEM); | ||
767 | 1276 | } | ||
768 | 1277 | while (*argument) | ||
769 | 1278 | { | ||
770 | 1279 | /* Overwriting password with 'x' */ | ||
771 | 1280 | *argument++= 'x'; | ||
772 | 1281 | } | ||
773 | 1282 | if (*start) | ||
774 | 1283 | { | ||
775 | 1284 | /* Cut length of argument */ | ||
776 | 1285 | start[1]= 0; | ||
777 | 1286 | } | ||
778 | 1287 | tty_password= 0; | ||
779 | 1288 | } | ||
780 | 1289 | else | ||
781 | 1290 | tty_password= 1; | ||
782 | 1291 | break; | ||
783 | 1292 | case 'V': | ||
784 | 1293 | print_version(); | ||
785 | 1294 | exit(0); | ||
786 | 1295 | case '?': | ||
787 | 1296 | case 'I': /* Info */ | ||
788 | 1297 | usage(); | ||
789 | 1298 | exit(0); | ||
790 | 1299 | } | ||
791 | 1300 | return(0); | ||
792 | 1301 | } | ||
793 | 1302 | |||
794 | 1303 | 1262 | ||
795 | 1304 | uint | 1263 | uint |
796 | 1305 | get_random_string(char *buf, size_t size) | 1264 | get_random_string(char *buf, size_t size) |
797 | @@ -1698,9 +1657,9 @@ | |||
798 | 1698 | query_string.reserve(HUGE_STRING_LENGTH); | 1657 | query_string.reserve(HUGE_STRING_LENGTH); |
799 | 1699 | 1658 | ||
800 | 1700 | query_string.append("SELECT ", 7); | 1659 | query_string.append("SELECT ", 7); |
802 | 1701 | if (auto_generate_selected_columns_opt) | 1660 | if (!auto_generate_selected_columns_opt.empty()) |
803 | 1702 | { | 1661 | { |
805 | 1703 | query_string.append(auto_generate_selected_columns_opt); | 1662 | query_string.append(auto_generate_selected_columns_opt.c_str()); |
806 | 1704 | } | 1663 | } |
807 | 1705 | else | 1664 | else |
808 | 1706 | { | 1665 | { |
809 | @@ -1777,27 +1736,24 @@ | |||
810 | 1777 | } | 1736 | } |
811 | 1778 | 1737 | ||
812 | 1779 | static int | 1738 | static int |
814 | 1780 | get_options(int *argc,char ***argv) | 1739 | process_options(void) |
815 | 1781 | { | 1740 | { |
816 | 1782 | int ho_error; | ||
817 | 1783 | char *tmp_string; | 1741 | char *tmp_string; |
818 | 1784 | struct stat sbuf; | 1742 | struct stat sbuf; |
819 | 1785 | OptionString *sql_type; | 1743 | OptionString *sql_type; |
820 | 1786 | unsigned int sql_type_count= 0; | 1744 | unsigned int sql_type_count= 0; |
821 | 1787 | ssize_t bytes_read= 0; | 1745 | ssize_t bytes_read= 0; |
829 | 1788 | 1746 | ||
830 | 1789 | 1747 | if (user.empty()) | |
831 | 1790 | if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option))) | 1748 | user= "root"; |
832 | 1791 | exit(ho_error); | 1749 | |
833 | 1792 | 1750 | verbose= opt_verbose.length(); | |
827 | 1793 | if (!user) | ||
828 | 1794 | user= (char *)"root"; | ||
834 | 1795 | 1751 | ||
835 | 1796 | /* If something is created we clean it up, otherwise we leave schemas alone */ | 1752 | /* If something is created we clean it up, otherwise we leave schemas alone */ |
837 | 1797 | if (create_string || auto_generate_sql) | 1753 | if ( (!create_string.empty()) || auto_generate_sql) |
838 | 1798 | opt_preserve= false; | 1754 | opt_preserve= false; |
839 | 1799 | 1755 | ||
841 | 1800 | if (auto_generate_sql && (create_string || user_supplied_query)) | 1756 | if (auto_generate_sql && (!create_string.empty() || !user_supplied_query.empty())) |
842 | 1801 | { | 1757 | { |
843 | 1802 | fprintf(stderr, | 1758 | fprintf(stderr, |
844 | 1803 | "%s: Can't use --auto-generate-sql when create and query strings are specified!\n", | 1759 | "%s: Can't use --auto-generate-sql when create and query strings are specified!\n", |
845 | @@ -1822,9 +1778,9 @@ | |||
846 | 1822 | exit(1); | 1778 | exit(1); |
847 | 1823 | } | 1779 | } |
848 | 1824 | 1780 | ||
850 | 1825 | parse_comma(concurrency_str ? concurrency_str : "1", &concurrency); | 1781 | parse_comma(!concurrency_str.empty() ? concurrency_str.c_str() : "1", &concurrency); |
851 | 1826 | 1782 | ||
853 | 1827 | if (opt_csv_str) | 1783 | if (!opt_csv_str.empty()) |
854 | 1828 | { | 1784 | { |
855 | 1829 | opt_silent= true; | 1785 | opt_silent= true; |
856 | 1830 | 1786 | ||
857 | @@ -1834,11 +1790,11 @@ | |||
858 | 1834 | } | 1790 | } |
859 | 1835 | else | 1791 | else |
860 | 1836 | { | 1792 | { |
862 | 1837 | if ((csv_file= open(opt_csv_str, O_CREAT|O_WRONLY|O_APPEND, | 1793 | if ((csv_file= open(opt_csv_str.c_str(), O_CREAT|O_WRONLY|O_APPEND, |
863 | 1838 | S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) == -1) | 1794 | S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) == -1) |
864 | 1839 | { | 1795 | { |
865 | 1840 | fprintf(stderr,"%s: Could not open csv file: %sn\n", | 1796 | fprintf(stderr,"%s: Could not open csv file: %sn\n", |
867 | 1841 | internal::my_progname, opt_csv_str); | 1797 | internal::my_progname, opt_csv_str.c_str()); |
868 | 1842 | exit(1); | 1798 | exit(1); |
869 | 1843 | } | 1799 | } |
870 | 1844 | } | 1800 | } |
871 | @@ -1847,20 +1803,20 @@ | |||
872 | 1847 | if (opt_only_print) | 1803 | if (opt_only_print) |
873 | 1848 | opt_silent= true; | 1804 | opt_silent= true; |
874 | 1849 | 1805 | ||
876 | 1850 | if (num_int_cols_opt) | 1806 | if (!num_int_cols_opt.empty()) |
877 | 1851 | { | 1807 | { |
878 | 1852 | OptionString *str; | 1808 | OptionString *str; |
880 | 1853 | parse_option(num_int_cols_opt, &str, ','); | 1809 | parse_option(num_int_cols_opt.c_str(), &str, ','); |
881 | 1854 | num_int_cols= atoi(str->getString()); | 1810 | num_int_cols= atoi(str->getString()); |
882 | 1855 | if (str->getOption()) | 1811 | if (str->getOption()) |
883 | 1856 | num_int_cols_index= atoi(str->getOption()); | 1812 | num_int_cols_index= atoi(str->getOption()); |
884 | 1857 | option_cleanup(str); | 1813 | option_cleanup(str); |
885 | 1858 | } | 1814 | } |
886 | 1859 | 1815 | ||
888 | 1860 | if (num_char_cols_opt) | 1816 | if (!num_char_cols_opt.empty()) |
889 | 1861 | { | 1817 | { |
890 | 1862 | OptionString *str; | 1818 | OptionString *str; |
892 | 1863 | parse_option(num_char_cols_opt, &str, ','); | 1819 | parse_option(num_char_cols_opt.c_str(), &str, ','); |
893 | 1864 | num_char_cols= atoi(str->getString()); | 1820 | num_char_cols= atoi(str->getString()); |
894 | 1865 | if (str->getOption()) | 1821 | if (str->getOption()) |
895 | 1866 | num_char_cols_index= atoi(str->getOption()); | 1822 | num_char_cols_index= atoi(str->getOption()); |
896 | @@ -1869,10 +1825,10 @@ | |||
897 | 1869 | option_cleanup(str); | 1825 | option_cleanup(str); |
898 | 1870 | } | 1826 | } |
899 | 1871 | 1827 | ||
901 | 1872 | if (num_blob_cols_opt) | 1828 | if (!num_blob_cols_opt.empty()) |
902 | 1873 | { | 1829 | { |
903 | 1874 | OptionString *str; | 1830 | OptionString *str; |
905 | 1875 | parse_option(num_blob_cols_opt, &str, ','); | 1831 | parse_option(num_blob_cols_opt.c_str(), &str, ','); |
906 | 1876 | num_blob_cols= atoi(str->getString()); | 1832 | num_blob_cols= atoi(str->getString()); |
907 | 1877 | if (str->getOption()) | 1833 | if (str->getOption()) |
908 | 1878 | { | 1834 | { |
909 | @@ -1919,11 +1875,11 @@ | |||
910 | 1919 | if (verbose >= 2) | 1875 | if (verbose >= 2) |
911 | 1920 | printf("Building Query Statements for Auto\n"); | 1876 | printf("Building Query Statements for Auto\n"); |
912 | 1921 | 1877 | ||
914 | 1922 | if (!opt_auto_generate_sql_type) | 1878 | if (opt_auto_generate_sql_type.empty()) |
915 | 1923 | opt_auto_generate_sql_type= "mixed"; | 1879 | opt_auto_generate_sql_type= "mixed"; |
916 | 1924 | 1880 | ||
917 | 1925 | query_statements_count= | 1881 | query_statements_count= |
919 | 1926 | parse_option(opt_auto_generate_sql_type, &query_options, ','); | 1882 | parse_option(opt_auto_generate_sql_type.c_str(), &query_options, ','); |
920 | 1927 | 1883 | ||
921 | 1928 | query_statements= (Statement **)malloc(sizeof(Statement *) * query_statements_count); | 1884 | query_statements= (Statement **)malloc(sizeof(Statement *) * query_statements_count); |
922 | 1929 | if (query_statements == NULL) | 1885 | if (query_statements == NULL) |
923 | @@ -2037,7 +1993,7 @@ | |||
924 | 2037 | } | 1993 | } |
925 | 2038 | else | 1994 | else |
926 | 2039 | { | 1995 | { |
928 | 2040 | if (create_string && !stat(create_string, &sbuf)) | 1996 | if (!create_string.empty() && !stat(create_string.c_str(), &sbuf)) |
929 | 2041 | { | 1997 | { |
930 | 2042 | int data_file; | 1998 | int data_file; |
931 | 2043 | if (!S_ISREG(sbuf.st_mode)) | 1999 | if (!S_ISREG(sbuf.st_mode)) |
932 | @@ -2046,7 +2002,7 @@ | |||
933 | 2046 | internal::my_progname); | 2002 | internal::my_progname); |
934 | 2047 | exit(1); | 2003 | exit(1); |
935 | 2048 | } | 2004 | } |
937 | 2049 | if ((data_file= open(create_string, O_RDWR)) == -1) | 2005 | if ((data_file= open(create_string.c_str(), O_RDWR)) == -1) |
938 | 2050 | { | 2006 | { |
939 | 2051 | fprintf(stderr,"%s: Could not open create file\n", internal::my_progname); | 2007 | fprintf(stderr,"%s: Could not open create file\n", internal::my_progname); |
940 | 2052 | exit(1); | 2008 | exit(1); |
941 | @@ -2074,13 +2030,13 @@ | |||
942 | 2074 | parse_delimiter(tmp_string, &create_statements, delimiter[0]); | 2030 | parse_delimiter(tmp_string, &create_statements, delimiter[0]); |
943 | 2075 | free(tmp_string); | 2031 | free(tmp_string); |
944 | 2076 | } | 2032 | } |
946 | 2077 | else if (create_string) | 2033 | else if (!create_string.empty()) |
947 | 2078 | { | 2034 | { |
949 | 2079 | parse_delimiter(create_string, &create_statements, delimiter[0]); | 2035 | parse_delimiter(create_string.c_str(), &create_statements, delimiter[0]); |
950 | 2080 | } | 2036 | } |
951 | 2081 | 2037 | ||
952 | 2082 | /* Set this up till we fully support options on user generated queries */ | 2038 | /* Set this up till we fully support options on user generated queries */ |
954 | 2083 | if (user_supplied_query) | 2039 | if (!user_supplied_query.empty()) |
955 | 2084 | { | 2040 | { |
956 | 2085 | query_statements_count= | 2041 | query_statements_count= |
957 | 2086 | parse_option("default", &query_options, ','); | 2042 | parse_option("default", &query_options, ','); |
958 | @@ -2094,7 +2050,7 @@ | |||
959 | 2094 | memset(query_statements, 0, sizeof(Statement *) * query_statements_count); | 2050 | memset(query_statements, 0, sizeof(Statement *) * query_statements_count); |
960 | 2095 | } | 2051 | } |
961 | 2096 | 2052 | ||
963 | 2097 | if (user_supplied_query && !stat(user_supplied_query, &sbuf)) | 2053 | if (!user_supplied_query.empty() && !stat(user_supplied_query.c_str(), &sbuf)) |
964 | 2098 | { | 2054 | { |
965 | 2099 | int data_file; | 2055 | int data_file; |
966 | 2100 | if (!S_ISREG(sbuf.st_mode)) | 2056 | if (!S_ISREG(sbuf.st_mode)) |
967 | @@ -2103,7 +2059,7 @@ | |||
968 | 2103 | internal::my_progname); | 2059 | internal::my_progname); |
969 | 2104 | exit(1); | 2060 | exit(1); |
970 | 2105 | } | 2061 | } |
972 | 2106 | if ((data_file= open(user_supplied_query, O_RDWR)) == -1) | 2062 | if ((data_file= open(user_supplied_query.c_str(), O_RDWR)) == -1) |
973 | 2107 | { | 2063 | { |
974 | 2108 | fprintf(stderr,"%s: Could not open query supplied file\n", internal::my_progname); | 2064 | fprintf(stderr,"%s: Could not open query supplied file\n", internal::my_progname); |
975 | 2109 | exit(1); | 2065 | exit(1); |
976 | @@ -2128,20 +2084,20 @@ | |||
977 | 2128 | { | 2084 | { |
978 | 2129 | fprintf(stderr, "Problem reading file: read less bytes than requested\n"); | 2085 | fprintf(stderr, "Problem reading file: read less bytes than requested\n"); |
979 | 2130 | } | 2086 | } |
981 | 2131 | if (user_supplied_query) | 2087 | if (!user_supplied_query.empty()) |
982 | 2132 | actual_queries= parse_delimiter(tmp_string, &query_statements[0], | 2088 | actual_queries= parse_delimiter(tmp_string, &query_statements[0], |
983 | 2133 | delimiter[0]); | 2089 | delimiter[0]); |
984 | 2134 | free(tmp_string); | 2090 | free(tmp_string); |
985 | 2135 | } | 2091 | } |
987 | 2136 | else if (user_supplied_query) | 2092 | else if (!user_supplied_query.empty()) |
988 | 2137 | { | 2093 | { |
990 | 2138 | actual_queries= parse_delimiter(user_supplied_query, &query_statements[0], | 2094 | actual_queries= parse_delimiter(user_supplied_query.c_str(), &query_statements[0], |
991 | 2139 | delimiter[0]); | 2095 | delimiter[0]); |
992 | 2140 | } | 2096 | } |
993 | 2141 | } | 2097 | } |
994 | 2142 | 2098 | ||
997 | 2143 | if (user_supplied_pre_statements | 2099 | if (!user_supplied_pre_statements.empty() |
998 | 2144 | && !stat(user_supplied_pre_statements, &sbuf)) | 2100 | && !stat(user_supplied_pre_statements.c_str(), &sbuf)) |
999 | 2145 | { | 2101 | { |
1000 | 2146 | int data_file; | 2102 | int data_file; |
1001 | 2147 | if (!S_ISREG(sbuf.st_mode)) | 2103 | if (!S_ISREG(sbuf.st_mode)) |
1002 | @@ -2150,7 +2106,7 @@ | |||
1003 | 2150 | internal::my_progname); | 2106 | internal::my_progname); |
1004 | 2151 | exit(1); | 2107 | exit(1); |
1005 | 2152 | } | 2108 | } |
1007 | 2153 | if ((data_file= open(user_supplied_pre_statements, O_RDWR)) == -1) | 2109 | if ((data_file= open(user_supplied_pre_statements.c_str(), O_RDWR)) == -1) |
1008 | 2154 | { | 2110 | { |
1009 | 2155 | fprintf(stderr,"%s: Could not open query supplied file\n", internal::my_progname); | 2111 | fprintf(stderr,"%s: Could not open query supplied file\n", internal::my_progname); |
1010 | 2156 | exit(1); | 2112 | exit(1); |
1011 | @@ -2175,20 +2131,20 @@ | |||
1012 | 2175 | { | 2131 | { |
1013 | 2176 | fprintf(stderr, "Problem reading file: read less bytes than requested\n"); | 2132 | fprintf(stderr, "Problem reading file: read less bytes than requested\n"); |
1014 | 2177 | } | 2133 | } |
1016 | 2178 | if (user_supplied_pre_statements) | 2134 | if (!user_supplied_pre_statements.empty()) |
1017 | 2179 | (void)parse_delimiter(tmp_string, &pre_statements, | 2135 | (void)parse_delimiter(tmp_string, &pre_statements, |
1018 | 2180 | delimiter[0]); | 2136 | delimiter[0]); |
1019 | 2181 | free(tmp_string); | 2137 | free(tmp_string); |
1020 | 2182 | } | 2138 | } |
1022 | 2183 | else if (user_supplied_pre_statements) | 2139 | else if (!user_supplied_pre_statements.empty()) |
1023 | 2184 | { | 2140 | { |
1025 | 2185 | (void)parse_delimiter(user_supplied_pre_statements, | 2141 | (void)parse_delimiter(user_supplied_pre_statements.c_str(), |
1026 | 2186 | &pre_statements, | 2142 | &pre_statements, |
1027 | 2187 | delimiter[0]); | 2143 | delimiter[0]); |
1028 | 2188 | } | 2144 | } |
1029 | 2189 | 2145 | ||
1032 | 2190 | if (user_supplied_post_statements | 2146 | if (!user_supplied_post_statements.empty() |
1033 | 2191 | && !stat(user_supplied_post_statements, &sbuf)) | 2147 | && !stat(user_supplied_post_statements.c_str(), &sbuf)) |
1034 | 2192 | { | 2148 | { |
1035 | 2193 | int data_file; | 2149 | int data_file; |
1036 | 2194 | if (!S_ISREG(sbuf.st_mode)) | 2150 | if (!S_ISREG(sbuf.st_mode)) |
1037 | @@ -2197,7 +2153,7 @@ | |||
1038 | 2197 | internal::my_progname); | 2153 | internal::my_progname); |
1039 | 2198 | exit(1); | 2154 | exit(1); |
1040 | 2199 | } | 2155 | } |
1042 | 2200 | if ((data_file= open(user_supplied_post_statements, O_RDWR)) == -1) | 2156 | if ((data_file= open(user_supplied_post_statements.c_str(), O_RDWR)) == -1) |
1043 | 2201 | { | 2157 | { |
1044 | 2202 | fprintf(stderr,"%s: Could not open query supplied file\n", internal::my_progname); | 2158 | fprintf(stderr,"%s: Could not open query supplied file\n", internal::my_progname); |
1045 | 2203 | exit(1); | 2159 | exit(1); |
1046 | @@ -2224,22 +2180,22 @@ | |||
1047 | 2224 | { | 2180 | { |
1048 | 2225 | fprintf(stderr, "Problem reading file: read less bytes than requested\n"); | 2181 | fprintf(stderr, "Problem reading file: read less bytes than requested\n"); |
1049 | 2226 | } | 2182 | } |
1051 | 2227 | if (user_supplied_post_statements) | 2183 | if (!user_supplied_post_statements.empty()) |
1052 | 2228 | (void)parse_delimiter(tmp_string, &post_statements, | 2184 | (void)parse_delimiter(tmp_string, &post_statements, |
1053 | 2229 | delimiter[0]); | 2185 | delimiter[0]); |
1054 | 2230 | free(tmp_string); | 2186 | free(tmp_string); |
1055 | 2231 | } | 2187 | } |
1057 | 2232 | else if (user_supplied_post_statements) | 2188 | else if (!user_supplied_post_statements.empty()) |
1058 | 2233 | { | 2189 | { |
1060 | 2234 | (void)parse_delimiter(user_supplied_post_statements, &post_statements, | 2190 | (void)parse_delimiter(user_supplied_post_statements.c_str(), &post_statements, |
1061 | 2235 | delimiter[0]); | 2191 | delimiter[0]); |
1062 | 2236 | } | 2192 | } |
1063 | 2237 | 2193 | ||
1064 | 2238 | if (verbose >= 2) | 2194 | if (verbose >= 2) |
1065 | 2239 | printf("Parsing engines to use.\n"); | 2195 | printf("Parsing engines to use.\n"); |
1066 | 2240 | 2196 | ||
1069 | 2241 | if (default_engine) | 2197 | if (!default_engine.empty()) |
1070 | 2242 | parse_option(default_engine, &engine_options, ','); | 2198 | parse_option(default_engine.c_str(), &engine_options, ','); |
1071 | 2243 | 2199 | ||
1072 | 2244 | if (tty_password) | 2200 | if (tty_password) |
1073 | 2245 | opt_password= client_get_tty_password(NULL); | 2201 | opt_password= client_get_tty_password(NULL); |
1074 | @@ -3004,10 +2960,10 @@ | |||
1075 | 3004 | printf("Benchmark\n"); | 2960 | printf("Benchmark\n"); |
1076 | 3005 | if (con->getEngine()) | 2961 | if (con->getEngine()) |
1077 | 3006 | printf("\tRunning for engine %s\n", con->getEngine()); | 2962 | printf("\tRunning for engine %s\n", con->getEngine()); |
1079 | 3007 | if (opt_label || opt_auto_generate_sql_type) | 2963 | if (!opt_label.empty() || !opt_auto_generate_sql_type.empty()) |
1080 | 3008 | { | 2964 | { |
1083 | 3009 | const char *ptr= opt_auto_generate_sql_type ? opt_auto_generate_sql_type : "query"; | 2965 | const char *ptr= opt_auto_generate_sql_type.c_str() ? opt_auto_generate_sql_type.c_str() : "query"; |
1084 | 3010 | printf("\tLoad: %s\n", opt_label ? opt_label : ptr); | 2966 | printf("\tLoad: %s\n", !opt_label.empty() ? opt_label.c_str() : ptr); |
1085 | 3011 | } | 2967 | } |
1086 | 3012 | printf("\tAverage Time took to generate schema and initial data: %ld.%03ld seconds\n", | 2968 | printf("\tAverage Time took to generate schema and initial data: %ld.%03ld seconds\n", |
1087 | 3013 | con->getCreateAvgTiming() / 1000, con->getCreateAvgTiming() % 1000); | 2969 | con->getCreateAvgTiming() / 1000, con->getCreateAvgTiming() % 1000); |
1088 | @@ -3035,24 +2991,25 @@ | |||
1089 | 3035 | char buffer[HUGE_STRING_LENGTH]; | 2991 | char buffer[HUGE_STRING_LENGTH]; |
1090 | 3036 | char label_buffer[HUGE_STRING_LENGTH]; | 2992 | char label_buffer[HUGE_STRING_LENGTH]; |
1091 | 3037 | size_t string_len; | 2993 | size_t string_len; |
1092 | 2994 | const char *temp_label= opt_label.c_str(); | ||
1093 | 3038 | 2995 | ||
1094 | 3039 | memset(label_buffer, 0, HUGE_STRING_LENGTH); | 2996 | memset(label_buffer, 0, HUGE_STRING_LENGTH); |
1095 | 3040 | 2997 | ||
1097 | 3041 | if (opt_label) | 2998 | if (!opt_label.empty()) |
1098 | 3042 | { | 2999 | { |
1100 | 3043 | string_len= strlen(opt_label); | 3000 | string_len= opt_label.length(); |
1101 | 3044 | 3001 | ||
1102 | 3045 | for (x= 0; x < string_len; x++) | 3002 | for (x= 0; x < string_len; x++) |
1103 | 3046 | { | 3003 | { |
1105 | 3047 | if (opt_label[x] == ',') | 3004 | if (temp_label[x] == ',') |
1106 | 3048 | label_buffer[x]= '-'; | 3005 | label_buffer[x]= '-'; |
1107 | 3049 | else | 3006 | else |
1109 | 3050 | label_buffer[x]= opt_label[x] ; | 3007 | label_buffer[x]= temp_label[x] ; |
1110 | 3051 | } | 3008 | } |
1111 | 3052 | } | 3009 | } |
1113 | 3053 | else if (opt_auto_generate_sql_type) | 3010 | else if (!opt_auto_generate_sql_type.empty()) |
1114 | 3054 | { | 3011 | { |
1116 | 3055 | string_len= strlen(opt_auto_generate_sql_type); | 3012 | string_len= opt_auto_generate_sql_type.length(); |
1117 | 3056 | 3013 | ||
1118 | 3057 | for (x= 0; x < string_len; x++) | 3014 | for (x= 0; x < string_len; x++) |
1119 | 3058 | { | 3015 | { |
1120 | @@ -3198,9 +3155,9 @@ | |||
1121 | 3198 | usleep(random()%opt_delayed_start); | 3155 | usleep(random()%opt_delayed_start); |
1122 | 3199 | 3156 | ||
1123 | 3200 | if ((drizzle= drizzle_create(NULL)) == NULL || | 3157 | if ((drizzle= drizzle_create(NULL)) == NULL || |
1127 | 3201 | drizzle_con_add_tcp(drizzle, con, host, opt_drizzle_port, user, | 3158 | drizzle_con_add_tcp(drizzle, con, host.c_str(), opt_drizzle_port, user.c_str(), |
1128 | 3202 | opt_password, | 3159 | opt_password.c_str(), |
1129 | 3203 | connect_to_schema ? create_schema_string : NULL, | 3160 | connect_to_schema ? create_schema_string.c_str() : NULL, |
1130 | 3204 | opt_mysql ? DRIZZLE_CON_MYSQL : DRIZZLE_CON_NONE) == NULL) | 3161 | opt_mysql ? DRIZZLE_CON_MYSQL : DRIZZLE_CON_NONE) == NULL) |
1131 | 3205 | { | 3162 | { |
1132 | 3206 | fprintf(stderr,"%s: Error creating drizzle object\n", internal::my_progname); | 3163 | fprintf(stderr,"%s: Error creating drizzle object\n", internal::my_progname); |
1133 | 3207 | 3164 | ||
1134 | === modified file 'client/include.am' | |||
1135 | --- client/include.am 2010-01-11 23:50:15 +0000 | |||
1136 | +++ client/include.am 2010-06-02 21:23:22 +0000 | |||
1137 | @@ -10,6 +10,10 @@ | |||
1138 | 10 | gnulib/libgnu.la \ | 10 | gnulib/libgnu.la \ |
1139 | 11 | client/libgetpassword.la | 11 | client/libgetpassword.la |
1140 | 12 | 12 | ||
1141 | 13 | CLIENT_CXXFLAGS= \ | ||
1142 | 14 | ${AM_CXXFLAGS} \ | ||
1143 | 15 | ${BOOSTSKIP_WARNINGS} | ||
1144 | 16 | |||
1145 | 13 | noinst_LTLIBRARIES+= \ | 17 | noinst_LTLIBRARIES+= \ |
1146 | 14 | client/libgetpassword.la | 18 | client/libgetpassword.la |
1147 | 15 | 19 | ||
1148 | @@ -42,16 +46,22 @@ | |||
1149 | 42 | 46 | ||
1150 | 43 | client_drizzle_SOURCES= client/drizzle.cc client/linebuffer.cc | 47 | client_drizzle_SOURCES= client/drizzle.cc client/linebuffer.cc |
1151 | 44 | client_drizzle_LDADD= ${CLIENT_LDADD} ${READLINE_LIBS} | 48 | client_drizzle_LDADD= ${CLIENT_LDADD} ${READLINE_LIBS} |
1152 | 49 | client_drizzle_CXXFLAGS= ${CLIENT_CXXFLAGS} | ||
1153 | 45 | 50 | ||
1154 | 46 | client_drizzledump_SOURCES= client/drizzledump.cc | 51 | client_drizzledump_SOURCES= client/drizzledump.cc |
1155 | 47 | client_drizzledump_LDADD= ${CLIENT_LDADD} | 52 | client_drizzledump_LDADD= ${CLIENT_LDADD} |
1156 | 53 | client_drizzledump_CXXFLAGS= ${CLIENT_CXXFLAGS} | ||
1157 | 48 | 54 | ||
1158 | 49 | client_drizzleimport_SOURCES= client/drizzleimport.cc | 55 | client_drizzleimport_SOURCES= client/drizzleimport.cc |
1160 | 50 | client_drizzleimport_LDADD= ${CLIENT_LDADD} | 56 | client_drizzleimport_LDADD= ${CLIENT_LDADD} |
1161 | 57 | client_drizzleimport_CXXFLAGS= ${CLIENT_CXXFLAGS} | ||
1162 | 51 | 58 | ||
1163 | 52 | client_drizzleslap_SOURCES= client/drizzleslap.cc | 59 | client_drizzleslap_SOURCES= client/drizzleslap.cc |
1165 | 53 | client_drizzleslap_LDADD= ${CLIENT_LDADD} | 60 | client_drizzleslap_LDADD= ${CLIENT_LDADD} ${BOOST_LIBS} |
1166 | 61 | client_drizzleslap_CXXFLAGS= ${CLIENT_CXXFLAGS} | ||
1167 | 54 | 62 | ||
1168 | 55 | client_drizzletest_SOURCES= client/drizzletest.cc client/errname.cc | 63 | client_drizzletest_SOURCES= client/drizzletest.cc client/errname.cc |
1169 | 56 | client_drizzletest_LDADD= ${CLIENT_LDADD} ${LIBPCRE} | 64 | client_drizzletest_LDADD= ${CLIENT_LDADD} ${LIBPCRE} |
1170 | 65 | client_drizzletest_CXXFLAGS= ${CLIENT_CXXFLAGS} | ||
1171 | 66 | |||
1172 | 57 | 67 | ||
1173 | 58 | 68 | ||
1174 | === modified file 'm4/pandora_warnings.m4' | |||
1175 | --- m4/pandora_warnings.m4 2010-06-01 20:26:16 +0000 | |||
1176 | +++ m4/pandora_warnings.m4 2010-06-02 21:23:22 +0000 | |||
1177 | @@ -293,7 +293,9 @@ | |||
1178 | 293 | PROTOSKIP_WARNINGS="-Wno-effc++ -Wno-shadow -Wno-missing-braces ${NO_ATTRIBUTES}" | 293 | PROTOSKIP_WARNINGS="-Wno-effc++ -Wno-shadow -Wno-missing-braces ${NO_ATTRIBUTES}" |
1179 | 294 | NO_WERROR="-Wno-error" | 294 | NO_WERROR="-Wno-error" |
1180 | 295 | INNOBASE_SKIP_WARNINGS="-Wno-shadow -Wno-cast-align" | 295 | INNOBASE_SKIP_WARNINGS="-Wno-shadow -Wno-cast-align" |
1182 | 296 | 296 | AS_IF([test "$host_vendor" = "apple"],[ | |
1183 | 297 | BOOSTSKIP_WARNINGS="-Wno-uninitialized" | ||
1184 | 298 | ]) | ||
1185 | 297 | ]) | 299 | ]) |
1186 | 298 | ]) | 300 | ]) |
1187 | 299 | 301 | ||
1188 | @@ -334,7 +336,7 @@ | |||
1189 | 334 | CC_WARNINGS="-v -errtags=yes ${W_FAIL} ${CC_WARNINGS_FULL} ${CFLAG_VISIBILITY}" | 336 | CC_WARNINGS="-v -errtags=yes ${W_FAIL} ${CC_WARNINGS_FULL} ${CFLAG_VISIBILITY}" |
1190 | 335 | CXX_WARNINGS="+w +w2 -xwe -xport64 -errtags=yes ${CXX_WARNINGS_FULL} ${W_FAIL} ${CFLAG_VISIBILITY}" | 337 | CXX_WARNINGS="+w +w2 -xwe -xport64 -errtags=yes ${CXX_WARNINGS_FULL} ${W_FAIL} ${CFLAG_VISIBILITY}" |
1191 | 336 | PROTOSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn,partinit,notused,badargtype2w,wbadinit" | 338 | PROTOSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn,partinit,notused,badargtype2w,wbadinit" |
1193 | 337 | BOOSTSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint,hidef" | 339 | BOOSTSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint,hidef,wvarhidenmem" |
1194 | 338 | NO_UNREACHED="-erroff=E_STATEMENT_NOT_REACHED" | 340 | NO_UNREACHED="-erroff=E_STATEMENT_NOT_REACHED" |
1195 | 339 | NO_WERROR="-errwarn=%none" | 341 | NO_WERROR="-errwarn=%none" |
1196 | 340 | 342 | ||
1197 | 341 | 343 | ||
1198 | === modified file 'tests/t/drizzleslap.test' | |||
1199 | --- tests/t/drizzleslap.test 2009-12-01 17:50:17 +0000 | |||
1200 | +++ tests/t/drizzleslap.test 2010-06-02 21:23:22 +0000 | |||
1201 | @@ -44,7 +44,7 @@ | |||
1202 | 44 | 44 | ||
1203 | 45 | --exec $DRIZZLE_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=write --timer-length=1 --commit=100 | 45 | --exec $DRIZZLE_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=write --timer-length=1 --commit=100 |
1204 | 46 | 46 | ||
1206 | 47 | --exec $DRIZZLE_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=write --delayed_start=1234 --commit=100 | 47 | --exec $DRIZZLE_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=write --delayed-start=1234 --commit=100 |
1207 | 48 | 48 | ||
1208 | 49 | --exec $DRIZZLE_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=write --number-blob-cols=2:1024/2048 --commit=100 | 49 | --exec $DRIZZLE_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=write --number-blob-cols=2:1024/2048 --commit=100 |
1209 | 50 | 50 |
Quick note, please remove the commented out code.
Thanks!