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