381
by Monty Taylor
Reformatted slap and test. |
1 |
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2008 MySQL
|
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; either version 2 of the License, or
|
|
9 |
* (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 |
*/
|
|
1
by brian
clean slate |
20 |
|
21 |
||
22 |
/*
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
23 |
Drizzle Slap
|
1
by brian
clean slate |
24 |
|
25 |
A simple program designed to work as if multiple clients querying the database,
|
|
26 |
then reporting the timing of each stage.
|
|
27 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
28 |
Drizzle slap runs three stages:
|
1
by brian
clean slate |
29 |
1) Create schema,table, and optionally any SP or data you want to beign
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
30 |
the test with. (single client)
|
1
by brian
clean slate |
31 |
2) Load test (many clients)
|
32 |
3) Cleanup (disconnection, drop table if specified, single client)
|
|
33 |
||
34 |
Examples:
|
|
35 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
36 |
Supply your own create and query SQL statements, with 50 clients
|
1
by brian
clean slate |
37 |
querying (200 selects for each):
|
38 |
||
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
39 |
drizzleslap --delimiter=";" \
|
40 |
--create="CREATE TABLE A (a int);INSERT INTO A VALUES (23)" \
|
|
41 |
--query="SELECT * FROM A" --concurrency=50 --iterations=200
|
|
1
by brian
clean slate |
42 |
|
43 |
Let the program build the query SQL statement with a table of two int
|
|
44 |
columns, three varchar columns, five clients querying (20 times each),
|
|
45 |
don't create the table or insert the data (using the previous test's
|
|
46 |
schema and data):
|
|
47 |
||
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
48 |
drizzleslap --concurrency=5 --iterations=20 \
|
49 |
--number-int-cols=2 --number-char-cols=3 \
|
|
50 |
--auto-generate-sql
|
|
1
by brian
clean slate |
51 |
|
52 |
Tell the program to load the create, insert and query SQL statements from
|
|
53 |
the specified files, where the create.sql file has multiple table creation
|
|
54 |
statements delimited by ';' and multiple insert statements delimited by ';'.
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
55 |
The --query file will have multiple queries delimited by ';', run all the
|
1
by brian
clean slate |
56 |
load statements, and then run all the queries in the query file
|
57 |
with five clients (five times each):
|
|
58 |
||
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
59 |
drizzleslap --concurrency=5 \
|
60 |
--iterations=5 --query=query.sql --create=create.sql \
|
|
61 |
--delimiter=";"
|
|
1
by brian
clean slate |
62 |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
63 |
TODO:
|
1
by brian
clean slate |
64 |
Add language for better tests
|
65 |
String length for files and those put on the command line are not
|
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
66 |
setup to handle binary data.
|
1
by brian
clean slate |
67 |
More stats
|
68 |
Break up tests and run them on multiple hosts at once.
|
|
69 |
Allow output to be fed into a database directly.
|
|
70 |
||
71 |
*/
|
|
72 |
||
1531.3.1
by Monty Taylor
Fixed the centos issue. |
73 |
#include "config.h" |
1
by brian
clean slate |
74 |
|
75 |
#include "client_priv.h" |
|
76 |
#include <signal.h> |
|
77 |
#include <stdarg.h> |
|
78 |
#include <sys/types.h> |
|
79 |
#include <sys/wait.h> |
|
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
80 |
#ifdef HAVE_SYS_STAT_H
|
81 |
# include <sys/stat.h>
|
|
82 |
#endif
|
|
83 |
#include <fcntl.h> |
|
84 |
#include <math.h> |
|
85 |
#include <cassert> |
|
86 |
#include <cstdlib> |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
87 |
#include <string> |
1531.2.1
by Vijay Samuel
Slap refactored |
88 |
#include <iostream> |
1531.2.27
by Vijay Samuel
Slap completely refactored with boost::program_options. |
89 |
#include <fstream> |
1241.9.58
by Monty Taylor
Dear god. I think we're not including anything from mysys in drizzled anymore. |
90 |
#include <pthread.h> |
1531.2.27
by Vijay Samuel
Slap completely refactored with boost::program_options. |
91 |
#include <drizzled/configmake.h> |
673.5.13
by Andrew Hutchings
Apply -p means port changes to all client apps |
92 |
/* Added this for string translation. */
|
93 |
#include <drizzled/gettext.h> |
|
1531.3.1
by Monty Taylor
Fixed the centos issue. |
94 |
#include <boost/program_options.hpp> |
95 |
||
96 |
#define SLAP_VERSION "1.5"
|
|
97 |
||
98 |
#define HUGE_STRING_LENGTH 8196
|
|
99 |
#define RAND_STRING_SIZE 126
|
|
100 |
#define DEFAULT_BLOB_SIZE 1024
|
|
673.5.13
by Andrew Hutchings
Apply -p means port changes to all client apps |
101 |
|
398.1.5
by Monty Taylor
Removed C++ includes and std namespace from global.h. |
102 |
using namespace std; |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
103 |
using namespace drizzled; |
1531.3.1
by Monty Taylor
Fixed the centos issue. |
104 |
namespace po= boost::program_options; |
398.1.5
by Monty Taylor
Removed C++ includes and std namespace from global.h. |
105 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
106 |
#ifdef HAVE_SMEM
|
1
by brian
clean slate |
107 |
static char *shared_memory_base_name=0; |
108 |
#endif
|
|
109 |
||
110 |
/* Global Thread counter */
|
|
893
by Brian Aker
First pass of stripping uint |
111 |
uint32_t thread_counter; |
1
by brian
clean slate |
112 |
pthread_mutex_t counter_mutex; |
113 |
pthread_cond_t count_threshhold; |
|
893
by Brian Aker
First pass of stripping uint |
114 |
uint32_t master_wakeup; |
1
by brian
clean slate |
115 |
pthread_mutex_t sleeper_mutex; |
116 |
pthread_cond_t sleep_threshhold; |
|
117 |
||
118 |
/* Global Thread timer */
|
|
163
by Brian Aker
Merge Monty's code. |
119 |
static bool timer_alarm= false; |
1
by brian
clean slate |
120 |
pthread_mutex_t timer_alarm_mutex; |
121 |
pthread_cond_t timer_alarm_threshold; |
|
122 |
||
123 |
char **primary_keys; |
|
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
124 |
/* This gets passed to malloc, so lets set it to an arch-dependant size */
|
125 |
size_t primary_keys_number_of; |
|
1
by brian
clean slate |
126 |
|
1531.2.5
by Vijay Samuel
Updated slap |
127 |
static string host, |
128 |
opt_password, |
|
129 |
user, |
|
130 |
user_supplied_query, |
|
131 |
user_supplied_pre_statements, |
|
132 |
user_supplied_post_statements, |
|
133 |
default_engine, |
|
134 |
pre_system, |
|
135 |
post_system; |
|
136 |
||
1531.2.10
by Vijay Samuel
Slap refactored with boost::program_options. |
137 |
static vector<string> user_supplied_queries; |
1531.2.18
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
138 |
static string opt_verbose; |
1531.2.5
by Vijay Samuel
Updated slap |
139 |
string delimiter; |
140 |
||
141 |
string create_schema_string; |
|
142 |
||
143 |
static bool opt_mysql; |
|
163
by Brian Aker
Merge Monty's code. |
144 |
static bool opt_preserve= true; |
1531.2.5
by Vijay Samuel
Updated slap |
145 |
static bool opt_only_print; |
146 |
static bool opt_burnin; |
|
163
by Brian Aker
Merge Monty's code. |
147 |
static bool opt_ignore_sql_errors= false; |
1235.3.4
by Stewart Smith
remove outdated --compress option from drizzleslap |
148 |
static bool tty_password= false, |
1531.2.5
by Vijay Samuel
Updated slap |
149 |
opt_silent, |
150 |
auto_generate_sql_autoincrement, |
|
151 |
auto_generate_sql_guid_primary, |
|
152 |
auto_generate_sql; |
|
153 |
std::string opt_auto_generate_sql_type; |
|
1
by brian
clean slate |
154 |
|
1531.2.19
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
155 |
static int32_t verbose= 0; |
1531.2.11
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
156 |
static uint32_t delimiter_length; |
893
by Brian Aker
First pass of stripping uint |
157 |
static uint32_t commit_rate; |
158 |
static uint32_t detach_rate; |
|
159 |
static uint32_t opt_timer_length; |
|
160 |
static uint32_t opt_delayed_start; |
|
1531.2.8
by Vijay Samuel
Updated Slap |
161 |
string num_blob_cols_opt, |
162 |
num_char_cols_opt, |
|
163 |
num_int_cols_opt; |
|
1531.2.1
by Vijay Samuel
Slap refactored |
164 |
string opt_label; |
1
by brian
clean slate |
165 |
static unsigned int opt_set_random_seed; |
166 |
||
1531.2.2
by Vijay Samuel
Updated slap code |
167 |
string auto_generate_selected_columns_opt; |
1
by brian
clean slate |
168 |
|
169 |
/* Yes, we do set defaults here */
|
|
1531.2.9
by Vijay Samuel
updated slap |
170 |
static unsigned int num_int_cols= 1; |
171 |
static unsigned int num_char_cols= 1; |
|
172 |
static unsigned int num_blob_cols= 0; |
|
1
by brian
clean slate |
173 |
static unsigned int num_blob_cols_size; |
174 |
static unsigned int num_blob_cols_size_min; |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
175 |
static unsigned int num_int_cols_index= 0; |
1
by brian
clean slate |
176 |
static unsigned int num_char_cols_index= 0; |
1531.2.11
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
177 |
static uint32_t iterations; |
151
by Brian Aker
Ulonglong to uint64_t |
178 |
static uint64_t actual_queries= 0; |
179 |
static uint64_t auto_actual_queries; |
|
180 |
static uint64_t auto_generate_sql_unique_write_number; |
|
181 |
static uint64_t auto_generate_sql_unique_query_number; |
|
1531.2.11
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
182 |
static uint32_t auto_generate_sql_secondary_indexes; |
151
by Brian Aker
Ulonglong to uint64_t |
183 |
static uint64_t num_of_query; |
1531.3.1
by Monty Taylor
Fixed the centos issue. |
184 |
static uint64_t auto_generate_sql_number; |
1531.2.5
by Vijay Samuel
Updated slap |
185 |
string concurrency_str; |
186 |
string create_string; |
|
893
by Brian Aker
First pass of stripping uint |
187 |
uint32_t *concurrency; |
1
by brian
clean slate |
188 |
|
673.5.13
by Andrew Hutchings
Apply -p means port changes to all client apps |
189 |
const char *default_dbug_option= "d:t:o,/tmp/drizzleslap.trace"; |
1531.2.1
by Vijay Samuel
Slap refactored |
190 |
std::string opt_csv_str; |
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
191 |
int csv_file; |
1
by brian
clean slate |
192 |
|
1531.2.11
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
193 |
static int process_options(void); |
1531.2.9
by Vijay Samuel
updated slap |
194 |
static uint32_t opt_drizzle_port= 0; |
1
by brian
clean slate |
195 |
|
196 |
||
197 |
/* Types */
|
|
198 |
typedef enum { |
|
199 |
SELECT_TYPE= 0, |
|
200 |
UPDATE_TYPE= 1, |
|
201 |
INSERT_TYPE= 2, |
|
202 |
UPDATE_TYPE_REQUIRES_PREFIX= 3, |
|
203 |
CREATE_TABLE_TYPE= 4, |
|
204 |
SELECT_TYPE_REQUIRES_PREFIX= 5, |
|
205 |
DELETE_TYPE_REQUIRES_PREFIX= 6 |
|
206 |
} slap_query_type; |
|
207 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
208 |
class Statement; |
209 |
||
210 |
class Statement |
|
211 |
{
|
|
212 |
public: |
|
213 |
Statement(char *in_string, |
|
214 |
size_t in_length, |
|
215 |
slap_query_type in_type, |
|
216 |
char *in_option, |
|
217 |
size_t in_option_length, |
|
218 |
Statement *in_next) |
|
219 |
:
|
|
220 |
string(in_string), |
|
221 |
length(in_length), |
|
222 |
type(in_type), |
|
223 |
option(in_option), |
|
224 |
option_length(in_option_length), |
|
225 |
next(in_next) |
|
226 |
{}
|
|
227 |
||
228 |
Statement() |
|
229 |
:
|
|
230 |
string(NULL), |
|
231 |
length(0), |
|
232 |
type(), |
|
233 |
option(NULL), |
|
234 |
option_length(0), |
|
235 |
next(NULL) |
|
236 |
{}
|
|
237 |
||
238 |
char *getString() const |
|
239 |
{
|
|
240 |
return string; |
|
241 |
}
|
|
242 |
||
243 |
size_t getLength() const |
|
244 |
{
|
|
245 |
return length; |
|
246 |
}
|
|
247 |
||
248 |
slap_query_type getType() const |
|
249 |
{
|
|
250 |
return type; |
|
251 |
}
|
|
252 |
||
253 |
char *getOption() const |
|
254 |
{
|
|
255 |
return option; |
|
256 |
}
|
|
257 |
||
258 |
size_t getOptionLength() const |
|
259 |
{
|
|
260 |
return option_length; |
|
261 |
}
|
|
262 |
||
263 |
Statement *getNext() const |
|
264 |
{
|
|
265 |
return next; |
|
266 |
}
|
|
267 |
||
268 |
void setString(char *in_string) |
|
269 |
{
|
|
270 |
string= in_string; |
|
271 |
}
|
|
272 |
||
273 |
void setString(size_t in_length, char in_char) |
|
274 |
{
|
|
275 |
string[in_length]= in_char; |
|
276 |
}
|
|
277 |
||
278 |
void setLength(size_t in_length) |
|
279 |
{
|
|
280 |
length= in_length; |
|
281 |
}
|
|
282 |
||
283 |
void setType(slap_query_type in_type) |
|
284 |
{
|
|
285 |
type= in_type; |
|
286 |
}
|
|
287 |
||
288 |
void setOption(char *in_option) |
|
289 |
{
|
|
290 |
option= in_option; |
|
291 |
}
|
|
292 |
||
293 |
void setOptionLength(size_t in_option_length) |
|
294 |
{
|
|
295 |
option_length= in_option_length; |
|
296 |
}
|
|
297 |
||
298 |
void setNext(Statement *in_next) |
|
299 |
{
|
|
300 |
next= in_next; |
|
301 |
}
|
|
302 |
||
303 |
private: |
|
1
by brian
clean slate |
304 |
char *string; |
305 |
size_t length; |
|
306 |
slap_query_type type; |
|
307 |
char *option; |
|
308 |
size_t option_length; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
309 |
Statement *next; |
1
by brian
clean slate |
310 |
};
|
311 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
312 |
class OptionString; |
313 |
||
314 |
class OptionString |
|
315 |
{
|
|
316 |
public: |
|
317 |
OptionString(char *in_string, |
|
318 |
size_t in_length, |
|
319 |
char *in_option, |
|
320 |
size_t in_option_length, |
|
321 |
OptionString *in_next) |
|
322 |
:
|
|
323 |
string(in_string), |
|
324 |
length(in_length), |
|
325 |
option(in_option), |
|
326 |
option_length(in_option_length), |
|
327 |
next(in_next) |
|
328 |
{}
|
|
329 |
||
330 |
OptionString() |
|
331 |
:
|
|
332 |
string(NULL), |
|
333 |
length(0), |
|
334 |
option(NULL), |
|
335 |
option_length(0), |
|
336 |
next(NULL) |
|
337 |
{}
|
|
338 |
||
339 |
char *getString() const |
|
340 |
{
|
|
341 |
return string; |
|
342 |
}
|
|
343 |
||
344 |
size_t getLength() const |
|
345 |
{
|
|
346 |
return length; |
|
347 |
}
|
|
348 |
||
349 |
char *getOption() const |
|
350 |
{
|
|
351 |
return option; |
|
352 |
}
|
|
353 |
||
354 |
size_t getOptionLength() const |
|
355 |
{
|
|
356 |
return option_length; |
|
357 |
}
|
|
358 |
||
359 |
OptionString *getNext() const |
|
360 |
{
|
|
361 |
return next; |
|
362 |
}
|
|
363 |
||
364 |
void setString(char *in_string) |
|
365 |
{
|
|
366 |
string= in_string; |
|
367 |
}
|
|
368 |
||
369 |
void setOptionLength(size_t in_option_length) |
|
370 |
{
|
|
371 |
option_length= in_option_length; |
|
372 |
}
|
|
373 |
||
374 |
void setLength(size_t in_length) |
|
375 |
{
|
|
376 |
length= in_length; |
|
377 |
}
|
|
378 |
||
379 |
void setOption(char *in_option) |
|
380 |
{
|
|
381 |
option= in_option; |
|
382 |
}
|
|
383 |
||
384 |
void setOption(size_t in_option_length, char in_char) |
|
385 |
{
|
|
386 |
option[in_option_length]= in_char; |
|
387 |
}
|
|
388 |
||
389 |
void setNext(OptionString *in_next) |
|
390 |
{
|
|
391 |
next= in_next; |
|
392 |
}
|
|
393 |
||
394 |
private: |
|
1
by brian
clean slate |
395 |
char *string; |
396 |
size_t length; |
|
397 |
char *option; |
|
398 |
size_t option_length; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
399 |
OptionString *next; |
1
by brian
clean slate |
400 |
};
|
401 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
402 |
class Stats; |
403 |
||
404 |
class Stats |
|
405 |
{
|
|
406 |
public: |
|
407 |
Stats(long int in_timing, |
|
408 |
uint32_t in_users, |
|
409 |
uint32_t in_real_users, |
|
410 |
uint32_t in_rows, |
|
411 |
long int in_create_timing, |
|
412 |
uint64_t in_create_count) |
|
413 |
:
|
|
414 |
timing(in_timing), |
|
415 |
users(in_users), |
|
416 |
real_users(in_real_users), |
|
417 |
rows(in_rows), |
|
418 |
create_timing(in_create_timing), |
|
419 |
create_count(in_create_count) |
|
420 |
{}
|
|
421 |
||
422 |
Stats() |
|
423 |
:
|
|
424 |
timing(0), |
|
425 |
users(0), |
|
426 |
real_users(0), |
|
1531.2.11
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
427 |
rows(0), |
1441.3.1
by Vijay Samuel
all required updations have been made |
428 |
create_timing(0), |
429 |
create_count(0) |
|
430 |
{}
|
|
431 |
||
432 |
long int getTiming() const |
|
433 |
{
|
|
434 |
return timing; |
|
435 |
}
|
|
436 |
||
437 |
uint32_t getUsers() const |
|
438 |
{
|
|
439 |
return users; |
|
440 |
}
|
|
441 |
||
442 |
uint32_t getRealUsers() const |
|
443 |
{
|
|
444 |
return real_users; |
|
445 |
}
|
|
446 |
||
447 |
uint64_t getRows() const |
|
448 |
{
|
|
449 |
return rows; |
|
450 |
}
|
|
451 |
||
452 |
long int getCreateTiming() const |
|
453 |
{
|
|
454 |
return create_timing; |
|
455 |
}
|
|
456 |
||
457 |
uint64_t getCreateCount() const |
|
458 |
{
|
|
459 |
return create_count; |
|
460 |
}
|
|
461 |
||
462 |
void setTiming(long int in_timing) |
|
463 |
{
|
|
464 |
timing= in_timing; |
|
465 |
}
|
|
466 |
||
467 |
void setUsers(uint32_t in_users) |
|
468 |
{
|
|
469 |
users= in_users; |
|
470 |
}
|
|
471 |
||
472 |
void setRealUsers(uint32_t in_real_users) |
|
473 |
{
|
|
474 |
real_users= in_real_users; |
|
475 |
}
|
|
476 |
||
477 |
void setRows(uint64_t in_rows) |
|
478 |
{
|
|
479 |
rows= in_rows; |
|
480 |
}
|
|
481 |
||
482 |
void setCreateTiming(long int in_create_timing) |
|
483 |
{
|
|
484 |
create_timing= in_create_timing; |
|
485 |
}
|
|
486 |
||
487 |
void setCreateCount(uint64_t in_create_count) |
|
488 |
{
|
|
489 |
create_count= in_create_count; |
|
490 |
}
|
|
491 |
||
492 |
private: |
|
1
by brian
clean slate |
493 |
long int timing; |
893
by Brian Aker
First pass of stripping uint |
494 |
uint32_t users; |
495 |
uint32_t real_users; |
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
496 |
uint64_t rows; |
1
by brian
clean slate |
497 |
long int create_timing; |
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
498 |
uint64_t create_count; |
1
by brian
clean slate |
499 |
};
|
500 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
501 |
class ThreadContext; |
502 |
||
503 |
class ThreadContext |
|
504 |
{
|
|
505 |
public: |
|
506 |
ThreadContext(Statement *in_stmt, |
|
507 |
uint64_t in_limit) |
|
508 |
:
|
|
509 |
stmt(in_stmt), |
|
510 |
limit(in_limit) |
|
511 |
{}
|
|
512 |
||
513 |
ThreadContext() |
|
514 |
:
|
|
515 |
stmt(), |
|
516 |
limit(0) |
|
517 |
{}
|
|
518 |
||
519 |
Statement *getStmt() const |
|
520 |
{
|
|
521 |
return stmt; |
|
522 |
}
|
|
523 |
||
524 |
uint64_t getLimit() const |
|
525 |
{
|
|
526 |
return limit; |
|
527 |
}
|
|
528 |
||
529 |
void setStmt(Statement *in_stmt) |
|
530 |
{
|
|
531 |
stmt= in_stmt; |
|
532 |
}
|
|
533 |
||
534 |
void setLimit(uint64_t in_limit) |
|
535 |
{
|
|
536 |
limit= in_limit; |
|
537 |
}
|
|
538 |
||
539 |
private: |
|
540 |
Statement *stmt; |
|
151
by Brian Aker
Ulonglong to uint64_t |
541 |
uint64_t limit; |
1
by brian
clean slate |
542 |
};
|
543 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
544 |
class Conclusions; |
545 |
||
546 |
class Conclusions |
|
547 |
{
|
|
548 |
||
549 |
public: |
|
550 |
Conclusions(char *in_engine, |
|
551 |
long int in_avg_timing, |
|
552 |
long int in_max_timing, |
|
553 |
long int in_min_timing, |
|
554 |
uint32_t in_users, |
|
555 |
uint32_t in_real_users, |
|
556 |
uint64_t in_avg_rows, |
|
557 |
long int in_sum_of_time, |
|
558 |
long int in_std_dev, |
|
559 |
long int in_create_avg_timing, |
|
560 |
long int in_create_max_timing, |
|
561 |
long int in_create_min_timing, |
|
562 |
uint64_t in_create_count, |
|
563 |
uint64_t in_max_rows, |
|
564 |
uint64_t in_min_rows) |
|
565 |
:
|
|
566 |
engine(in_engine), |
|
567 |
avg_timing(in_avg_timing), |
|
568 |
max_timing(in_max_timing), |
|
569 |
min_timing(in_min_timing), |
|
570 |
users(in_users), |
|
571 |
real_users(in_real_users), |
|
572 |
avg_rows(in_avg_rows), |
|
573 |
sum_of_time(in_sum_of_time), |
|
574 |
std_dev(in_std_dev), |
|
575 |
create_avg_timing(in_create_avg_timing), |
|
576 |
create_max_timing(in_create_max_timing), |
|
577 |
create_min_timing(in_create_min_timing), |
|
578 |
create_count(in_create_count), |
|
579 |
max_rows(in_max_rows), |
|
580 |
min_rows(in_min_rows) |
|
581 |
{}
|
|
582 |
||
583 |
Conclusions() |
|
584 |
:
|
|
585 |
engine(NULL), |
|
586 |
avg_timing(0), |
|
587 |
max_timing(0), |
|
588 |
min_timing(0), |
|
589 |
users(0), |
|
590 |
real_users(0), |
|
591 |
avg_rows(0), |
|
592 |
sum_of_time(0), |
|
593 |
std_dev(0), |
|
594 |
create_avg_timing(0), |
|
595 |
create_max_timing(0), |
|
596 |
create_min_timing(0), |
|
597 |
create_count(0), |
|
598 |
max_rows(0), |
|
599 |
min_rows(0) |
|
600 |
{}
|
|
601 |
||
602 |
char *getEngine() const |
|
603 |
{
|
|
604 |
return engine; |
|
605 |
}
|
|
606 |
||
607 |
long int getAvgTiming() const |
|
608 |
{
|
|
609 |
return avg_timing; |
|
610 |
}
|
|
611 |
||
612 |
long int getMaxTiming() const |
|
613 |
{
|
|
614 |
return max_timing; |
|
615 |
}
|
|
616 |
||
617 |
long int getMinTiming() const |
|
618 |
{
|
|
619 |
return min_timing; |
|
620 |
}
|
|
621 |
||
622 |
uint32_t getUsers() const |
|
623 |
{
|
|
624 |
return users; |
|
625 |
}
|
|
626 |
||
627 |
uint32_t getRealUsers() const |
|
628 |
{
|
|
629 |
return real_users; |
|
630 |
}
|
|
631 |
||
632 |
uint64_t getAvgRows() const |
|
633 |
{
|
|
634 |
return avg_rows; |
|
635 |
}
|
|
636 |
||
637 |
long int getSumOfTime() const |
|
638 |
{
|
|
639 |
return sum_of_time; |
|
640 |
}
|
|
641 |
||
642 |
long int getStdDev() const |
|
643 |
{
|
|
644 |
return std_dev; |
|
645 |
}
|
|
646 |
||
647 |
long int getCreateAvgTiming() const |
|
648 |
{
|
|
649 |
return create_avg_timing; |
|
650 |
}
|
|
651 |
||
652 |
long int getCreateMaxTiming() const |
|
653 |
{
|
|
654 |
return create_max_timing; |
|
655 |
}
|
|
656 |
||
657 |
long int getCreateMinTiming() const |
|
658 |
{
|
|
659 |
return create_min_timing; |
|
660 |
}
|
|
661 |
||
662 |
uint64_t getCreateCount() const |
|
663 |
{
|
|
664 |
return create_count; |
|
665 |
}
|
|
666 |
||
667 |
uint64_t getMinRows() const |
|
668 |
{
|
|
669 |
return min_rows; |
|
670 |
}
|
|
671 |
||
672 |
uint64_t getMaxRows() const |
|
673 |
{
|
|
674 |
return max_rows; |
|
675 |
}
|
|
676 |
||
677 |
void setEngine(char *in_engine) |
|
678 |
{
|
|
679 |
engine= in_engine; |
|
680 |
}
|
|
681 |
||
682 |
void setAvgTiming(long int in_avg_timing) |
|
683 |
{
|
|
684 |
avg_timing= in_avg_timing; |
|
685 |
}
|
|
686 |
||
687 |
void setMaxTiming(long int in_max_timing) |
|
688 |
{
|
|
689 |
max_timing= in_max_timing; |
|
690 |
}
|
|
691 |
||
692 |
void setMinTiming(long int in_min_timing) |
|
693 |
{
|
|
694 |
min_timing= in_min_timing; |
|
695 |
}
|
|
696 |
||
697 |
void setUsers(uint32_t in_users) |
|
698 |
{
|
|
699 |
users= in_users; |
|
700 |
}
|
|
701 |
||
702 |
void setRealUsers(uint32_t in_real_users) |
|
703 |
{
|
|
704 |
real_users= in_real_users; |
|
705 |
}
|
|
706 |
||
707 |
void setAvgRows(uint64_t in_avg_rows) |
|
708 |
{
|
|
709 |
avg_rows= in_avg_rows; |
|
710 |
}
|
|
711 |
||
712 |
void setSumOfTime(long int in_sum_of_time) |
|
713 |
{
|
|
714 |
sum_of_time= in_sum_of_time; |
|
715 |
}
|
|
716 |
||
717 |
void setStdDev(long int in_std_dev) |
|
718 |
{
|
|
719 |
std_dev= in_std_dev; |
|
720 |
}
|
|
721 |
||
722 |
void setCreateAvgTiming(long int in_create_avg_timing) |
|
723 |
{
|
|
724 |
create_avg_timing= in_create_avg_timing; |
|
725 |
}
|
|
726 |
||
727 |
void setCreateMaxTiming(long int in_create_max_timing) |
|
728 |
{
|
|
729 |
create_max_timing= in_create_max_timing; |
|
730 |
}
|
|
731 |
||
732 |
void setCreateMinTiming(long int in_create_min_timing) |
|
733 |
{
|
|
734 |
create_min_timing= in_create_min_timing; |
|
735 |
}
|
|
736 |
||
737 |
void setCreateCount(uint64_t in_create_count) |
|
738 |
{
|
|
739 |
create_count= in_create_count; |
|
740 |
}
|
|
741 |
||
742 |
void setMinRows(uint64_t in_min_rows) |
|
743 |
{
|
|
744 |
min_rows= in_min_rows; |
|
745 |
}
|
|
746 |
||
747 |
void setMaxRows(uint64_t in_max_rows) |
|
748 |
{
|
|
749 |
max_rows= in_max_rows; |
|
750 |
}
|
|
751 |
||
752 |
private: |
|
1
by brian
clean slate |
753 |
char *engine; |
754 |
long int avg_timing; |
|
755 |
long int max_timing; |
|
756 |
long int min_timing; |
|
893
by Brian Aker
First pass of stripping uint |
757 |
uint32_t users; |
758 |
uint32_t real_users; |
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
759 |
uint64_t avg_rows; |
1
by brian
clean slate |
760 |
long int sum_of_time; |
761 |
long int std_dev; |
|
762 |
/* These are just for create time stats */
|
|
763 |
long int create_avg_timing; |
|
764 |
long int create_max_timing; |
|
765 |
long int create_min_timing; |
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
766 |
uint64_t create_count; |
1
by brian
clean slate |
767 |
/* The following are not used yet */
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
768 |
uint64_t max_rows; |
769 |
uint64_t min_rows; |
|
1
by brian
clean slate |
770 |
};
|
771 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
772 |
|
773 |
static OptionString *engine_options= NULL; |
|
774 |
static OptionString *query_options= NULL; |
|
775 |
static Statement *pre_statements= NULL; |
|
776 |
static Statement *post_statements= NULL; |
|
777 |
static Statement *create_statements= NULL; |
|
778 |
||
779 |
static Statement **query_statements= NULL; |
|
1
by brian
clean slate |
780 |
static unsigned int query_statements_count; |
781 |
||
782 |
||
783 |
/* Prototypes */
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
784 |
void print_conclusions(Conclusions *con); |
785 |
void print_conclusions_csv(Conclusions *con); |
|
786 |
void generate_stats(Conclusions *con, OptionString *eng, Stats *sptr); |
|
893
by Brian Aker
First pass of stripping uint |
787 |
uint32_t parse_comma(const char *string, uint32_t **range); |
1441.3.1
by Vijay Samuel
all required updations have been made |
788 |
uint32_t parse_delimiter(const char *script, Statement **stmt, char delm); |
789 |
uint32_t parse_option(const char *origin, OptionString **stmt, char delm); |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
790 |
static int drop_schema(drizzle_con_st *con, const char *db); |
893
by Brian Aker
First pass of stripping uint |
791 |
uint32_t get_random_string(char *buf, size_t size); |
1441.3.1
by Vijay Samuel
all required updations have been made |
792 |
static Statement *build_table_string(void); |
793 |
static Statement *build_insert_string(void); |
|
794 |
static Statement *build_update_string(void); |
|
795 |
static Statement * build_select_string(bool key); |
|
796 |
static int generate_primary_key_list(drizzle_con_st *con, OptionString *engine_stmt); |
|
1
by brian
clean slate |
797 |
static int drop_primary_key_list(void); |
1441.3.1
by Vijay Samuel
all required updations have been made |
798 |
static int create_schema(drizzle_con_st *con, const char *db, Statement *stmt, |
799 |
OptionString *engine_stmt, Stats *sptr); |
|
800 |
static int run_scheduler(Stats *sptr, Statement **stmts, uint32_t concur, |
|
151
by Brian Aker
Ulonglong to uint64_t |
801 |
uint64_t limit); |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
802 |
extern "C" pthread_handler_t run_task(void *p); |
803 |
extern "C" pthread_handler_t timer_thread(void *p); |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
804 |
void statement_cleanup(Statement *stmt); |
805 |
void option_cleanup(OptionString *stmt); |
|
806 |
void concurrency_loop(drizzle_con_st *con, uint32_t current, OptionString *eptr); |
|
807 |
static int run_statements(drizzle_con_st *con, Statement *stmt); |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
808 |
void slap_connect(drizzle_con_st *con, bool connect_to_schema); |
809 |
void slap_close(drizzle_con_st *con); |
|
810 |
static int run_query(drizzle_con_st *con, drizzle_result_st *result, const char *query, int len); |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
811 |
void standard_deviation (Conclusions *con, Stats *sptr); |
1
by brian
clean slate |
812 |
|
813 |
static const char ALPHANUMERICS[]= |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
814 |
"0123456789ABCDEFGHIJKLMNOPQRSTWXYZabcdefghijklmnopqrstuvwxyz"; |
1
by brian
clean slate |
815 |
|
816 |
#define ALPHANUMERICS_SIZE (sizeof(ALPHANUMERICS)-1)
|
|
817 |
||
818 |
||
819 |
static long int timedif(struct timeval a, struct timeval b) |
|
820 |
{
|
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
821 |
register int us, s; |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
822 |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
823 |
us = a.tv_usec - b.tv_usec; |
824 |
us /= 1000; |
|
825 |
s = a.tv_sec - b.tv_sec; |
|
826 |
s *= 1000; |
|
827 |
return s + us; |
|
1
by brian
clean slate |
828 |
}
|
829 |
||
1531.2.10
by Vijay Samuel
Slap refactored with boost::program_options. |
830 |
static void combine_queries(vector<string> queries) |
831 |
{
|
|
832 |
user_supplied_query.erase(); |
|
833 |
for (vector<string>::iterator it= queries.begin(); |
|
834 |
it != queries.end(); |
|
835 |
++it) |
|
836 |
{
|
|
837 |
user_supplied_query.append(*it); |
|
838 |
user_supplied_query.append(delimiter); |
|
839 |
}
|
|
840 |
}
|
|
1531.2.29
by Vijay Samuel
Slap completely refactored using boost::program_options. |
841 |
/**
|
842 |
* commandline_options is the set of all options that can only be called via the command line.
|
|
843 |
||
844 |
* client_options is the set of all options that can be defined via both command line and via
|
|
845 |
* the configuration file client.cnf
|
|
846 |
||
847 |
* slap_options is the set of all drizzleslap specific options which behave in a manner
|
|
848 |
* similar to that of client_options. It's configuration file is drizzleslap.cnf
|
|
849 |
||
850 |
* long_options is the union of commandline_options, slap_options and client_options.
|
|
851 |
||
852 |
* There are two configuration files per set of options, one which is defined by the user and
|
|
853 |
* which is found at ~/.drizzle directory and the other which is the system configuration
|
|
854 |
* file which is found in the SYSCONFDIR/drizzle directory.
|
|
855 |
||
856 |
* The system configuration file is over ridden by the user's configuration file which
|
|
857 |
* in turn is over ridden by the command line.
|
|
858 |
*/
|
|
1
by brian
clean slate |
859 |
int main(int argc, char **argv) |
860 |
{
|
|
1531.2.1
by Vijay Samuel
Slap refactored |
861 |
char *password= NULL; |
1531.2.7
by Vijay Samuel
updated slap |
862 |
try
|
863 |
{
|
|
1531.2.27
by Vijay Samuel
Slap completely refactored with boost::program_options. |
864 |
po::options_description commandline_options("Options used only in command line"); |
865 |
commandline_options.add_options() |
|
1531.2.1
by Vijay Samuel
Slap refactored |
866 |
("help,?","Display this help and exit") |
867 |
("info,i","Gives information and exit") |
|
1531.2.27
by Vijay Samuel
Slap completely refactored with boost::program_options. |
868 |
("burnin",po::value<bool>(&opt_burnin)->default_value(false)->zero_tokens(), |
869 |
"Run full test case in infinite loop") |
|
870 |
("ignore-sql-errors", po::value<bool>(&opt_ignore_sql_errors)->default_value(false)->zero_tokens(), |
|
871 |
"Ignore SQL errors in query run") |
|
872 |
("create-schema",po::value<string>(&create_schema_string)->default_value("drizzleslap"), |
|
873 |
"Schema to run tests in") |
|
874 |
("create",po::value<string>(&create_string)->default_value(""), |
|
875 |
"File or string to use to create tables") |
|
876 |
("detach",po::value<uint32_t>(&detach_rate)->default_value(0), |
|
877 |
"Detach (close and re open) connections after X number of requests") |
|
878 |
("iterations,i",po::value<uint32_t>(&iterations)->default_value(1), |
|
879 |
"Number of times to run the tests") |
|
880 |
("label",po::value<string>(&opt_label)->default_value(""), |
|
881 |
"Label to use for print and csv") |
|
882 |
("number-blob-cols",po::value<string>(&num_blob_cols_opt)->default_value(""), |
|
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. ") |
|
884 |
("number-char-cols,x",po::value<string>(&num_char_cols_opt)->default_value(""), |
|
885 |
"Number of VARCHAR columns to create in table if specifying --auto-generate-sql.") |
|
886 |
("number-int-cols,y",po::value<string>(&num_int_cols_opt)->default_value(""), |
|
887 |
"Number of INT columns to create in table if specifying --auto-generate-sql.") |
|
888 |
("number-of-queries", |
|
889 |
po::value<uint64_t>(&num_of_query)->default_value(0), |
|
890 |
"Limit each client to this number of queries(this is not exact)") |
|
891 |
("only-print",po::value<bool>(&opt_only_print)->default_value(false)->zero_tokens(), |
|
892 |
"This causes drizzleslap to not connect to the database instead print out what it would have done instead") |
|
893 |
("post-query", po::value<string>(&user_supplied_post_statements)->default_value(""), |
|
894 |
"Query to run or file containing query to execute after tests have completed.") |
|
895 |
("post-system",po::value<string>(&post_system)->default_value(""), |
|
896 |
"system() string to execute after tests have completed") |
|
897 |
("pre-query", |
|
898 |
po::value<string>(&user_supplied_pre_statements)->default_value(""), |
|
899 |
"Query to run or file containing query to execute before running tests.") |
|
900 |
("pre-system",po::value<string>(&pre_system)->default_value(""), |
|
901 |
"system() string to execute before running tests.") |
|
902 |
("query,q",po::value<vector<string> >(&user_supplied_queries)->composing()->notifier(&combine_queries), |
|
903 |
"Query to run or file containing query") |
|
904 |
("verbose,v", po::value<string>(&opt_verbose)->default_value("v"), "Increase verbosity level by one.") |
|
905 |
("version,V","Output version information and exit") |
|
906 |
;
|
|
907 |
||
908 |
po::options_description slap_options("Options specific to drizzleslap"); |
|
909 |
slap_options.add_options() |
|
1531.2.1
by Vijay Samuel
Slap refactored |
910 |
("auto-generate-sql-select-columns", |
1531.2.3
by Vijay Samuel
Updated Slap code |
911 |
po::value<string>(&auto_generate_selected_columns_opt)->default_value(""), |
1531.2.1
by Vijay Samuel
Slap refactored |
912 |
"Provide a string to use for the select fields used in auto tests") |
913 |
("auto-generate-sql,a",po::value<bool>(&auto_generate_sql)->default_value(false)->zero_tokens(), |
|
914 |
"Generate SQL where not supplied by file or command line") |
|
915 |
("auto-generate-sql-add-autoincrement", |
|
916 |
po::value<bool>(&auto_generate_sql_autoincrement)->default_value(false)->zero_tokens(), |
|
917 |
"Add an AUTO_INCREMENT column to auto-generated tables") |
|
918 |
("auto-generate-sql-execute-number", |
|
919 |
po::value<uint64_t>(&auto_actual_queries)->default_value(0), |
|
920 |
"See this number and generate a set of queries to run") |
|
921 |
("auto-generate-sql-guid-primary", |
|
922 |
po::value<bool>(&auto_generate_sql_guid_primary)->default_value(false)->zero_tokens(), |
|
923 |
"Add GUID based primary keys to auto-generated tables") |
|
924 |
("auto-generate-sql-load-type", |
|
925 |
po::value<string>(&opt_auto_generate_sql_type)->default_value("mixed"), |
|
926 |
"Specify test load type: mixed, update, write, key or read; default is mixed") |
|
927 |
("auto-generate-sql-secondary-indexes", |
|
1531.2.2
by Vijay Samuel
Updated slap code |
928 |
po::value<uint32_t>(&auto_generate_sql_secondary_indexes)->default_value(0), |
1531.2.1
by Vijay Samuel
Slap refactored |
929 |
"Number of secondary indexes to add to auto-generated tables") |
930 |
("auto-generated-sql-unique-query-number", |
|
931 |
po::value<uint64_t>(&auto_generate_sql_unique_query_number)->default_value(10), |
|
932 |
"Number of unique queries to generate for automatic tests") |
|
933 |
("auto-generate-sql-unique-write-number", |
|
934 |
po::value<uint64_t>(&auto_generate_sql_unique_write_number)->default_value(10), |
|
935 |
"Number of unique queries to generate for auto-generate-sql-write-number") |
|
936 |
("auto-generate-sql-write-number", |
|
1531.3.1
by Monty Taylor
Fixed the centos issue. |
937 |
po::value<uint64_t>(&auto_generate_sql_number)->default_value(100), |
1531.2.1
by Vijay Samuel
Slap refactored |
938 |
"Number of row inserts to perform for each thread (default is 100).") |
1531.2.2
by Vijay Samuel
Updated slap code |
939 |
("commit",po::value<uint32_t>(&commit_rate)->default_value(0), |
1531.2.1
by Vijay Samuel
Slap refactored |
940 |
"Commit records every X number of statements") |
1531.2.4
by Vijay Samuel
Updated Slap |
941 |
("concurrency,c",po::value<string>(&concurrency_str)->default_value(""), |
1531.2.1
by Vijay Samuel
Slap refactored |
942 |
"Number of clients to simulate for query to run") |
1531.2.3
by Vijay Samuel
Updated Slap code |
943 |
("csv",po::value<std::string>(&opt_csv_str)->default_value(""), |
1531.2.1
by Vijay Samuel
Slap refactored |
944 |
"Generate CSV output to named file or to stdout if no file is name.") |
1531.2.2
by Vijay Samuel
Updated slap code |
945 |
("delayed-start",po::value<uint32_t>(&opt_delayed_start)->default_value(0), |
1531.2.1
by Vijay Samuel
Slap refactored |
946 |
"Delay the startup of threads by a random number of microsends (the maximum of the delay") |
947 |
("delimiter,F",po::value<string>(&delimiter)->default_value("\n"), |
|
948 |
"Delimiter to use in SQL statements supplied in file or command line") |
|
1531.2.3
by Vijay Samuel
Updated Slap code |
949 |
("engine ,e",po::value<string>(&default_engine)->default_value(""), |
1531.2.1
by Vijay Samuel
Slap refactored |
950 |
"Storage engien to use for creating the table") |
951 |
("set-random-seed", |
|
1531.2.3
by Vijay Samuel
Updated Slap code |
952 |
po::value<uint32_t>(&opt_set_random_seed)->default_value(0), |
1531.2.1
by Vijay Samuel
Slap refactored |
953 |
"Seed for random number generator (srandom(3)) ") |
954 |
("silent,s",po::value<bool>(&opt_silent)->default_value(false)->zero_tokens(), |
|
955 |
"Run program in silent mode - no output. ") |
|
1531.2.2
by Vijay Samuel
Updated slap code |
956 |
("timer-length",po::value<uint32_t>(&opt_timer_length)->default_value(0), |
1531.2.1
by Vijay Samuel
Slap refactored |
957 |
"Require drizzleslap to run each specific test a certain amount of time in seconds") |
1531.2.27
by Vijay Samuel
Slap completely refactored with boost::program_options. |
958 |
;
|
959 |
||
960 |
po::options_description client_options("Options specific to the client"); |
|
961 |
client_options.add_options() |
|
1531.2.31
by Vijay Samuel
slap completely refactored using boost::program_options. |
962 |
("mysql,m", po::value<bool>(&opt_mysql)->default_value(true)->zero_tokens(), |
963 |
N_("Use MySQL Protocol.")) |
|
1531.2.27
by Vijay Samuel
Slap completely refactored with boost::program_options. |
964 |
("host,h",po::value<string>(&host)->default_value("localhost"),"Connect to the host") |
965 |
("password,P",po::value<char *>(&password), |
|
966 |
"Password to use when connecting to server. If password is not given it's asked from the tty") |
|
967 |
("port,p",po::value<uint32_t>(), "Port number to use for connection") |
|
968 |
("protocol",po::value<string>(), |
|
969 |
"The protocol of connection (tcp,socket,pipe,memory).") |
|
1531.2.3
by Vijay Samuel
Updated Slap code |
970 |
("user,u",po::value<string>(&user)->default_value(""), |
1531.2.1
by Vijay Samuel
Slap refactored |
971 |
"User for login if not current user") |
972 |
;
|
|
973 |
||
1531.2.27
by Vijay Samuel
Slap completely refactored with boost::program_options. |
974 |
po::options_description long_options("Allowed Options"); |
975 |
long_options.add(commandline_options).add(slap_options).add(client_options); |
|
976 |
||
977 |
std::string system_config_dir_slap(SYSCONFDIR); |
|
978 |
system_config_dir_slap.append("/drizzle/drizzleslap.cnf"); |
|
979 |
||
980 |
std::string system_config_dir_client(SYSCONFDIR); |
|
981 |
system_config_dir_client.append("/drizzle/client.cnf"); |
|
982 |
||
1531.2.1
by Vijay Samuel
Slap refactored |
983 |
uint64_t temp_drizzle_port= 0; |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
984 |
drizzle_con_st con; |
1441.3.1
by Vijay Samuel
all required updations have been made |
985 |
OptionString *eptr; |
1531.2.2
by Vijay Samuel
Updated slap code |
986 |
uint32_t x; |
1
by brian
clean slate |
987 |
|
1531.2.4
by Vijay Samuel
Updated Slap |
988 |
|
1531.2.1
by Vijay Samuel
Slap refactored |
989 |
po::variables_map vm; |
990 |
po::store(po::parse_command_line(argc,argv,long_options),vm); |
|
1531.2.27
by Vijay Samuel
Slap completely refactored with boost::program_options. |
991 |
|
992 |
ifstream user_slap_ifs("~/.drizzle/drizzleslap.cnf"); |
|
993 |
po::store(parse_config_file(user_slap_ifs, slap_options), vm); |
|
994 |
||
1531.2.30
by Vijay Samuel
Slap completely refactored using boost::program_options. |
995 |
ifstream system_slap_ifs(system_config_dir_slap.c_str()); |
1531.2.27
by Vijay Samuel
Slap completely refactored with boost::program_options. |
996 |
store(parse_config_file(system_slap_ifs, slap_options), vm); |
997 |
||
998 |
ifstream user_client_ifs("~/.drizzle/client.cnf"); |
|
999 |
po::store(parse_config_file(user_client_ifs, client_options), vm); |
|
1000 |
||
1531.2.30
by Vijay Samuel
Slap completely refactored using boost::program_options. |
1001 |
ifstream system_client_ifs(system_config_dir_client.c_str()); |
1531.2.27
by Vijay Samuel
Slap completely refactored with boost::program_options. |
1002 |
store(parse_config_file(system_client_ifs, client_options), vm); |
1003 |
||
1531.2.1
by Vijay Samuel
Slap refactored |
1004 |
po::notify(vm); |
1005 |
||
1531.2.11
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
1006 |
if (process_options()) |
1531.2.4
by Vijay Samuel
Updated Slap |
1007 |
exit(1); |
1008 |
||
1009 |
if( vm.count("help") || vm.count("info")) |
|
1010 |
{
|
|
1011 |
printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION, |
|
1012 |
drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU); |
|
1013 |
puts("Copyright (C) 2008 Sun Microsystems"); |
|
1014 |
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\ |
|
1015 |
\nand you are welcome to modify and redistribute it under the GPL \ |
|
1016 |
license\n"); |
|
1017 |
puts("Run a query multiple times against the server\n"); |
|
1018 |
cout<<long_options<<endl; |
|
1019 |
exit(0); |
|
1020 |
}
|
|
1021 |
||
1531.2.1
by Vijay Samuel
Slap refactored |
1022 |
if(vm.count("port")) |
1023 |
{
|
|
1531.2.2
by Vijay Samuel
Updated slap code |
1024 |
temp_drizzle_port= vm["port"].as<uint32_t>(); |
1531.2.4
by Vijay Samuel
Updated Slap |
1025 |
|
1531.2.1
by Vijay Samuel
Slap refactored |
1026 |
if ((temp_drizzle_port == 0) || (temp_drizzle_port > 65535)) |
1027 |
{
|
|
1028 |
fprintf(stderr, _("Value supplied for port is not valid.\n")); |
|
1029 |
exit(1); |
|
1030 |
}
|
|
1031 |
else
|
|
1032 |
{
|
|
1033 |
opt_drizzle_port= (uint32_t) temp_drizzle_port; |
|
1034 |
}
|
|
1035 |
}
|
|
1036 |
||
1037 |
if( vm.count("password") ) |
|
1038 |
{
|
|
1039 |
char *start= vm["password"].as<char *>(); |
|
1531.2.4
by Vijay Samuel
Updated Slap |
1040 |
if (!opt_password.empty()) |
1531.2.2
by Vijay Samuel
Updated slap code |
1041 |
opt_password.erase(); |
1531.2.1
by Vijay Samuel
Slap refactored |
1042 |
opt_password = strdup(vm["password"].as<char *>()); |
1531.2.2
by Vijay Samuel
Updated slap code |
1043 |
if (opt_password.c_str() == NULL) |
1531.2.1
by Vijay Samuel
Slap refactored |
1044 |
{
|
1045 |
fprintf(stderr, "Memory allocation error while copying password. " |
|
1046 |
"Aborting.\n"); |
|
1047 |
exit(ENOMEM); |
|
1048 |
}
|
|
1049 |
||
1050 |
while (*password) |
|
1051 |
{
|
|
1052 |
/* Overwriting password with 'x' */
|
|
1053 |
*password++= 'x'; |
|
1054 |
}
|
|
1055 |
||
1056 |
if (*start) |
|
1057 |
{
|
|
1058 |
/* Cut length of argument */
|
|
1059 |
start[1]= 0; |
|
1060 |
}
|
|
1061 |
tty_password= 0; |
|
1062 |
}
|
|
1063 |
else
|
|
1064 |
tty_password= 1; |
|
1065 |
||
1066 |
||
1067 |
if( vm.count("version") ) |
|
1068 |
{
|
|
1069 |
printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION, |
|
1070 |
drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU); |
|
1071 |
exit(0); |
|
1072 |
}
|
|
1073 |
||
1
by brian
clean slate |
1074 |
/* Seed the random number generator if we will be using it. */
|
1075 |
if (auto_generate_sql) |
|
1076 |
{
|
|
1077 |
if (opt_set_random_seed == 0) |
|
1078 |
opt_set_random_seed= (unsigned int)time(NULL); |
|
1079 |
srandom(opt_set_random_seed); |
|
1080 |
}
|
|
1081 |
||
1082 |
/* globals? Yes, so we only have to run strlen once */
|
|
1531.2.1
by Vijay Samuel
Slap refactored |
1083 |
delimiter_length= delimiter.length(); |
1
by brian
clean slate |
1084 |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1085 |
slap_connect(&con, false); |
1
by brian
clean slate |
1086 |
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
1087 |
pthread_mutex_init(&counter_mutex, NULL); |
1088 |
pthread_cond_init(&count_threshhold, NULL); |
|
1089 |
pthread_mutex_init(&sleeper_mutex, NULL); |
|
1090 |
pthread_cond_init(&sleep_threshhold, NULL); |
|
1091 |
pthread_mutex_init(&timer_alarm_mutex, NULL); |
|
1092 |
pthread_cond_init(&timer_alarm_threshold, NULL); |
|
1
by brian
clean slate |
1093 |
|
1094 |
||
1095 |
/* Main iterations loop */
|
|
1096 |
burnin: |
|
1097 |
eptr= engine_options; |
|
1098 |
do
|
|
1099 |
{
|
|
1100 |
/* For the final stage we run whatever queries we were asked to run */
|
|
893
by Brian Aker
First pass of stripping uint |
1101 |
uint32_t *current; |
1
by brian
clean slate |
1102 |
|
1103 |
if (verbose >= 2) |
|
1104 |
printf("Starting Concurrency Test\n"); |
|
1105 |
||
1106 |
if (*concurrency) |
|
1107 |
{
|
|
1108 |
for (current= concurrency; current && *current; current++) |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1109 |
concurrency_loop(&con, *current, eptr); |
1
by brian
clean slate |
1110 |
}
|
1111 |
else
|
|
1112 |
{
|
|
893
by Brian Aker
First pass of stripping uint |
1113 |
uint32_t infinite= 1; |
1
by brian
clean slate |
1114 |
do { |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1115 |
concurrency_loop(&con, infinite, eptr); |
1
by brian
clean slate |
1116 |
}
|
1117 |
while (infinite++); |
|
1118 |
}
|
|
1119 |
||
1120 |
if (!opt_preserve) |
|
1531.2.1
by Vijay Samuel
Slap refactored |
1121 |
drop_schema(&con, create_schema_string.c_str()); |
1
by brian
clean slate |
1122 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1123 |
} while (eptr ? (eptr= eptr->getNext()) : 0); |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
1124 |
|
1
by brian
clean slate |
1125 |
if (opt_burnin) |
1126 |
goto burnin; |
|
1127 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
1128 |
pthread_mutex_destroy(&counter_mutex); |
1129 |
pthread_cond_destroy(&count_threshhold); |
|
1130 |
pthread_mutex_destroy(&sleeper_mutex); |
|
1131 |
pthread_cond_destroy(&sleep_threshhold); |
|
1132 |
pthread_mutex_destroy(&timer_alarm_mutex); |
|
1133 |
pthread_cond_destroy(&timer_alarm_threshold); |
|
1
by brian
clean slate |
1134 |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1135 |
slap_close(&con); |
1
by brian
clean slate |
1136 |
|
1137 |
/* now free all the strings we created */
|
|
1531.2.4
by Vijay Samuel
Updated Slap |
1138 |
if (!opt_password.empty()) |
1531.2.2
by Vijay Samuel
Updated slap code |
1139 |
opt_password.erase(); |
1
by brian
clean slate |
1140 |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
1141 |
free(concurrency); |
1
by brian
clean slate |
1142 |
|
1143 |
statement_cleanup(create_statements); |
|
1144 |
for (x= 0; x < query_statements_count; x++) |
|
1145 |
statement_cleanup(query_statements[x]); |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
1146 |
free(query_statements); |
1
by brian
clean slate |
1147 |
statement_cleanup(pre_statements); |
1148 |
statement_cleanup(post_statements); |
|
1149 |
option_cleanup(engine_options); |
|
1150 |
option_cleanup(query_options); |
|
1151 |
||
1152 |
#ifdef HAVE_SMEM
|
|
1153 |
if (shared_memory_base_name) |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
1154 |
free(shared_memory_base_name); |
1
by brian
clean slate |
1155 |
#endif
|
1531.2.27
by Vijay Samuel
Slap completely refactored with boost::program_options. |
1156 |
|
1531.2.7
by Vijay Samuel
updated slap |
1157 |
}
|
1
by brian
clean slate |
1158 |
|
1531.2.7
by Vijay Samuel
updated slap |
1159 |
catch(exception &err) |
1160 |
{
|
|
1161 |
cerr<<"Error:"<<err.what()<<endl; |
|
1162 |
}
|
|
1
by brian
clean slate |
1163 |
return 0; |
1164 |
}
|
|
1165 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
1166 |
void concurrency_loop(drizzle_con_st *con, uint32_t current, OptionString *eptr) |
1
by brian
clean slate |
1167 |
{
|
1168 |
unsigned int x; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1169 |
Stats *head_sptr; |
1170 |
Stats *sptr; |
|
1171 |
Conclusions conclusion; |
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
1172 |
uint64_t client_limit; |
1
by brian
clean slate |
1173 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1174 |
head_sptr= (Stats *)malloc(sizeof(Stats) * iterations); |
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
1175 |
if (head_sptr == NULL) |
1176 |
{
|
|
1177 |
fprintf(stderr,"Error allocating memory in concurrency_loop\n"); |
|
1178 |
exit(1); |
|
1179 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1180 |
memset(head_sptr, 0, sizeof(Stats) * iterations); |
1
by brian
clean slate |
1181 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1182 |
memset(&conclusion, 0, sizeof(Conclusions)); |
1
by brian
clean slate |
1183 |
|
1184 |
if (auto_actual_queries) |
|
1185 |
client_limit= auto_actual_queries; |
|
1186 |
else if (num_of_query) |
|
1187 |
client_limit= num_of_query / current; |
|
1188 |
else
|
|
1189 |
client_limit= actual_queries; |
|
1190 |
||
1191 |
for (x= 0, sptr= head_sptr; x < iterations; x++, sptr++) |
|
1192 |
{
|
|
1193 |
/*
|
|
1194 |
We might not want to load any data, such as when we are calling
|
|
1195 |
a stored_procedure that doesn't use data, or we know we already have
|
|
1196 |
data in the table.
|
|
1197 |
*/
|
|
163
by Brian Aker
Merge Monty's code. |
1198 |
if (opt_preserve == false) |
1531.2.1
by Vijay Samuel
Slap refactored |
1199 |
drop_schema(con, create_schema_string.c_str()); |
1
by brian
clean slate |
1200 |
|
1201 |
/* First we create */
|
|
1202 |
if (create_statements) |
|
1531.2.1
by Vijay Samuel
Slap refactored |
1203 |
create_schema(con, create_schema_string.c_str(), create_statements, eptr, sptr); |
1
by brian
clean slate |
1204 |
|
1205 |
/*
|
|
1206 |
If we generated GUID we need to build a list of them from creation that
|
|
1207 |
we can later use.
|
|
1208 |
*/
|
|
1209 |
if (verbose >= 2) |
|
1210 |
printf("Generating primary key list\n"); |
|
1211 |
if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary) |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1212 |
generate_primary_key_list(con, eptr); |
1
by brian
clean slate |
1213 |
|
1214 |
if (commit_rate) |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1215 |
run_query(con, NULL, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0")); |
1
by brian
clean slate |
1216 |
|
1531.2.4
by Vijay Samuel
Updated Slap |
1217 |
if (!pre_system.empty()) |
1090.1.3
by Monty Taylor
Removed dangerous asserts... mainly to upset Stewart. |
1218 |
{
|
1531.2.2
by Vijay Samuel
Updated slap code |
1219 |
int ret= system(pre_system.c_str()); |
1090.1.3
by Monty Taylor
Removed dangerous asserts... mainly to upset Stewart. |
1220 |
assert(ret != -1); |
1221 |
}
|
|
1222 |
||
1
by brian
clean slate |
1223 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1224 |
/*
|
1225 |
Pre statements are always run after all other logic so they can
|
|
1226 |
correct/adjust any item that they want.
|
|
1
by brian
clean slate |
1227 |
*/
|
1228 |
if (pre_statements) |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1229 |
run_statements(con, pre_statements); |
1
by brian
clean slate |
1230 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1231 |
run_scheduler(sptr, query_statements, current, client_limit); |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
1232 |
|
1
by brian
clean slate |
1233 |
if (post_statements) |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1234 |
run_statements(con, post_statements); |
1
by brian
clean slate |
1235 |
|
1531.2.4
by Vijay Samuel
Updated Slap |
1236 |
if (!post_system.empty()) |
1090.1.3
by Monty Taylor
Removed dangerous asserts... mainly to upset Stewart. |
1237 |
{
|
1531.2.2
by Vijay Samuel
Updated slap code |
1238 |
int ret= system(post_system.c_str()); |
1090.1.3
by Monty Taylor
Removed dangerous asserts... mainly to upset Stewart. |
1239 |
assert(ret !=-1); |
1240 |
}
|
|
1
by brian
clean slate |
1241 |
|
1242 |
/* We are finished with this run */
|
|
1243 |
if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary) |
|
1244 |
drop_primary_key_list(); |
|
1245 |
}
|
|
1246 |
||
1247 |
if (verbose >= 2) |
|
1248 |
printf("Generating stats\n"); |
|
1249 |
||
1250 |
generate_stats(&conclusion, eptr, head_sptr); |
|
1251 |
||
1252 |
if (!opt_silent) |
|
1253 |
print_conclusions(&conclusion); |
|
1531.2.4
by Vijay Samuel
Updated Slap |
1254 |
if (!opt_csv_str.empty()) |
1
by brian
clean slate |
1255 |
print_conclusions_csv(&conclusion); |
1256 |
||
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
1257 |
free(head_sptr); |
1
by brian
clean slate |
1258 |
|
1259 |
}
|
|
1260 |
||
1261 |
||
1262 |
||
1263 |
uint
|
|
1264 |
get_random_string(char *buf, size_t size) |
|
1265 |
{
|
|
1266 |
char *buf_ptr= buf; |
|
1267 |
size_t x; |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1268 |
|
1
by brian
clean slate |
1269 |
for (x= size; x > 0; x--) |
1270 |
*buf_ptr++= ALPHANUMERICS[random() % ALPHANUMERICS_SIZE]; |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1271 |
return(buf_ptr - buf); |
1
by brian
clean slate |
1272 |
}
|
1273 |
||
1274 |
||
1275 |
/*
|
|
1276 |
build_table_string
|
|
1277 |
||
1278 |
This function builds a create table query if the user opts to not supply
|
|
1279 |
a file or string containing a create table statement
|
|
1280 |
*/
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1281 |
static Statement * |
1
by brian
clean slate |
1282 |
build_table_string(void) |
1283 |
{
|
|
1284 |
char buf[HUGE_STRING_LENGTH]; |
|
1285 |
unsigned int col_count; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1286 |
Statement *ptr; |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1287 |
string table_string; |
1288 |
||
1289 |
table_string.reserve(HUGE_STRING_LENGTH); |
|
1290 |
||
1291 |
table_string= "CREATE TABLE `t1` ("; |
|
1
by brian
clean slate |
1292 |
|
1293 |
if (auto_generate_sql_autoincrement) |
|
1294 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1295 |
table_string.append("id serial"); |
1
by brian
clean slate |
1296 |
|
1297 |
if (num_int_cols || num_char_cols) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1298 |
table_string.append(","); |
1
by brian
clean slate |
1299 |
}
|
1300 |
||
1301 |
if (auto_generate_sql_guid_primary) |
|
1302 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1303 |
table_string.append("id varchar(128) primary key"); |
1
by brian
clean slate |
1304 |
|
1305 |
if (num_int_cols || num_char_cols || auto_generate_sql_guid_primary) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1306 |
table_string.append(","); |
1
by brian
clean slate |
1307 |
}
|
1308 |
||
1309 |
if (auto_generate_sql_secondary_indexes) |
|
1310 |
{
|
|
1311 |
unsigned int count; |
|
1312 |
||
1313 |
for (count= 0; count < auto_generate_sql_secondary_indexes; count++) |
|
1314 |
{
|
|
1315 |
if (count) /* Except for the first pass we add a comma */ |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1316 |
table_string.append(","); |
1
by brian
clean slate |
1317 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1318 |
if (snprintf(buf, HUGE_STRING_LENGTH, "id%d varchar(32) unique key", count) |
1
by brian
clean slate |
1319 |
> HUGE_STRING_LENGTH) |
1320 |
{
|
|
1321 |
fprintf(stderr, "Memory Allocation error in create table\n"); |
|
1322 |
exit(1); |
|
1323 |
}
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1324 |
table_string.append(buf); |
1
by brian
clean slate |
1325 |
}
|
1326 |
||
1327 |
if (num_int_cols || num_char_cols) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1328 |
table_string.append(","); |
1
by brian
clean slate |
1329 |
}
|
1330 |
||
1331 |
if (num_int_cols) |
|
1332 |
for (col_count= 1; col_count <= num_int_cols; col_count++) |
|
1333 |
{
|
|
1334 |
if (num_int_cols_index) |
|
1335 |
{
|
|
223
by Brian Aker
Cleanup int() work. |
1336 |
if (snprintf(buf, HUGE_STRING_LENGTH, "intcol%d INT, INDEX(intcol%d)", |
1
by brian
clean slate |
1337 |
col_count, col_count) > HUGE_STRING_LENGTH) |
1338 |
{
|
|
1339 |
fprintf(stderr, "Memory Allocation error in create table\n"); |
|
1340 |
exit(1); |
|
1341 |
}
|
|
1342 |
}
|
|
1343 |
else
|
|
1344 |
{
|
|
223
by Brian Aker
Cleanup int() work. |
1345 |
if (snprintf(buf, HUGE_STRING_LENGTH, "intcol%d INT ", col_count) |
1
by brian
clean slate |
1346 |
> HUGE_STRING_LENGTH) |
1347 |
{
|
|
1348 |
fprintf(stderr, "Memory Allocation error in create table\n"); |
|
1349 |
exit(1); |
|
1350 |
}
|
|
1351 |
}
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1352 |
table_string.append(buf); |
1
by brian
clean slate |
1353 |
|
1354 |
if (col_count < num_int_cols || num_char_cols > 0) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1355 |
table_string.append(","); |
1
by brian
clean slate |
1356 |
}
|
1357 |
||
1358 |
if (num_char_cols) |
|
1359 |
for (col_count= 1; col_count <= num_char_cols; col_count++) |
|
1360 |
{
|
|
1361 |
if (num_char_cols_index) |
|
1362 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1363 |
if (snprintf(buf, HUGE_STRING_LENGTH, |
1364 |
"charcol%d VARCHAR(128), INDEX(charcol%d) ", |
|
1
by brian
clean slate |
1365 |
col_count, col_count) > HUGE_STRING_LENGTH) |
1366 |
{
|
|
1367 |
fprintf(stderr, "Memory Allocation error in creating table\n"); |
|
1368 |
exit(1); |
|
1369 |
}
|
|
1370 |
}
|
|
1371 |
else
|
|
1372 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1373 |
if (snprintf(buf, HUGE_STRING_LENGTH, "charcol%d VARCHAR(128)", |
1
by brian
clean slate |
1374 |
col_count) > HUGE_STRING_LENGTH) |
1375 |
{
|
|
1376 |
fprintf(stderr, "Memory Allocation error in creating table\n"); |
|
1377 |
exit(1); |
|
1378 |
}
|
|
1379 |
}
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1380 |
table_string.append(buf); |
1
by brian
clean slate |
1381 |
|
1382 |
if (col_count < num_char_cols || num_blob_cols > 0) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1383 |
table_string.append(","); |
1
by brian
clean slate |
1384 |
}
|
1385 |
||
1386 |
if (num_blob_cols) |
|
1387 |
for (col_count= 1; col_count <= num_blob_cols; col_count++) |
|
1388 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1389 |
if (snprintf(buf, HUGE_STRING_LENGTH, "blobcol%d blob", |
1
by brian
clean slate |
1390 |
col_count) > HUGE_STRING_LENGTH) |
1391 |
{
|
|
1392 |
fprintf(stderr, "Memory Allocation error in creating table\n"); |
|
1393 |
exit(1); |
|
1394 |
}
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1395 |
table_string.append(buf); |
1
by brian
clean slate |
1396 |
|
1397 |
if (col_count < num_blob_cols) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1398 |
table_string.append(","); |
1
by brian
clean slate |
1399 |
}
|
1400 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1401 |
table_string.append(")"); |
1441.3.1
by Vijay Samuel
all required updations have been made |
1402 |
ptr= (Statement *)malloc(sizeof(Statement)); |
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
1403 |
if (ptr == NULL) |
1404 |
{
|
|
1405 |
fprintf(stderr, "Memory Allocation error in creating table\n"); |
|
1406 |
exit(1); |
|
1407 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1408 |
memset(ptr, 0, sizeof(Statement)); |
1409 |
ptr->setString((char *)malloc(table_string.length()+1)); |
|
1410 |
if (ptr->getString()==NULL) |
|
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
1411 |
{
|
1412 |
fprintf(stderr, "Memory Allocation error in creating table\n"); |
|
1413 |
exit(1); |
|
1414 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1415 |
memset(ptr->getString(), 0, table_string.length()+1); |
1416 |
ptr->setLength(table_string.length()+1); |
|
1417 |
ptr->setType(CREATE_TABLE_TYPE); |
|
1418 |
strcpy(ptr->getString(), table_string.c_str()); |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1419 |
return(ptr); |
1
by brian
clean slate |
1420 |
}
|
1421 |
||
1422 |
/*
|
|
1423 |
build_update_string()
|
|
1424 |
||
1425 |
This function builds insert statements when the user opts to not supply
|
|
1426 |
an insert file or string containing insert data
|
|
1427 |
*/
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1428 |
static Statement * |
1
by brian
clean slate |
1429 |
build_update_string(void) |
1430 |
{
|
|
1431 |
char buf[HUGE_STRING_LENGTH]; |
|
1432 |
unsigned int col_count; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1433 |
Statement *ptr; |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1434 |
string update_string; |
1435 |
||
1436 |
update_string.reserve(HUGE_STRING_LENGTH); |
|
1437 |
||
1438 |
update_string= "UPDATE t1 SET "; |
|
1
by brian
clean slate |
1439 |
|
1440 |
if (num_int_cols) |
|
1441 |
for (col_count= 1; col_count <= num_int_cols; col_count++) |
|
1442 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1443 |
if (snprintf(buf, HUGE_STRING_LENGTH, "intcol%d = %ld", col_count, |
1
by brian
clean slate |
1444 |
random()) > HUGE_STRING_LENGTH) |
1445 |
{
|
|
1446 |
fprintf(stderr, "Memory Allocation error in creating update\n"); |
|
1447 |
exit(1); |
|
1448 |
}
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1449 |
update_string.append(buf); |
1
by brian
clean slate |
1450 |
|
1451 |
if (col_count < num_int_cols || num_char_cols > 0) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1452 |
update_string.append(",", 1); |
1
by brian
clean slate |
1453 |
}
|
1454 |
||
1455 |
if (num_char_cols) |
|
1456 |
for (col_count= 1; col_count <= num_char_cols; col_count++) |
|
1457 |
{
|
|
1458 |
char rand_buffer[RAND_STRING_SIZE]; |
|
1459 |
int buf_len= get_random_string(rand_buffer, RAND_STRING_SIZE); |
|
1460 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1461 |
if (snprintf(buf, HUGE_STRING_LENGTH, "charcol%d = '%.*s'", col_count, |
1462 |
buf_len, rand_buffer) |
|
1
by brian
clean slate |
1463 |
> HUGE_STRING_LENGTH) |
1464 |
{
|
|
1465 |
fprintf(stderr, "Memory Allocation error in creating update\n"); |
|
1466 |
exit(1); |
|
1467 |
}
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1468 |
update_string.append(buf); |
1
by brian
clean slate |
1469 |
|
1470 |
if (col_count < num_char_cols) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1471 |
update_string.append(",", 1); |
1
by brian
clean slate |
1472 |
}
|
1473 |
||
1474 |
if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1475 |
update_string.append(" WHERE id = "); |
1
by brian
clean slate |
1476 |
|
1477 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
1478 |
ptr= (Statement *)malloc(sizeof(Statement)); |
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
1479 |
if (ptr == NULL) |
1480 |
{
|
|
1481 |
fprintf(stderr, "Memory Allocation error in creating update\n"); |
|
1482 |
exit(1); |
|
1483 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1484 |
memset(ptr, 0, sizeof(Statement)); |
1
by brian
clean slate |
1485 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1486 |
ptr->setLength(update_string.length()+1); |
1487 |
ptr->setString((char *)malloc(ptr->getLength())); |
|
1488 |
if (ptr->getString() == NULL) |
|
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
1489 |
{
|
1490 |
fprintf(stderr, "Memory Allocation error in creating update\n"); |
|
1491 |
exit(1); |
|
1492 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1493 |
memset(ptr->getString(), 0, ptr->getLength()); |
1
by brian
clean slate |
1494 |
if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary) |
1441.3.1
by Vijay Samuel
all required updations have been made |
1495 |
ptr->setType(UPDATE_TYPE_REQUIRES_PREFIX); |
1
by brian
clean slate |
1496 |
else
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1497 |
ptr->setType(UPDATE_TYPE); |
1498 |
strncpy(ptr->getString(), update_string.c_str(), ptr->getLength()); |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1499 |
return(ptr); |
1
by brian
clean slate |
1500 |
}
|
1501 |
||
1502 |
||
1503 |
/*
|
|
1504 |
build_insert_string()
|
|
1505 |
||
1506 |
This function builds insert statements when the user opts to not supply
|
|
1507 |
an insert file or string containing insert data
|
|
1508 |
*/
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1509 |
static Statement * |
1
by brian
clean slate |
1510 |
build_insert_string(void) |
1511 |
{
|
|
1512 |
char buf[HUGE_STRING_LENGTH]; |
|
1513 |
unsigned int col_count; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1514 |
Statement *ptr; |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1515 |
string insert_string; |
1516 |
||
1517 |
insert_string.reserve(HUGE_STRING_LENGTH); |
|
1518 |
||
1519 |
insert_string= "INSERT INTO t1 VALUES ("; |
|
1
by brian
clean slate |
1520 |
|
1521 |
if (auto_generate_sql_autoincrement) |
|
1522 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1523 |
insert_string.append("NULL"); |
1
by brian
clean slate |
1524 |
|
1525 |
if (num_int_cols || num_char_cols) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1526 |
insert_string.append(","); |
1
by brian
clean slate |
1527 |
}
|
1528 |
||
1529 |
if (auto_generate_sql_guid_primary) |
|
1530 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1531 |
insert_string.append("uuid()"); |
1
by brian
clean slate |
1532 |
|
1533 |
if (num_int_cols || num_char_cols) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1534 |
insert_string.append(","); |
1
by brian
clean slate |
1535 |
}
|
1536 |
||
1537 |
if (auto_generate_sql_secondary_indexes) |
|
1538 |
{
|
|
1539 |
unsigned int count; |
|
1540 |
||
1541 |
for (count= 0; count < auto_generate_sql_secondary_indexes; count++) |
|
1542 |
{
|
|
1543 |
if (count) /* Except for the first pass we add a comma */ |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1544 |
insert_string.append(","); |
1
by brian
clean slate |
1545 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1546 |
insert_string.append("uuid()"); |
1
by brian
clean slate |
1547 |
}
|
1548 |
||
1549 |
if (num_int_cols || num_char_cols) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1550 |
insert_string.append(","); |
1
by brian
clean slate |
1551 |
}
|
1552 |
||
1553 |
if (num_int_cols) |
|
1554 |
for (col_count= 1; col_count <= num_int_cols; col_count++) |
|
1555 |
{
|
|
1556 |
if (snprintf(buf, HUGE_STRING_LENGTH, "%ld", random()) > HUGE_STRING_LENGTH) |
|
1557 |
{
|
|
1558 |
fprintf(stderr, "Memory Allocation error in creating insert\n"); |
|
1559 |
exit(1); |
|
1560 |
}
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1561 |
insert_string.append(buf); |
1
by brian
clean slate |
1562 |
|
1563 |
if (col_count < num_int_cols || num_char_cols > 0) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1564 |
insert_string.append(","); |
1
by brian
clean slate |
1565 |
}
|
1566 |
||
1567 |
if (num_char_cols) |
|
1568 |
for (col_count= 1; col_count <= num_char_cols; col_count++) |
|
1569 |
{
|
|
1570 |
int buf_len= get_random_string(buf, RAND_STRING_SIZE); |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1571 |
insert_string.append("'", 1); |
1572 |
insert_string.append(buf, buf_len); |
|
1573 |
insert_string.append("'", 1); |
|
1
by brian
clean slate |
1574 |
|
1575 |
if (col_count < num_char_cols || num_blob_cols > 0) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1576 |
insert_string.append(",", 1); |
1
by brian
clean slate |
1577 |
}
|
1578 |
||
1579 |
if (num_blob_cols) |
|
1580 |
{
|
|
1581 |
char *blob_ptr; |
|
1582 |
||
1583 |
if (num_blob_cols_size > HUGE_STRING_LENGTH) |
|
1584 |
{
|
|
656.1.20
by Monty Taylor
Removed my_strdup, my_malloc, my_realloc from client/ |
1585 |
blob_ptr= (char *)malloc(sizeof(char)*num_blob_cols_size); |
1
by brian
clean slate |
1586 |
if (!blob_ptr) |
1587 |
{
|
|
1588 |
fprintf(stderr, "Memory Allocation error in creating select\n"); |
|
1589 |
exit(1); |
|
1590 |
}
|
|
656.1.20
by Monty Taylor
Removed my_strdup, my_malloc, my_realloc from client/ |
1591 |
memset(blob_ptr, 0, sizeof(char)*num_blob_cols_size); |
1
by brian
clean slate |
1592 |
}
|
1593 |
else
|
|
1594 |
{
|
|
1595 |
blob_ptr= buf; |
|
1596 |
}
|
|
1597 |
||
1598 |
for (col_count= 1; col_count <= num_blob_cols; col_count++) |
|
1599 |
{
|
|
1600 |
unsigned int buf_len; |
|
1601 |
unsigned int size; |
|
1602 |
unsigned int difference= num_blob_cols_size - num_blob_cols_size_min; |
|
1603 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1604 |
size= difference ? (num_blob_cols_size_min + (random() % difference)) : |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
1605 |
num_blob_cols_size; |
1
by brian
clean slate |
1606 |
|
1607 |
buf_len= get_random_string(blob_ptr, size); |
|
1608 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1609 |
insert_string.append("'", 1); |
1610 |
insert_string.append(blob_ptr, buf_len); |
|
1611 |
insert_string.append("'", 1); |
|
1
by brian
clean slate |
1612 |
|
1613 |
if (col_count < num_blob_cols) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1614 |
insert_string.append(",", 1); |
1
by brian
clean slate |
1615 |
}
|
1616 |
||
1617 |
if (num_blob_cols_size > HUGE_STRING_LENGTH) |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
1618 |
free(blob_ptr); |
1
by brian
clean slate |
1619 |
}
|
1620 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1621 |
insert_string.append(")", 1); |
1
by brian
clean slate |
1622 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1623 |
if (!(ptr= (Statement *)malloc(sizeof(Statement)))) |
1624 |
{
|
|
1625 |
fprintf(stderr, "Memory Allocation error in creating select\n"); |
|
1626 |
exit(1); |
|
1627 |
}
|
|
1628 |
memset(ptr, 0, sizeof(Statement)); |
|
1629 |
ptr->setLength(insert_string.length()+1); |
|
1630 |
ptr->setString((char *)malloc(ptr->getLength())); |
|
1631 |
if (ptr->getString()==NULL) |
|
1632 |
{
|
|
1633 |
fprintf(stderr, "Memory Allocation error in creating select\n"); |
|
1634 |
exit(1); |
|
1635 |
}
|
|
1636 |
memset(ptr->getString(), 0, ptr->getLength()); |
|
1637 |
ptr->setType(INSERT_TYPE); |
|
1638 |
strcpy(ptr->getString(), insert_string.c_str()); |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1639 |
return(ptr); |
1
by brian
clean slate |
1640 |
}
|
1641 |
||
1642 |
||
1643 |
/*
|
|
1644 |
build_select_string()
|
|
1645 |
||
1646 |
This function builds a query if the user opts to not supply a query
|
|
1647 |
statement or file containing a query statement
|
|
1648 |
*/
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1649 |
static Statement * |
143
by Brian Aker
Bool cleanup. |
1650 |
build_select_string(bool key) |
1
by brian
clean slate |
1651 |
{
|
1652 |
char buf[HUGE_STRING_LENGTH]; |
|
1653 |
unsigned int col_count; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1654 |
Statement *ptr; |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1655 |
string query_string; |
1656 |
||
1657 |
query_string.reserve(HUGE_STRING_LENGTH); |
|
1658 |
||
1659 |
query_string.append("SELECT ", 7); |
|
1531.2.4
by Vijay Samuel
Updated Slap |
1660 |
if (!auto_generate_selected_columns_opt.empty()) |
1
by brian
clean slate |
1661 |
{
|
1531.2.2
by Vijay Samuel
Updated slap code |
1662 |
query_string.append(auto_generate_selected_columns_opt.c_str()); |
1
by brian
clean slate |
1663 |
}
|
1664 |
else
|
|
1665 |
{
|
|
1666 |
for (col_count= 1; col_count <= num_int_cols; col_count++) |
|
1667 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1668 |
if (snprintf(buf, HUGE_STRING_LENGTH, "intcol%d", col_count) |
1
by brian
clean slate |
1669 |
> HUGE_STRING_LENGTH) |
1670 |
{
|
|
1671 |
fprintf(stderr, "Memory Allocation error in creating select\n"); |
|
1672 |
exit(1); |
|
1673 |
}
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1674 |
query_string.append(buf); |
1
by brian
clean slate |
1675 |
|
1676 |
if (col_count < num_int_cols || num_char_cols > 0) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1677 |
query_string.append(",", 1); |
1
by brian
clean slate |
1678 |
|
1679 |
}
|
|
1680 |
for (col_count= 1; col_count <= num_char_cols; col_count++) |
|
1681 |
{
|
|
1682 |
if (snprintf(buf, HUGE_STRING_LENGTH, "charcol%d", col_count) |
|
1683 |
> HUGE_STRING_LENGTH) |
|
1684 |
{
|
|
1685 |
fprintf(stderr, "Memory Allocation error in creating select\n"); |
|
1686 |
exit(1); |
|
1687 |
}
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1688 |
query_string.append(buf); |
1
by brian
clean slate |
1689 |
|
1690 |
if (col_count < num_char_cols || num_blob_cols > 0) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1691 |
query_string.append(",", 1); |
1
by brian
clean slate |
1692 |
|
1693 |
}
|
|
1694 |
for (col_count= 1; col_count <= num_blob_cols; col_count++) |
|
1695 |
{
|
|
1696 |
if (snprintf(buf, HUGE_STRING_LENGTH, "blobcol%d", col_count) |
|
1697 |
> HUGE_STRING_LENGTH) |
|
1698 |
{
|
|
1699 |
fprintf(stderr, "Memory Allocation error in creating select\n"); |
|
1700 |
exit(1); |
|
1701 |
}
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1702 |
query_string.append(buf); |
1
by brian
clean slate |
1703 |
|
1704 |
if (col_count < num_blob_cols) |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1705 |
query_string.append(",", 1); |
1
by brian
clean slate |
1706 |
}
|
1707 |
}
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1708 |
query_string.append(" FROM t1"); |
1
by brian
clean slate |
1709 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1710 |
if ((key) && |
1
by brian
clean slate |
1711 |
(auto_generate_sql_autoincrement || auto_generate_sql_guid_primary)) |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1712 |
query_string.append(" WHERE id = "); |
1
by brian
clean slate |
1713 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1714 |
ptr= (Statement *)malloc(sizeof(Statement)); |
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
1715 |
if (ptr == NULL) |
1716 |
{
|
|
1717 |
fprintf(stderr, "Memory Allocation error in creating select\n"); |
|
1718 |
exit(1); |
|
1719 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1720 |
memset(ptr, 0, sizeof(Statement)); |
1721 |
ptr->setLength(query_string.length()+1); |
|
1722 |
ptr->setString((char *)malloc(ptr->getLength())); |
|
1723 |
if (ptr->getString() == NULL) |
|
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
1724 |
{
|
1725 |
fprintf(stderr, "Memory Allocation error in creating select\n"); |
|
1726 |
exit(1); |
|
1727 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1728 |
memset(ptr->getString(), 0, ptr->getLength()); |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1729 |
if ((key) && |
1
by brian
clean slate |
1730 |
(auto_generate_sql_autoincrement || auto_generate_sql_guid_primary)) |
1441.3.1
by Vijay Samuel
all required updations have been made |
1731 |
ptr->setType(SELECT_TYPE_REQUIRES_PREFIX); |
1
by brian
clean slate |
1732 |
else
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1733 |
ptr->setType(SELECT_TYPE); |
1734 |
strcpy(ptr->getString(), query_string.c_str()); |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1735 |
return(ptr); |
1
by brian
clean slate |
1736 |
}
|
1737 |
||
1738 |
static int |
|
1531.2.11
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
1739 |
process_options(void) |
1
by brian
clean slate |
1740 |
{
|
1741 |
char *tmp_string; |
|
15
by brian
Fix for stat, NETWARE removal |
1742 |
struct stat sbuf; |
1441.3.1
by Vijay Samuel
all required updations have been made |
1743 |
OptionString *sql_type; |
1
by brian
clean slate |
1744 |
unsigned int sql_type_count= 0; |
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
1745 |
ssize_t bytes_read= 0; |
1531.2.1
by Vijay Samuel
Slap refactored |
1746 |
|
1531.2.4
by Vijay Samuel
Updated Slap |
1747 |
if (user.empty()) |
1531.2.2
by Vijay Samuel
Updated slap code |
1748 |
user= "root"; |
1
by brian
clean slate |
1749 |
|
1531.2.19
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
1750 |
verbose= opt_verbose.length(); |
1531.2.18
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
1751 |
|
1
by brian
clean slate |
1752 |
/* If something is created we clean it up, otherwise we leave schemas alone */
|
1531.2.4
by Vijay Samuel
Updated Slap |
1753 |
if ( (!create_string.empty()) || auto_generate_sql) |
163
by Brian Aker
Merge Monty's code. |
1754 |
opt_preserve= false; |
1
by brian
clean slate |
1755 |
|
1531.2.4
by Vijay Samuel
Updated Slap |
1756 |
if (auto_generate_sql && (!create_string.empty() || !user_supplied_query.empty())) |
1
by brian
clean slate |
1757 |
{
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
1758 |
fprintf(stderr, |
1759 |
"%s: Can't use --auto-generate-sql when create and query strings are specified!\n", |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1760 |
internal::my_progname); |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
1761 |
exit(1); |
1
by brian
clean slate |
1762 |
}
|
1763 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1764 |
if (auto_generate_sql && auto_generate_sql_guid_primary && |
1
by brian
clean slate |
1765 |
auto_generate_sql_autoincrement) |
1766 |
{
|
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
1767 |
fprintf(stderr, |
1768 |
"%s: Either auto-generate-sql-guid-primary or auto-generate-sql-add-autoincrement can be used!\n", |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1769 |
internal::my_progname); |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
1770 |
exit(1); |
1
by brian
clean slate |
1771 |
}
|
1772 |
||
1773 |
if (auto_generate_sql && num_of_query && auto_actual_queries) |
|
1774 |
{
|
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
1775 |
fprintf(stderr, |
1776 |
"%s: Either auto-generate-sql-execute-number or number-of-queries can be used!\n", |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1777 |
internal::my_progname); |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
1778 |
exit(1); |
1
by brian
clean slate |
1779 |
}
|
1780 |
||
1531.2.4
by Vijay Samuel
Updated Slap |
1781 |
parse_comma(!concurrency_str.empty() ? concurrency_str.c_str() : "1", &concurrency); |
1
by brian
clean slate |
1782 |
|
1531.2.4
by Vijay Samuel
Updated Slap |
1783 |
if (!opt_csv_str.empty()) |
1
by brian
clean slate |
1784 |
{
|
163
by Brian Aker
Merge Monty's code. |
1785 |
opt_silent= true; |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
1786 |
|
1
by brian
clean slate |
1787 |
if (opt_csv_str[0] == '-') |
1788 |
{
|
|
1789 |
csv_file= fileno(stdout); |
|
1790 |
}
|
|
1791 |
else
|
|
1792 |
{
|
|
1531.2.1
by Vijay Samuel
Slap refactored |
1793 |
if ((csv_file= open(opt_csv_str.c_str(), O_CREAT|O_WRONLY|O_APPEND, |
1054.2.8
by Monty Taylor
Fixed staging build issue. |
1794 |
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) == -1) |
1
by brian
clean slate |
1795 |
{
|
1796 |
fprintf(stderr,"%s: Could not open csv file: %sn\n", |
|
1531.2.1
by Vijay Samuel
Slap refactored |
1797 |
internal::my_progname, opt_csv_str.c_str()); |
1
by brian
clean slate |
1798 |
exit(1); |
1799 |
}
|
|
1800 |
}
|
|
1801 |
}
|
|
1802 |
||
1803 |
if (opt_only_print) |
|
163
by Brian Aker
Merge Monty's code. |
1804 |
opt_silent= true; |
1
by brian
clean slate |
1805 |
|
1531.2.8
by Vijay Samuel
Updated Slap |
1806 |
if (!num_int_cols_opt.empty()) |
1807 |
{
|
|
1808 |
OptionString *str; |
|
1809 |
parse_option(num_int_cols_opt.c_str(), &str, ','); |
|
1810 |
num_int_cols= atoi(str->getString()); |
|
1811 |
if (str->getOption()) |
|
1812 |
num_int_cols_index= atoi(str->getOption()); |
|
1813 |
option_cleanup(str); |
|
1814 |
}
|
|
1531.2.1
by Vijay Samuel
Slap refactored |
1815 |
|
1531.2.8
by Vijay Samuel
Updated Slap |
1816 |
if (!num_char_cols_opt.empty()) |
1817 |
{
|
|
1818 |
OptionString *str; |
|
1819 |
parse_option(num_char_cols_opt.c_str(), &str, ','); |
|
1820 |
num_char_cols= atoi(str->getString()); |
|
1821 |
if (str->getOption()) |
|
1822 |
num_char_cols_index= atoi(str->getOption()); |
|
1823 |
else
|
|
1824 |
num_char_cols_index= 0; |
|
1825 |
option_cleanup(str); |
|
1826 |
}
|
|
1531.2.1
by Vijay Samuel
Slap refactored |
1827 |
|
1531.2.4
by Vijay Samuel
Updated Slap |
1828 |
if (!num_blob_cols_opt.empty()) |
1531.2.1
by Vijay Samuel
Slap refactored |
1829 |
{
|
1830 |
OptionString *str; |
|
1831 |
parse_option(num_blob_cols_opt.c_str(), &str, ','); |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1832 |
num_blob_cols= atoi(str->getString()); |
1833 |
if (str->getOption()) |
|
1
by brian
clean slate |
1834 |
{
|
1835 |
char *sep_ptr; |
|
1836 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
1837 |
if ((sep_ptr= strchr(str->getOption(), '/'))) |
1
by brian
clean slate |
1838 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1839 |
num_blob_cols_size_min= atoi(str->getOption()); |
1
by brian
clean slate |
1840 |
num_blob_cols_size= atoi(sep_ptr+1); |
1841 |
}
|
|
1842 |
else
|
|
1843 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1844 |
num_blob_cols_size_min= num_blob_cols_size= atoi(str->getOption()); |
1
by brian
clean slate |
1845 |
}
|
1846 |
}
|
|
1847 |
else
|
|
1848 |
{
|
|
1849 |
num_blob_cols_size= DEFAULT_BLOB_SIZE; |
|
1850 |
num_blob_cols_size_min= DEFAULT_BLOB_SIZE; |
|
1851 |
}
|
|
1852 |
option_cleanup(str); |
|
1853 |
}
|
|
1854 |
||
1855 |
||
1856 |
if (auto_generate_sql) |
|
1857 |
{
|
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
1858 |
uint64_t x= 0; |
1441.3.1
by Vijay Samuel
all required updations have been made |
1859 |
Statement *ptr_statement; |
1
by brian
clean slate |
1860 |
|
1861 |
if (verbose >= 2) |
|
1862 |
printf("Building Create Statements for Auto\n"); |
|
1863 |
||
1864 |
create_statements= build_table_string(); |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1865 |
/*
|
1866 |
Pre-populate table
|
|
1
by brian
clean slate |
1867 |
*/
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1868 |
for (ptr_statement= create_statements, x= 0; |
1869 |
x < auto_generate_sql_unique_write_number; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1870 |
x++, ptr_statement= ptr_statement->getNext()) |
1
by brian
clean slate |
1871 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1872 |
ptr_statement->setNext(build_insert_string()); |
1
by brian
clean slate |
1873 |
}
|
1874 |
||
1875 |
if (verbose >= 2) |
|
1876 |
printf("Building Query Statements for Auto\n"); |
|
1877 |
||
1531.2.4
by Vijay Samuel
Updated Slap |
1878 |
if (opt_auto_generate_sql_type.empty()) |
1
by brian
clean slate |
1879 |
opt_auto_generate_sql_type= "mixed"; |
1880 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1881 |
query_statements_count= |
1531.2.1
by Vijay Samuel
Slap refactored |
1882 |
parse_option(opt_auto_generate_sql_type.c_str(), &query_options, ','); |
1
by brian
clean slate |
1883 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1884 |
query_statements= (Statement **)malloc(sizeof(Statement *) * query_statements_count); |
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
1885 |
if (query_statements == NULL) |
1886 |
{
|
|
1887 |
fprintf(stderr, "Memory Allocation error in Building Query Statements\n"); |
|
1888 |
exit(1); |
|
1889 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1890 |
memset(query_statements, 0, sizeof(Statement *) * query_statements_count); |
1
by brian
clean slate |
1891 |
|
1892 |
sql_type= query_options; |
|
1893 |
do
|
|
1894 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1895 |
if (sql_type->getString()[0] == 'r') |
1
by brian
clean slate |
1896 |
{
|
1897 |
if (verbose >= 2) |
|
1898 |
printf("Generating SELECT Statements for Auto\n"); |
|
1899 |
||
163
by Brian Aker
Merge Monty's code. |
1900 |
query_statements[sql_type_count]= build_select_string(false); |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1901 |
for (ptr_statement= query_statements[sql_type_count], x= 0; |
1902 |
x < auto_generate_sql_unique_query_number; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1903 |
x++, ptr_statement= ptr_statement->getNext()) |
1
by brian
clean slate |
1904 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1905 |
ptr_statement->setNext(build_select_string(false)); |
1
by brian
clean slate |
1906 |
}
|
1907 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1908 |
else if (sql_type->getString()[0] == 'k') |
1
by brian
clean slate |
1909 |
{
|
1910 |
if (verbose >= 2) |
|
1911 |
printf("Generating SELECT for keys Statements for Auto\n"); |
|
1912 |
||
163
by Brian Aker
Merge Monty's code. |
1913 |
if ( auto_generate_sql_autoincrement == false && |
1914 |
auto_generate_sql_guid_primary == false) |
|
1
by brian
clean slate |
1915 |
{
|
1916 |
fprintf(stderr, |
|
1917 |
"%s: Can't perform key test without a primary key!\n", |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1918 |
internal::my_progname); |
1
by brian
clean slate |
1919 |
exit(1); |
1920 |
}
|
|
1921 |
||
163
by Brian Aker
Merge Monty's code. |
1922 |
query_statements[sql_type_count]= build_select_string(true); |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1923 |
for (ptr_statement= query_statements[sql_type_count], x= 0; |
1924 |
x < auto_generate_sql_unique_query_number; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1925 |
x++, ptr_statement= ptr_statement->getNext()) |
1
by brian
clean slate |
1926 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1927 |
ptr_statement->setNext(build_select_string(true)); |
1
by brian
clean slate |
1928 |
}
|
1929 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1930 |
else if (sql_type->getString()[0] == 'w') |
1
by brian
clean slate |
1931 |
{
|
1932 |
/*
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1933 |
We generate a number of strings in case the engine is
|
1
by brian
clean slate |
1934 |
Archive (since strings which were identical one after another
|
1935 |
would be too easily optimized).
|
|
1936 |
*/
|
|
1937 |
if (verbose >= 2) |
|
1938 |
printf("Generating INSERT Statements for Auto\n"); |
|
1939 |
query_statements[sql_type_count]= build_insert_string(); |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1940 |
for (ptr_statement= query_statements[sql_type_count], x= 0; |
1941 |
x < auto_generate_sql_unique_query_number; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1942 |
x++, ptr_statement= ptr_statement->getNext()) |
1
by brian
clean slate |
1943 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1944 |
ptr_statement->setNext(build_insert_string()); |
1
by brian
clean slate |
1945 |
}
|
1946 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1947 |
else if (sql_type->getString()[0] == 'u') |
1
by brian
clean slate |
1948 |
{
|
163
by Brian Aker
Merge Monty's code. |
1949 |
if ( auto_generate_sql_autoincrement == false && |
1950 |
auto_generate_sql_guid_primary == false) |
|
1
by brian
clean slate |
1951 |
{
|
1952 |
fprintf(stderr, |
|
1953 |
"%s: Can't perform update test without a primary key!\n", |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1954 |
internal::my_progname); |
1
by brian
clean slate |
1955 |
exit(1); |
1956 |
}
|
|
1957 |
||
1958 |
query_statements[sql_type_count]= build_update_string(); |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1959 |
for (ptr_statement= query_statements[sql_type_count], x= 0; |
1960 |
x < auto_generate_sql_unique_query_number; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1961 |
x++, ptr_statement= ptr_statement->getNext()) |
1
by brian
clean slate |
1962 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1963 |
ptr_statement->setNext(build_update_string()); |
1
by brian
clean slate |
1964 |
}
|
1965 |
}
|
|
1966 |
else /* Mixed mode is default */ |
|
1967 |
{
|
|
1968 |
int coin= 0; |
|
1969 |
||
1970 |
query_statements[sql_type_count]= build_insert_string(); |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1971 |
/*
|
1
by brian
clean slate |
1972 |
This logic should be extended to do a more mixed load,
|
1973 |
at the moment it results in "every other".
|
|
1974 |
*/
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1975 |
for (ptr_statement= query_statements[sql_type_count], x= 0; |
1976 |
x < auto_generate_sql_unique_query_number; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1977 |
x++, ptr_statement= ptr_statement->getNext()) |
1
by brian
clean slate |
1978 |
{
|
1979 |
if (coin) |
|
1980 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1981 |
ptr_statement->setNext(build_insert_string()); |
1
by brian
clean slate |
1982 |
coin= 0; |
1983 |
}
|
|
1984 |
else
|
|
1985 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1986 |
ptr_statement->setNext(build_select_string(true)); |
1
by brian
clean slate |
1987 |
coin= 1; |
1988 |
}
|
|
1989 |
}
|
|
1990 |
}
|
|
1991 |
sql_type_count++; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1992 |
} while (sql_type ? (sql_type= sql_type->getNext()) : 0); |
1
by brian
clean slate |
1993 |
}
|
1994 |
else
|
|
1995 |
{
|
|
1531.2.4
by Vijay Samuel
Updated Slap |
1996 |
if (!create_string.empty() && !stat(create_string.c_str(), &sbuf)) |
1
by brian
clean slate |
1997 |
{
|
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
1998 |
int data_file; |
212.5.37
by Monty Taylor
Removed my_stat. |
1999 |
if (!S_ISREG(sbuf.st_mode)) |
1
by brian
clean slate |
2000 |
{
|
2001 |
fprintf(stderr,"%s: Create file was not a regular file\n", |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2002 |
internal::my_progname); |
1
by brian
clean slate |
2003 |
exit(1); |
2004 |
}
|
|
1531.2.3
by Vijay Samuel
Updated Slap code |
2005 |
if ((data_file= open(create_string.c_str(), O_RDWR)) == -1) |
1
by brian
clean slate |
2006 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2007 |
fprintf(stderr,"%s: Could not open create file\n", internal::my_progname); |
1
by brian
clean slate |
2008 |
exit(1); |
2009 |
}
|
|
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
2010 |
if ((uint64_t)(sbuf.st_size + 1) > SIZE_MAX) |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
2011 |
{
|
2012 |
fprintf(stderr, "Request for more memory than architecture supports\n"); |
|
2013 |
exit(1); |
|
2014 |
}
|
|
2015 |
tmp_string= (char *)malloc((size_t)(sbuf.st_size + 1)); |
|
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
2016 |
if (tmp_string == NULL) |
2017 |
{
|
|
2018 |
fprintf(stderr, "Memory Allocation error in option processing\n"); |
|
2019 |
exit(1); |
|
2020 |
}
|
|
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
2021 |
memset(tmp_string, 0, (size_t)(sbuf.st_size + 1)); |
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
2022 |
bytes_read= read(data_file, (unsigned char*) tmp_string, |
2023 |
(size_t)sbuf.st_size); |
|
1
by brian
clean slate |
2024 |
tmp_string[sbuf.st_size]= '\0'; |
1014.8.4
by Toru Maesaka
Replace occrrences of my_(open|close) with straight open() and close() system calls |
2025 |
close(data_file); |
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
2026 |
if (bytes_read != sbuf.st_size) |
2027 |
{
|
|
2028 |
fprintf(stderr, "Problem reading file: read less bytes than requested\n"); |
|
2029 |
}
|
|
1
by brian
clean slate |
2030 |
parse_delimiter(tmp_string, &create_statements, delimiter[0]); |
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
2031 |
free(tmp_string); |
1
by brian
clean slate |
2032 |
}
|
1531.2.4
by Vijay Samuel
Updated Slap |
2033 |
else if (!create_string.empty()) |
1
by brian
clean slate |
2034 |
{
|
1531.2.3
by Vijay Samuel
Updated Slap code |
2035 |
parse_delimiter(create_string.c_str(), &create_statements, delimiter[0]); |
1
by brian
clean slate |
2036 |
}
|
2037 |
||
2038 |
/* Set this up till we fully support options on user generated queries */
|
|
1531.2.4
by Vijay Samuel
Updated Slap |
2039 |
if (!user_supplied_query.empty()) |
1
by brian
clean slate |
2040 |
{
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2041 |
query_statements_count= |
1
by brian
clean slate |
2042 |
parse_option("default", &query_options, ','); |
2043 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
2044 |
query_statements= (Statement **)malloc(sizeof(Statement *) * query_statements_count); |
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
2045 |
if (query_statements == NULL) |
2046 |
{
|
|
2047 |
fprintf(stderr, "Memory Allocation error in option processing\n"); |
|
2048 |
exit(1); |
|
2049 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2050 |
memset(query_statements, 0, sizeof(Statement *) * query_statements_count); |
1
by brian
clean slate |
2051 |
}
|
2052 |
||
1531.2.4
by Vijay Samuel
Updated Slap |
2053 |
if (!user_supplied_query.empty() && !stat(user_supplied_query.c_str(), &sbuf)) |
1
by brian
clean slate |
2054 |
{
|
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
2055 |
int data_file; |
212.5.37
by Monty Taylor
Removed my_stat. |
2056 |
if (!S_ISREG(sbuf.st_mode)) |
1
by brian
clean slate |
2057 |
{
|
2058 |
fprintf(stderr,"%s: User query supplied file was not a regular file\n", |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2059 |
internal::my_progname); |
1
by brian
clean slate |
2060 |
exit(1); |
2061 |
}
|
|
1531.2.2
by Vijay Samuel
Updated slap code |
2062 |
if ((data_file= open(user_supplied_query.c_str(), O_RDWR)) == -1) |
1
by brian
clean slate |
2063 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2064 |
fprintf(stderr,"%s: Could not open query supplied file\n", internal::my_progname); |
1
by brian
clean slate |
2065 |
exit(1); |
2066 |
}
|
|
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
2067 |
if ((uint64_t)(sbuf.st_size + 1) > SIZE_MAX) |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
2068 |
{
|
2069 |
fprintf(stderr, "Request for more memory than architecture supports\n"); |
|
2070 |
exit(1); |
|
2071 |
}
|
|
2072 |
tmp_string= (char *)malloc((size_t)(sbuf.st_size + 1)); |
|
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
2073 |
if (tmp_string == NULL) |
2074 |
{
|
|
2075 |
fprintf(stderr, "Memory Allocation error in option processing\n"); |
|
2076 |
exit(1); |
|
2077 |
}
|
|
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
2078 |
memset(tmp_string, 0, (size_t)(sbuf.st_size + 1)); |
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
2079 |
bytes_read= read(data_file, (unsigned char*) tmp_string, |
2080 |
(size_t)sbuf.st_size); |
|
1
by brian
clean slate |
2081 |
tmp_string[sbuf.st_size]= '\0'; |
1014.8.4
by Toru Maesaka
Replace occrrences of my_(open|close) with straight open() and close() system calls |
2082 |
close(data_file); |
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
2083 |
if (bytes_read != sbuf.st_size) |
2084 |
{
|
|
2085 |
fprintf(stderr, "Problem reading file: read less bytes than requested\n"); |
|
2086 |
}
|
|
1531.2.4
by Vijay Samuel
Updated Slap |
2087 |
if (!user_supplied_query.empty()) |
1
by brian
clean slate |
2088 |
actual_queries= parse_delimiter(tmp_string, &query_statements[0], |
2089 |
delimiter[0]); |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
2090 |
free(tmp_string); |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2091 |
}
|
1531.2.4
by Vijay Samuel
Updated Slap |
2092 |
else if (!user_supplied_query.empty()) |
1
by brian
clean slate |
2093 |
{
|
1531.2.2
by Vijay Samuel
Updated slap code |
2094 |
actual_queries= parse_delimiter(user_supplied_query.c_str(), &query_statements[0], |
1
by brian
clean slate |
2095 |
delimiter[0]); |
2096 |
}
|
|
2097 |
}
|
|
2098 |
||
1531.2.4
by Vijay Samuel
Updated Slap |
2099 |
if (!user_supplied_pre_statements.empty() |
1531.2.2
by Vijay Samuel
Updated slap code |
2100 |
&& !stat(user_supplied_pre_statements.c_str(), &sbuf)) |
1
by brian
clean slate |
2101 |
{
|
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
2102 |
int data_file; |
212.5.37
by Monty Taylor
Removed my_stat. |
2103 |
if (!S_ISREG(sbuf.st_mode)) |
1
by brian
clean slate |
2104 |
{
|
2105 |
fprintf(stderr,"%s: User query supplied file was not a regular file\n", |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2106 |
internal::my_progname); |
1
by brian
clean slate |
2107 |
exit(1); |
2108 |
}
|
|
1531.2.2
by Vijay Samuel
Updated slap code |
2109 |
if ((data_file= open(user_supplied_pre_statements.c_str(), O_RDWR)) == -1) |
1
by brian
clean slate |
2110 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2111 |
fprintf(stderr,"%s: Could not open query supplied file\n", internal::my_progname); |
1
by brian
clean slate |
2112 |
exit(1); |
2113 |
}
|
|
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
2114 |
if ((uint64_t)(sbuf.st_size + 1) > SIZE_MAX) |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
2115 |
{
|
2116 |
fprintf(stderr, "Request for more memory than architecture supports\n"); |
|
2117 |
exit(1); |
|
2118 |
}
|
|
2119 |
tmp_string= (char *)malloc((size_t)(sbuf.st_size + 1)); |
|
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
2120 |
if (tmp_string == NULL) |
2121 |
{
|
|
2122 |
fprintf(stderr, "Memory Allocation error in option processing\n"); |
|
2123 |
exit(1); |
|
2124 |
}
|
|
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
2125 |
memset(tmp_string, 0, (size_t)(sbuf.st_size + 1)); |
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
2126 |
bytes_read= read(data_file, (unsigned char*) tmp_string, |
2127 |
(size_t)sbuf.st_size); |
|
1
by brian
clean slate |
2128 |
tmp_string[sbuf.st_size]= '\0'; |
1014.8.4
by Toru Maesaka
Replace occrrences of my_(open|close) with straight open() and close() system calls |
2129 |
close(data_file); |
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
2130 |
if (bytes_read != sbuf.st_size) |
2131 |
{
|
|
2132 |
fprintf(stderr, "Problem reading file: read less bytes than requested\n"); |
|
2133 |
}
|
|
1531.2.4
by Vijay Samuel
Updated Slap |
2134 |
if (!user_supplied_pre_statements.empty()) |
1
by brian
clean slate |
2135 |
(void)parse_delimiter(tmp_string, &pre_statements, |
2136 |
delimiter[0]); |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
2137 |
free(tmp_string); |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2138 |
}
|
1531.2.4
by Vijay Samuel
Updated Slap |
2139 |
else if (!user_supplied_pre_statements.empty()) |
1
by brian
clean slate |
2140 |
{
|
1531.2.2
by Vijay Samuel
Updated slap code |
2141 |
(void)parse_delimiter(user_supplied_pre_statements.c_str(), |
1
by brian
clean slate |
2142 |
&pre_statements, |
2143 |
delimiter[0]); |
|
2144 |
}
|
|
2145 |
||
1531.2.4
by Vijay Samuel
Updated Slap |
2146 |
if (!user_supplied_post_statements.empty() |
1531.2.2
by Vijay Samuel
Updated slap code |
2147 |
&& !stat(user_supplied_post_statements.c_str(), &sbuf)) |
1
by brian
clean slate |
2148 |
{
|
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
2149 |
int data_file; |
212.5.37
by Monty Taylor
Removed my_stat. |
2150 |
if (!S_ISREG(sbuf.st_mode)) |
1
by brian
clean slate |
2151 |
{
|
2152 |
fprintf(stderr,"%s: User query supplied file was not a regular file\n", |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2153 |
internal::my_progname); |
1
by brian
clean slate |
2154 |
exit(1); |
2155 |
}
|
|
1531.2.2
by Vijay Samuel
Updated slap code |
2156 |
if ((data_file= open(user_supplied_post_statements.c_str(), O_RDWR)) == -1) |
1
by brian
clean slate |
2157 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2158 |
fprintf(stderr,"%s: Could not open query supplied file\n", internal::my_progname); |
1
by brian
clean slate |
2159 |
exit(1); |
2160 |
}
|
|
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
2161 |
|
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
2162 |
if ((uint64_t)(sbuf.st_size + 1) > SIZE_MAX) |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
2163 |
{
|
2164 |
fprintf(stderr, "Request for more memory than architecture supports\n"); |
|
2165 |
exit(1); |
|
2166 |
}
|
|
2167 |
tmp_string= (char *)malloc((size_t)(sbuf.st_size + 1)); |
|
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
2168 |
if (tmp_string == NULL) |
2169 |
{
|
|
2170 |
fprintf(stderr, "Memory Allocation error in option processing\n"); |
|
2171 |
exit(1); |
|
2172 |
}
|
|
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
2173 |
memset(tmp_string, 0, (size_t)(sbuf.st_size+1)); |
2174 |
||
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
2175 |
bytes_read= read(data_file, (unsigned char*) tmp_string, |
2176 |
(size_t)(sbuf.st_size)); |
|
1
by brian
clean slate |
2177 |
tmp_string[sbuf.st_size]= '\0'; |
1014.8.4
by Toru Maesaka
Replace occrrences of my_(open|close) with straight open() and close() system calls |
2178 |
close(data_file); |
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
2179 |
if (bytes_read != sbuf.st_size) |
2180 |
{
|
|
2181 |
fprintf(stderr, "Problem reading file: read less bytes than requested\n"); |
|
2182 |
}
|
|
1531.2.4
by Vijay Samuel
Updated Slap |
2183 |
if (!user_supplied_post_statements.empty()) |
1
by brian
clean slate |
2184 |
(void)parse_delimiter(tmp_string, &post_statements, |
2185 |
delimiter[0]); |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
2186 |
free(tmp_string); |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2187 |
}
|
1531.2.4
by Vijay Samuel
Updated Slap |
2188 |
else if (!user_supplied_post_statements.empty()) |
1
by brian
clean slate |
2189 |
{
|
1531.2.2
by Vijay Samuel
Updated slap code |
2190 |
(void)parse_delimiter(user_supplied_post_statements.c_str(), &post_statements, |
1
by brian
clean slate |
2191 |
delimiter[0]); |
2192 |
}
|
|
2193 |
||
2194 |
if (verbose >= 2) |
|
2195 |
printf("Parsing engines to use.\n"); |
|
2196 |
||
1531.2.4
by Vijay Samuel
Updated Slap |
2197 |
if (!default_engine.empty()) |
1531.2.2
by Vijay Samuel
Updated slap code |
2198 |
parse_option(default_engine.c_str(), &engine_options, ','); |
1
by brian
clean slate |
2199 |
|
2200 |
if (tty_password) |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2201 |
opt_password= client_get_tty_password(NULL); |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2202 |
return(0); |
1
by brian
clean slate |
2203 |
}
|
2204 |
||
2205 |
||
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2206 |
static int run_query(drizzle_con_st *con, drizzle_result_st *result, |
2207 |
const char *query, int len) |
|
1
by brian
clean slate |
2208 |
{
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2209 |
drizzle_return_t ret; |
2210 |
drizzle_result_st result_buffer; |
|
2211 |
||
1
by brian
clean slate |
2212 |
if (opt_only_print) |
2213 |
{
|
|
2214 |
printf("%.*s;\n", len, query); |
|
2215 |
return 0; |
|
2216 |
}
|
|
2217 |
||
2218 |
if (verbose >= 3) |
|
2219 |
printf("%.*s;\n", len, query); |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2220 |
|
2221 |
if (result == NULL) |
|
2222 |
result= &result_buffer; |
|
2223 |
||
2224 |
result= drizzle_query(con, result, query, len, &ret); |
|
2225 |
||
2226 |
if (ret == DRIZZLE_RETURN_OK) |
|
2227 |
ret= drizzle_result_buffer(result); |
|
2228 |
||
2229 |
if (result == &result_buffer) |
|
2230 |
drizzle_result_free(result); |
|
2231 |
||
2232 |
return ret; |
|
1
by brian
clean slate |
2233 |
}
|
2234 |
||
2235 |
||
2236 |
static int |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2237 |
generate_primary_key_list(drizzle_con_st *con, OptionString *engine_stmt) |
1
by brian
clean slate |
2238 |
{
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2239 |
drizzle_result_st result; |
2240 |
drizzle_row_t row; |
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
2241 |
uint64_t counter; |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2242 |
|
1
by brian
clean slate |
2243 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2244 |
/*
|
2245 |
Blackhole is a special case, this allows us to test the upper end
|
|
1
by brian
clean slate |
2246 |
of the server during load runs.
|
2247 |
*/
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2248 |
if (opt_only_print || (engine_stmt && |
1441.3.1
by Vijay Samuel
all required updations have been made |
2249 |
strstr(engine_stmt->getString(), "blackhole"))) |
1
by brian
clean slate |
2250 |
{
|
2251 |
primary_keys_number_of= 1; |
|
656.1.20
by Monty Taylor
Removed my_strdup, my_malloc, my_realloc from client/ |
2252 |
primary_keys= (char **)malloc((sizeof(char *) * |
2253 |
primary_keys_number_of)); |
|
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
2254 |
if (primary_keys == NULL) |
2255 |
{
|
|
2256 |
fprintf(stderr, "Memory Allocation error in option processing\n"); |
|
2257 |
exit(1); |
|
2258 |
}
|
|
656.1.20
by Monty Taylor
Removed my_strdup, my_malloc, my_realloc from client/ |
2259 |
|
2260 |
memset(primary_keys, 0, (sizeof(char *) * primary_keys_number_of)); |
|
1
by brian
clean slate |
2261 |
/* Yes, we strdup a const string to simplify the interface */
|
656.1.20
by Monty Taylor
Removed my_strdup, my_malloc, my_realloc from client/ |
2262 |
primary_keys[0]= strdup("796c4422-1d94-102a-9d6d-00e0812d"); |
656.1.51
by Monty Taylor
Fixed strdup return checking in client/ |
2263 |
if (primary_keys[0] == NULL) |
2264 |
{
|
|
2265 |
fprintf(stderr, "Memory Allocation error in option processing\n"); |
|
2266 |
exit(1); |
|
2267 |
}
|
|
1
by brian
clean slate |
2268 |
}
|
2269 |
else
|
|
2270 |
{
|
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2271 |
if (run_query(con, &result, "SELECT id from t1", strlen("SELECT id from t1"))) |
1
by brian
clean slate |
2272 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2273 |
fprintf(stderr,"%s: Cannot select GUID primary keys. (%s)\n", internal::my_progname, |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2274 |
drizzle_con_error(con)); |
1
by brian
clean slate |
2275 |
exit(1); |
2276 |
}
|
|
2277 |
||
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2278 |
uint64_t num_rows_ret= drizzle_result_row_count(&result); |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
2279 |
if (num_rows_ret > SIZE_MAX) |
2280 |
{
|
|
2281 |
fprintf(stderr, "More primary keys than than architecture supports\n"); |
|
2282 |
exit(1); |
|
2283 |
}
|
|
2284 |
primary_keys_number_of= (size_t)num_rows_ret; |
|
1
by brian
clean slate |
2285 |
|
2286 |
/* So why check this? Blackhole :) */
|
|
2287 |
if (primary_keys_number_of) |
|
2288 |
{
|
|
2289 |
/*
|
|
2290 |
We create the structure and loop and create the items.
|
|
2291 |
*/
|
|
656.1.20
by Monty Taylor
Removed my_strdup, my_malloc, my_realloc from client/ |
2292 |
primary_keys= (char **)malloc(sizeof(char *) * |
2293 |
primary_keys_number_of); |
|
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
2294 |
if (primary_keys == NULL) |
2295 |
{
|
|
2296 |
fprintf(stderr, "Memory Allocation error in option processing\n"); |
|
2297 |
exit(1); |
|
2298 |
}
|
|
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
2299 |
memset(primary_keys, 0, (size_t)(sizeof(char *) * primary_keys_number_of)); |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2300 |
row= drizzle_row_next(&result); |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2301 |
for (counter= 0; counter < primary_keys_number_of; |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2302 |
counter++, row= drizzle_row_next(&result)) |
656.1.51
by Monty Taylor
Fixed strdup return checking in client/ |
2303 |
{
|
656.1.20
by Monty Taylor
Removed my_strdup, my_malloc, my_realloc from client/ |
2304 |
primary_keys[counter]= strdup(row[0]); |
656.1.51
by Monty Taylor
Fixed strdup return checking in client/ |
2305 |
if (primary_keys[counter] == NULL) |
2306 |
{
|
|
2307 |
fprintf(stderr, "Memory Allocation error in option processing\n"); |
|
2308 |
exit(1); |
|
2309 |
}
|
|
2310 |
}
|
|
1
by brian
clean slate |
2311 |
}
|
2312 |
||
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2313 |
drizzle_result_free(&result); |
1
by brian
clean slate |
2314 |
}
|
2315 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2316 |
return(0); |
1
by brian
clean slate |
2317 |
}
|
2318 |
||
2319 |
static int |
|
2320 |
drop_primary_key_list(void) |
|
2321 |
{
|
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
2322 |
uint64_t counter; |
1
by brian
clean slate |
2323 |
|
2324 |
if (primary_keys_number_of) |
|
2325 |
{
|
|
2326 |
for (counter= 0; counter < primary_keys_number_of; counter++) |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
2327 |
free(primary_keys[counter]); |
1
by brian
clean slate |
2328 |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
2329 |
free(primary_keys); |
1
by brian
clean slate |
2330 |
}
|
2331 |
||
2332 |
return 0; |
|
2333 |
}
|
|
2334 |
||
2335 |
static int |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2336 |
create_schema(drizzle_con_st *con, const char *db, Statement *stmt, |
2337 |
OptionString *engine_stmt, Stats *sptr) |
|
1
by brian
clean slate |
2338 |
{
|
2339 |
char query[HUGE_STRING_LENGTH]; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2340 |
Statement *ptr; |
2341 |
Statement *after_create; |
|
1
by brian
clean slate |
2342 |
int len; |
151
by Brian Aker
Ulonglong to uint64_t |
2343 |
uint64_t count; |
1
by brian
clean slate |
2344 |
struct timeval start_time, end_time; |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2345 |
|
1
by brian
clean slate |
2346 |
|
2347 |
gettimeofday(&start_time, NULL); |
|
2348 |
||
2349 |
len= snprintf(query, HUGE_STRING_LENGTH, "CREATE SCHEMA `%s`", db); |
|
2350 |
||
2351 |
if (verbose >= 2) |
|
2352 |
printf("Loading Pre-data\n"); |
|
2353 |
||
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2354 |
if (run_query(con, NULL, query, len)) |
1
by brian
clean slate |
2355 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2356 |
fprintf(stderr,"%s: Cannot create schema %s : %s\n", internal::my_progname, db, |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2357 |
drizzle_con_error(con)); |
1
by brian
clean slate |
2358 |
exit(1); |
2359 |
}
|
|
2360 |
else
|
|
2361 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2362 |
sptr->setCreateCount(sptr->getCreateCount()+1); |
1
by brian
clean slate |
2363 |
}
|
2364 |
||
2365 |
if (opt_only_print) |
|
2366 |
{
|
|
2367 |
printf("use %s;\n", db); |
|
2368 |
}
|
|
2369 |
else
|
|
2370 |
{
|
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2371 |
drizzle_result_st result; |
2372 |
drizzle_return_t ret; |
|
2373 |
||
1
by brian
clean slate |
2374 |
if (verbose >= 3) |
2375 |
printf("%s;\n", query); |
|
2376 |
||
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2377 |
if (drizzle_select_db(con, &result, db, &ret) == NULL || |
2378 |
ret != DRIZZLE_RETURN_OK) |
|
1
by brian
clean slate |
2379 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2380 |
fprintf(stderr,"%s: Cannot select schema '%s': %s\n",internal::my_progname, db, |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2381 |
ret == DRIZZLE_RETURN_ERROR_CODE ? |
2382 |
drizzle_result_error(&result) : drizzle_con_error(con)); |
|
1
by brian
clean slate |
2383 |
exit(1); |
2384 |
}
|
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2385 |
drizzle_result_free(&result); |
1441.3.1
by Vijay Samuel
all required updations have been made |
2386 |
sptr->setCreateCount(sptr->getCreateCount()+1); |
1
by brian
clean slate |
2387 |
}
|
2388 |
||
2389 |
if (engine_stmt) |
|
2390 |
{
|
|
2391 |
len= snprintf(query, HUGE_STRING_LENGTH, "set storage_engine=`%s`", |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2392 |
engine_stmt->getString()); |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2393 |
if (run_query(con, NULL, query, len)) |
1
by brian
clean slate |
2394 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2395 |
fprintf(stderr,"%s: Cannot set default engine: %s\n", internal::my_progname, |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2396 |
drizzle_con_error(con)); |
1
by brian
clean slate |
2397 |
exit(1); |
2398 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2399 |
sptr->setCreateCount(sptr->getCreateCount()+1); |
1
by brian
clean slate |
2400 |
}
|
2401 |
||
2402 |
count= 0; |
|
2403 |
after_create= stmt; |
|
2404 |
||
2405 |
limit_not_met: |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2406 |
for (ptr= after_create; ptr && ptr->getLength(); ptr= ptr->getNext(), count++) |
1
by brian
clean slate |
2407 |
{
|
2408 |
if (auto_generate_sql && ( auto_generate_sql_number == count)) |
|
2409 |
break; |
|
2410 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
2411 |
if (engine_stmt && engine_stmt->getOption() && ptr->getType() == CREATE_TABLE_TYPE) |
1
by brian
clean slate |
2412 |
{
|
2413 |
char buffer[HUGE_STRING_LENGTH]; |
|
2414 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
2415 |
snprintf(buffer, HUGE_STRING_LENGTH, "%s %s", ptr->getString(), |
2416 |
engine_stmt->getOption()); |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2417 |
if (run_query(con, NULL, buffer, strlen(buffer))) |
1
by brian
clean slate |
2418 |
{
|
2419 |
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n", |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2420 |
internal::my_progname, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(con)); |
1
by brian
clean slate |
2421 |
if (!opt_ignore_sql_errors) |
2422 |
exit(1); |
|
2423 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2424 |
sptr->setCreateCount(sptr->getCreateCount()+1); |
1
by brian
clean slate |
2425 |
}
|
2426 |
else
|
|
2427 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2428 |
if (run_query(con, NULL, ptr->getString(), ptr->getLength())) |
1
by brian
clean slate |
2429 |
{
|
2430 |
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n", |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2431 |
internal::my_progname, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(con)); |
1
by brian
clean slate |
2432 |
if (!opt_ignore_sql_errors) |
2433 |
exit(1); |
|
2434 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2435 |
sptr->setCreateCount(sptr->getCreateCount()+1); |
1
by brian
clean slate |
2436 |
}
|
2437 |
}
|
|
2438 |
||
2439 |
if (auto_generate_sql && (auto_generate_sql_number > count )) |
|
2440 |
{
|
|
2441 |
/* Special case for auto create, we don't want to create tables twice */
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2442 |
after_create= stmt->getNext(); |
1
by brian
clean slate |
2443 |
goto limit_not_met; |
2444 |
}
|
|
2445 |
||
2446 |
gettimeofday(&end_time, NULL); |
|
2447 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
2448 |
sptr->setCreateTiming(timedif(end_time, start_time)); |
1
by brian
clean slate |
2449 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2450 |
return(0); |
1
by brian
clean slate |
2451 |
}
|
2452 |
||
2453 |
static int |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2454 |
drop_schema(drizzle_con_st *con, const char *db) |
1
by brian
clean slate |
2455 |
{
|
2456 |
char query[HUGE_STRING_LENGTH]; |
|
2457 |
int len; |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2458 |
|
1
by brian
clean slate |
2459 |
len= snprintf(query, HUGE_STRING_LENGTH, "DROP SCHEMA IF EXISTS `%s`", db); |
2460 |
||
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2461 |
if (run_query(con, NULL, query, len)) |
1
by brian
clean slate |
2462 |
{
|
2463 |
fprintf(stderr,"%s: Cannot drop database '%s' ERROR : %s\n", |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2464 |
internal::my_progname, db, drizzle_con_error(con)); |
1
by brian
clean slate |
2465 |
exit(1); |
2466 |
}
|
|
2467 |
||
2468 |
||
2469 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2470 |
return(0); |
1
by brian
clean slate |
2471 |
}
|
2472 |
||
2473 |
static int |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2474 |
run_statements(drizzle_con_st *con, Statement *stmt) |
1
by brian
clean slate |
2475 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2476 |
Statement *ptr; |
1
by brian
clean slate |
2477 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2478 |
for (ptr= stmt; ptr && ptr->getLength(); ptr= ptr->getNext()) |
1
by brian
clean slate |
2479 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2480 |
if (run_query(con, NULL, ptr->getString(), ptr->getLength())) |
1
by brian
clean slate |
2481 |
{
|
2482 |
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n", |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2483 |
internal::my_progname, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(con)); |
1
by brian
clean slate |
2484 |
exit(1); |
2485 |
}
|
|
2486 |
}
|
|
2487 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2488 |
return(0); |
1
by brian
clean slate |
2489 |
}
|
2490 |
||
2491 |
static int |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2492 |
run_scheduler(Stats *sptr, Statement **stmts, uint32_t concur, uint64_t limit) |
1
by brian
clean slate |
2493 |
{
|
893
by Brian Aker
First pass of stripping uint |
2494 |
uint32_t x; |
2495 |
uint32_t y; |
|
1
by brian
clean slate |
2496 |
unsigned int real_concurrency; |
2497 |
struct timeval start_time, end_time; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2498 |
OptionString *sql_type; |
2499 |
ThreadContext *con; |
|
1
by brian
clean slate |
2500 |
pthread_t mainthread; /* Thread descriptor */ |
2501 |
pthread_attr_t attr; /* Thread attributes */ |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2502 |
|
1
by brian
clean slate |
2503 |
|
2504 |
pthread_attr_init(&attr); |
|
2505 |
pthread_attr_setdetachstate(&attr, |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2506 |
PTHREAD_CREATE_DETACHED); |
1
by brian
clean slate |
2507 |
|
2508 |
pthread_mutex_lock(&counter_mutex); |
|
2509 |
thread_counter= 0; |
|
2510 |
||
2511 |
pthread_mutex_lock(&sleeper_mutex); |
|
2512 |
master_wakeup= 1; |
|
2513 |
pthread_mutex_unlock(&sleeper_mutex); |
|
2514 |
||
2515 |
real_concurrency= 0; |
|
2516 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2517 |
for (y= 0, sql_type= query_options; |
2518 |
y < query_statements_count; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2519 |
y++, sql_type= sql_type->getNext()) |
1
by brian
clean slate |
2520 |
{
|
2521 |
unsigned int options_loop= 1; |
|
2522 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
2523 |
if (sql_type->getOption()) |
1
by brian
clean slate |
2524 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2525 |
options_loop= strtol(sql_type->getOption(), |
1
by brian
clean slate |
2526 |
(char **)NULL, 10); |
2527 |
options_loop= options_loop ? options_loop : 1; |
|
2528 |
}
|
|
2529 |
||
2530 |
while (options_loop--) |
|
2531 |
for (x= 0; x < concur; x++) |
|
2532 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2533 |
con= (ThreadContext *)malloc(sizeof(ThreadContext)); |
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
2534 |
if (con == NULL) |
2535 |
{
|
|
2536 |
fprintf(stderr, "Memory Allocation error in scheduler\n"); |
|
2537 |
exit(1); |
|
2538 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2539 |
con->setStmt(stmts[y]); |
2540 |
con->setLimit(limit); |
|
1
by brian
clean slate |
2541 |
|
2542 |
real_concurrency++; |
|
2543 |
/* now you create the thread */
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2544 |
if (pthread_create(&mainthread, &attr, run_task, |
1
by brian
clean slate |
2545 |
(void *)con) != 0) |
2546 |
{
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2547 |
fprintf(stderr,"%s: Could not create thread\n", internal::my_progname); |
1
by brian
clean slate |
2548 |
exit(1); |
2549 |
}
|
|
2550 |
thread_counter++; |
|
2551 |
}
|
|
2552 |
}
|
|
2553 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2554 |
/*
|
2555 |
The timer_thread belongs to all threads so it too obeys the wakeup
|
|
1
by brian
clean slate |
2556 |
call that run tasks obey.
|
2557 |
*/
|
|
2558 |
if (opt_timer_length) |
|
2559 |
{
|
|
2560 |
pthread_mutex_lock(&timer_alarm_mutex); |
|
163
by Brian Aker
Merge Monty's code. |
2561 |
timer_alarm= true; |
1
by brian
clean slate |
2562 |
pthread_mutex_unlock(&timer_alarm_mutex); |
2563 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2564 |
if (pthread_create(&mainthread, &attr, timer_thread, |
1
by brian
clean slate |
2565 |
(void *)&opt_timer_length) != 0) |
2566 |
{
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2567 |
fprintf(stderr,"%s: Could not create timer thread\n", internal::my_progname); |
1
by brian
clean slate |
2568 |
exit(1); |
2569 |
}
|
|
2570 |
}
|
|
2571 |
||
2572 |
pthread_mutex_unlock(&counter_mutex); |
|
2573 |
pthread_attr_destroy(&attr); |
|
2574 |
||
2575 |
pthread_mutex_lock(&sleeper_mutex); |
|
2576 |
master_wakeup= 0; |
|
2577 |
pthread_mutex_unlock(&sleeper_mutex); |
|
2578 |
pthread_cond_broadcast(&sleep_threshhold); |
|
2579 |
||
2580 |
gettimeofday(&start_time, NULL); |
|
2581 |
||
2582 |
/*
|
|
2583 |
We loop until we know that all children have cleaned up.
|
|
2584 |
*/
|
|
2585 |
pthread_mutex_lock(&counter_mutex); |
|
2586 |
while (thread_counter) |
|
2587 |
{
|
|
2588 |
struct timespec abstime; |
|
2589 |
||
2590 |
set_timespec(abstime, 3); |
|
2591 |
pthread_cond_timedwait(&count_threshhold, &counter_mutex, &abstime); |
|
2592 |
}
|
|
2593 |
pthread_mutex_unlock(&counter_mutex); |
|
2594 |
||
2595 |
gettimeofday(&end_time, NULL); |
|
2596 |
||
2597 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
2598 |
sptr->setTiming(timedif(end_time, start_time)); |
2599 |
sptr->setUsers(concur); |
|
2600 |
sptr->setRealUsers(real_concurrency); |
|
2601 |
sptr->setRows(limit); |
|
1
by brian
clean slate |
2602 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2603 |
return(0); |
1
by brian
clean slate |
2604 |
}
|
2605 |
||
2606 |
||
2607 |
pthread_handler_t timer_thread(void *p) |
|
2608 |
{
|
|
893
by Brian Aker
First pass of stripping uint |
2609 |
uint32_t *timer_length= (uint32_t *)p; |
1
by brian
clean slate |
2610 |
struct timespec abstime; |
2611 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2612 |
|
2613 |
/*
|
|
2614 |
We lock around the initial call in case were we in a loop. This
|
|
1
by brian
clean slate |
2615 |
also keeps the value properly syncronized across call threads.
|
2616 |
*/
|
|
2617 |
pthread_mutex_lock(&sleeper_mutex); |
|
2618 |
while (master_wakeup) |
|
2619 |
{
|
|
2620 |
pthread_cond_wait(&sleep_threshhold, &sleeper_mutex); |
|
2621 |
}
|
|
2622 |
pthread_mutex_unlock(&sleeper_mutex); |
|
2623 |
||
2624 |
set_timespec(abstime, *timer_length); |
|
2625 |
||
2626 |
pthread_mutex_lock(&timer_alarm_mutex); |
|
2627 |
pthread_cond_timedwait(&timer_alarm_threshold, &timer_alarm_mutex, &abstime); |
|
2628 |
pthread_mutex_unlock(&timer_alarm_mutex); |
|
2629 |
||
2630 |
pthread_mutex_lock(&timer_alarm_mutex); |
|
163
by Brian Aker
Merge Monty's code. |
2631 |
timer_alarm= false; |
1
by brian
clean slate |
2632 |
pthread_mutex_unlock(&timer_alarm_mutex); |
2633 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2634 |
return(0); |
1
by brian
clean slate |
2635 |
}
|
2636 |
||
2637 |
pthread_handler_t run_task(void *p) |
|
2638 |
{
|
|
151
by Brian Aker
Ulonglong to uint64_t |
2639 |
uint64_t counter= 0, queries; |
2640 |
uint64_t detach_counter; |
|
1
by brian
clean slate |
2641 |
unsigned int commit_counter; |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2642 |
drizzle_con_st con; |
2643 |
drizzle_result_st result; |
|
2644 |
drizzle_row_t row; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2645 |
Statement *ptr; |
2646 |
ThreadContext *ctx= (ThreadContext *)p; |
|
1
by brian
clean slate |
2647 |
|
2648 |
pthread_mutex_lock(&sleeper_mutex); |
|
2649 |
while (master_wakeup) |
|
2650 |
{
|
|
2651 |
pthread_cond_wait(&sleep_threshhold, &sleeper_mutex); |
|
2652 |
}
|
|
2653 |
pthread_mutex_unlock(&sleeper_mutex); |
|
2654 |
||
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2655 |
slap_connect(&con, true); |
1
by brian
clean slate |
2656 |
|
2657 |
if (verbose >= 3) |
|
2658 |
printf("connected!\n"); |
|
2659 |
queries= 0; |
|
2660 |
||
2661 |
commit_counter= 0; |
|
2662 |
if (commit_rate) |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2663 |
run_query(&con, NULL, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0")); |
1
by brian
clean slate |
2664 |
|
2665 |
limit_not_met: |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2666 |
for (ptr= ctx->getStmt(), detach_counter= 0; |
2667 |
ptr && ptr->getLength(); |
|
2668 |
ptr= ptr->getNext(), detach_counter++) |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2669 |
{
|
2670 |
if (!opt_only_print && detach_rate && !(detach_counter % detach_rate)) |
|
2671 |
{
|
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2672 |
slap_close(&con); |
2673 |
slap_connect(&con, true); |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2674 |
}
|
2675 |
||
2676 |
/*
|
|
2677 |
We have to execute differently based on query type. This should become a function.
|
|
2678 |
*/
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2679 |
if ((ptr->getType() == UPDATE_TYPE_REQUIRES_PREFIX) || |
2680 |
(ptr->getType() == SELECT_TYPE_REQUIRES_PREFIX)) |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2681 |
{
|
2682 |
int length; |
|
2683 |
unsigned int key_val; |
|
2684 |
char *key; |
|
2685 |
char buffer[HUGE_STRING_LENGTH]; |
|
1
by brian
clean slate |
2686 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2687 |
/*
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2688 |
This should only happen if some sort of new engine was
|
2689 |
implemented that didn't properly handle UPDATEs.
|
|
2690 |
||
2691 |
Just in case someone runs this under an experimental engine we don't
|
|
2692 |
want a crash so the if() is placed here.
|
|
1
by brian
clean slate |
2693 |
*/
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2694 |
assert(primary_keys_number_of); |
2695 |
if (primary_keys_number_of) |
|
2696 |
{
|
|
2697 |
key_val= (unsigned int)(random() % primary_keys_number_of); |
|
2698 |
key= primary_keys[key_val]; |
|
2699 |
||
2700 |
assert(key); |
|
2701 |
||
2702 |
length= snprintf(buffer, HUGE_STRING_LENGTH, "%.*s '%s'", |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2703 |
(int)ptr->getLength(), ptr->getString(), key); |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2704 |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2705 |
if (run_query(&con, &result, buffer, length)) |
1
by brian
clean slate |
2706 |
{
|
2707 |
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n", |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2708 |
internal::my_progname, (uint32_t)length, buffer, drizzle_con_error(&con)); |
1
by brian
clean slate |
2709 |
exit(1); |
2710 |
}
|
|
2711 |
}
|
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2712 |
}
|
2713 |
else
|
|
2714 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2715 |
if (run_query(&con, &result, ptr->getString(), ptr->getLength())) |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2716 |
{
|
2717 |
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n", |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2718 |
internal::my_progname, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(&con)); |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2719 |
exit(1); |
2720 |
}
|
|
2721 |
}
|
|
1
by brian
clean slate |
2722 |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2723 |
if (!opt_only_print) |
2724 |
{
|
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2725 |
while ((row = drizzle_row_next(&result))) |
2726 |
counter++; |
|
2727 |
drizzle_result_free(&result); |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2728 |
}
|
2729 |
queries++; |
|
2730 |
||
2731 |
if (commit_rate && (++commit_counter == commit_rate)) |
|
2732 |
{
|
|
2733 |
commit_counter= 0; |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2734 |
run_query(&con, NULL, "COMMIT", strlen("COMMIT")); |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2735 |
}
|
2736 |
||
2737 |
/* If the timer is set, and the alarm is not active then end */
|
|
2738 |
if (opt_timer_length && timer_alarm == false) |
|
2739 |
goto end; |
|
2740 |
||
2741 |
/* If limit has been reached, and we are not in a timer_alarm just end */
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2742 |
if (ctx->getLimit() && queries == ctx->getLimit() && timer_alarm == false) |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2743 |
goto end; |
2744 |
}
|
|
2745 |
||
2746 |
if (opt_timer_length && timer_alarm == true) |
|
2747 |
goto limit_not_met; |
|
2748 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
2749 |
if (ctx->getLimit() && queries < ctx->getLimit()) |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2750 |
goto limit_not_met; |
1
by brian
clean slate |
2751 |
|
2752 |
||
2753 |
end: |
|
2754 |
if (commit_rate) |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2755 |
run_query(&con, NULL, "COMMIT", strlen("COMMIT")); |
1
by brian
clean slate |
2756 |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2757 |
slap_close(&con); |
1
by brian
clean slate |
2758 |
|
2759 |
pthread_mutex_lock(&counter_mutex); |
|
2760 |
thread_counter--; |
|
2761 |
pthread_cond_signal(&count_threshhold); |
|
2762 |
pthread_mutex_unlock(&counter_mutex); |
|
2763 |
||
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2764 |
free(ctx); |
1
by brian
clean slate |
2765 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2766 |
return(0); |
1
by brian
clean slate |
2767 |
}
|
2768 |
||
2769 |
/*
|
|
2770 |
Parse records from comma seperated string. : is a reserved character and is used for options
|
|
2771 |
on variables.
|
|
2772 |
*/
|
|
2773 |
uint
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2774 |
parse_option(const char *origin, OptionString **stmt, char delm) |
1
by brian
clean slate |
2775 |
{
|
2776 |
char *string; |
|
2777 |
char *begin_ptr; |
|
2778 |
char *end_ptr; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2779 |
OptionString **sptr= stmt; |
2780 |
OptionString *tmp; |
|
893
by Brian Aker
First pass of stripping uint |
2781 |
uint32_t length= strlen(origin); |
2782 |
uint32_t count= 0; /* We know that there is always one */ |
|
1
by brian
clean slate |
2783 |
|
2784 |
end_ptr= (char *)origin + length; |
|
2785 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
2786 |
tmp= *sptr= (OptionString *)malloc(sizeof(OptionString)); |
656.1.44
by Monty Taylor
Added some return checking. |
2787 |
if (tmp == NULL) |
2788 |
{
|
|
2789 |
fprintf(stderr,"Error allocating memory while parsing options\n"); |
|
2790 |
exit(1); |
|
2791 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2792 |
memset(tmp, 0, sizeof(OptionString)); |
1
by brian
clean slate |
2793 |
|
2794 |
for (begin_ptr= (char *)origin; |
|
2795 |
begin_ptr != end_ptr; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2796 |
tmp= tmp->getNext()) |
1
by brian
clean slate |
2797 |
{
|
2798 |
char buffer[HUGE_STRING_LENGTH]; |
|
2799 |
char *buffer_ptr; |
|
2800 |
||
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
2801 |
memset(buffer, 0, HUGE_STRING_LENGTH); |
1
by brian
clean slate |
2802 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2803 |
string= strchr(begin_ptr, delm); |
1
by brian
clean slate |
2804 |
|
2805 |
if (string) |
|
2806 |
{
|
|
2807 |
memcpy(buffer, begin_ptr, string - begin_ptr); |
|
2808 |
begin_ptr= string+1; |
|
2809 |
}
|
|
2810 |
else
|
|
2811 |
{
|
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
2812 |
size_t begin_len= strlen(begin_ptr); |
2813 |
memcpy(buffer, begin_ptr, begin_len); |
|
1
by brian
clean slate |
2814 |
begin_ptr= end_ptr; |
2815 |
}
|
|
2816 |
||
2817 |
if ((buffer_ptr= strchr(buffer, ':'))) |
|
2818 |
{
|
|
2819 |
/* Set a null so that we can get strlen() correct later on */
|
|
2820 |
buffer_ptr[0]= 0; |
|
2821 |
buffer_ptr++; |
|
2822 |
||
2823 |
/* Move past the : and the first string */
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2824 |
tmp->setOptionLength(strlen(buffer_ptr)); |
2825 |
tmp->setOption((char *)malloc(tmp->getOptionLength() + 1)); |
|
2826 |
if (tmp->getOption() == NULL) |
|
656.1.44
by Monty Taylor
Added some return checking. |
2827 |
{
|
2828 |
fprintf(stderr,"Error allocating memory while parsing options\n"); |
|
2829 |
exit(1); |
|
2830 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2831 |
memcpy(tmp->getOption(), buffer_ptr, tmp->getOptionLength()); |
2832 |
tmp->setOption(tmp->getOptionLength(),0); |
|
1
by brian
clean slate |
2833 |
}
|
2834 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
2835 |
tmp->setLength(strlen(buffer)); |
2836 |
tmp->setString(strdup(buffer)); |
|
2837 |
if (tmp->getString() == NULL) |
|
656.1.51
by Monty Taylor
Fixed strdup return checking in client/ |
2838 |
{
|
2839 |
fprintf(stderr,"Error allocating memory while parsing options\n"); |
|
2840 |
exit(1); |
|
2841 |
}
|
|
1
by brian
clean slate |
2842 |
|
2843 |
if (isspace(*begin_ptr)) |
|
2844 |
begin_ptr++; |
|
2845 |
||
2846 |
count++; |
|
2847 |
||
2848 |
if (begin_ptr != end_ptr) |
|
656.1.20
by Monty Taylor
Removed my_strdup, my_malloc, my_realloc from client/ |
2849 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2850 |
tmp->setNext((OptionString *)malloc(sizeof(OptionString))); |
2851 |
if (tmp->getNext() == NULL) |
|
656.1.44
by Monty Taylor
Added some return checking. |
2852 |
{
|
2853 |
fprintf(stderr,"Error allocating memory while parsing options\n"); |
|
2854 |
exit(1); |
|
2855 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2856 |
memset(tmp->getNext(), 0, sizeof(OptionString)); |
656.1.20
by Monty Taylor
Removed my_strdup, my_malloc, my_realloc from client/ |
2857 |
}
|
2858 |
||
1
by brian
clean slate |
2859 |
}
|
2860 |
||
2861 |
return count; |
|
2862 |
}
|
|
2863 |
||
2864 |
||
2865 |
/*
|
|
2866 |
Raw parsing interface. If you want the slap specific parser look at
|
|
2867 |
parse_option.
|
|
2868 |
*/
|
|
2869 |
uint
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2870 |
parse_delimiter(const char *script, Statement **stmt, char delm) |
1
by brian
clean slate |
2871 |
{
|
2872 |
char *retstr; |
|
2873 |
char *ptr= (char *)script; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2874 |
Statement **sptr= stmt; |
2875 |
Statement *tmp; |
|
893
by Brian Aker
First pass of stripping uint |
2876 |
uint32_t length= strlen(script); |
2877 |
uint32_t count= 0; /* We know that there is always one */ |
|
1
by brian
clean slate |
2878 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2879 |
for (tmp= *sptr= (Statement *)calloc(1, sizeof(Statement)); |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2880 |
(retstr= strchr(ptr, delm)); |
1441.3.1
by Vijay Samuel
all required updations have been made |
2881 |
tmp->setNext((Statement *)calloc(1, sizeof(Statement))), |
2882 |
tmp= tmp->getNext()) |
|
1
by brian
clean slate |
2883 |
{
|
1014.8.2
by Toru Maesaka
Add memory allocation check and fix SEGV problem caused in statement_cleanup() by using calloc. This is temporary, the query statement list should be migrated to a proper container like std::vector |
2884 |
if (tmp == NULL) |
2885 |
{
|
|
2886 |
fprintf(stderr,"Error allocating memory while parsing delimiter\n"); |
|
2887 |
exit(1); |
|
2888 |
}
|
|
2889 |
||
1
by brian
clean slate |
2890 |
count++; |
1441.3.1
by Vijay Samuel
all required updations have been made |
2891 |
tmp->setLength((size_t)(retstr - ptr)); |
2892 |
tmp->setString((char *)malloc(tmp->getLength() + 1)); |
|
1014.8.2
by Toru Maesaka
Add memory allocation check and fix SEGV problem caused in statement_cleanup() by using calloc. This is temporary, the query statement list should be migrated to a proper container like std::vector |
2893 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2894 |
if (tmp->getString() == NULL) |
656.1.50
by Monty Taylor
More malloc return type checking |
2895 |
{
|
2896 |
fprintf(stderr,"Error allocating memory while parsing delimiter\n"); |
|
2897 |
exit(1); |
|
2898 |
}
|
|
1014.8.2
by Toru Maesaka
Add memory allocation check and fix SEGV problem caused in statement_cleanup() by using calloc. This is temporary, the query statement list should be migrated to a proper container like std::vector |
2899 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2900 |
memcpy(tmp->getString(), ptr, tmp->getLength()); |
2901 |
tmp->setString(tmp->getLength(), 0); |
|
1
by brian
clean slate |
2902 |
ptr+= retstr - ptr + 1; |
2903 |
if (isspace(*ptr)) |
|
2904 |
ptr++; |
|
2905 |
}
|
|
2906 |
||
2907 |
if (ptr != script+length) |
|
2908 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2909 |
tmp->setLength((size_t)((script + length) - ptr)); |
2910 |
tmp->setString((char *)malloc(tmp->getLength() + 1)); |
|
2911 |
if (tmp->getString() == NULL) |
|
656.1.50
by Monty Taylor
More malloc return type checking |
2912 |
{
|
2913 |
fprintf(stderr,"Error allocating memory while parsing delimiter\n"); |
|
2914 |
exit(1); |
|
2915 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2916 |
memcpy(tmp->getString(), ptr, tmp->getLength()); |
2917 |
tmp->setString(tmp->getLength(),0); |
|
1
by brian
clean slate |
2918 |
count++; |
2919 |
}
|
|
2920 |
||
2921 |
return count; |
|
2922 |
}
|
|
2923 |
||
2924 |
||
2925 |
/*
|
|
2926 |
Parse comma is different from parse_delimeter in that it parses
|
|
2927 |
number ranges from a comma seperated string.
|
|
2928 |
In restrospect, this is a lousy name from this function.
|
|
2929 |
*/
|
|
2930 |
uint
|
|
893
by Brian Aker
First pass of stripping uint |
2931 |
parse_comma(const char *string, uint32_t **range) |
1
by brian
clean slate |
2932 |
{
|
656.1.20
by Monty Taylor
Removed my_strdup, my_malloc, my_realloc from client/ |
2933 |
unsigned int count= 1,x; /* We know that there is always one */ |
1
by brian
clean slate |
2934 |
char *retstr; |
2935 |
char *ptr= (char *)string; |
|
656.1.20
by Monty Taylor
Removed my_strdup, my_malloc, my_realloc from client/ |
2936 |
unsigned int *nptr; |
1
by brian
clean slate |
2937 |
|
2938 |
for (;*ptr; ptr++) |
|
2939 |
if (*ptr == ',') count++; |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2940 |
|
1
by brian
clean slate |
2941 |
/* One extra spot for the NULL */
|
893
by Brian Aker
First pass of stripping uint |
2942 |
nptr= *range= (uint32_t *)malloc(sizeof(unsigned int) * (count + 1)); |
656.1.20
by Monty Taylor
Removed my_strdup, my_malloc, my_realloc from client/ |
2943 |
memset(nptr, 0, sizeof(unsigned int) * (count + 1)); |
1
by brian
clean slate |
2944 |
|
2945 |
ptr= (char *)string; |
|
2946 |
x= 0; |
|
2947 |
while ((retstr= strchr(ptr,','))) |
|
2948 |
{
|
|
2949 |
nptr[x++]= atoi(ptr); |
|
2950 |
ptr+= retstr - ptr + 1; |
|
2951 |
}
|
|
2952 |
nptr[x++]= atoi(ptr); |
|
2953 |
||
2954 |
return count; |
|
2955 |
}
|
|
2956 |
||
2957 |
void
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2958 |
print_conclusions(Conclusions *con) |
1
by brian
clean slate |
2959 |
{
|
2960 |
printf("Benchmark\n"); |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2961 |
if (con->getEngine()) |
2962 |
printf("\tRunning for engine %s\n", con->getEngine()); |
|
1531.2.4
by Vijay Samuel
Updated Slap |
2963 |
if (!opt_label.empty() || !opt_auto_generate_sql_type.empty()) |
1
by brian
clean slate |
2964 |
{
|
1531.2.1
by Vijay Samuel
Slap refactored |
2965 |
const char *ptr= opt_auto_generate_sql_type.c_str() ? opt_auto_generate_sql_type.c_str() : "query"; |
1531.2.4
by Vijay Samuel
Updated Slap |
2966 |
printf("\tLoad: %s\n", !opt_label.empty() ? opt_label.c_str() : ptr); |
1
by brian
clean slate |
2967 |
}
|
2968 |
printf("\tAverage Time took to generate schema and initial data: %ld.%03ld seconds\n", |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2969 |
con->getCreateAvgTiming() / 1000, con->getCreateAvgTiming() % 1000); |
1
by brian
clean slate |
2970 |
printf("\tAverage number of seconds to run all queries: %ld.%03ld seconds\n", |
1441.3.1
by Vijay Samuel
all required updations have been made |
2971 |
con->getAvgTiming() / 1000, con->getAvgTiming() % 1000); |
1
by brian
clean slate |
2972 |
printf("\tMinimum number of seconds to run all queries: %ld.%03ld seconds\n", |
1441.3.1
by Vijay Samuel
all required updations have been made |
2973 |
con->getMinTiming() / 1000, con->getMinTiming() % 1000); |
1
by brian
clean slate |
2974 |
printf("\tMaximum number of seconds to run all queries: %ld.%03ld seconds\n", |
1441.3.1
by Vijay Samuel
all required updations have been made |
2975 |
con->getMaxTiming() / 1000, con->getMaxTiming() % 1000); |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2976 |
printf("\tTotal time for tests: %ld.%03ld seconds\n", |
1441.3.1
by Vijay Samuel
all required updations have been made |
2977 |
con->getSumOfTime() / 1000, con->getSumOfTime() % 1000); |
2978 |
printf("\tStandard Deviation: %ld.%03ld\n", con->getStdDev() / 1000, con->getStdDev() % 1000); |
|
2979 |
printf("\tNumber of queries in create queries: %"PRIu64"\n", con->getCreateCount()); |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2980 |
printf("\tNumber of clients running queries: %u/%u\n", |
1441.3.1
by Vijay Samuel
all required updations have been made |
2981 |
con->getUsers(), con->getRealUsers()); |
1
by brian
clean slate |
2982 |
printf("\tNumber of times test was run: %u\n", iterations); |
1441.3.1
by Vijay Samuel
all required updations have been made |
2983 |
printf("\tAverage number of queries per client: %"PRIu64"\n", con->getAvgRows()); |
1
by brian
clean slate |
2984 |
printf("\n"); |
2985 |
}
|
|
2986 |
||
2987 |
void
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2988 |
print_conclusions_csv(Conclusions *con) |
1
by brian
clean slate |
2989 |
{
|
2990 |
unsigned int x; |
|
2991 |
char buffer[HUGE_STRING_LENGTH]; |
|
2992 |
char label_buffer[HUGE_STRING_LENGTH]; |
|
2993 |
size_t string_len; |
|
1531.2.7
by Vijay Samuel
updated slap |
2994 |
const char *temp_label= opt_label.c_str(); |
1
by brian
clean slate |
2995 |
|
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
2996 |
memset(label_buffer, 0, HUGE_STRING_LENGTH); |
1
by brian
clean slate |
2997 |
|
1531.2.4
by Vijay Samuel
Updated Slap |
2998 |
if (!opt_label.empty()) |
1
by brian
clean slate |
2999 |
{
|
1531.2.1
by Vijay Samuel
Slap refactored |
3000 |
string_len= opt_label.length(); |
1
by brian
clean slate |
3001 |
|
3002 |
for (x= 0; x < string_len; x++) |
|
3003 |
{
|
|
1531.2.7
by Vijay Samuel
updated slap |
3004 |
if (temp_label[x] == ',') |
1
by brian
clean slate |
3005 |
label_buffer[x]= '-'; |
3006 |
else
|
|
1531.2.7
by Vijay Samuel
updated slap |
3007 |
label_buffer[x]= temp_label[x] ; |
1
by brian
clean slate |
3008 |
}
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
3009 |
}
|
1531.2.4
by Vijay Samuel
Updated Slap |
3010 |
else if (!opt_auto_generate_sql_type.empty()) |
1
by brian
clean slate |
3011 |
{
|
1531.2.1
by Vijay Samuel
Slap refactored |
3012 |
string_len= opt_auto_generate_sql_type.length(); |
1
by brian
clean slate |
3013 |
|
3014 |
for (x= 0; x < string_len; x++) |
|
3015 |
{
|
|
3016 |
if (opt_auto_generate_sql_type[x] == ',') |
|
3017 |
label_buffer[x]= '-'; |
|
3018 |
else
|
|
3019 |
label_buffer[x]= opt_auto_generate_sql_type[x] ; |
|
3020 |
}
|
|
3021 |
}
|
|
3022 |
else
|
|
3023 |
snprintf(label_buffer, HUGE_STRING_LENGTH, "query"); |
|
3024 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
3025 |
snprintf(buffer, HUGE_STRING_LENGTH, |
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
3026 |
"%s,%s,%ld.%03ld,%ld.%03ld,%ld.%03ld,%ld.%03ld,%ld.%03ld,"
|
3027 |
"%u,%u,%u,%"PRIu64"\n", |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3028 |
con->getEngine() ? con->getEngine() : "", /* Storage engine we ran against */ |
1
by brian
clean slate |
3029 |
label_buffer, /* Load type */ |
1441.3.1
by Vijay Samuel
all required updations have been made |
3030 |
con->getAvgTiming() / 1000, con->getAvgTiming() % 1000, /* Time to load */ |
3031 |
con->getMinTiming() / 1000, con->getMinTiming() % 1000, /* Min time */ |
|
3032 |
con->getMaxTiming() / 1000, con->getMaxTiming() % 1000, /* Max time */ |
|
3033 |
con->getSumOfTime() / 1000, con->getSumOfTime() % 1000, /* Total time */ |
|
3034 |
con->getStdDev() / 1000, con->getStdDev() % 1000, /* Standard Deviation */ |
|
1
by brian
clean slate |
3035 |
iterations, /* Iterations */ |
1441.3.1
by Vijay Samuel
all required updations have been made |
3036 |
con->getUsers(), /* Children used max_timing */ |
3037 |
con->getRealUsers(), /* Children used max_timing */ |
|
3038 |
con->getAvgRows() /* Queries run */ |
|
381
by Monty Taylor
Reformatted slap and test. |
3039 |
);
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
3040 |
internal::my_write(csv_file, (unsigned char*) buffer, (uint32_t)strlen(buffer), MYF(0)); |
1
by brian
clean slate |
3041 |
}
|
3042 |
||
3043 |
void
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3044 |
generate_stats(Conclusions *con, OptionString *eng, Stats *sptr) |
1
by brian
clean slate |
3045 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3046 |
Stats *ptr; |
1
by brian
clean slate |
3047 |
unsigned int x; |
3048 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
3049 |
con->setMinTiming(sptr->getTiming()); |
3050 |
con->setMaxTiming(sptr->getTiming()); |
|
3051 |
con->setMinRows(sptr->getRows()); |
|
3052 |
con->setMaxRows(sptr->getRows()); |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
3053 |
|
1
by brian
clean slate |
3054 |
/* At the moment we assume uniform */
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3055 |
con->setUsers(sptr->getUsers()); |
3056 |
con->setRealUsers(sptr->getRealUsers()); |
|
3057 |
con->setAvgRows(sptr->getRows()); |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
3058 |
|
1
by brian
clean slate |
3059 |
/* With no next, we know it is the last element that was malloced */
|
3060 |
for (ptr= sptr, x= 0; x < iterations; ptr++, x++) |
|
3061 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3062 |
con->setAvgTiming(ptr->getTiming()+con->getAvgTiming()); |
1
by brian
clean slate |
3063 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3064 |
if (ptr->getTiming() > con->getMaxTiming()) |
3065 |
con->setMaxTiming(ptr->getTiming()); |
|
3066 |
if (ptr->getTiming() < con->getMinTiming()) |
|
3067 |
con->setMinTiming(ptr->getTiming()); |
|
1
by brian
clean slate |
3068 |
}
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3069 |
con->setSumOfTime(con->getAvgTiming()); |
3070 |
con->setAvgTiming(con->getAvgTiming()/iterations); |
|
1
by brian
clean slate |
3071 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3072 |
if (eng && eng->getString()) |
3073 |
con->setEngine(eng->getString()); |
|
1
by brian
clean slate |
3074 |
else
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3075 |
con->setEngine(NULL); |
1
by brian
clean slate |
3076 |
|
3077 |
standard_deviation(con, sptr); |
|
3078 |
||
3079 |
/* Now we do the create time operations */
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3080 |
con->setCreateMinTiming(sptr->getCreateTiming()); |
3081 |
con->setCreateMaxTiming(sptr->getCreateTiming()); |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
3082 |
|
1
by brian
clean slate |
3083 |
/* At the moment we assume uniform */
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3084 |
con->setCreateCount(sptr->getCreateCount()); |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
3085 |
|
1
by brian
clean slate |
3086 |
/* With no next, we know it is the last element that was malloced */
|
3087 |
for (ptr= sptr, x= 0; x < iterations; ptr++, x++) |
|
3088 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3089 |
con->setCreateAvgTiming(ptr->getCreateTiming()+con->getCreateAvgTiming()); |
1
by brian
clean slate |
3090 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3091 |
if (ptr->getCreateTiming() > con->getCreateMaxTiming()) |
3092 |
con->setCreateMaxTiming(ptr->getCreateTiming()); |
|
3093 |
if (ptr->getCreateTiming() < con->getCreateMinTiming()) |
|
3094 |
con->setCreateMinTiming(ptr->getCreateTiming()); |
|
1
by brian
clean slate |
3095 |
}
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3096 |
con->setCreateAvgTiming(con->getCreateAvgTiming()/iterations); |
1
by brian
clean slate |
3097 |
}
|
3098 |
||
3099 |
void
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3100 |
option_cleanup(OptionString *stmt) |
1
by brian
clean slate |
3101 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3102 |
OptionString *ptr, *nptr; |
1
by brian
clean slate |
3103 |
if (!stmt) |
3104 |
return; |
|
3105 |
||
3106 |
for (ptr= stmt; ptr; ptr= nptr) |
|
3107 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3108 |
nptr= ptr->getNext(); |
3109 |
if (ptr->getString()) |
|
3110 |
free(ptr->getString()); |
|
3111 |
if (ptr->getOption()) |
|
3112 |
free(ptr->getOption()); |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
3113 |
free(ptr); |
1
by brian
clean slate |
3114 |
}
|
3115 |
}
|
|
3116 |
||
3117 |
void
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3118 |
statement_cleanup(Statement *stmt) |
1
by brian
clean slate |
3119 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3120 |
Statement *ptr, *nptr; |
1
by brian
clean slate |
3121 |
if (!stmt) |
3122 |
return; |
|
3123 |
||
3124 |
for (ptr= stmt; ptr; ptr= nptr) |
|
3125 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3126 |
nptr= ptr->getNext(); |
3127 |
if (ptr->getString()) |
|
3128 |
free(ptr->getString()); |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
3129 |
free(ptr); |
1
by brian
clean slate |
3130 |
}
|
3131 |
}
|
|
3132 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
3133 |
void
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
3134 |
slap_close(drizzle_con_st *con) |
1
by brian
clean slate |
3135 |
{
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
3136 |
if (opt_only_print) |
1
by brian
clean slate |
3137 |
return; |
3138 |
||
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
3139 |
drizzle_free(drizzle_con_drizzle(con)); |
1
by brian
clean slate |
3140 |
}
|
3141 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
3142 |
void
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
3143 |
slap_connect(drizzle_con_st *con, bool connect_to_schema) |
1
by brian
clean slate |
3144 |
{
|
3145 |
/* Connect to server */
|
|
288
by Brian Aker
ulong cleanp in client apps |
3146 |
static uint32_t connection_retry_sleep= 100000; /* Microseconds */ |
1
by brian
clean slate |
3147 |
int x, connect_error= 1; |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
3148 |
drizzle_return_t ret; |
3149 |
drizzle_st *drizzle; |
|
1
by brian
clean slate |
3150 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
3151 |
if (opt_only_print) |
1
by brian
clean slate |
3152 |
return; |
3153 |
||
3154 |
if (opt_delayed_start) |
|
685.3.1
by Toru Maesaka
Removed my_mkdir() and my_sleep() |
3155 |
usleep(random()%opt_delayed_start); |
1
by brian
clean slate |
3156 |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
3157 |
if ((drizzle= drizzle_create(NULL)) == NULL || |
1531.2.2
by Vijay Samuel
Updated slap code |
3158 |
drizzle_con_add_tcp(drizzle, con, host.c_str(), opt_drizzle_port, user.c_str(), |
3159 |
opt_password.c_str(), |
|
1531.2.1
by Vijay Samuel
Slap refactored |
3160 |
connect_to_schema ? create_schema_string.c_str() : NULL, |
971.8.4
by Eric Day
Added --mysql option flags to client utilities. Also removed the socket option since that is no used anymoe (requested from mailing list). |
3161 |
opt_mysql ? DRIZZLE_CON_MYSQL : DRIZZLE_CON_NONE) == NULL) |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
3162 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
3163 |
fprintf(stderr,"%s: Error creating drizzle object\n", internal::my_progname); |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
3164 |
exit(1); |
3165 |
}
|
|
1
by brian
clean slate |
3166 |
|
3167 |
for (x= 0; x < 10; x++) |
|
3168 |
{
|
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
3169 |
if ((ret= drizzle_con_connect(con)) == DRIZZLE_RETURN_OK) |
1
by brian
clean slate |
3170 |
{
|
3171 |
/* Connect suceeded */
|
|
3172 |
connect_error= 0; |
|
3173 |
break; |
|
3174 |
}
|
|
685.3.1
by Toru Maesaka
Removed my_mkdir() and my_sleep() |
3175 |
usleep(connection_retry_sleep); |
1
by brian
clean slate |
3176 |
}
|
3177 |
if (connect_error) |
|
3178 |
{
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
3179 |
fprintf(stderr,"%s: Error when connecting to server: %d %s\n", internal::my_progname, |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
3180 |
ret, drizzle_con_error(con)); |
1
by brian
clean slate |
3181 |
exit(1); |
3182 |
}
|
|
3183 |
||
3184 |
return; |
|
3185 |
}
|
|
3186 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
3187 |
void
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3188 |
standard_deviation (Conclusions *con, Stats *sptr) |
1
by brian
clean slate |
3189 |
{
|
3190 |
unsigned int x; |
|
3191 |
long int sum_of_squares; |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
3192 |
double the_catch; |
1441.3.1
by Vijay Samuel
all required updations have been made |
3193 |
Stats *ptr; |
1
by brian
clean slate |
3194 |
|
3195 |
if (iterations == 1 || iterations == 0) |
|
3196 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3197 |
con->setStdDev(0); |
1
by brian
clean slate |
3198 |
return; |
3199 |
}
|
|
3200 |
||
3201 |
for (ptr= sptr, x= 0, sum_of_squares= 0; x < iterations; ptr++, x++) |
|
3202 |
{
|
|
3203 |
long int deviation; |
|
3204 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
3205 |
deviation= ptr->getTiming() - con->getAvgTiming(); |
1
by brian
clean slate |
3206 |
sum_of_squares+= deviation*deviation; |
3207 |
}
|
|
3208 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
3209 |
the_catch= sqrt((double)(sum_of_squares/(iterations -1))); |
1441.3.1
by Vijay Samuel
all required updations have been made |
3210 |
con->setStdDev((long int)the_catch); |
1
by brian
clean slate |
3211 |
}
|