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