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 |
#include "client_priv.h" |
1848.5.1
by Vijay Samuel
Merge pushed classes of drizzleslap out into separate classes. |
76 |
|
77 |
#include "option_string.h" |
|
78 |
#include "stats.h" |
|
79 |
#include "thread_context.h" |
|
80 |
#include "conclusions.h" |
|
1897.1.3
by Brian Aker
Updating with moving out wakeup to its own file. Why not use barrier for |
81 |
#include "wakeup.h" |
1848.5.1
by Vijay Samuel
Merge pushed classes of drizzleslap out into separate classes. |
82 |
|
1
by brian
clean slate |
83 |
#include <signal.h> |
84 |
#include <stdarg.h> |
|
85 |
#include <sys/types.h> |
|
86 |
#include <sys/wait.h> |
|
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
87 |
#ifdef HAVE_SYS_STAT_H
|
88 |
# include <sys/stat.h>
|
|
89 |
#endif
|
|
90 |
#include <fcntl.h> |
|
91 |
#include <math.h> |
|
92 |
#include <cassert> |
|
93 |
#include <cstdlib> |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
94 |
#include <string> |
1531.2.1
by Vijay Samuel
Slap refactored |
95 |
#include <iostream> |
1531.2.27
by Vijay Samuel
Slap completely refactored with boost::program_options. |
96 |
#include <fstream> |
97 |
#include <drizzled/configmake.h> |
|
1897.1.3
by Brian Aker
Updating with moving out wakeup to its own file. Why not use barrier for |
98 |
|
673.5.13
by Andrew Hutchings
Apply -p means port changes to all client apps |
99 |
/* Added this for string translation. */
|
100 |
#include <drizzled/gettext.h> |
|
1897
by Brian Aker
Boost fixup for slap |
101 |
|
102 |
#include <boost/thread.hpp> |
|
103 |
#include <boost/thread/mutex.hpp> |
|
104 |
#include <boost/thread/condition_variable.hpp> |
|
1531.3.1
by Monty Taylor
Fixed the centos issue. |
105 |
#include <boost/program_options.hpp> |
1894.2.1
by Stewart Smith
for drizzleslap --only-print, display which connection (an incrementing number, stored in the client context of the drizzle obj) the query is going against. |
106 |
#include <drizzled/atomics.h> |
1531.3.1
by Monty Taylor
Fixed the centos issue. |
107 |
|
108 |
#define SLAP_VERSION "1.5"
|
|
109 |
||
110 |
#define HUGE_STRING_LENGTH 8196
|
|
111 |
#define RAND_STRING_SIZE 126
|
|
112 |
#define DEFAULT_BLOB_SIZE 1024
|
|
673.5.13
by Andrew Hutchings
Apply -p means port changes to all client apps |
113 |
|
398.1.5
by Monty Taylor
Removed C++ includes and std namespace from global.h. |
114 |
using namespace std; |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
115 |
using namespace drizzled; |
1531.3.1
by Monty Taylor
Fixed the centos issue. |
116 |
namespace po= boost::program_options; |
398.1.5
by Monty Taylor
Removed C++ includes and std namespace from global.h. |
117 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
118 |
#ifdef HAVE_SMEM
|
1
by brian
clean slate |
119 |
static char *shared_memory_base_name=0; |
120 |
#endif
|
|
121 |
||
122 |
/* Global Thread counter */
|
|
893
by Brian Aker
First pass of stripping uint |
123 |
uint32_t thread_counter; |
1897
by Brian Aker
Boost fixup for slap |
124 |
boost::mutex counter_mutex; |
125 |
boost::condition_variable_any count_threshhold; |
|
1897.1.3
by Brian Aker
Updating with moving out wakeup to its own file. Why not use barrier for |
126 |
|
127 |
client::Wakeup master_wakeup; |
|
1
by brian
clean slate |
128 |
|
129 |
/* Global Thread timer */
|
|
163
by Brian Aker
Merge Monty's code. |
130 |
static bool timer_alarm= false; |
1897
by Brian Aker
Boost fixup for slap |
131 |
boost::mutex timer_alarm_mutex; |
132 |
boost::condition_variable_any timer_alarm_threshold; |
|
1
by brian
clean slate |
133 |
|
1707.1.11
by Brian Aker
Move primary_keys to being a vector. |
134 |
std::vector < std::string > primary_keys; |
1
by brian
clean slate |
135 |
|
1894.2.7
by Stewart Smith
fix connection_count to be size_t instead of uint32_t to work on solaris |
136 |
drizzled::atomic<size_t> connection_count; |
1894.2.1
by Stewart Smith
for drizzleslap --only-print, display which connection (an incrementing number, stored in the client context of the drizzle obj) the query is going against. |
137 |
|
1531.2.5
by Vijay Samuel
Updated slap |
138 |
static string host, |
139 |
opt_password, |
|
140 |
user, |
|
141 |
user_supplied_query, |
|
142 |
user_supplied_pre_statements, |
|
143 |
user_supplied_post_statements, |
|
144 |
default_engine, |
|
145 |
pre_system, |
|
146 |
post_system; |
|
147 |
||
1531.2.10
by Vijay Samuel
Slap refactored with boost::program_options. |
148 |
static vector<string> user_supplied_queries; |
1531.2.18
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
149 |
static string opt_verbose; |
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
150 |
std::string opt_protocol; |
1531.2.5
by Vijay Samuel
Updated slap |
151 |
string delimiter; |
152 |
||
153 |
string create_schema_string; |
|
154 |
||
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
155 |
static bool use_drizzle_protocol= false; |
163
by Brian Aker
Merge Monty's code. |
156 |
static bool opt_preserve= true; |
1531.2.5
by Vijay Samuel
Updated slap |
157 |
static bool opt_only_print; |
158 |
static bool opt_burnin; |
|
163
by Brian Aker
Merge Monty's code. |
159 |
static bool opt_ignore_sql_errors= false; |
1627.2.2
by Monty Taylor
Moved password parsing code into get_password.cc. |
160 |
static bool opt_silent, |
1531.2.5
by Vijay Samuel
Updated slap |
161 |
auto_generate_sql_autoincrement, |
162 |
auto_generate_sql_guid_primary, |
|
163 |
auto_generate_sql; |
|
164 |
std::string opt_auto_generate_sql_type; |
|
1
by brian
clean slate |
165 |
|
1531.2.19
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
166 |
static int32_t verbose= 0; |
1531.2.11
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
167 |
static uint32_t delimiter_length; |
893
by Brian Aker
First pass of stripping uint |
168 |
static uint32_t commit_rate; |
169 |
static uint32_t detach_rate; |
|
170 |
static uint32_t opt_timer_length; |
|
171 |
static uint32_t opt_delayed_start; |
|
1531.2.8
by Vijay Samuel
Updated Slap |
172 |
string num_blob_cols_opt, |
173 |
num_char_cols_opt, |
|
174 |
num_int_cols_opt; |
|
1531.2.1
by Vijay Samuel
Slap refactored |
175 |
string opt_label; |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
176 |
static uint32_t opt_set_random_seed; |
1
by brian
clean slate |
177 |
|
1531.2.2
by Vijay Samuel
Updated slap code |
178 |
string auto_generate_selected_columns_opt; |
1
by brian
clean slate |
179 |
|
180 |
/* Yes, we do set defaults here */
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
181 |
static uint32_t num_int_cols= 1; |
182 |
static uint32_t num_char_cols= 1; |
|
183 |
static uint32_t num_blob_cols= 0; |
|
184 |
static uint32_t num_blob_cols_size; |
|
185 |
static uint32_t num_blob_cols_size_min; |
|
186 |
static uint32_t num_int_cols_index= 0; |
|
187 |
static uint32_t num_char_cols_index= 0; |
|
1531.2.11
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
188 |
static uint32_t iterations; |
151
by Brian Aker
Ulonglong to uint64_t |
189 |
static uint64_t actual_queries= 0; |
190 |
static uint64_t auto_actual_queries; |
|
191 |
static uint64_t auto_generate_sql_unique_write_number; |
|
192 |
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 |
193 |
static uint32_t auto_generate_sql_secondary_indexes; |
151
by Brian Aker
Ulonglong to uint64_t |
194 |
static uint64_t num_of_query; |
1531.3.1
by Monty Taylor
Fixed the centos issue. |
195 |
static uint64_t auto_generate_sql_number; |
1531.2.5
by Vijay Samuel
Updated slap |
196 |
string concurrency_str; |
197 |
string create_string; |
|
1894.2.7
by Stewart Smith
fix connection_count to be size_t instead of uint32_t to work on solaris |
198 |
std::vector <uint32_t> concurrency; |
1
by brian
clean slate |
199 |
|
1531.2.1
by Vijay Samuel
Slap refactored |
200 |
std::string opt_csv_str; |
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
201 |
int csv_file; |
1
by brian
clean slate |
202 |
|
1531.2.11
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
203 |
static int process_options(void); |
1531.2.9
by Vijay Samuel
updated slap |
204 |
static uint32_t opt_drizzle_port= 0; |
1
by brian
clean slate |
205 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
206 |
static OptionString *engine_options= NULL; |
207 |
static OptionString *query_options= NULL; |
|
208 |
static Statement *pre_statements= NULL; |
|
209 |
static Statement *post_statements= NULL; |
|
210 |
static Statement *create_statements= NULL; |
|
211 |
||
1707.1.17
by Brian Aker
REmove malloc() for vector. |
212 |
static std::vector <Statement *> query_statements; |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
213 |
static uint32_t query_statements_count; |
1
by brian
clean slate |
214 |
|
215 |
||
216 |
/* Prototypes */
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
217 |
void print_conclusions(Conclusions &con); |
218 |
void print_conclusions_csv(Conclusions &con); |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
219 |
void generate_stats(Conclusions *con, OptionString *eng, Stats *sptr); |
1707.1.13
by Brian Aker
Merge in changes for allocation on concurrency |
220 |
uint32_t parse_comma(const char *string, std::vector <uint32_t> &range); |
1441.3.1
by Vijay Samuel
all required updations have been made |
221 |
uint32_t parse_delimiter(const char *script, Statement **stmt, char delm); |
222 |
uint32_t parse_option(const char *origin, OptionString **stmt, char delm); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
223 |
static void drop_schema(drizzle_con_st &con, const char *db); |
893
by Brian Aker
First pass of stripping uint |
224 |
uint32_t get_random_string(char *buf, size_t size); |
1441.3.1
by Vijay Samuel
all required updations have been made |
225 |
static Statement *build_table_string(void); |
226 |
static Statement *build_insert_string(void); |
|
227 |
static Statement *build_update_string(void); |
|
228 |
static Statement * build_select_string(bool key); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
229 |
static int generate_primary_key_list(drizzle_con_st &con, OptionString *engine_stmt); |
230 |
static void create_schema(drizzle_con_st &con, const char *db, Statement *stmt, OptionString *engine_stmt, Stats *sptr); |
|
231 |
static void run_scheduler(Stats *sptr, Statement **stmts, uint32_t concur, uint64_t limit); |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
232 |
void statement_cleanup(Statement *stmt); |
233 |
void option_cleanup(OptionString *stmt); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
234 |
void concurrency_loop(drizzle_con_st &con, uint32_t current, OptionString *eptr); |
235 |
static void run_statements(drizzle_con_st &con, Statement *stmt); |
|
236 |
void slap_connect(drizzle_con_st &con, bool connect_to_schema); |
|
237 |
void slap_close(drizzle_con_st &con); |
|
238 |
static int run_query(drizzle_con_st &con, drizzle_result_st *result, const char *query, int len); |
|
239 |
void standard_deviation(Conclusions &con, Stats *sptr); |
|
1
by brian
clean slate |
240 |
|
241 |
static const char ALPHANUMERICS[]= |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
242 |
"0123456789ABCDEFGHIJKLMNOPQRSTWXYZabcdefghijklmnopqrstuvwxyz"; |
1
by brian
clean slate |
243 |
|
244 |
#define ALPHANUMERICS_SIZE (sizeof(ALPHANUMERICS)-1)
|
|
245 |
||
246 |
||
247 |
static long int timedif(struct timeval a, struct timeval b) |
|
248 |
{
|
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
249 |
register int us, s; |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
250 |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
251 |
us = a.tv_usec - b.tv_usec; |
252 |
us /= 1000; |
|
253 |
s = a.tv_sec - b.tv_sec; |
|
254 |
s *= 1000; |
|
255 |
return s + us; |
|
1
by brian
clean slate |
256 |
}
|
257 |
||
1531.2.10
by Vijay Samuel
Slap refactored with boost::program_options. |
258 |
static void combine_queries(vector<string> queries) |
259 |
{
|
|
260 |
user_supplied_query.erase(); |
|
261 |
for (vector<string>::iterator it= queries.begin(); |
|
262 |
it != queries.end(); |
|
263 |
++it) |
|
264 |
{
|
|
265 |
user_supplied_query.append(*it); |
|
266 |
user_supplied_query.append(delimiter); |
|
267 |
}
|
|
268 |
}
|
|
1897
by Brian Aker
Boost fixup for slap |
269 |
|
270 |
||
271 |
static void run_task(ThreadContext *ctx) |
|
272 |
{
|
|
273 |
uint64_t counter= 0, queries; |
|
274 |
uint64_t detach_counter; |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
275 |
uint32_t commit_counter; |
1897
by Brian Aker
Boost fixup for slap |
276 |
drizzle_con_st con; |
277 |
drizzle_result_st result; |
|
278 |
drizzle_row_t row; |
|
279 |
Statement *ptr; |
|
280 |
||
1897.1.3
by Brian Aker
Updating with moving out wakeup to its own file. Why not use barrier for |
281 |
master_wakeup.wait(); |
1897
by Brian Aker
Boost fixup for slap |
282 |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
283 |
slap_connect(con, true); |
1897
by Brian Aker
Boost fixup for slap |
284 |
|
285 |
if (verbose >= 3) |
|
286 |
printf("connected!\n"); |
|
287 |
queries= 0; |
|
288 |
||
289 |
commit_counter= 0; |
|
290 |
if (commit_rate) |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
291 |
run_query(con, NULL, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0")); |
1897
by Brian Aker
Boost fixup for slap |
292 |
|
293 |
limit_not_met: |
|
294 |
for (ptr= ctx->getStmt(), detach_counter= 0; |
|
295 |
ptr && ptr->getLength(); |
|
296 |
ptr= ptr->getNext(), detach_counter++) |
|
297 |
{
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
298 |
if (not opt_only_print && detach_rate && !(detach_counter % detach_rate)) |
1897
by Brian Aker
Boost fixup for slap |
299 |
{
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
300 |
slap_close(con); |
301 |
slap_connect(con, true); |
|
1897
by Brian Aker
Boost fixup for slap |
302 |
}
|
303 |
||
304 |
/*
|
|
305 |
We have to execute differently based on query type. This should become a function.
|
|
306 |
*/
|
|
307 |
if ((ptr->getType() == UPDATE_TYPE_REQUIRES_PREFIX) || |
|
308 |
(ptr->getType() == SELECT_TYPE_REQUIRES_PREFIX)) |
|
309 |
{
|
|
310 |
int length; |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
311 |
uint32_t key_val; |
1897
by Brian Aker
Boost fixup for slap |
312 |
char buffer[HUGE_STRING_LENGTH]; |
313 |
||
314 |
/*
|
|
315 |
This should only happen if some sort of new engine was
|
|
316 |
implemented that didn't properly handle UPDATEs.
|
|
317 |
||
318 |
Just in case someone runs this under an experimental engine we don't
|
|
319 |
want a crash so the if() is placed here.
|
|
320 |
*/
|
|
321 |
assert(primary_keys.size()); |
|
322 |
if (primary_keys.size()) |
|
323 |
{
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
324 |
key_val= (uint32_t)(random() % primary_keys.size()); |
1897
by Brian Aker
Boost fixup for slap |
325 |
const char *key; |
326 |
key= primary_keys[key_val].c_str(); |
|
327 |
||
328 |
assert(key); |
|
329 |
||
330 |
length= snprintf(buffer, HUGE_STRING_LENGTH, "%.*s '%s'", |
|
331 |
(int)ptr->getLength(), ptr->getString(), key); |
|
332 |
||
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
333 |
if (run_query(con, &result, buffer, length)) |
1897
by Brian Aker
Boost fixup for slap |
334 |
{
|
335 |
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n", |
|
336 |
internal::my_progname, (uint32_t)length, buffer, drizzle_con_error(&con)); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
337 |
abort(); |
1897
by Brian Aker
Boost fixup for slap |
338 |
}
|
339 |
}
|
|
340 |
}
|
|
341 |
else
|
|
342 |
{
|
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
343 |
if (run_query(con, &result, ptr->getString(), ptr->getLength())) |
1897
by Brian Aker
Boost fixup for slap |
344 |
{
|
345 |
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n", |
|
346 |
internal::my_progname, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(&con)); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
347 |
abort(); |
1897
by Brian Aker
Boost fixup for slap |
348 |
}
|
349 |
}
|
|
350 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
351 |
if (not opt_only_print) |
1897
by Brian Aker
Boost fixup for slap |
352 |
{
|
353 |
while ((row = drizzle_row_next(&result))) |
|
354 |
counter++; |
|
355 |
drizzle_result_free(&result); |
|
356 |
}
|
|
357 |
queries++; |
|
358 |
||
359 |
if (commit_rate && (++commit_counter == commit_rate)) |
|
360 |
{
|
|
361 |
commit_counter= 0; |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
362 |
run_query(con, NULL, "COMMIT", strlen("COMMIT")); |
1897
by Brian Aker
Boost fixup for slap |
363 |
}
|
364 |
||
365 |
/* If the timer is set, and the alarm is not active then end */
|
|
366 |
if (opt_timer_length && timer_alarm == false) |
|
367 |
goto end; |
|
368 |
||
369 |
/* If limit has been reached, and we are not in a timer_alarm just end */
|
|
370 |
if (ctx->getLimit() && queries == ctx->getLimit() && timer_alarm == false) |
|
371 |
goto end; |
|
372 |
}
|
|
373 |
||
374 |
if (opt_timer_length && timer_alarm == true) |
|
375 |
goto limit_not_met; |
|
376 |
||
377 |
if (ctx->getLimit() && queries < ctx->getLimit()) |
|
378 |
goto limit_not_met; |
|
379 |
||
380 |
||
381 |
end: |
|
382 |
if (commit_rate) |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
383 |
run_query(con, NULL, "COMMIT", strlen("COMMIT")); |
1897
by Brian Aker
Boost fixup for slap |
384 |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
385 |
slap_close(con); |
1897
by Brian Aker
Boost fixup for slap |
386 |
|
387 |
{
|
|
388 |
boost::mutex::scoped_lock scopedLock(counter_mutex); |
|
389 |
thread_counter--; |
|
390 |
count_threshhold.notify_one(); |
|
391 |
}
|
|
392 |
||
393 |
delete ctx; |
|
394 |
}
|
|
395 |
||
1531.2.29
by Vijay Samuel
Slap completely refactored using boost::program_options. |
396 |
/**
|
397 |
* commandline_options is the set of all options that can only be called via the command line.
|
|
398 |
||
399 |
* client_options is the set of all options that can be defined via both command line and via
|
|
400 |
* the configuration file client.cnf
|
|
401 |
||
402 |
* slap_options is the set of all drizzleslap specific options which behave in a manner
|
|
403 |
* similar to that of client_options. It's configuration file is drizzleslap.cnf
|
|
404 |
||
405 |
* long_options is the union of commandline_options, slap_options and client_options.
|
|
406 |
||
1671.2.1
by Vijay Samuel
Merge new user config file processing system. |
407 |
* There are two configuration files per set of options, one which is defined by the user
|
408 |
* which is found at either $XDG_CONFIG_HOME/drizzle or ~/.config/drizzle directory and the other which
|
|
409 |
* 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. |
410 |
|
411 |
* The system configuration file is over ridden by the user's configuration file which
|
|
412 |
* in turn is over ridden by the command line.
|
|
413 |
*/
|
|
1
by brian
clean slate |
414 |
int main(int argc, char **argv) |
415 |
{
|
|
1531.2.1
by Vijay Samuel
Slap refactored |
416 |
char *password= NULL; |
1531.2.7
by Vijay Samuel
updated slap |
417 |
try
|
418 |
{
|
|
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
419 |
po::options_description commandline_options("Options used only in command line"); |
420 |
commandline_options.add_options() |
|
421 |
("help,?","Display this help and exit") |
|
422 |
("info,i","Gives information and exit") |
|
423 |
("burnin",po::value<bool>(&opt_burnin)->default_value(false)->zero_tokens(), |
|
424 |
"Run full test case in infinite loop") |
|
425 |
("ignore-sql-errors", po::value<bool>(&opt_ignore_sql_errors)->default_value(false)->zero_tokens(), |
|
426 |
"Ignore SQL errors in query run") |
|
427 |
("create-schema",po::value<string>(&create_schema_string)->default_value("drizzleslap"), |
|
428 |
"Schema to run tests in") |
|
429 |
("create",po::value<string>(&create_string)->default_value(""), |
|
430 |
"File or string to use to create tables") |
|
431 |
("detach",po::value<uint32_t>(&detach_rate)->default_value(0), |
|
432 |
"Detach (close and re open) connections after X number of requests") |
|
433 |
("iterations,i",po::value<uint32_t>(&iterations)->default_value(1), |
|
434 |
"Number of times to run the tests") |
|
435 |
("label",po::value<string>(&opt_label)->default_value(""), |
|
436 |
"Label to use for print and csv") |
|
437 |
("number-blob-cols",po::value<string>(&num_blob_cols_opt)->default_value(""), |
|
438 |
"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. ") |
|
439 |
("number-char-cols,x",po::value<string>(&num_char_cols_opt)->default_value(""), |
|
440 |
"Number of VARCHAR columns to create in table if specifying --auto-generate-sql.") |
|
441 |
("number-int-cols,y",po::value<string>(&num_int_cols_opt)->default_value(""), |
|
442 |
"Number of INT columns to create in table if specifying --auto-generate-sql.") |
|
443 |
("number-of-queries", |
|
444 |
po::value<uint64_t>(&num_of_query)->default_value(0), |
|
445 |
"Limit each client to this number of queries(this is not exact)") |
|
446 |
("only-print",po::value<bool>(&opt_only_print)->default_value(false)->zero_tokens(), |
|
447 |
"This causes drizzleslap to not connect to the database instead print out what it would have done instead") |
|
448 |
("post-query", po::value<string>(&user_supplied_post_statements)->default_value(""), |
|
449 |
"Query to run or file containing query to execute after tests have completed.") |
|
450 |
("post-system",po::value<string>(&post_system)->default_value(""), |
|
451 |
"system() string to execute after tests have completed") |
|
452 |
("pre-query", |
|
453 |
po::value<string>(&user_supplied_pre_statements)->default_value(""), |
|
454 |
"Query to run or file containing query to execute before running tests.") |
|
455 |
("pre-system",po::value<string>(&pre_system)->default_value(""), |
|
456 |
"system() string to execute before running tests.") |
|
457 |
("query,q",po::value<vector<string> >(&user_supplied_queries)->composing()->notifier(&combine_queries), |
|
458 |
"Query to run or file containing query") |
|
459 |
("verbose,v", po::value<string>(&opt_verbose)->default_value("v"), "Increase verbosity level by one.") |
|
460 |
("version,V","Output version information and exit") |
|
461 |
;
|
|
462 |
||
463 |
po::options_description slap_options("Options specific to drizzleslap"); |
|
464 |
slap_options.add_options() |
|
465 |
("auto-generate-sql-select-columns", |
|
466 |
po::value<string>(&auto_generate_selected_columns_opt)->default_value(""), |
|
467 |
"Provide a string to use for the select fields used in auto tests") |
|
468 |
("auto-generate-sql,a",po::value<bool>(&auto_generate_sql)->default_value(false)->zero_tokens(), |
|
469 |
"Generate SQL where not supplied by file or command line") |
|
470 |
("auto-generate-sql-add-autoincrement", |
|
471 |
po::value<bool>(&auto_generate_sql_autoincrement)->default_value(false)->zero_tokens(), |
|
472 |
"Add an AUTO_INCREMENT column to auto-generated tables") |
|
473 |
("auto-generate-sql-execute-number", |
|
474 |
po::value<uint64_t>(&auto_actual_queries)->default_value(0), |
|
475 |
"See this number and generate a set of queries to run") |
|
476 |
("auto-generate-sql-guid-primary", |
|
477 |
po::value<bool>(&auto_generate_sql_guid_primary)->default_value(false)->zero_tokens(), |
|
478 |
"Add GUID based primary keys to auto-generated tables") |
|
479 |
("auto-generate-sql-load-type", |
|
480 |
po::value<string>(&opt_auto_generate_sql_type)->default_value("mixed"), |
|
481 |
"Specify test load type: mixed, update, write, key or read; default is mixed") |
|
482 |
("auto-generate-sql-secondary-indexes", |
|
483 |
po::value<uint32_t>(&auto_generate_sql_secondary_indexes)->default_value(0), |
|
484 |
"Number of secondary indexes to add to auto-generated tables") |
|
485 |
("auto-generated-sql-unique-query-number", |
|
486 |
po::value<uint64_t>(&auto_generate_sql_unique_query_number)->default_value(10), |
|
487 |
"Number of unique queries to generate for automatic tests") |
|
488 |
("auto-generate-sql-unique-write-number", |
|
489 |
po::value<uint64_t>(&auto_generate_sql_unique_write_number)->default_value(10), |
|
490 |
"Number of unique queries to generate for auto-generate-sql-write-number") |
|
491 |
("auto-generate-sql-write-number", |
|
492 |
po::value<uint64_t>(&auto_generate_sql_number)->default_value(100), |
|
493 |
"Number of row inserts to perform for each thread (default is 100).") |
|
494 |
("commit",po::value<uint32_t>(&commit_rate)->default_value(0), |
|
495 |
"Commit records every X number of statements") |
|
496 |
("concurrency,c",po::value<string>(&concurrency_str)->default_value(""), |
|
497 |
"Number of clients to simulate for query to run") |
|
498 |
("csv",po::value<std::string>(&opt_csv_str)->default_value(""), |
|
499 |
"Generate CSV output to named file or to stdout if no file is name.") |
|
500 |
("delayed-start",po::value<uint32_t>(&opt_delayed_start)->default_value(0), |
|
501 |
"Delay the startup of threads by a random number of microsends (the maximum of the delay") |
|
502 |
("delimiter,F",po::value<string>(&delimiter)->default_value("\n"), |
|
503 |
"Delimiter to use in SQL statements supplied in file or command line") |
|
1793.3.2
by Andrew Hutchings
Fix engine option in drizzleslap |
504 |
("engine,e",po::value<string>(&default_engine)->default_value(""), |
1793.3.3
by Andrew Hutchings
Fix spelling mistake |
505 |
"Storage engine to use for creating the table") |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
506 |
("set-random-seed", |
507 |
po::value<uint32_t>(&opt_set_random_seed)->default_value(0), |
|
508 |
"Seed for random number generator (srandom(3)) ") |
|
509 |
("silent,s",po::value<bool>(&opt_silent)->default_value(false)->zero_tokens(), |
|
510 |
"Run program in silent mode - no output. ") |
|
511 |
("timer-length",po::value<uint32_t>(&opt_timer_length)->default_value(0), |
|
512 |
"Require drizzleslap to run each specific test a certain amount of time in seconds") |
|
513 |
;
|
|
514 |
||
515 |
po::options_description client_options("Options specific to the client"); |
|
516 |
client_options.add_options() |
|
517 |
("host,h",po::value<string>(&host)->default_value("localhost"),"Connect to the host") |
|
518 |
("password,P",po::value<char *>(&password), |
|
519 |
"Password to use when connecting to server. If password is not given it's asked from the tty") |
|
520 |
("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. |
521 |
("protocol",po::value<string>(&opt_protocol)->default_value("mysql"), |
522 |
"The protocol of connection (mysql or drizzle).") |
|
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
523 |
("user,u",po::value<string>(&user)->default_value(""), |
524 |
"User for login if not current user") |
|
525 |
;
|
|
526 |
||
527 |
po::options_description long_options("Allowed Options"); |
|
528 |
long_options.add(commandline_options).add(slap_options).add(client_options); |
|
529 |
||
530 |
std::string system_config_dir_slap(SYSCONFDIR); |
|
531 |
system_config_dir_slap.append("/drizzle/drizzleslap.cnf"); |
|
532 |
||
533 |
std::string system_config_dir_client(SYSCONFDIR); |
|
534 |
system_config_dir_client.append("/drizzle/client.cnf"); |
|
535 |
||
1671.2.1
by Vijay Samuel
Merge new user config file processing system. |
536 |
std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config")); |
537 |
||
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
538 |
uint64_t temp_drizzle_port= 0; |
539 |
drizzle_con_st con; |
|
540 |
OptionString *eptr; |
|
541 |
||
1793.3.1
by Andrew Hutchings
Disable boost:po allow_guessing which was making some wrong assumptions |
542 |
// Disable allow_guessing
|
543 |
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. |
544 |
|
545 |
po::variables_map vm; |
|
1633.5.2
by Vijay Samuel
Merge fix for password in client/ |
546 |
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 |
547 |
style(style).extra_parser(parse_password_arg).run(), vm); |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
548 |
|
1671.2.1
by Vijay Samuel
Merge new user config file processing system. |
549 |
std::string user_config_dir_slap(user_config_dir); |
550 |
user_config_dir_slap.append("/drizzle/drizzleslap.cnf"); |
|
551 |
||
552 |
std::string user_config_dir_client(user_config_dir); |
|
553 |
user_config_dir_client.append("/drizzle/client.cnf"); |
|
554 |
||
555 |
ifstream user_slap_ifs(user_config_dir_slap.c_str()); |
|
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
556 |
po::store(parse_config_file(user_slap_ifs, slap_options), vm); |
557 |
||
1671.2.1
by Vijay Samuel
Merge new user config file processing system. |
558 |
ifstream user_client_ifs(user_config_dir_client.c_str()); |
559 |
po::store(parse_config_file(user_client_ifs, client_options), vm); |
|
560 |
||
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
561 |
ifstream system_slap_ifs(system_config_dir_slap.c_str()); |
562 |
store(parse_config_file(system_slap_ifs, slap_options), vm); |
|
563 |
||
564 |
ifstream system_client_ifs(system_config_dir_client.c_str()); |
|
565 |
store(parse_config_file(system_client_ifs, client_options), vm); |
|
566 |
||
567 |
po::notify(vm); |
|
568 |
||
569 |
if (process_options()) |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
570 |
abort(); |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
571 |
|
1671.2.1
by Vijay Samuel
Merge new user config file processing system. |
572 |
if ( vm.count("help") || vm.count("info")) |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
573 |
{
|
574 |
printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION, |
|
575 |
drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU); |
|
576 |
puts("Copyright (C) 2008 Sun Microsystems"); |
|
1757.2.15
by Monty Taylor
Fixed a silly quote thing. |
577 |
puts("This software comes with ABSOLUTELY NO WARRANTY. " |
578 |
"This is free software,\n" |
|
579 |
"and you are welcome to modify and redistribute it under the GPL "
|
|
580 |
"license\n"); |
|
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
581 |
puts("Run a query multiple times against the server\n"); |
1671.2.1
by Vijay Samuel
Merge new user config file processing system. |
582 |
cout << long_options << endl; |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
583 |
abort(); |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
584 |
}
|
585 |
||
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
586 |
if (vm.count("protocol")) |
587 |
{
|
|
588 |
std::transform(opt_protocol.begin(), opt_protocol.end(), |
|
589 |
opt_protocol.begin(), ::tolower); |
|
590 |
||
591 |
if (not opt_protocol.compare("mysql")) |
|
592 |
use_drizzle_protocol=false; |
|
593 |
else if (not opt_protocol.compare("drizzle")) |
|
594 |
use_drizzle_protocol=true; |
|
595 |
else
|
|
596 |
{
|
|
597 |
cout << _("Error: Unknown protocol") << " '" << opt_protocol << "'" << endl; |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
598 |
abort(); |
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
599 |
}
|
600 |
}
|
|
1671.2.1
by Vijay Samuel
Merge new user config file processing system. |
601 |
if (vm.count("port")) |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
602 |
{
|
603 |
temp_drizzle_port= vm["port"].as<uint32_t>(); |
|
604 |
||
605 |
if ((temp_drizzle_port == 0) || (temp_drizzle_port > 65535)) |
|
606 |
{
|
|
607 |
fprintf(stderr, _("Value supplied for port is not valid.\n")); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
608 |
abort(); |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
609 |
}
|
610 |
else
|
|
611 |
{
|
|
612 |
opt_drizzle_port= (uint32_t) temp_drizzle_port; |
|
613 |
}
|
|
614 |
}
|
|
615 |
||
1671.2.1
by Vijay Samuel
Merge new user config file processing system. |
616 |
if ( vm.count("password") ) |
1633.5.2
by Vijay Samuel
Merge fix for password in client/ |
617 |
{
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
618 |
if (not opt_password.empty()) |
1633.5.2
by Vijay Samuel
Merge fix for password in client/ |
619 |
opt_password.erase(); |
620 |
if (password == PASSWORD_SENTINEL) |
|
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
621 |
{
|
1633.5.2
by Vijay Samuel
Merge fix for password in client/ |
622 |
opt_password= ""; |
1531.2.1
by Vijay Samuel
Slap refactored |
623 |
}
|
624 |
else
|
|
1633.5.2
by Vijay Samuel
Merge fix for password in client/ |
625 |
{
|
626 |
opt_password= password; |
|
627 |
tty_password= false; |
|
628 |
}
|
|
629 |
}
|
|
630 |
else
|
|
631 |
{
|
|
632 |
tty_password= true; |
|
633 |
}
|
|
634 |
||
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
635 |
|
636 |
||
1671.2.1
by Vijay Samuel
Merge new user config file processing system. |
637 |
if ( vm.count("version") ) |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
638 |
{
|
639 |
printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION, |
|
640 |
drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
641 |
abort(); |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
642 |
}
|
643 |
||
644 |
/* Seed the random number generator if we will be using it. */
|
|
645 |
if (auto_generate_sql) |
|
646 |
{
|
|
647 |
if (opt_set_random_seed == 0) |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
648 |
opt_set_random_seed= (uint32_t)time(NULL); |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
649 |
srandom(opt_set_random_seed); |
650 |
}
|
|
651 |
||
652 |
/* globals? Yes, so we only have to run strlen once */
|
|
653 |
delimiter_length= delimiter.length(); |
|
654 |
||
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
655 |
slap_connect(con, false); |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
656 |
|
657 |
/* Main iterations loop */
|
|
658 |
burnin: |
|
659 |
eptr= engine_options; |
|
660 |
do
|
|
661 |
{
|
|
662 |
/* For the final stage we run whatever queries we were asked to run */
|
|
663 |
uint32_t *current; |
|
664 |
||
665 |
if (verbose >= 2) |
|
666 |
printf("Starting Concurrency Test\n"); |
|
667 |
||
1707.1.13
by Brian Aker
Merge in changes for allocation on concurrency |
668 |
if (concurrency.size()) |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
669 |
{
|
1707.1.13
by Brian Aker
Merge in changes for allocation on concurrency |
670 |
for (current= &concurrency[0]; current && *current; current++) |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
671 |
concurrency_loop(con, *current, eptr); |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
672 |
}
|
673 |
else
|
|
674 |
{
|
|
675 |
uint32_t infinite= 1; |
|
676 |
do { |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
677 |
concurrency_loop(con, infinite, eptr); |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
678 |
}
|
679 |
while (infinite++); |
|
680 |
}
|
|
681 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
682 |
if (not opt_preserve) |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
683 |
drop_schema(con, create_schema_string.c_str()); |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
684 |
|
685 |
} while (eptr ? (eptr= eptr->getNext()) : 0); |
|
686 |
||
687 |
if (opt_burnin) |
|
688 |
goto burnin; |
|
689 |
||
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
690 |
slap_close(con); |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
691 |
|
692 |
/* now free all the strings we created */
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
693 |
if (not opt_password.empty()) |
1531.2.2
by Vijay Samuel
Updated slap code |
694 |
opt_password.erase(); |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
695 |
|
1707.1.13
by Brian Aker
Merge in changes for allocation on concurrency |
696 |
concurrency.clear(); |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
697 |
|
698 |
statement_cleanup(create_statements); |
|
1707.1.17
by Brian Aker
REmove malloc() for vector. |
699 |
for (uint32_t x= 0; x < query_statements_count; x++) |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
700 |
statement_cleanup(query_statements[x]); |
1707.1.17
by Brian Aker
REmove malloc() for vector. |
701 |
query_statements.clear(); |
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
702 |
statement_cleanup(pre_statements); |
703 |
statement_cleanup(post_statements); |
|
704 |
option_cleanup(engine_options); |
|
705 |
option_cleanup(query_options); |
|
1
by brian
clean slate |
706 |
|
707 |
#ifdef HAVE_SMEM
|
|
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
708 |
if (shared_memory_base_name) |
709 |
free(shared_memory_base_name); |
|
1
by brian
clean slate |
710 |
#endif
|
1531.2.27
by Vijay Samuel
Slap completely refactored with boost::program_options. |
711 |
|
1531.2.7
by Vijay Samuel
updated slap |
712 |
}
|
1
by brian
clean slate |
713 |
|
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
714 |
catch(std::exception &err) |
1531.2.7
by Vijay Samuel
updated slap |
715 |
{
|
1627.2.8
by Monty Taylor
Fixed drizzleslap build issue on Solaris. |
716 |
cerr<<"Error:"<<err.what()<<endl; |
1531.2.7
by Vijay Samuel
updated slap |
717 |
}
|
1707.1.8
by Brian Aker
Minor cleanups in the slap code. |
718 |
|
719 |
if (csv_file != fileno(stdout)) |
|
720 |
close(csv_file); |
|
721 |
||
1
by brian
clean slate |
722 |
return 0; |
723 |
}
|
|
724 |
||
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
725 |
void concurrency_loop(drizzle_con_st &con, uint32_t current, OptionString *eptr) |
1
by brian
clean slate |
726 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
727 |
Stats *head_sptr; |
728 |
Stats *sptr; |
|
729 |
Conclusions conclusion; |
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
730 |
uint64_t client_limit; |
1
by brian
clean slate |
731 |
|
1707.1.8
by Brian Aker
Minor cleanups in the slap code. |
732 |
head_sptr= new Stats[iterations]; |
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
733 |
if (head_sptr == NULL) |
734 |
{
|
|
735 |
fprintf(stderr,"Error allocating memory in concurrency_loop\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
736 |
abort(); |
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
737 |
}
|
1
by brian
clean slate |
738 |
|
739 |
if (auto_actual_queries) |
|
740 |
client_limit= auto_actual_queries; |
|
741 |
else if (num_of_query) |
|
742 |
client_limit= num_of_query / current; |
|
743 |
else
|
|
744 |
client_limit= actual_queries; |
|
745 |
||
1707.1.18
by Brian Aker
Style cleanups. |
746 |
uint32_t x; |
1
by brian
clean slate |
747 |
for (x= 0, sptr= head_sptr; x < iterations; x++, sptr++) |
748 |
{
|
|
749 |
/*
|
|
750 |
We might not want to load any data, such as when we are calling
|
|
751 |
a stored_procedure that doesn't use data, or we know we already have
|
|
752 |
data in the table.
|
|
753 |
*/
|
|
163
by Brian Aker
Merge Monty's code. |
754 |
if (opt_preserve == false) |
1531.2.1
by Vijay Samuel
Slap refactored |
755 |
drop_schema(con, create_schema_string.c_str()); |
1
by brian
clean slate |
756 |
|
757 |
/* First we create */
|
|
758 |
if (create_statements) |
|
1531.2.1
by Vijay Samuel
Slap refactored |
759 |
create_schema(con, create_schema_string.c_str(), create_statements, eptr, sptr); |
1
by brian
clean slate |
760 |
|
761 |
/*
|
|
762 |
If we generated GUID we need to build a list of them from creation that
|
|
763 |
we can later use.
|
|
764 |
*/
|
|
765 |
if (verbose >= 2) |
|
766 |
printf("Generating primary key list\n"); |
|
767 |
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. |
768 |
generate_primary_key_list(con, eptr); |
1
by brian
clean slate |
769 |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
770 |
if (not pre_system.empty()) |
1090.1.3
by Monty Taylor
Removed dangerous asserts... mainly to upset Stewart. |
771 |
{
|
1531.2.2
by Vijay Samuel
Updated slap code |
772 |
int ret= system(pre_system.c_str()); |
1090.1.3
by Monty Taylor
Removed dangerous asserts... mainly to upset Stewart. |
773 |
assert(ret != -1); |
774 |
}
|
|
1
by brian
clean slate |
775 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
776 |
/*
|
777 |
Pre statements are always run after all other logic so they can
|
|
778 |
correct/adjust any item that they want.
|
|
1
by brian
clean slate |
779 |
*/
|
780 |
if (pre_statements) |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
781 |
run_statements(con, pre_statements); |
1
by brian
clean slate |
782 |
|
1707.1.17
by Brian Aker
REmove malloc() for vector. |
783 |
run_scheduler(sptr, &query_statements[0], current, client_limit); |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
784 |
|
1
by brian
clean slate |
785 |
if (post_statements) |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
786 |
run_statements(con, post_statements); |
1
by brian
clean slate |
787 |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
788 |
if (not post_system.empty()) |
1090.1.3
by Monty Taylor
Removed dangerous asserts... mainly to upset Stewart. |
789 |
{
|
1531.2.2
by Vijay Samuel
Updated slap code |
790 |
int ret= system(post_system.c_str()); |
1090.1.3
by Monty Taylor
Removed dangerous asserts... mainly to upset Stewart. |
791 |
assert(ret !=-1); |
792 |
}
|
|
1
by brian
clean slate |
793 |
|
794 |
/* We are finished with this run */
|
|
795 |
if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary) |
|
1707.1.11
by Brian Aker
Move primary_keys to being a vector. |
796 |
primary_keys.clear(); |
1
by brian
clean slate |
797 |
}
|
798 |
||
799 |
if (verbose >= 2) |
|
800 |
printf("Generating stats\n"); |
|
801 |
||
802 |
generate_stats(&conclusion, eptr, head_sptr); |
|
803 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
804 |
if (not opt_silent) |
805 |
print_conclusions(conclusion); |
|
806 |
if (not opt_csv_str.empty()) |
|
807 |
print_conclusions_csv(conclusion); |
|
1
by brian
clean slate |
808 |
|
1707.1.14
by Brian Aker
Remove valgrind warning. |
809 |
delete [] head_sptr; |
1
by brian
clean slate |
810 |
}
|
811 |
||
812 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
813 |
uint32_t get_random_string(char *buf, size_t size) |
1
by brian
clean slate |
814 |
{
|
815 |
char *buf_ptr= buf; |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
816 |
|
1707.1.18
by Brian Aker
Style cleanups. |
817 |
for (size_t x= size; x > 0; x--) |
1
by brian
clean slate |
818 |
*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. |
819 |
return(buf_ptr - buf); |
1
by brian
clean slate |
820 |
}
|
821 |
||
822 |
||
823 |
/*
|
|
824 |
build_table_string
|
|
825 |
||
826 |
This function builds a create table query if the user opts to not supply
|
|
827 |
a file or string containing a create table statement
|
|
828 |
*/
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
829 |
static Statement * |
1
by brian
clean slate |
830 |
build_table_string(void) |
831 |
{
|
|
832 |
char buf[HUGE_STRING_LENGTH]; |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
833 |
uint32_t col_count; |
1441.3.1
by Vijay Samuel
all required updations have been made |
834 |
Statement *ptr; |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
835 |
string table_string; |
836 |
||
837 |
table_string.reserve(HUGE_STRING_LENGTH); |
|
838 |
||
839 |
table_string= "CREATE TABLE `t1` ("; |
|
1
by brian
clean slate |
840 |
|
841 |
if (auto_generate_sql_autoincrement) |
|
842 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
843 |
table_string.append("id serial"); |
1
by brian
clean slate |
844 |
|
845 |
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. |
846 |
table_string.append(","); |
1
by brian
clean slate |
847 |
}
|
848 |
||
849 |
if (auto_generate_sql_guid_primary) |
|
850 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
851 |
table_string.append("id varchar(128) primary key"); |
1
by brian
clean slate |
852 |
|
853 |
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. |
854 |
table_string.append(","); |
1
by brian
clean slate |
855 |
}
|
856 |
||
857 |
if (auto_generate_sql_secondary_indexes) |
|
858 |
{
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
859 |
for (uint32_t count= 0; count < auto_generate_sql_secondary_indexes; count++) |
1
by brian
clean slate |
860 |
{
|
861 |
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. |
862 |
table_string.append(","); |
1
by brian
clean slate |
863 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
864 |
if (snprintf(buf, HUGE_STRING_LENGTH, "id%d varchar(32) unique key", count) |
1
by brian
clean slate |
865 |
> HUGE_STRING_LENGTH) |
866 |
{
|
|
867 |
fprintf(stderr, "Memory Allocation error in create table\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
868 |
abort(); |
1
by brian
clean slate |
869 |
}
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
870 |
table_string.append(buf); |
1
by brian
clean slate |
871 |
}
|
872 |
||
873 |
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. |
874 |
table_string.append(","); |
1
by brian
clean slate |
875 |
}
|
876 |
||
877 |
if (num_int_cols) |
|
878 |
for (col_count= 1; col_count <= num_int_cols; col_count++) |
|
879 |
{
|
|
880 |
if (num_int_cols_index) |
|
881 |
{
|
|
223
by Brian Aker
Cleanup int() work. |
882 |
if (snprintf(buf, HUGE_STRING_LENGTH, "intcol%d INT, INDEX(intcol%d)", |
1
by brian
clean slate |
883 |
col_count, col_count) > HUGE_STRING_LENGTH) |
884 |
{
|
|
885 |
fprintf(stderr, "Memory Allocation error in create table\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
886 |
abort(); |
1
by brian
clean slate |
887 |
}
|
888 |
}
|
|
889 |
else
|
|
890 |
{
|
|
223
by Brian Aker
Cleanup int() work. |
891 |
if (snprintf(buf, HUGE_STRING_LENGTH, "intcol%d INT ", col_count) |
1
by brian
clean slate |
892 |
> HUGE_STRING_LENGTH) |
893 |
{
|
|
894 |
fprintf(stderr, "Memory Allocation error in create table\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
895 |
abort(); |
1
by brian
clean slate |
896 |
}
|
897 |
}
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
898 |
table_string.append(buf); |
1
by brian
clean slate |
899 |
|
900 |
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. |
901 |
table_string.append(","); |
1
by brian
clean slate |
902 |
}
|
903 |
||
904 |
if (num_char_cols) |
|
905 |
for (col_count= 1; col_count <= num_char_cols; col_count++) |
|
906 |
{
|
|
907 |
if (num_char_cols_index) |
|
908 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
909 |
if (snprintf(buf, HUGE_STRING_LENGTH, |
910 |
"charcol%d VARCHAR(128), INDEX(charcol%d) ", |
|
1
by brian
clean slate |
911 |
col_count, col_count) > HUGE_STRING_LENGTH) |
912 |
{
|
|
913 |
fprintf(stderr, "Memory Allocation error in creating table\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
914 |
abort(); |
1
by brian
clean slate |
915 |
}
|
916 |
}
|
|
917 |
else
|
|
918 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
919 |
if (snprintf(buf, HUGE_STRING_LENGTH, "charcol%d VARCHAR(128)", |
1
by brian
clean slate |
920 |
col_count) > HUGE_STRING_LENGTH) |
921 |
{
|
|
922 |
fprintf(stderr, "Memory Allocation error in creating table\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
923 |
abort(); |
1
by brian
clean slate |
924 |
}
|
925 |
}
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
926 |
table_string.append(buf); |
1
by brian
clean slate |
927 |
|
928 |
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. |
929 |
table_string.append(","); |
1
by brian
clean slate |
930 |
}
|
931 |
||
932 |
if (num_blob_cols) |
|
933 |
for (col_count= 1; col_count <= num_blob_cols; col_count++) |
|
934 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
935 |
if (snprintf(buf, HUGE_STRING_LENGTH, "blobcol%d blob", |
1
by brian
clean slate |
936 |
col_count) > HUGE_STRING_LENGTH) |
937 |
{
|
|
938 |
fprintf(stderr, "Memory Allocation error in creating table\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
939 |
abort(); |
1
by brian
clean slate |
940 |
}
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
941 |
table_string.append(buf); |
1
by brian
clean slate |
942 |
|
943 |
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. |
944 |
table_string.append(","); |
1
by brian
clean slate |
945 |
}
|
946 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
947 |
table_string.append(")"); |
1707.1.8
by Brian Aker
Minor cleanups in the slap code. |
948 |
ptr= new Statement; |
1707.1.9
by Brian Aker
Partial pass through the string in statement. |
949 |
ptr->setString(table_string.length()); |
1441.3.1
by Vijay Samuel
all required updations have been made |
950 |
if (ptr->getString()==NULL) |
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
951 |
{
|
952 |
fprintf(stderr, "Memory Allocation error in creating table\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
953 |
abort(); |
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
954 |
}
|
1441.3.1
by Vijay Samuel
all required updations have been made |
955 |
ptr->setType(CREATE_TABLE_TYPE); |
956 |
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. |
957 |
return(ptr); |
1
by brian
clean slate |
958 |
}
|
959 |
||
960 |
/*
|
|
961 |
build_update_string()
|
|
962 |
||
963 |
This function builds insert statements when the user opts to not supply
|
|
964 |
an insert file or string containing insert data
|
|
965 |
*/
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
966 |
static Statement * |
1
by brian
clean slate |
967 |
build_update_string(void) |
968 |
{
|
|
969 |
char buf[HUGE_STRING_LENGTH]; |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
970 |
uint32_t col_count; |
1441.3.1
by Vijay Samuel
all required updations have been made |
971 |
Statement *ptr; |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
972 |
string update_string; |
973 |
||
974 |
update_string.reserve(HUGE_STRING_LENGTH); |
|
975 |
||
976 |
update_string= "UPDATE t1 SET "; |
|
1
by brian
clean slate |
977 |
|
978 |
if (num_int_cols) |
|
979 |
for (col_count= 1; col_count <= num_int_cols; col_count++) |
|
980 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
981 |
if (snprintf(buf, HUGE_STRING_LENGTH, "intcol%d = %ld", col_count, |
1
by brian
clean slate |
982 |
random()) > HUGE_STRING_LENGTH) |
983 |
{
|
|
984 |
fprintf(stderr, "Memory Allocation error in creating update\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
985 |
abort(); |
1
by brian
clean slate |
986 |
}
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
987 |
update_string.append(buf); |
1
by brian
clean slate |
988 |
|
989 |
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. |
990 |
update_string.append(",", 1); |
1
by brian
clean slate |
991 |
}
|
992 |
||
993 |
if (num_char_cols) |
|
994 |
for (col_count= 1; col_count <= num_char_cols; col_count++) |
|
995 |
{
|
|
996 |
char rand_buffer[RAND_STRING_SIZE]; |
|
997 |
int buf_len= get_random_string(rand_buffer, RAND_STRING_SIZE); |
|
998 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
999 |
if (snprintf(buf, HUGE_STRING_LENGTH, "charcol%d = '%.*s'", col_count, |
1000 |
buf_len, rand_buffer) |
|
1
by brian
clean slate |
1001 |
> HUGE_STRING_LENGTH) |
1002 |
{
|
|
1003 |
fprintf(stderr, "Memory Allocation error in creating update\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1004 |
abort(); |
1
by brian
clean slate |
1005 |
}
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1006 |
update_string.append(buf); |
1
by brian
clean slate |
1007 |
|
1008 |
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. |
1009 |
update_string.append(",", 1); |
1
by brian
clean slate |
1010 |
}
|
1011 |
||
1012 |
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. |
1013 |
update_string.append(" WHERE id = "); |
1
by brian
clean slate |
1014 |
|
1015 |
||
1707.1.8
by Brian Aker
Minor cleanups in the slap code. |
1016 |
ptr= new Statement; |
1
by brian
clean slate |
1017 |
|
1707.1.9
by Brian Aker
Partial pass through the string in statement. |
1018 |
ptr->setString(update_string.length()); |
1441.3.1
by Vijay Samuel
all required updations have been made |
1019 |
if (ptr->getString() == NULL) |
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
1020 |
{
|
1021 |
fprintf(stderr, "Memory Allocation error in creating update\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1022 |
abort(); |
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
1023 |
}
|
1
by brian
clean slate |
1024 |
if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary) |
1441.3.1
by Vijay Samuel
all required updations have been made |
1025 |
ptr->setType(UPDATE_TYPE_REQUIRES_PREFIX); |
1
by brian
clean slate |
1026 |
else
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1027 |
ptr->setType(UPDATE_TYPE); |
1028 |
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. |
1029 |
return(ptr); |
1
by brian
clean slate |
1030 |
}
|
1031 |
||
1032 |
||
1033 |
/*
|
|
1034 |
build_insert_string()
|
|
1035 |
||
1036 |
This function builds insert statements when the user opts to not supply
|
|
1037 |
an insert file or string containing insert data
|
|
1038 |
*/
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1039 |
static Statement * |
1
by brian
clean slate |
1040 |
build_insert_string(void) |
1041 |
{
|
|
1042 |
char buf[HUGE_STRING_LENGTH]; |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1043 |
uint32_t col_count; |
1441.3.1
by Vijay Samuel
all required updations have been made |
1044 |
Statement *ptr; |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1045 |
string insert_string; |
1046 |
||
1047 |
insert_string.reserve(HUGE_STRING_LENGTH); |
|
1048 |
||
1049 |
insert_string= "INSERT INTO t1 VALUES ("; |
|
1
by brian
clean slate |
1050 |
|
1051 |
if (auto_generate_sql_autoincrement) |
|
1052 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1053 |
insert_string.append("NULL"); |
1
by brian
clean slate |
1054 |
|
1055 |
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. |
1056 |
insert_string.append(","); |
1
by brian
clean slate |
1057 |
}
|
1058 |
||
1059 |
if (auto_generate_sql_guid_primary) |
|
1060 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1061 |
insert_string.append("uuid()"); |
1
by brian
clean slate |
1062 |
|
1063 |
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. |
1064 |
insert_string.append(","); |
1
by brian
clean slate |
1065 |
}
|
1066 |
||
1067 |
if (auto_generate_sql_secondary_indexes) |
|
1068 |
{
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1069 |
uint32_t count; |
1
by brian
clean slate |
1070 |
|
1071 |
for (count= 0; count < auto_generate_sql_secondary_indexes; count++) |
|
1072 |
{
|
|
1073 |
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. |
1074 |
insert_string.append(","); |
1
by brian
clean slate |
1075 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1076 |
insert_string.append("uuid()"); |
1
by brian
clean slate |
1077 |
}
|
1078 |
||
1079 |
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. |
1080 |
insert_string.append(","); |
1
by brian
clean slate |
1081 |
}
|
1082 |
||
1083 |
if (num_int_cols) |
|
1084 |
for (col_count= 1; col_count <= num_int_cols; col_count++) |
|
1085 |
{
|
|
1086 |
if (snprintf(buf, HUGE_STRING_LENGTH, "%ld", random()) > HUGE_STRING_LENGTH) |
|
1087 |
{
|
|
1088 |
fprintf(stderr, "Memory Allocation error in creating insert\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1089 |
abort(); |
1
by brian
clean slate |
1090 |
}
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1091 |
insert_string.append(buf); |
1
by brian
clean slate |
1092 |
|
1093 |
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. |
1094 |
insert_string.append(","); |
1
by brian
clean slate |
1095 |
}
|
1096 |
||
1097 |
if (num_char_cols) |
|
1098 |
for (col_count= 1; col_count <= num_char_cols; col_count++) |
|
1099 |
{
|
|
1100 |
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. |
1101 |
insert_string.append("'", 1); |
1102 |
insert_string.append(buf, buf_len); |
|
1103 |
insert_string.append("'", 1); |
|
1
by brian
clean slate |
1104 |
|
1105 |
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. |
1106 |
insert_string.append(",", 1); |
1
by brian
clean slate |
1107 |
}
|
1108 |
||
1109 |
if (num_blob_cols) |
|
1110 |
{
|
|
1707.1.15
by Brian Aker
New fix in drizzleslap. |
1111 |
vector <char> blob_ptr; |
1
by brian
clean slate |
1112 |
|
1707.1.15
by Brian Aker
New fix in drizzleslap. |
1113 |
blob_ptr.resize(num_blob_cols_size); |
1
by brian
clean slate |
1114 |
|
1115 |
for (col_count= 1; col_count <= num_blob_cols; col_count++) |
|
1116 |
{
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1117 |
uint32_t buf_len; |
1118 |
uint32_t size; |
|
1119 |
uint32_t difference= num_blob_cols_size - num_blob_cols_size_min; |
|
1
by brian
clean slate |
1120 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1121 |
size= difference ? (num_blob_cols_size_min + (random() % difference)) : |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
1122 |
num_blob_cols_size; |
1
by brian
clean slate |
1123 |
|
1707.1.15
by Brian Aker
New fix in drizzleslap. |
1124 |
buf_len= get_random_string(&blob_ptr[0], size); |
1
by brian
clean slate |
1125 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1126 |
insert_string.append("'", 1); |
1707.1.15
by Brian Aker
New fix in drizzleslap. |
1127 |
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. |
1128 |
insert_string.append("'", 1); |
1
by brian
clean slate |
1129 |
|
1130 |
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. |
1131 |
insert_string.append(",", 1); |
1
by brian
clean slate |
1132 |
}
|
1133 |
}
|
|
1134 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1135 |
insert_string.append(")", 1); |
1
by brian
clean slate |
1136 |
|
1707.1.8
by Brian Aker
Minor cleanups in the slap code. |
1137 |
ptr= new Statement; |
1707.1.9
by Brian Aker
Partial pass through the string in statement. |
1138 |
ptr->setString(insert_string.length()); |
1441.3.1
by Vijay Samuel
all required updations have been made |
1139 |
if (ptr->getString()==NULL) |
1140 |
{
|
|
1141 |
fprintf(stderr, "Memory Allocation error in creating select\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1142 |
abort(); |
1441.3.1
by Vijay Samuel
all required updations have been made |
1143 |
}
|
1144 |
ptr->setType(INSERT_TYPE); |
|
1145 |
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. |
1146 |
return(ptr); |
1
by brian
clean slate |
1147 |
}
|
1148 |
||
1149 |
||
1150 |
/*
|
|
1151 |
build_select_string()
|
|
1152 |
||
1153 |
This function builds a query if the user opts to not supply a query
|
|
1154 |
statement or file containing a query statement
|
|
1155 |
*/
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1156 |
static Statement * |
143
by Brian Aker
Bool cleanup. |
1157 |
build_select_string(bool key) |
1
by brian
clean slate |
1158 |
{
|
1159 |
char buf[HUGE_STRING_LENGTH]; |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1160 |
uint32_t col_count; |
1441.3.1
by Vijay Samuel
all required updations have been made |
1161 |
Statement *ptr; |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1162 |
string query_string; |
1163 |
||
1164 |
query_string.reserve(HUGE_STRING_LENGTH); |
|
1165 |
||
1166 |
query_string.append("SELECT ", 7); |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1167 |
if (not auto_generate_selected_columns_opt.empty()) |
1
by brian
clean slate |
1168 |
{
|
1531.2.2
by Vijay Samuel
Updated slap code |
1169 |
query_string.append(auto_generate_selected_columns_opt.c_str()); |
1
by brian
clean slate |
1170 |
}
|
1171 |
else
|
|
1172 |
{
|
|
1173 |
for (col_count= 1; col_count <= num_int_cols; col_count++) |
|
1174 |
{
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1175 |
if (snprintf(buf, HUGE_STRING_LENGTH, "intcol%d", col_count) |
1
by brian
clean slate |
1176 |
> HUGE_STRING_LENGTH) |
1177 |
{
|
|
1178 |
fprintf(stderr, "Memory Allocation error in creating select\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1179 |
abort(); |
1
by brian
clean slate |
1180 |
}
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1181 |
query_string.append(buf); |
1
by brian
clean slate |
1182 |
|
1183 |
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. |
1184 |
query_string.append(",", 1); |
1
by brian
clean slate |
1185 |
|
1186 |
}
|
|
1187 |
for (col_count= 1; col_count <= num_char_cols; col_count++) |
|
1188 |
{
|
|
1189 |
if (snprintf(buf, HUGE_STRING_LENGTH, "charcol%d", col_count) |
|
1190 |
> HUGE_STRING_LENGTH) |
|
1191 |
{
|
|
1192 |
fprintf(stderr, "Memory Allocation error in creating select\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1193 |
abort(); |
1
by brian
clean slate |
1194 |
}
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1195 |
query_string.append(buf); |
1
by brian
clean slate |
1196 |
|
1197 |
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. |
1198 |
query_string.append(",", 1); |
1
by brian
clean slate |
1199 |
|
1200 |
}
|
|
1201 |
for (col_count= 1; col_count <= num_blob_cols; col_count++) |
|
1202 |
{
|
|
1203 |
if (snprintf(buf, HUGE_STRING_LENGTH, "blobcol%d", col_count) |
|
1204 |
> HUGE_STRING_LENGTH) |
|
1205 |
{
|
|
1206 |
fprintf(stderr, "Memory Allocation error in creating select\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1207 |
abort(); |
1
by brian
clean slate |
1208 |
}
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1209 |
query_string.append(buf); |
1
by brian
clean slate |
1210 |
|
1211 |
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. |
1212 |
query_string.append(",", 1); |
1
by brian
clean slate |
1213 |
}
|
1214 |
}
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1215 |
query_string.append(" FROM t1"); |
1
by brian
clean slate |
1216 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1217 |
if ((key) && |
1
by brian
clean slate |
1218 |
(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. |
1219 |
query_string.append(" WHERE id = "); |
1
by brian
clean slate |
1220 |
|
1707.1.8
by Brian Aker
Minor cleanups in the slap code. |
1221 |
ptr= new Statement; |
1707.1.9
by Brian Aker
Partial pass through the string in statement. |
1222 |
ptr->setString(query_string.length()); |
1441.3.1
by Vijay Samuel
all required updations have been made |
1223 |
if (ptr->getString() == NULL) |
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
1224 |
{
|
1225 |
fprintf(stderr, "Memory Allocation error in creating select\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1226 |
abort(); |
656.1.45
by Monty Taylor
Added null return checks to mallocs in drizzleslap. |
1227 |
}
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1228 |
if ((key) && |
1
by brian
clean slate |
1229 |
(auto_generate_sql_autoincrement || auto_generate_sql_guid_primary)) |
1441.3.1
by Vijay Samuel
all required updations have been made |
1230 |
ptr->setType(SELECT_TYPE_REQUIRES_PREFIX); |
1
by brian
clean slate |
1231 |
else
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1232 |
ptr->setType(SELECT_TYPE); |
1233 |
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. |
1234 |
return(ptr); |
1
by brian
clean slate |
1235 |
}
|
1236 |
||
1237 |
static int |
|
1531.2.11
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
1238 |
process_options(void) |
1
by brian
clean slate |
1239 |
{
|
15
by brian
Fix for stat, NETWARE removal |
1240 |
struct stat sbuf; |
1441.3.1
by Vijay Samuel
all required updations have been made |
1241 |
OptionString *sql_type; |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1242 |
uint32_t 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. |
1243 |
ssize_t bytes_read= 0; |
1531.2.1
by Vijay Samuel
Slap refactored |
1244 |
|
1531.2.4
by Vijay Samuel
Updated Slap |
1245 |
if (user.empty()) |
1531.2.2
by Vijay Samuel
Updated slap code |
1246 |
user= "root"; |
1
by brian
clean slate |
1247 |
|
1531.2.19
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
1248 |
verbose= opt_verbose.length(); |
1531.2.18
by Vijay Samuel
Refactored command line options for slap using boost::program_options |
1249 |
|
1
by brian
clean slate |
1250 |
/* If something is created we clean it up, otherwise we leave schemas alone */
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1251 |
if ( (not create_string.empty()) || auto_generate_sql) |
163
by Brian Aker
Merge Monty's code. |
1252 |
opt_preserve= false; |
1
by brian
clean slate |
1253 |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1254 |
if (auto_generate_sql && (not create_string.empty() || !user_supplied_query.empty())) |
1
by brian
clean slate |
1255 |
{
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
1256 |
fprintf(stderr, |
1257 |
"%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. |
1258 |
internal::my_progname); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1259 |
abort(); |
1
by brian
clean slate |
1260 |
}
|
1261 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1262 |
if (auto_generate_sql && auto_generate_sql_guid_primary && |
1
by brian
clean slate |
1263 |
auto_generate_sql_autoincrement) |
1264 |
{
|
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
1265 |
fprintf(stderr, |
1266 |
"%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. |
1267 |
internal::my_progname); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1268 |
abort(); |
1
by brian
clean slate |
1269 |
}
|
1270 |
||
1271 |
if (auto_generate_sql && num_of_query && auto_actual_queries) |
|
1272 |
{
|
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
1273 |
fprintf(stderr, |
1274 |
"%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. |
1275 |
internal::my_progname); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1276 |
abort(); |
1
by brian
clean slate |
1277 |
}
|
1278 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1279 |
parse_comma(not concurrency_str.empty() ? concurrency_str.c_str() : "1", concurrency); |
1
by brian
clean slate |
1280 |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1281 |
if (not opt_csv_str.empty()) |
1
by brian
clean slate |
1282 |
{
|
163
by Brian Aker
Merge Monty's code. |
1283 |
opt_silent= true; |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
1284 |
|
1
by brian
clean slate |
1285 |
if (opt_csv_str[0] == '-') |
1286 |
{
|
|
1287 |
csv_file= fileno(stdout); |
|
1288 |
}
|
|
1289 |
else
|
|
1290 |
{
|
|
1531.2.1
by Vijay Samuel
Slap refactored |
1291 |
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. |
1292 |
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) == -1) |
1
by brian
clean slate |
1293 |
{
|
1294 |
fprintf(stderr,"%s: Could not open csv file: %sn\n", |
|
1531.2.1
by Vijay Samuel
Slap refactored |
1295 |
internal::my_progname, opt_csv_str.c_str()); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1296 |
abort(); |
1
by brian
clean slate |
1297 |
}
|
1298 |
}
|
|
1299 |
}
|
|
1300 |
||
1301 |
if (opt_only_print) |
|
163
by Brian Aker
Merge Monty's code. |
1302 |
opt_silent= true; |
1
by brian
clean slate |
1303 |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1304 |
if (not num_int_cols_opt.empty()) |
1531.2.8
by Vijay Samuel
Updated Slap |
1305 |
{
|
1306 |
OptionString *str; |
|
1307 |
parse_option(num_int_cols_opt.c_str(), &str, ','); |
|
1308 |
num_int_cols= atoi(str->getString()); |
|
1309 |
if (str->getOption()) |
|
1310 |
num_int_cols_index= atoi(str->getOption()); |
|
1311 |
option_cleanup(str); |
|
1312 |
}
|
|
1531.2.1
by Vijay Samuel
Slap refactored |
1313 |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1314 |
if (not num_char_cols_opt.empty()) |
1531.2.8
by Vijay Samuel
Updated Slap |
1315 |
{
|
1316 |
OptionString *str; |
|
1317 |
parse_option(num_char_cols_opt.c_str(), &str, ','); |
|
1318 |
num_char_cols= atoi(str->getString()); |
|
1319 |
if (str->getOption()) |
|
1320 |
num_char_cols_index= atoi(str->getOption()); |
|
1321 |
else
|
|
1322 |
num_char_cols_index= 0; |
|
1323 |
option_cleanup(str); |
|
1324 |
}
|
|
1531.2.1
by Vijay Samuel
Slap refactored |
1325 |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1326 |
if (not num_blob_cols_opt.empty()) |
1531.2.1
by Vijay Samuel
Slap refactored |
1327 |
{
|
1328 |
OptionString *str; |
|
1329 |
parse_option(num_blob_cols_opt.c_str(), &str, ','); |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1330 |
num_blob_cols= atoi(str->getString()); |
1331 |
if (str->getOption()) |
|
1
by brian
clean slate |
1332 |
{
|
1333 |
char *sep_ptr; |
|
1334 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
1335 |
if ((sep_ptr= strchr(str->getOption(), '/'))) |
1
by brian
clean slate |
1336 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1337 |
num_blob_cols_size_min= atoi(str->getOption()); |
1
by brian
clean slate |
1338 |
num_blob_cols_size= atoi(sep_ptr+1); |
1339 |
}
|
|
1340 |
else
|
|
1341 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1342 |
num_blob_cols_size_min= num_blob_cols_size= atoi(str->getOption()); |
1
by brian
clean slate |
1343 |
}
|
1344 |
}
|
|
1345 |
else
|
|
1346 |
{
|
|
1347 |
num_blob_cols_size= DEFAULT_BLOB_SIZE; |
|
1348 |
num_blob_cols_size_min= DEFAULT_BLOB_SIZE; |
|
1349 |
}
|
|
1350 |
option_cleanup(str); |
|
1351 |
}
|
|
1352 |
||
1353 |
||
1354 |
if (auto_generate_sql) |
|
1355 |
{
|
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
1356 |
uint64_t x= 0; |
1441.3.1
by Vijay Samuel
all required updations have been made |
1357 |
Statement *ptr_statement; |
1
by brian
clean slate |
1358 |
|
1359 |
if (verbose >= 2) |
|
1360 |
printf("Building Create Statements for Auto\n"); |
|
1361 |
||
1362 |
create_statements= build_table_string(); |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1363 |
/*
|
1364 |
Pre-populate table
|
|
1
by brian
clean slate |
1365 |
*/
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1366 |
for (ptr_statement= create_statements, x= 0; |
1367 |
x < auto_generate_sql_unique_write_number; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1368 |
x++, ptr_statement= ptr_statement->getNext()) |
1
by brian
clean slate |
1369 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1370 |
ptr_statement->setNext(build_insert_string()); |
1
by brian
clean slate |
1371 |
}
|
1372 |
||
1373 |
if (verbose >= 2) |
|
1374 |
printf("Building Query Statements for Auto\n"); |
|
1375 |
||
1531.2.4
by Vijay Samuel
Updated Slap |
1376 |
if (opt_auto_generate_sql_type.empty()) |
1
by brian
clean slate |
1377 |
opt_auto_generate_sql_type= "mixed"; |
1378 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1379 |
query_statements_count= |
1531.2.1
by Vijay Samuel
Slap refactored |
1380 |
parse_option(opt_auto_generate_sql_type.c_str(), &query_options, ','); |
1
by brian
clean slate |
1381 |
|
1707.1.17
by Brian Aker
REmove malloc() for vector. |
1382 |
query_statements.resize(query_statements_count); |
1
by brian
clean slate |
1383 |
|
1384 |
sql_type= query_options; |
|
1385 |
do
|
|
1386 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1387 |
if (sql_type->getString()[0] == 'r') |
1
by brian
clean slate |
1388 |
{
|
1389 |
if (verbose >= 2) |
|
1390 |
printf("Generating SELECT Statements for Auto\n"); |
|
1391 |
||
163
by Brian Aker
Merge Monty's code. |
1392 |
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. |
1393 |
for (ptr_statement= query_statements[sql_type_count], x= 0; |
1394 |
x < auto_generate_sql_unique_query_number; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1395 |
x++, ptr_statement= ptr_statement->getNext()) |
1
by brian
clean slate |
1396 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1397 |
ptr_statement->setNext(build_select_string(false)); |
1
by brian
clean slate |
1398 |
}
|
1399 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1400 |
else if (sql_type->getString()[0] == 'k') |
1
by brian
clean slate |
1401 |
{
|
1402 |
if (verbose >= 2) |
|
1403 |
printf("Generating SELECT for keys Statements for Auto\n"); |
|
1404 |
||
163
by Brian Aker
Merge Monty's code. |
1405 |
if ( auto_generate_sql_autoincrement == false && |
1406 |
auto_generate_sql_guid_primary == false) |
|
1
by brian
clean slate |
1407 |
{
|
1408 |
fprintf(stderr, |
|
1409 |
"%s: Can't perform key test without a primary key!\n", |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1410 |
internal::my_progname); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1411 |
abort(); |
1
by brian
clean slate |
1412 |
}
|
1413 |
||
163
by Brian Aker
Merge Monty's code. |
1414 |
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. |
1415 |
for (ptr_statement= query_statements[sql_type_count], x= 0; |
1416 |
x < auto_generate_sql_unique_query_number; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1417 |
x++, ptr_statement= ptr_statement->getNext()) |
1
by brian
clean slate |
1418 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1419 |
ptr_statement->setNext(build_select_string(true)); |
1
by brian
clean slate |
1420 |
}
|
1421 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1422 |
else if (sql_type->getString()[0] == 'w') |
1
by brian
clean slate |
1423 |
{
|
1424 |
/*
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1425 |
We generate a number of strings in case the engine is
|
1
by brian
clean slate |
1426 |
Archive (since strings which were identical one after another
|
1427 |
would be too easily optimized).
|
|
1428 |
*/
|
|
1429 |
if (verbose >= 2) |
|
1430 |
printf("Generating INSERT Statements for Auto\n"); |
|
1431 |
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. |
1432 |
for (ptr_statement= query_statements[sql_type_count], x= 0; |
1433 |
x < auto_generate_sql_unique_query_number; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1434 |
x++, ptr_statement= ptr_statement->getNext()) |
1
by brian
clean slate |
1435 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1436 |
ptr_statement->setNext(build_insert_string()); |
1
by brian
clean slate |
1437 |
}
|
1438 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1439 |
else if (sql_type->getString()[0] == 'u') |
1
by brian
clean slate |
1440 |
{
|
163
by Brian Aker
Merge Monty's code. |
1441 |
if ( auto_generate_sql_autoincrement == false && |
1442 |
auto_generate_sql_guid_primary == false) |
|
1
by brian
clean slate |
1443 |
{
|
1444 |
fprintf(stderr, |
|
1445 |
"%s: Can't perform update test without a primary key!\n", |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1446 |
internal::my_progname); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1447 |
abort(); |
1
by brian
clean slate |
1448 |
}
|
1449 |
||
1450 |
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. |
1451 |
for (ptr_statement= query_statements[sql_type_count], x= 0; |
1452 |
x < auto_generate_sql_unique_query_number; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1453 |
x++, ptr_statement= ptr_statement->getNext()) |
1
by brian
clean slate |
1454 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1455 |
ptr_statement->setNext(build_update_string()); |
1
by brian
clean slate |
1456 |
}
|
1457 |
}
|
|
1458 |
else /* Mixed mode is default */ |
|
1459 |
{
|
|
1460 |
int coin= 0; |
|
1461 |
||
1462 |
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. |
1463 |
/*
|
1
by brian
clean slate |
1464 |
This logic should be extended to do a more mixed load,
|
1465 |
at the moment it results in "every other".
|
|
1466 |
*/
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1467 |
for (ptr_statement= query_statements[sql_type_count], x= 0; |
1468 |
x < auto_generate_sql_unique_query_number; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1469 |
x++, ptr_statement= ptr_statement->getNext()) |
1
by brian
clean slate |
1470 |
{
|
1471 |
if (coin) |
|
1472 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1473 |
ptr_statement->setNext(build_insert_string()); |
1
by brian
clean slate |
1474 |
coin= 0; |
1475 |
}
|
|
1476 |
else
|
|
1477 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1478 |
ptr_statement->setNext(build_select_string(true)); |
1
by brian
clean slate |
1479 |
coin= 1; |
1480 |
}
|
|
1481 |
}
|
|
1482 |
}
|
|
1483 |
sql_type_count++; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1484 |
} while (sql_type ? (sql_type= sql_type->getNext()) : 0); |
1
by brian
clean slate |
1485 |
}
|
1486 |
else
|
|
1487 |
{
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1488 |
if (not create_string.empty() && !stat(create_string.c_str(), &sbuf)) |
1
by brian
clean slate |
1489 |
{
|
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
1490 |
int data_file; |
1707.1.10
by Brian Aker
Further memory cleanup |
1491 |
std::vector<char> tmp_string; |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1492 |
if (not S_ISREG(sbuf.st_mode)) |
1
by brian
clean slate |
1493 |
{
|
1494 |
fprintf(stderr,"%s: Create file was not a regular file\n", |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1495 |
internal::my_progname); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1496 |
abort(); |
1
by brian
clean slate |
1497 |
}
|
1531.2.3
by Vijay Samuel
Updated Slap code |
1498 |
if ((data_file= open(create_string.c_str(), O_RDWR)) == -1) |
1
by brian
clean slate |
1499 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1500 |
fprintf(stderr,"%s: Could not open create file\n", internal::my_progname); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1501 |
abort(); |
1
by brian
clean slate |
1502 |
}
|
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
1503 |
if ((uint64_t)(sbuf.st_size + 1) > SIZE_MAX) |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
1504 |
{
|
1505 |
fprintf(stderr, "Request for more memory than architecture supports\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1506 |
abort(); |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
1507 |
}
|
1707.1.10
by Brian Aker
Further memory cleanup |
1508 |
tmp_string.resize(sbuf.st_size + 1); |
1509 |
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. |
1510 |
(size_t)sbuf.st_size); |
1014.8.4
by Toru Maesaka
Replace occrrences of my_(open|close) with straight open() and close() system calls |
1511 |
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. |
1512 |
if (bytes_read != sbuf.st_size) |
1513 |
{
|
|
1514 |
fprintf(stderr, "Problem reading file: read less bytes than requested\n"); |
|
1515 |
}
|
|
1707.1.10
by Brian Aker
Further memory cleanup |
1516 |
parse_delimiter(&tmp_string[0], &create_statements, delimiter[0]); |
1
by brian
clean slate |
1517 |
}
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1518 |
else if (not create_string.empty()) |
1
by brian
clean slate |
1519 |
{
|
1531.2.3
by Vijay Samuel
Updated Slap code |
1520 |
parse_delimiter(create_string.c_str(), &create_statements, delimiter[0]); |
1
by brian
clean slate |
1521 |
}
|
1522 |
||
1523 |
/* Set this up till we fully support options on user generated queries */
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1524 |
if (not user_supplied_query.empty()) |
1
by brian
clean slate |
1525 |
{
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1526 |
query_statements_count= |
1
by brian
clean slate |
1527 |
parse_option("default", &query_options, ','); |
1528 |
||
1707.1.17
by Brian Aker
REmove malloc() for vector. |
1529 |
query_statements.resize(query_statements_count); |
1
by brian
clean slate |
1530 |
}
|
1531 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1532 |
if (not user_supplied_query.empty() && !stat(user_supplied_query.c_str(), &sbuf)) |
1
by brian
clean slate |
1533 |
{
|
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
1534 |
int data_file; |
1707.1.10
by Brian Aker
Further memory cleanup |
1535 |
std::vector<char> tmp_string; |
1536 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1537 |
if (not S_ISREG(sbuf.st_mode)) |
1
by brian
clean slate |
1538 |
{
|
1539 |
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. |
1540 |
internal::my_progname); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1541 |
abort(); |
1
by brian
clean slate |
1542 |
}
|
1531.2.2
by Vijay Samuel
Updated slap code |
1543 |
if ((data_file= open(user_supplied_query.c_str(), O_RDWR)) == -1) |
1
by brian
clean slate |
1544 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1545 |
fprintf(stderr,"%s: Could not open query supplied file\n", internal::my_progname); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1546 |
abort(); |
1
by brian
clean slate |
1547 |
}
|
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
1548 |
if ((uint64_t)(sbuf.st_size + 1) > SIZE_MAX) |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
1549 |
{
|
1550 |
fprintf(stderr, "Request for more memory than architecture supports\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1551 |
abort(); |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
1552 |
}
|
1707.1.10
by Brian Aker
Further memory cleanup |
1553 |
tmp_string.resize((size_t)(sbuf.st_size + 1)); |
1554 |
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. |
1555 |
(size_t)sbuf.st_size); |
1014.8.4
by Toru Maesaka
Replace occrrences of my_(open|close) with straight open() and close() system calls |
1556 |
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. |
1557 |
if (bytes_read != sbuf.st_size) |
1558 |
{
|
|
1559 |
fprintf(stderr, "Problem reading file: read less bytes than requested\n"); |
|
1560 |
}
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1561 |
if (not user_supplied_query.empty()) |
1707.1.10
by Brian Aker
Further memory cleanup |
1562 |
actual_queries= parse_delimiter(&tmp_string[0], &query_statements[0], |
1
by brian
clean slate |
1563 |
delimiter[0]); |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1564 |
}
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1565 |
else if (not user_supplied_query.empty()) |
1
by brian
clean slate |
1566 |
{
|
1531.2.2
by Vijay Samuel
Updated slap code |
1567 |
actual_queries= parse_delimiter(user_supplied_query.c_str(), &query_statements[0], |
1
by brian
clean slate |
1568 |
delimiter[0]); |
1569 |
}
|
|
1570 |
}
|
|
1571 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1572 |
if (not user_supplied_pre_statements.empty() |
1531.2.2
by Vijay Samuel
Updated slap code |
1573 |
&& !stat(user_supplied_pre_statements.c_str(), &sbuf)) |
1
by brian
clean slate |
1574 |
{
|
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
1575 |
int data_file; |
1707.1.10
by Brian Aker
Further memory cleanup |
1576 |
std::vector<char> tmp_string; |
1577 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1578 |
if (not S_ISREG(sbuf.st_mode)) |
1
by brian
clean slate |
1579 |
{
|
1580 |
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. |
1581 |
internal::my_progname); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1582 |
abort(); |
1
by brian
clean slate |
1583 |
}
|
1531.2.2
by Vijay Samuel
Updated slap code |
1584 |
if ((data_file= open(user_supplied_pre_statements.c_str(), O_RDWR)) == -1) |
1
by brian
clean slate |
1585 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1586 |
fprintf(stderr,"%s: Could not open query supplied file\n", internal::my_progname); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1587 |
abort(); |
1
by brian
clean slate |
1588 |
}
|
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
1589 |
if ((uint64_t)(sbuf.st_size + 1) > SIZE_MAX) |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
1590 |
{
|
1591 |
fprintf(stderr, "Request for more memory than architecture supports\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1592 |
abort(); |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
1593 |
}
|
1707.1.10
by Brian Aker
Further memory cleanup |
1594 |
tmp_string.resize((size_t)(sbuf.st_size + 1)); |
1595 |
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. |
1596 |
(size_t)sbuf.st_size); |
1014.8.4
by Toru Maesaka
Replace occrrences of my_(open|close) with straight open() and close() system calls |
1597 |
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. |
1598 |
if (bytes_read != sbuf.st_size) |
1599 |
{
|
|
1600 |
fprintf(stderr, "Problem reading file: read less bytes than requested\n"); |
|
1601 |
}
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1602 |
if (not user_supplied_pre_statements.empty()) |
1707.1.10
by Brian Aker
Further memory cleanup |
1603 |
(void)parse_delimiter(&tmp_string[0], &pre_statements, |
1
by brian
clean slate |
1604 |
delimiter[0]); |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1605 |
}
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1606 |
else if (not user_supplied_pre_statements.empty()) |
1
by brian
clean slate |
1607 |
{
|
1531.2.2
by Vijay Samuel
Updated slap code |
1608 |
(void)parse_delimiter(user_supplied_pre_statements.c_str(), |
1
by brian
clean slate |
1609 |
&pre_statements, |
1610 |
delimiter[0]); |
|
1611 |
}
|
|
1612 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1613 |
if (not user_supplied_post_statements.empty() |
1531.2.2
by Vijay Samuel
Updated slap code |
1614 |
&& !stat(user_supplied_post_statements.c_str(), &sbuf)) |
1
by brian
clean slate |
1615 |
{
|
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
1616 |
int data_file; |
1707.1.10
by Brian Aker
Further memory cleanup |
1617 |
std::vector<char> tmp_string; |
1618 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1619 |
if (not S_ISREG(sbuf.st_mode)) |
1
by brian
clean slate |
1620 |
{
|
1621 |
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. |
1622 |
internal::my_progname); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1623 |
abort(); |
1
by brian
clean slate |
1624 |
}
|
1531.2.2
by Vijay Samuel
Updated slap code |
1625 |
if ((data_file= open(user_supplied_post_statements.c_str(), O_RDWR)) == -1) |
1
by brian
clean slate |
1626 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1627 |
fprintf(stderr,"%s: Could not open query supplied file\n", internal::my_progname); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1628 |
abort(); |
1
by brian
clean slate |
1629 |
}
|
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
1630 |
|
779.3.21
by Monty Taylor
Fixed solaris fixes for linux. Oh, and I also seem to have fixed some more configure stuff. |
1631 |
if ((uint64_t)(sbuf.st_size + 1) > SIZE_MAX) |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
1632 |
{
|
1633 |
fprintf(stderr, "Request for more memory than architecture supports\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1634 |
abort(); |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
1635 |
}
|
1707.1.10
by Brian Aker
Further memory cleanup |
1636 |
tmp_string.resize((size_t)(sbuf.st_size + 1)); |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
1637 |
|
1707.1.10
by Brian Aker
Further memory cleanup |
1638 |
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. |
1639 |
(size_t)(sbuf.st_size)); |
1014.8.4
by Toru Maesaka
Replace occrrences of my_(open|close) with straight open() and close() system calls |
1640 |
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. |
1641 |
if (bytes_read != sbuf.st_size) |
1642 |
{
|
|
1643 |
fprintf(stderr, "Problem reading file: read less bytes than requested\n"); |
|
1644 |
}
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1645 |
if (not user_supplied_post_statements.empty()) |
1707.1.10
by Brian Aker
Further memory cleanup |
1646 |
(void)parse_delimiter(&tmp_string[0], &post_statements, |
1
by brian
clean slate |
1647 |
delimiter[0]); |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1648 |
}
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1649 |
else if (not user_supplied_post_statements.empty()) |
1
by brian
clean slate |
1650 |
{
|
1531.2.2
by Vijay Samuel
Updated slap code |
1651 |
(void)parse_delimiter(user_supplied_post_statements.c_str(), &post_statements, |
1
by brian
clean slate |
1652 |
delimiter[0]); |
1653 |
}
|
|
1654 |
||
1655 |
if (verbose >= 2) |
|
1656 |
printf("Parsing engines to use.\n"); |
|
1657 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1658 |
if (not default_engine.empty()) |
1531.2.2
by Vijay Samuel
Updated slap code |
1659 |
parse_option(default_engine.c_str(), &engine_options, ','); |
1
by brian
clean slate |
1660 |
|
1661 |
if (tty_password) |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1662 |
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. |
1663 |
return(0); |
1
by brian
clean slate |
1664 |
}
|
1665 |
||
1666 |
||
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1667 |
static int run_query(drizzle_con_st &con, drizzle_result_st *result, |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1668 |
const char *query, int len) |
1
by brian
clean slate |
1669 |
{
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1670 |
drizzle_return_t ret; |
1671 |
drizzle_result_st result_buffer; |
|
1672 |
||
1
by brian
clean slate |
1673 |
if (opt_only_print) |
1674 |
{
|
|
1894.2.9
by Stewart Smith
cast connection id correctly (solaris complier complains) |
1675 |
printf("/* CON: %lu */ %.*s;\n", |
1894.2.8
by Stewart Smith
cast connection id correctly (solaris complier complains) |
1676 |
(size_t)drizzle_context(drizzle_con_drizzle(&con)), |
1894.2.1
by Stewart Smith
for drizzleslap --only-print, display which connection (an incrementing number, stored in the client context of the drizzle obj) the query is going against. |
1677 |
len, query); |
1
by brian
clean slate |
1678 |
return 0; |
1679 |
}
|
|
1680 |
||
1681 |
if (verbose >= 3) |
|
1682 |
printf("%.*s;\n", len, query); |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1683 |
|
1684 |
if (result == NULL) |
|
1685 |
result= &result_buffer; |
|
1686 |
||
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1687 |
result= drizzle_query(&con, result, query, len, &ret); |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1688 |
|
1689 |
if (ret == DRIZZLE_RETURN_OK) |
|
1690 |
ret= drizzle_result_buffer(result); |
|
1691 |
||
1692 |
if (result == &result_buffer) |
|
1693 |
drizzle_result_free(result); |
|
1694 |
||
1695 |
return ret; |
|
1
by brian
clean slate |
1696 |
}
|
1697 |
||
1698 |
||
1699 |
static int |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1700 |
generate_primary_key_list(drizzle_con_st &con, OptionString *engine_stmt) |
1
by brian
clean slate |
1701 |
{
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1702 |
drizzle_result_st result; |
1703 |
drizzle_row_t row; |
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
1704 |
uint64_t counter; |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1705 |
|
1
by brian
clean slate |
1706 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1707 |
/*
|
1708 |
Blackhole is a special case, this allows us to test the upper end
|
|
1
by brian
clean slate |
1709 |
of the server during load runs.
|
1710 |
*/
|
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1711 |
if (opt_only_print || (engine_stmt && |
1441.3.1
by Vijay Samuel
all required updations have been made |
1712 |
strstr(engine_stmt->getString(), "blackhole"))) |
1
by brian
clean slate |
1713 |
{
|
1714 |
/* Yes, we strdup a const string to simplify the interface */
|
|
1707.1.11
by Brian Aker
Move primary_keys to being a vector. |
1715 |
primary_keys.push_back("796c4422-1d94-102a-9d6d-00e0812d"); |
1
by brian
clean slate |
1716 |
}
|
1717 |
else
|
|
1718 |
{
|
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1719 |
if (run_query(con, &result, "SELECT id from t1", strlen("SELECT id from t1"))) |
1
by brian
clean slate |
1720 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1721 |
fprintf(stderr,"%s: Cannot select GUID primary keys. (%s)\n", internal::my_progname, |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1722 |
drizzle_con_error(&con)); |
1723 |
abort(); |
|
1
by brian
clean slate |
1724 |
}
|
1725 |
||
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1726 |
uint64_t num_rows_ret= drizzle_result_row_count(&result); |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
1727 |
if (num_rows_ret > SIZE_MAX) |
1728 |
{
|
|
1729 |
fprintf(stderr, "More primary keys than than architecture supports\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1730 |
abort(); |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
1731 |
}
|
1707.1.12
by Brian Aker
Remove global for size around primary keys. |
1732 |
size_t primary_keys_number_of; |
779.3.15
by Monty Taylor
Fixed 32-64bit bugs in drizzleslap. |
1733 |
primary_keys_number_of= (size_t)num_rows_ret; |
1
by brian
clean slate |
1734 |
|
1735 |
/* So why check this? Blackhole :) */
|
|
1736 |
if (primary_keys_number_of) |
|
1737 |
{
|
|
1738 |
/*
|
|
1739 |
We create the structure and loop and create the items.
|
|
1740 |
*/
|
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1741 |
row= drizzle_row_next(&result); |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1742 |
for (counter= 0; counter < primary_keys_number_of; |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1743 |
counter++, row= drizzle_row_next(&result)) |
656.1.51
by Monty Taylor
Fixed strdup return checking in client/ |
1744 |
{
|
1707.1.11
by Brian Aker
Move primary_keys to being a vector. |
1745 |
primary_keys.push_back(row[0]); |
656.1.51
by Monty Taylor
Fixed strdup return checking in client/ |
1746 |
}
|
1
by brian
clean slate |
1747 |
}
|
1748 |
||
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1749 |
drizzle_result_free(&result); |
1
by brian
clean slate |
1750 |
}
|
1751 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1752 |
return(0); |
1
by brian
clean slate |
1753 |
}
|
1754 |
||
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1755 |
static void create_schema(drizzle_con_st &con, const char *db, Statement *stmt, OptionString *engine_stmt, Stats *sptr) |
1
by brian
clean slate |
1756 |
{
|
1757 |
char query[HUGE_STRING_LENGTH]; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1758 |
Statement *ptr; |
1759 |
Statement *after_create; |
|
1
by brian
clean slate |
1760 |
int len; |
1761 |
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. |
1762 |
|
1
by brian
clean slate |
1763 |
|
1764 |
gettimeofday(&start_time, NULL); |
|
1765 |
||
1766 |
len= snprintf(query, HUGE_STRING_LENGTH, "CREATE SCHEMA `%s`", db); |
|
1767 |
||
1768 |
if (verbose >= 2) |
|
1769 |
printf("Loading Pre-data\n"); |
|
1770 |
||
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1771 |
if (run_query(con, NULL, query, len)) |
1
by brian
clean slate |
1772 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1773 |
fprintf(stderr,"%s: Cannot create schema %s : %s\n", internal::my_progname, db, |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1774 |
drizzle_con_error(&con)); |
1775 |
abort(); |
|
1
by brian
clean slate |
1776 |
}
|
1777 |
else
|
|
1778 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1779 |
sptr->setCreateCount(sptr->getCreateCount()+1); |
1
by brian
clean slate |
1780 |
}
|
1781 |
||
1782 |
if (opt_only_print) |
|
1783 |
{
|
|
1894.2.9
by Stewart Smith
cast connection id correctly (solaris complier complains) |
1784 |
printf("/* CON: %lu */ use %s;\n", |
1894.2.8
by Stewart Smith
cast connection id correctly (solaris complier complains) |
1785 |
(size_t)drizzle_context(drizzle_con_drizzle(&con)), |
1894.2.1
by Stewart Smith
for drizzleslap --only-print, display which connection (an incrementing number, stored in the client context of the drizzle obj) the query is going against. |
1786 |
db); |
1
by brian
clean slate |
1787 |
}
|
1788 |
else
|
|
1789 |
{
|
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1790 |
drizzle_result_st result; |
1791 |
drizzle_return_t ret; |
|
1792 |
||
1
by brian
clean slate |
1793 |
if (verbose >= 3) |
1794 |
printf("%s;\n", query); |
|
1795 |
||
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1796 |
if (drizzle_select_db(&con, &result, db, &ret) == NULL || |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1797 |
ret != DRIZZLE_RETURN_OK) |
1
by brian
clean slate |
1798 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1799 |
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. |
1800 |
ret == DRIZZLE_RETURN_ERROR_CODE ? |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1801 |
drizzle_result_error(&result) : drizzle_con_error(&con)); |
1802 |
abort(); |
|
1
by brian
clean slate |
1803 |
}
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1804 |
drizzle_result_free(&result); |
1441.3.1
by Vijay Samuel
all required updations have been made |
1805 |
sptr->setCreateCount(sptr->getCreateCount()+1); |
1
by brian
clean slate |
1806 |
}
|
1807 |
||
1808 |
if (engine_stmt) |
|
1809 |
{
|
|
1810 |
len= snprintf(query, HUGE_STRING_LENGTH, "set storage_engine=`%s`", |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1811 |
engine_stmt->getString()); |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1812 |
if (run_query(con, NULL, query, len)) |
1
by brian
clean slate |
1813 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1814 |
fprintf(stderr,"%s: Cannot set default engine: %s\n", internal::my_progname, |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1815 |
drizzle_con_error(&con)); |
1816 |
abort(); |
|
1
by brian
clean slate |
1817 |
}
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1818 |
sptr->setCreateCount(sptr->getCreateCount()+1); |
1
by brian
clean slate |
1819 |
}
|
1820 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1821 |
uint64_t count= 0; |
1
by brian
clean slate |
1822 |
after_create= stmt; |
1823 |
||
1824 |
limit_not_met: |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1825 |
for (ptr= after_create; ptr && ptr->getLength(); ptr= ptr->getNext(), count++) |
1
by brian
clean slate |
1826 |
{
|
1827 |
if (auto_generate_sql && ( auto_generate_sql_number == count)) |
|
1828 |
break; |
|
1829 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
1830 |
if (engine_stmt && engine_stmt->getOption() && ptr->getType() == CREATE_TABLE_TYPE) |
1
by brian
clean slate |
1831 |
{
|
1832 |
char buffer[HUGE_STRING_LENGTH]; |
|
1833 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
1834 |
snprintf(buffer, HUGE_STRING_LENGTH, "%s %s", ptr->getString(), |
1835 |
engine_stmt->getOption()); |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1836 |
if (run_query(con, NULL, buffer, strlen(buffer))) |
1
by brian
clean slate |
1837 |
{
|
1838 |
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n", |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1839 |
internal::my_progname, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(&con)); |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1840 |
if (not opt_ignore_sql_errors) |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1841 |
abort(); |
1
by brian
clean slate |
1842 |
}
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1843 |
sptr->setCreateCount(sptr->getCreateCount()+1); |
1
by brian
clean slate |
1844 |
}
|
1845 |
else
|
|
1846 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1847 |
if (run_query(con, NULL, ptr->getString(), ptr->getLength())) |
1
by brian
clean slate |
1848 |
{
|
1849 |
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n", |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1850 |
internal::my_progname, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(&con)); |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1851 |
if (not opt_ignore_sql_errors) |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1852 |
abort(); |
1
by brian
clean slate |
1853 |
}
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1854 |
sptr->setCreateCount(sptr->getCreateCount()+1); |
1
by brian
clean slate |
1855 |
}
|
1856 |
}
|
|
1857 |
||
1858 |
if (auto_generate_sql && (auto_generate_sql_number > count )) |
|
1859 |
{
|
|
1860 |
/* 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 |
1861 |
after_create= stmt->getNext(); |
1
by brian
clean slate |
1862 |
goto limit_not_met; |
1863 |
}
|
|
1864 |
||
1865 |
gettimeofday(&end_time, NULL); |
|
1866 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
1867 |
sptr->setCreateTiming(timedif(end_time, start_time)); |
1
by brian
clean slate |
1868 |
}
|
1869 |
||
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1870 |
static void drop_schema(drizzle_con_st &con, const char *db) |
1
by brian
clean slate |
1871 |
{
|
1872 |
char query[HUGE_STRING_LENGTH]; |
|
1873 |
int len; |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1874 |
|
1
by brian
clean slate |
1875 |
len= snprintf(query, HUGE_STRING_LENGTH, "DROP SCHEMA IF EXISTS `%s`", db); |
1876 |
||
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
1877 |
if (run_query(con, NULL, query, len)) |
1
by brian
clean slate |
1878 |
{
|
1879 |
fprintf(stderr,"%s: Cannot drop database '%s' ERROR : %s\n", |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1880 |
internal::my_progname, db, drizzle_con_error(&con)); |
1881 |
abort(); |
|
1
by brian
clean slate |
1882 |
}
|
1883 |
}
|
|
1884 |
||
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1885 |
static void run_statements(drizzle_con_st &con, Statement *stmt) |
1
by brian
clean slate |
1886 |
{
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1887 |
for (Statement *ptr= stmt; ptr && ptr->getLength(); ptr= ptr->getNext()) |
1
by brian
clean slate |
1888 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1889 |
if (run_query(con, NULL, ptr->getString(), ptr->getLength())) |
1
by brian
clean slate |
1890 |
{
|
1891 |
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n", |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1892 |
internal::my_progname, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(&con)); |
1893 |
abort(); |
|
1
by brian
clean slate |
1894 |
}
|
1895 |
}
|
|
1896 |
}
|
|
1897 |
||
1897
by Brian Aker
Boost fixup for slap |
1898 |
|
1899 |
static void timer_thread() |
|
1900 |
{
|
|
1901 |
/*
|
|
1902 |
We lock around the initial call in case were we in a loop. This
|
|
1903 |
also keeps the value properly syncronized across call threads.
|
|
1904 |
*/
|
|
1897.1.3
by Brian Aker
Updating with moving out wakeup to its own file. Why not use barrier for |
1905 |
master_wakeup.wait(); |
1897
by Brian Aker
Boost fixup for slap |
1906 |
|
1907 |
{
|
|
1908 |
boost::mutex::scoped_lock scopedLock(timer_alarm_mutex); |
|
1909 |
||
1910 |
boost::xtime xt; |
|
1911 |
xtime_get(&xt, boost::TIME_UTC); |
|
1912 |
xt.sec += opt_timer_length; |
|
1913 |
||
1914 |
(void)timer_alarm_threshold.timed_wait(scopedLock, xt); |
|
1915 |
}
|
|
1916 |
||
1917 |
{
|
|
1918 |
boost::mutex::scoped_lock scopedLock(timer_alarm_mutex); |
|
1919 |
timer_alarm= false; |
|
1920 |
}
|
|
1921 |
}
|
|
1922 |
||
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1923 |
static void run_scheduler(Stats *sptr, Statement **stmts, uint32_t concur, uint64_t limit) |
1
by brian
clean slate |
1924 |
{
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1925 |
uint32_t real_concurrency; |
1
by brian
clean slate |
1926 |
struct timeval start_time, end_time; |
1897
by Brian Aker
Boost fixup for slap |
1927 |
|
1928 |
{
|
|
1929 |
boost::mutex::scoped_lock lock(counter_mutex); |
|
1930 |
||
1931 |
OptionString *sql_type; |
|
1932 |
thread_counter= 0; |
|
1933 |
||
1897.1.3
by Brian Aker
Updating with moving out wakeup to its own file. Why not use barrier for |
1934 |
master_wakeup.reset(); |
1897
by Brian Aker
Boost fixup for slap |
1935 |
|
1936 |
real_concurrency= 0; |
|
1937 |
||
1938 |
uint32_t y; |
|
1939 |
for (y= 0, sql_type= query_options; |
|
1940 |
y < query_statements_count; |
|
1941 |
y++, sql_type= sql_type->getNext()) |
|
1942 |
{
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
1943 |
uint32_t options_loop= 1; |
1897
by Brian Aker
Boost fixup for slap |
1944 |
|
1945 |
if (sql_type->getOption()) |
|
1946 |
{
|
|
1947 |
options_loop= strtol(sql_type->getOption(), |
|
1948 |
(char **)NULL, 10); |
|
1949 |
options_loop= options_loop ? options_loop : 1; |
|
1950 |
}
|
|
1951 |
||
1952 |
while (options_loop--) |
|
1953 |
{
|
|
1954 |
for (uint32_t x= 0; x < concur; x++) |
|
1955 |
{
|
|
1956 |
ThreadContext *con; |
|
1957 |
con= new ThreadContext; |
|
1958 |
if (con == NULL) |
|
1959 |
{
|
|
1960 |
fprintf(stderr, "Memory Allocation error in scheduler\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
1961 |
abort(); |
1897
by Brian Aker
Boost fixup for slap |
1962 |
}
|
1963 |
con->setStmt(stmts[y]); |
|
1964 |
con->setLimit(limit); |
|
1965 |
||
1966 |
real_concurrency++; |
|
1967 |
||
1968 |
/* now you create the thread */
|
|
1969 |
boost::thread new_thread(boost::bind(&run_task, con)); |
|
1970 |
thread_counter++; |
|
1971 |
}
|
|
1972 |
}
|
|
1973 |
}
|
|
1974 |
||
1975 |
/*
|
|
1976 |
The timer_thread belongs to all threads so it too obeys the wakeup
|
|
1977 |
call that run tasks obey.
|
|
1978 |
*/
|
|
1979 |
if (opt_timer_length) |
|
1980 |
{
|
|
1981 |
{
|
|
1982 |
boost::mutex::scoped_lock alarmLock(timer_alarm_mutex); |
|
1983 |
timer_alarm= true; |
|
1984 |
}
|
|
1985 |
||
1986 |
boost::thread new_thread(&timer_thread); |
|
1987 |
}
|
|
1988 |
}
|
|
1989 |
||
1897.1.3
by Brian Aker
Updating with moving out wakeup to its own file. Why not use barrier for |
1990 |
master_wakeup.start(); |
1
by brian
clean slate |
1991 |
|
1992 |
gettimeofday(&start_time, NULL); |
|
1993 |
||
1994 |
/*
|
|
1995 |
We loop until we know that all children have cleaned up.
|
|
1996 |
*/
|
|
1997 |
{
|
|
1897
by Brian Aker
Boost fixup for slap |
1998 |
boost::mutex::scoped_lock scopedLock(counter_mutex); |
1999 |
while (thread_counter) |
|
2000 |
{
|
|
2001 |
boost::xtime xt; |
|
2002 |
xtime_get(&xt, boost::TIME_UTC); |
|
2003 |
xt.sec += 3; |
|
1
by brian
clean slate |
2004 |
|
1897
by Brian Aker
Boost fixup for slap |
2005 |
count_threshhold.timed_wait(scopedLock, xt); |
2006 |
}
|
|
1
by brian
clean slate |
2007 |
}
|
2008 |
||
2009 |
gettimeofday(&end_time, NULL); |
|
2010 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
2011 |
sptr->setTiming(timedif(end_time, start_time)); |
2012 |
sptr->setUsers(concur); |
|
2013 |
sptr->setRealUsers(real_concurrency); |
|
2014 |
sptr->setRows(limit); |
|
1
by brian
clean slate |
2015 |
}
|
2016 |
||
2017 |
/*
|
|
2018 |
Parse records from comma seperated string. : is a reserved character and is used for options
|
|
2019 |
on variables.
|
|
2020 |
*/
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2021 |
uint32_t parse_option(const char *origin, OptionString **stmt, char delm) |
1
by brian
clean slate |
2022 |
{
|
2023 |
char *string; |
|
2024 |
char *begin_ptr; |
|
2025 |
char *end_ptr; |
|
893
by Brian Aker
First pass of stripping uint |
2026 |
uint32_t length= strlen(origin); |
2027 |
uint32_t count= 0; /* We know that there is always one */ |
|
1
by brian
clean slate |
2028 |
|
2029 |
end_ptr= (char *)origin + length; |
|
2030 |
||
1707.1.15
by Brian Aker
New fix in drizzleslap. |
2031 |
OptionString *tmp; |
2032 |
*stmt= tmp= new OptionString; |
|
1
by brian
clean slate |
2033 |
|
2034 |
for (begin_ptr= (char *)origin; |
|
2035 |
begin_ptr != end_ptr; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2036 |
tmp= tmp->getNext()) |
1
by brian
clean slate |
2037 |
{
|
2038 |
char buffer[HUGE_STRING_LENGTH]; |
|
2039 |
char *buffer_ptr; |
|
2040 |
||
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
2041 |
memset(buffer, 0, HUGE_STRING_LENGTH); |
1
by brian
clean slate |
2042 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2043 |
string= strchr(begin_ptr, delm); |
1
by brian
clean slate |
2044 |
|
2045 |
if (string) |
|
2046 |
{
|
|
2047 |
memcpy(buffer, begin_ptr, string - begin_ptr); |
|
2048 |
begin_ptr= string+1; |
|
2049 |
}
|
|
2050 |
else
|
|
2051 |
{
|
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
2052 |
size_t begin_len= strlen(begin_ptr); |
2053 |
memcpy(buffer, begin_ptr, begin_len); |
|
1
by brian
clean slate |
2054 |
begin_ptr= end_ptr; |
2055 |
}
|
|
2056 |
||
2057 |
if ((buffer_ptr= strchr(buffer, ':'))) |
|
2058 |
{
|
|
2059 |
/* Set a null so that we can get strlen() correct later on */
|
|
2060 |
buffer_ptr[0]= 0; |
|
2061 |
buffer_ptr++; |
|
2062 |
||
2063 |
/* Move past the : and the first string */
|
|
1707.1.20
by Brian Aker
Remove someof the code around an option saving its option |
2064 |
tmp->setOption(buffer_ptr); |
1
by brian
clean slate |
2065 |
}
|
2066 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
2067 |
tmp->setString(strdup(buffer)); |
2068 |
if (tmp->getString() == NULL) |
|
656.1.51
by Monty Taylor
Fixed strdup return checking in client/ |
2069 |
{
|
2070 |
fprintf(stderr,"Error allocating memory while parsing options\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
2071 |
abort(); |
656.1.51
by Monty Taylor
Fixed strdup return checking in client/ |
2072 |
}
|
1
by brian
clean slate |
2073 |
|
2074 |
if (isspace(*begin_ptr)) |
|
2075 |
begin_ptr++; |
|
2076 |
||
2077 |
count++; |
|
2078 |
||
2079 |
if (begin_ptr != end_ptr) |
|
656.1.20
by Monty Taylor
Removed my_strdup, my_malloc, my_realloc from client/ |
2080 |
{
|
1707.1.15
by Brian Aker
New fix in drizzleslap. |
2081 |
tmp->setNext( new OptionString); |
656.1.20
by Monty Taylor
Removed my_strdup, my_malloc, my_realloc from client/ |
2082 |
}
|
2083 |
||
1
by brian
clean slate |
2084 |
}
|
2085 |
||
2086 |
return count; |
|
2087 |
}
|
|
2088 |
||
2089 |
||
2090 |
/*
|
|
2091 |
Raw parsing interface. If you want the slap specific parser look at
|
|
2092 |
parse_option.
|
|
2093 |
*/
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2094 |
uint32_t parse_delimiter(const char *script, Statement **stmt, char delm) |
1
by brian
clean slate |
2095 |
{
|
2096 |
char *retstr; |
|
2097 |
char *ptr= (char *)script; |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2098 |
Statement **sptr= stmt; |
2099 |
Statement *tmp; |
|
893
by Brian Aker
First pass of stripping uint |
2100 |
uint32_t length= strlen(script); |
2101 |
uint32_t count= 0; /* We know that there is always one */ |
|
1
by brian
clean slate |
2102 |
|
1707.1.9
by Brian Aker
Partial pass through the string in statement. |
2103 |
for (tmp= *sptr= new Statement; |
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2104 |
(retstr= strchr(ptr, delm)); |
1707.1.9
by Brian Aker
Partial pass through the string in statement. |
2105 |
tmp->setNext(new Statement), |
1441.3.1
by Vijay Samuel
all required updations have been made |
2106 |
tmp= tmp->getNext()) |
1
by brian
clean slate |
2107 |
{
|
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 |
2108 |
if (tmp == NULL) |
2109 |
{
|
|
2110 |
fprintf(stderr,"Error allocating memory while parsing delimiter\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
2111 |
abort(); |
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 |
2112 |
}
|
2113 |
||
1
by brian
clean slate |
2114 |
count++; |
1707.1.9
by Brian Aker
Partial pass through the string in statement. |
2115 |
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 |
2116 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2117 |
if (tmp->getString() == NULL) |
656.1.50
by Monty Taylor
More malloc return type checking |
2118 |
{
|
2119 |
fprintf(stderr,"Error allocating memory while parsing delimiter\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
2120 |
abort(); |
656.1.50
by Monty Taylor
More malloc return type checking |
2121 |
}
|
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 |
2122 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2123 |
memcpy(tmp->getString(), ptr, tmp->getLength()); |
1
by brian
clean slate |
2124 |
ptr+= retstr - ptr + 1; |
2125 |
if (isspace(*ptr)) |
|
2126 |
ptr++; |
|
2127 |
}
|
|
2128 |
||
2129 |
if (ptr != script+length) |
|
2130 |
{
|
|
1707.1.9
by Brian Aker
Partial pass through the string in statement. |
2131 |
tmp->setString((size_t)((script + length) - ptr)); |
1441.3.1
by Vijay Samuel
all required updations have been made |
2132 |
if (tmp->getString() == NULL) |
656.1.50
by Monty Taylor
More malloc return type checking |
2133 |
{
|
2134 |
fprintf(stderr,"Error allocating memory while parsing delimiter\n"); |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
2135 |
abort(); |
656.1.50
by Monty Taylor
More malloc return type checking |
2136 |
}
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2137 |
memcpy(tmp->getString(), ptr, tmp->getLength()); |
1
by brian
clean slate |
2138 |
count++; |
2139 |
}
|
|
2140 |
||
2141 |
return count; |
|
2142 |
}
|
|
2143 |
||
2144 |
||
2145 |
/*
|
|
2146 |
Parse comma is different from parse_delimeter in that it parses
|
|
2147 |
number ranges from a comma seperated string.
|
|
2148 |
In restrospect, this is a lousy name from this function.
|
|
2149 |
*/
|
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2150 |
uint32_t parse_comma(const char *string, std::vector <uint32_t> &range) |
1
by brian
clean slate |
2151 |
{
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2152 |
uint32_t count= 1; /* We know that there is always one */ |
1
by brian
clean slate |
2153 |
char *retstr; |
2154 |
char *ptr= (char *)string; |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2155 |
uint32_t *nptr; |
1
by brian
clean slate |
2156 |
|
2157 |
for (;*ptr; ptr++) |
|
2158 |
if (*ptr == ',') count++; |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2159 |
|
1
by brian
clean slate |
2160 |
/* One extra spot for the NULL */
|
1707.1.13
by Brian Aker
Merge in changes for allocation on concurrency |
2161 |
range.resize(count +1); |
2162 |
nptr= &range[0]; |
|
1
by brian
clean slate |
2163 |
|
2164 |
ptr= (char *)string; |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2165 |
uint32_t x= 0; |
1
by brian
clean slate |
2166 |
while ((retstr= strchr(ptr,','))) |
2167 |
{
|
|
2168 |
nptr[x++]= atoi(ptr); |
|
2169 |
ptr+= retstr - ptr + 1; |
|
2170 |
}
|
|
2171 |
nptr[x++]= atoi(ptr); |
|
2172 |
||
2173 |
return count; |
|
2174 |
}
|
|
2175 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2176 |
void print_conclusions(Conclusions &con) |
1
by brian
clean slate |
2177 |
{
|
2178 |
printf("Benchmark\n"); |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2179 |
if (con.getEngine()) |
2180 |
printf("\tRunning for engine %s\n", con.getEngine()); |
|
2181 |
||
2182 |
if (not opt_label.empty() || !opt_auto_generate_sql_type.empty()) |
|
1
by brian
clean slate |
2183 |
{
|
1531.2.1
by Vijay Samuel
Slap refactored |
2184 |
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 |
2185 |
printf("\tLoad: %s\n", !opt_label.empty() ? opt_label.c_str() : ptr); |
1
by brian
clean slate |
2186 |
}
|
2187 |
printf("\tAverage Time took to generate schema and initial data: %ld.%03ld seconds\n", |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2188 |
con.getCreateAvgTiming() / 1000, con.getCreateAvgTiming() % 1000); |
1
by brian
clean slate |
2189 |
printf("\tAverage number of seconds to run all queries: %ld.%03ld seconds\n", |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2190 |
con.getAvgTiming() / 1000, con.getAvgTiming() % 1000); |
1
by brian
clean slate |
2191 |
printf("\tMinimum number of seconds to run all queries: %ld.%03ld seconds\n", |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2192 |
con.getMinTiming() / 1000, con.getMinTiming() % 1000); |
1
by brian
clean slate |
2193 |
printf("\tMaximum number of seconds to run all queries: %ld.%03ld seconds\n", |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2194 |
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. |
2195 |
printf("\tTotal time for tests: %ld.%03ld seconds\n", |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2196 |
con.getSumOfTime() / 1000, con.getSumOfTime() % 1000); |
2197 |
printf("\tStandard Deviation: %ld.%03ld\n", con.getStdDev() / 1000, con.getStdDev() % 1000); |
|
2198 |
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. |
2199 |
printf("\tNumber of clients running queries: %u/%u\n", |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2200 |
con.getUsers(), con.getRealUsers()); |
1
by brian
clean slate |
2201 |
printf("\tNumber of times test was run: %u\n", iterations); |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2202 |
printf("\tAverage number of queries per client: %"PRIu64"\n", con.getAvgRows()); |
1
by brian
clean slate |
2203 |
printf("\n"); |
2204 |
}
|
|
2205 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2206 |
void print_conclusions_csv(Conclusions &con) |
1
by brian
clean slate |
2207 |
{
|
2208 |
char buffer[HUGE_STRING_LENGTH]; |
|
2209 |
char label_buffer[HUGE_STRING_LENGTH]; |
|
2210 |
size_t string_len; |
|
1531.2.7
by Vijay Samuel
updated slap |
2211 |
const char *temp_label= opt_label.c_str(); |
1
by brian
clean slate |
2212 |
|
1707.1.8
by Brian Aker
Minor cleanups in the slap code. |
2213 |
memset(label_buffer, 0, sizeof(label_buffer)); |
1
by brian
clean slate |
2214 |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2215 |
if (not opt_label.empty()) |
1
by brian
clean slate |
2216 |
{
|
1531.2.1
by Vijay Samuel
Slap refactored |
2217 |
string_len= opt_label.length(); |
1
by brian
clean slate |
2218 |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2219 |
for (uint32_t x= 0; x < string_len; x++) |
1
by brian
clean slate |
2220 |
{
|
1531.2.7
by Vijay Samuel
updated slap |
2221 |
if (temp_label[x] == ',') |
1
by brian
clean slate |
2222 |
label_buffer[x]= '-'; |
2223 |
else
|
|
1531.2.7
by Vijay Samuel
updated slap |
2224 |
label_buffer[x]= temp_label[x] ; |
1
by brian
clean slate |
2225 |
}
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2226 |
}
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2227 |
else if (not opt_auto_generate_sql_type.empty()) |
1
by brian
clean slate |
2228 |
{
|
1531.2.1
by Vijay Samuel
Slap refactored |
2229 |
string_len= opt_auto_generate_sql_type.length(); |
1
by brian
clean slate |
2230 |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2231 |
for (uint32_t x= 0; x < string_len; x++) |
1
by brian
clean slate |
2232 |
{
|
2233 |
if (opt_auto_generate_sql_type[x] == ',') |
|
2234 |
label_buffer[x]= '-'; |
|
2235 |
else
|
|
2236 |
label_buffer[x]= opt_auto_generate_sql_type[x] ; |
|
2237 |
}
|
|
2238 |
}
|
|
2239 |
else
|
|
1707.1.8
by Brian Aker
Minor cleanups in the slap code. |
2240 |
{
|
1
by brian
clean slate |
2241 |
snprintf(label_buffer, HUGE_STRING_LENGTH, "query"); |
1707.1.8
by Brian Aker
Minor cleanups in the slap code. |
2242 |
}
|
1
by brian
clean slate |
2243 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2244 |
snprintf(buffer, HUGE_STRING_LENGTH, |
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
2245 |
"%s,%s,%ld.%03ld,%ld.%03ld,%ld.%03ld,%ld.%03ld,%ld.%03ld,"
|
2246 |
"%u,%u,%u,%"PRIu64"\n", |
|
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2247 |
con.getEngine() ? con.getEngine() : "", /* Storage engine we ran against */ |
1
by brian
clean slate |
2248 |
label_buffer, /* Load type */ |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2249 |
con.getAvgTiming() / 1000, con.getAvgTiming() % 1000, /* Time to load */ |
2250 |
con.getMinTiming() / 1000, con.getMinTiming() % 1000, /* Min time */ |
|
2251 |
con.getMaxTiming() / 1000, con.getMaxTiming() % 1000, /* Max time */ |
|
2252 |
con.getSumOfTime() / 1000, con.getSumOfTime() % 1000, /* Total time */ |
|
2253 |
con.getStdDev() / 1000, con.getStdDev() % 1000, /* Standard Deviation */ |
|
1
by brian
clean slate |
2254 |
iterations, /* Iterations */ |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2255 |
con.getUsers(), /* Children used max_timing */ |
2256 |
con.getRealUsers(), /* Children used max_timing */ |
|
2257 |
con.getAvgRows() /* Queries run */ |
|
381
by Monty Taylor
Reformatted slap and test. |
2258 |
);
|
1711.1.20
by Monty Taylor
Fixed warning where return value of write() was not being checked. |
2259 |
size_t buff_len= strlen(buffer); |
2260 |
ssize_t write_ret= write(csv_file, (unsigned char*) buffer, buff_len); |
|
2261 |
if (write_ret != (ssize_t)buff_len) |
|
2262 |
{
|
|
2263 |
fprintf(stderr, _("Unable to fully write %"PRIu64" bytes. " |
|
2264 |
"Could only write %"PRId64"."), (uint64_t)write_ret, |
|
2265 |
(int64_t)buff_len); |
|
2266 |
exit(-1); |
|
2267 |
}
|
|
1
by brian
clean slate |
2268 |
}
|
2269 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2270 |
void generate_stats(Conclusions *con, OptionString *eng, Stats *sptr) |
1
by brian
clean slate |
2271 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2272 |
Stats *ptr; |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2273 |
uint32_t x; |
1
by brian
clean slate |
2274 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2275 |
con->setMinTiming(sptr->getTiming()); |
2276 |
con->setMaxTiming(sptr->getTiming()); |
|
2277 |
con->setMinRows(sptr->getRows()); |
|
2278 |
con->setMaxRows(sptr->getRows()); |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2279 |
|
1
by brian
clean slate |
2280 |
/* At the moment we assume uniform */
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2281 |
con->setUsers(sptr->getUsers()); |
2282 |
con->setRealUsers(sptr->getRealUsers()); |
|
2283 |
con->setAvgRows(sptr->getRows()); |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2284 |
|
1
by brian
clean slate |
2285 |
/* With no next, we know it is the last element that was malloced */
|
2286 |
for (ptr= sptr, x= 0; x < iterations; ptr++, x++) |
|
2287 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2288 |
con->setAvgTiming(ptr->getTiming()+con->getAvgTiming()); |
1
by brian
clean slate |
2289 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2290 |
if (ptr->getTiming() > con->getMaxTiming()) |
2291 |
con->setMaxTiming(ptr->getTiming()); |
|
2292 |
if (ptr->getTiming() < con->getMinTiming()) |
|
2293 |
con->setMinTiming(ptr->getTiming()); |
|
1
by brian
clean slate |
2294 |
}
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2295 |
con->setSumOfTime(con->getAvgTiming()); |
2296 |
con->setAvgTiming(con->getAvgTiming()/iterations); |
|
1
by brian
clean slate |
2297 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2298 |
if (eng && eng->getString()) |
2299 |
con->setEngine(eng->getString()); |
|
1
by brian
clean slate |
2300 |
else
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2301 |
con->setEngine(NULL); |
1
by brian
clean slate |
2302 |
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
2303 |
standard_deviation(*con, sptr); |
1
by brian
clean slate |
2304 |
|
2305 |
/* Now we do the create time operations */
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2306 |
con->setCreateMinTiming(sptr->getCreateTiming()); |
2307 |
con->setCreateMaxTiming(sptr->getCreateTiming()); |
|
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2308 |
|
1
by brian
clean slate |
2309 |
/* At the moment we assume uniform */
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2310 |
con->setCreateCount(sptr->getCreateCount()); |
377.1.5
by Brian Aker
Merge from Monty, cleanup in tabs during merg. |
2311 |
|
1
by brian
clean slate |
2312 |
/* With no next, we know it is the last element that was malloced */
|
2313 |
for (ptr= sptr, x= 0; x < iterations; ptr++, x++) |
|
2314 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2315 |
con->setCreateAvgTiming(ptr->getCreateTiming()+con->getCreateAvgTiming()); |
1
by brian
clean slate |
2316 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2317 |
if (ptr->getCreateTiming() > con->getCreateMaxTiming()) |
2318 |
con->setCreateMaxTiming(ptr->getCreateTiming()); |
|
2319 |
if (ptr->getCreateTiming() < con->getCreateMinTiming()) |
|
2320 |
con->setCreateMinTiming(ptr->getCreateTiming()); |
|
1
by brian
clean slate |
2321 |
}
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2322 |
con->setCreateAvgTiming(con->getCreateAvgTiming()/iterations); |
1
by brian
clean slate |
2323 |
}
|
2324 |
||
2325 |
void
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2326 |
option_cleanup(OptionString *stmt) |
1
by brian
clean slate |
2327 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2328 |
OptionString *ptr, *nptr; |
1707.1.16
by Brian Aker
Memory cleanup around threads. |
2329 |
if (not stmt) |
1
by brian
clean slate |
2330 |
return; |
2331 |
||
2332 |
for (ptr= stmt; ptr; ptr= nptr) |
|
2333 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2334 |
nptr= ptr->getNext(); |
1707.1.15
by Brian Aker
New fix in drizzleslap. |
2335 |
delete ptr; |
1
by brian
clean slate |
2336 |
}
|
2337 |
}
|
|
2338 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2339 |
void statement_cleanup(Statement *stmt) |
1
by brian
clean slate |
2340 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2341 |
Statement *ptr, *nptr; |
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2342 |
if (not stmt) |
1
by brian
clean slate |
2343 |
return; |
2344 |
||
2345 |
for (ptr= stmt; ptr; ptr= nptr) |
|
2346 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2347 |
nptr= ptr->getNext(); |
1707.1.8
by Brian Aker
Minor cleanups in the slap code. |
2348 |
delete ptr; |
1
by brian
clean slate |
2349 |
}
|
2350 |
}
|
|
2351 |
||
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
2352 |
void slap_close(drizzle_con_st &con) |
1
by brian
clean slate |
2353 |
{
|
1894.2.5
by Stewart Smith
fix drizzleslap modifications for connection count for updated drizzleslap |
2354 |
drizzle_free(drizzle_con_drizzle(&con)); |
1
by brian
clean slate |
2355 |
}
|
2356 |
||
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
2357 |
void slap_connect(drizzle_con_st &con, bool connect_to_schema) |
1
by brian
clean slate |
2358 |
{
|
2359 |
/* Connect to server */
|
|
288
by Brian Aker
ulong cleanp in client apps |
2360 |
static uint32_t connection_retry_sleep= 100000; /* Microseconds */ |
1707.1.18
by Brian Aker
Style cleanups. |
2361 |
int connect_error= 1; |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2362 |
drizzle_return_t ret; |
2363 |
drizzle_st *drizzle; |
|
1
by brian
clean slate |
2364 |
|
2365 |
if (opt_delayed_start) |
|
685.3.1
by Toru Maesaka
Removed my_mkdir() and my_sleep() |
2366 |
usleep(random()%opt_delayed_start); |
1
by brian
clean slate |
2367 |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2368 |
if ((drizzle= drizzle_create(NULL)) == NULL || |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
2369 |
drizzle_con_add_tcp(drizzle, &con, host.c_str(), opt_drizzle_port, |
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
2370 |
user.c_str(), |
2371 |
opt_password.c_str(), |
|
2372 |
connect_to_schema ? create_schema_string.c_str() : NULL, |
|
2373 |
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. |
2374 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2375 |
fprintf(stderr,"%s: Error creating drizzle object\n", internal::my_progname); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
2376 |
abort(); |
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
2377 |
}
|
1
by brian
clean slate |
2378 |
|
1894.2.6
by Stewart Smith
fix warning on solaris for drizzleslap connection count. use size_t instead of uint32_t as this will always fit properly into void* |
2379 |
drizzle_set_context(drizzle, (void*)(connection_count.fetch_and_increment())); |
1894.2.1
by Stewart Smith
for drizzleslap --only-print, display which connection (an incrementing number, stored in the client context of the drizzle obj) the query is going against. |
2380 |
|
2381 |
if (opt_only_print) |
|
2382 |
return; |
|
2383 |
||
1707.1.18
by Brian Aker
Style cleanups. |
2384 |
for (uint32_t x= 0; x < 10; x++) |
1
by brian
clean slate |
2385 |
{
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
2386 |
if ((ret= drizzle_con_connect(&con)) == DRIZZLE_RETURN_OK) |
1
by brian
clean slate |
2387 |
{
|
2388 |
/* Connect suceeded */
|
|
2389 |
connect_error= 0; |
|
2390 |
break; |
|
2391 |
}
|
|
685.3.1
by Toru Maesaka
Removed my_mkdir() and my_sleep() |
2392 |
usleep(connection_retry_sleep); |
1
by brian
clean slate |
2393 |
}
|
2394 |
if (connect_error) |
|
2395 |
{
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2396 |
fprintf(stderr,"%s: Error when connecting to server: %d %s\n", internal::my_progname, |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
2397 |
ret, drizzle_con_error(&con)); |
2398 |
abort(); |
|
1
by brian
clean slate |
2399 |
}
|
2400 |
}
|
|
2401 |
||
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
2402 |
void standard_deviation(Conclusions &con, Stats *sptr) |
1
by brian
clean slate |
2403 |
{
|
2404 |
long int sum_of_squares; |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2405 |
double the_catch; |
1441.3.1
by Vijay Samuel
all required updations have been made |
2406 |
Stats *ptr; |
1
by brian
clean slate |
2407 |
|
2408 |
if (iterations == 1 || iterations == 0) |
|
2409 |
{
|
|
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
2410 |
con.setStdDev(0); |
1
by brian
clean slate |
2411 |
return; |
2412 |
}
|
|
2413 |
||
1897.1.1
by Brian Aker
Small syntax updates to slap. |
2414 |
uint32_t x; |
1
by brian
clean slate |
2415 |
for (ptr= sptr, x= 0, sum_of_squares= 0; x < iterations; ptr++, x++) |
2416 |
{
|
|
2417 |
long int deviation; |
|
2418 |
||
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
2419 |
deviation= ptr->getTiming() - con.getAvgTiming(); |
1
by brian
clean slate |
2420 |
sum_of_squares+= deviation*deviation; |
2421 |
}
|
|
2422 |
||
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
2423 |
the_catch= sqrt((double)(sum_of_squares/(iterations -1))); |
1897.1.2
by Brian Aker
Merge in modifications for slap (upgrade the style). |
2424 |
con.setStdDev((long int)the_catch); |
1
by brian
clean slate |
2425 |
}
|