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