105
105
#include <boost/program_options.hpp>
106
106
#include <drizzled/atomics.h>
108
#define SLAP_NAME "drizzleslap"
108
109
#define SLAP_VERSION "1.5"
110
111
#define HUGE_STRING_LENGTH 8196
300
302
We have to execute differently based on query type. This should become a function.
304
bool is_failed_update= false;
302
305
if ((ptr->getType() == UPDATE_TYPE_REQUIRES_PREFIX) ||
303
306
(ptr->getType() == SELECT_TYPE_REQUIRES_PREFIX))
328
331
if (run_query(con, &result, buffer, length))
333
if ((ptr->getType() == UPDATE_TYPE_REQUIRES_PREFIX) and commit_rate)
335
// Expand to check to see if Innodb, if so we should restart the
338
is_failed_update= true;
339
failed_update_for_transaction.fetch_and_increment();
343
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
344
SLAP_NAME, (uint32_t)length, buffer, drizzle_con_error(&con));
352
if (run_query(con, &result, ptr->getString(), ptr->getLength()))
354
if ((ptr->getType() == UPDATE_TYPE_REQUIRES_PREFIX) and commit_rate)
356
// Expand to check to see if Innodb, if so we should restart the
359
is_failed_update= true;
360
failed_update_for_transaction.fetch_and_increment();
330
364
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
331
internal::my_progname, (uint32_t)length, buffer, drizzle_con_error(&con));
365
SLAP_NAME, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(&con));
338
if (run_query(con, &result, ptr->getString(), ptr->getLength()))
340
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
341
internal::my_progname, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(&con));
346
if (not opt_only_print)
371
if (not opt_only_print and not is_failed_update)
348
373
while ((row = drizzle_row_next(&result)))
354
if (commit_rate && (++commit_counter == commit_rate))
379
if (commit_rate && (++commit_counter == commit_rate) and not is_failed_update)
356
381
commit_counter= 0;
357
382
run_query(con, NULL, "COMMIT", strlen("COMMIT"));
561
586
if ( vm.count("help") || vm.count("info"))
563
printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION,
588
printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",SLAP_NAME, SLAP_VERSION,
564
589
drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU);
565
590
puts("Copyright (C) 2008 Sun Microsystems");
566
591
puts("This software comes with ABSOLUTELY NO WARRANTY. "
626
651
if ( vm.count("version") )
628
printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION,
653
printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",SLAP_NAME, SLAP_VERSION,
629
654
drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU);
1281
1306
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) == -1)
1283
1308
fprintf(stderr,"%s: Could not open csv file: %sn\n",
1284
internal::my_progname, opt_csv_str.c_str());
1309
SLAP_NAME, opt_csv_str.c_str());
1481
1506
if (not S_ISREG(sbuf.st_mode))
1483
1508
fprintf(stderr,"%s: Create file was not a regular file\n",
1484
internal::my_progname);
1487
1512
if ((data_file= open(create_string.c_str(), O_RDWR)) == -1)
1489
fprintf(stderr,"%s: Could not open create file\n", internal::my_progname);
1514
fprintf(stderr,"%s: Could not open create file\n", SLAP_NAME);
1492
1517
if ((uint64_t)(sbuf.st_size + 1) > SIZE_MAX)
1526
1551
if (not S_ISREG(sbuf.st_mode))
1528
1553
fprintf(stderr,"%s: User query supplied file was not a regular file\n",
1529
internal::my_progname);
1532
1557
if ((data_file= open(user_supplied_query.c_str(), O_RDWR)) == -1)
1534
fprintf(stderr,"%s: Could not open query supplied file\n", internal::my_progname);
1559
fprintf(stderr,"%s: Could not open query supplied file\n", SLAP_NAME);
1537
1562
if ((uint64_t)(sbuf.st_size + 1) > SIZE_MAX)
1567
1592
if (not S_ISREG(sbuf.st_mode))
1569
1594
fprintf(stderr,"%s: User query supplied file was not a regular file\n",
1570
internal::my_progname);
1573
1598
if ((data_file= open(user_supplied_pre_statements.c_str(), O_RDWR)) == -1)
1575
fprintf(stderr,"%s: Could not open query supplied file\n", internal::my_progname);
1600
fprintf(stderr,"%s: Could not open query supplied file\n", SLAP_NAME);
1578
1603
if ((uint64_t)(sbuf.st_size + 1) > SIZE_MAX)
1608
1633
if (not S_ISREG(sbuf.st_mode))
1610
1635
fprintf(stderr,"%s: User query supplied file was not a regular file\n",
1611
internal::my_progname);
1614
1639
if ((data_file= open(user_supplied_post_statements.c_str(), O_RDWR)) == -1)
1616
fprintf(stderr,"%s: Could not open query supplied file\n", internal::my_progname);
1641
fprintf(stderr,"%s: Could not open query supplied file\n", SLAP_NAME);
1708
1733
if (run_query(con, &result, "SELECT id from t1", strlen("SELECT id from t1")))
1710
fprintf(stderr,"%s: Cannot select GUID primary keys. (%s)\n", internal::my_progname,
1735
fprintf(stderr,"%s: Cannot select GUID primary keys. (%s)\n", SLAP_NAME,
1711
1736
drizzle_con_error(&con));
1760
1785
if (run_query(con, NULL, query, len))
1762
fprintf(stderr,"%s: Cannot create schema %s : %s\n", internal::my_progname, db,
1787
fprintf(stderr,"%s: Cannot create schema %s : %s\n", SLAP_NAME, db,
1763
1788
drizzle_con_error(&con));
1785
1810
if (drizzle_select_db(&con, &result, db, &ret) == NULL ||
1786
1811
ret != DRIZZLE_RETURN_OK)
1788
fprintf(stderr,"%s: Cannot select schema '%s': %s\n",internal::my_progname, db,
1813
fprintf(stderr,"%s: Cannot select schema '%s': %s\n",SLAP_NAME, db,
1789
1814
ret == DRIZZLE_RETURN_ERROR_CODE ?
1790
1815
drizzle_result_error(&result) : drizzle_con_error(&con));
1800
1825
engine_stmt->getString());
1801
1826
if (run_query(con, NULL, query, len))
1803
fprintf(stderr,"%s: Cannot set default engine: %s\n", internal::my_progname,
1828
fprintf(stderr,"%s: Cannot set default engine: %s\n", SLAP_NAME,
1804
1829
drizzle_con_error(&con));
1825
1850
if (run_query(con, NULL, buffer, strlen(buffer)))
1827
1852
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
1828
internal::my_progname, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(&con));
1853
SLAP_NAME, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(&con));
1829
1854
if (not opt_ignore_sql_errors)
1836
1861
if (run_query(con, NULL, ptr->getString(), ptr->getLength()))
1838
1863
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
1839
internal::my_progname, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(&con));
1864
SLAP_NAME, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(&con));
1840
1865
if (not opt_ignore_sql_errors)
1866
1891
if (run_query(con, NULL, query, len))
1868
1893
fprintf(stderr,"%s: Cannot drop database '%s' ERROR : %s\n",
1869
internal::my_progname, db, drizzle_con_error(&con));
1894
SLAP_NAME, db, drizzle_con_error(&con));
1878
1903
if (run_query(con, NULL, ptr->getString(), ptr->getLength()))
1880
1905
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
1881
internal::my_progname, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(&con));
1906
SLAP_NAME, (uint32_t)ptr->getLength(), ptr->getString(), drizzle_con_error(&con));
2187
2212
con.getUsers(), con.getRealUsers());
2188
2213
printf("\tNumber of times test was run: %u\n", iterations);
2189
2214
printf("\tAverage number of queries per client: %"PRIu64"\n", con.getAvgRows());
2216
uint64_t temp_val= failed_update_for_transaction;
2218
printf("\tFailed number of updates %"PRIu64"\n", temp_val);
2359
2389
connect_to_schema ? create_schema_string.c_str() : NULL,
2360
2390
use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL) == NULL)
2362
fprintf(stderr,"%s: Error creating drizzle object\n", internal::my_progname);
2392
fprintf(stderr,"%s: Error creating drizzle object\n", SLAP_NAME);
2381
2411
if (connect_error)
2383
fprintf(stderr,"%s: Error when connecting to server: %d %s\n", internal::my_progname,
2413
fprintf(stderr,"%s: Error when connecting to server: %d %s\n", SLAP_NAME,
2384
2414
ret, drizzle_con_error(&con));