~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzleslap.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-03-21 20:26:28 UTC
  • mto: (960.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 961.
  • Revision ID: osullivan.padraig@gmail.com-20090321202628-nh6qsi825m4d4av6
Removing the queues.[h,cc] files from the mysys directory. The only place
where they are needed now is in the MyISAM storage engine. Thus, I moved the
files there and updated the files in the MyISAM storage engine
appropriately.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
#include <ctype.h>
85
85
#include <string>
86
86
 
 
87
/* Added this for string translation. */
 
88
#include <drizzled/gettext.h>
 
89
 
87
90
using namespace std;
88
91
 
89
92
#ifdef HAVE_SMEM
90
93
static char *shared_memory_base_name=0;
91
94
#endif
92
95
 
 
96
extern "C"
 
97
bool get_one_option(int optid, const struct my_option *, char *argument);
 
98
 
93
99
/* Global Thread counter */
94
 
uint thread_counter;
 
100
uint32_t thread_counter;
95
101
pthread_mutex_t counter_mutex;
96
102
pthread_cond_t count_threshhold;
97
 
uint master_wakeup;
 
103
uint32_t master_wakeup;
98
104
pthread_mutex_t sleeper_mutex;
99
105
pthread_cond_t sleep_threshhold;
100
106
 
106
112
static char **defaults_argv;
107
113
 
108
114
char **primary_keys;
109
 
uint64_t primary_keys_number_of;
 
115
/* This gets passed to malloc, so lets set it to an arch-dependant size */
 
116
size_t primary_keys_number_of;
110
117
 
111
118
static char *host= NULL, *opt_password= NULL, *user= NULL,
112
119
  *user_supplied_query= NULL,
122
129
const char *create_schema_string= "drizzleslap";
123
130
 
124
131
static bool opt_preserve= true;
125
 
static bool debug_info_flag= 0, debug_check_flag= 0;
 
132
static bool debug_info_flag= false, debug_check_flag= false;
126
133
static bool opt_only_print= false;
127
134
static bool opt_burnin= false;
128
135
static bool opt_ignore_sql_errors= false;
137
144
  CLIENT_MULTI_STATEMENTS;
138
145
 
139
146
static int verbose, delimiter_length;
140
 
static uint commit_rate;
141
 
static uint detach_rate;
142
 
static uint opt_timer_length;
143
 
static uint opt_delayed_start;
 
147
static uint32_t commit_rate;
 
148
static uint32_t detach_rate;
 
149
static uint32_t opt_timer_length;
 
150
static uint32_t opt_delayed_start;
144
151
const char *num_int_cols_opt;
145
152
const char *num_char_cols_opt;
146
153
const char *num_blob_cols_opt;
158
165
static unsigned int num_int_cols_index= 0;
159
166
static unsigned int num_char_cols_index= 0;
160
167
static unsigned int iterations;
161
 
static uint my_end_arg= 0;
 
168
static uint32_t my_end_arg= 0;
162
169
static uint64_t actual_queries= 0;
163
170
static uint64_t auto_actual_queries;
164
171
static uint64_t auto_generate_sql_unique_write_number;
168
175
static uint64_t auto_generate_sql_number;
169
176
const char *concurrency_str= NULL;
170
177
static char *create_string;
171
 
uint *concurrency;
 
178
uint32_t *concurrency;
172
179
 
173
 
const char *default_dbug_option="d:t:o,/tmp/drizzleslap.trace";
 
180
const char *default_dbug_option= "d:t:o,/tmp/drizzleslap.trace";
174
181
const char *opt_csv_str;
175
182
File csv_file;
176
183
 
177
184
static int get_options(int *argc,char ***argv);
178
 
static uint opt_drizzle_port= 0;
 
185
static uint32_t opt_drizzle_port= 0;
179
186
 
180
187
static const char *load_default_groups[]= { "drizzleslap","client",0 };
181
188
 
215
222
 
216
223
struct stats {
217
224
  long int timing;
218
 
  uint users;
219
 
  uint real_users;
 
225
  uint32_t users;
 
226
  uint32_t real_users;
220
227
  uint64_t rows;
221
228
  long int create_timing;
222
229
  uint64_t create_count;
236
243
  long int avg_timing;
237
244
  long int max_timing;
238
245
  long int min_timing;
239
 
  uint users;
240
 
  uint real_users;
 
246
  uint32_t users;
 
247
  uint32_t real_users;
241
248
  uint64_t avg_rows;
242
249
  long int sum_of_time;
243
250
  long int std_dev;
265
272
void print_conclusions(conclusions *con);
266
273
void print_conclusions_csv(conclusions *con);
267
274
void generate_stats(conclusions *con, option_string *eng, stats *sptr);
268
 
uint parse_comma(const char *string, uint **range);
269
 
uint parse_delimiter(const char *script, statement **stmt, char delm);
270
 
uint parse_option(const char *origin, option_string **stmt, char delm);
 
275
uint32_t parse_comma(const char *string, uint32_t **range);
 
276
uint32_t parse_delimiter(const char *script, statement **stmt, char delm);
 
277
uint32_t parse_option(const char *origin, option_string **stmt, char delm);
271
278
static int drop_schema(DRIZZLE *drizzle, const char *db);
272
 
uint get_random_string(char *buf, size_t size);
 
279
uint32_t get_random_string(char *buf, size_t size);
273
280
static statement *build_table_string(void);
274
281
static statement *build_insert_string(void);
275
282
static statement *build_update_string(void);
278
285
static int drop_primary_key_list(void);
279
286
static int create_schema(DRIZZLE *drizzle, const char *db, statement *stmt,
280
287
                         option_string *engine_stmt, stats *sptr);
281
 
static int run_scheduler(stats *sptr, statement **stmts, uint concur,
 
288
static int run_scheduler(stats *sptr, statement **stmts, uint32_t concur,
282
289
                         uint64_t limit);
283
 
pthread_handler_t run_task(void *p);
284
 
pthread_handler_t timer_thread(void *p);
 
290
extern "C" pthread_handler_t run_task(void *p);
 
291
extern "C" pthread_handler_t timer_thread(void *p);
285
292
void statement_cleanup(statement *stmt);
286
293
void option_cleanup(option_string *stmt);
287
 
void concurrency_loop(DRIZZLE *drizzle, uint current, option_string *eptr);
 
294
void concurrency_loop(DRIZZLE *drizzle, uint32_t current, option_string *eptr);
288
295
static int run_statements(DRIZZLE *drizzle, statement *stmt);
289
296
void slap_connect(DRIZZLE *drizzle, bool connect_to_schema);
290
297
void slap_close(DRIZZLE *drizzle);
318
325
 
319
326
  MY_INIT(argv[0]);
320
327
 
321
 
  load_defaults("my",load_default_groups,&argc,&argv);
 
328
  load_defaults("drizzle",load_default_groups,&argc,&argv);
322
329
  defaults_argv=argv;
323
330
  if (get_options(&argc,&argv))
324
331
  {
362
369
  do
363
370
  {
364
371
    /* For the final stage we run whatever queries we were asked to run */
365
 
    uint *current;
 
372
    uint32_t *current;
366
373
 
367
374
    if (verbose >= 2)
368
375
      printf("Starting Concurrency Test\n");
374
381
    }
375
382
    else
376
383
    {
377
 
      uint infinite= 1;
 
384
      uint32_t infinite= 1;
378
385
      do {
379
386
        concurrency_loop(&drizzle, infinite, eptr);
380
387
      }
423
430
  return 0;
424
431
}
425
432
 
426
 
void concurrency_loop(DRIZZLE *drizzle, uint current, option_string *eptr)
 
433
void concurrency_loop(DRIZZLE *drizzle, uint32_t current, option_string *eptr)
427
434
{
428
435
  unsigned int x;
429
436
  stats *head_sptr;
431
438
  conclusions conclusion;
432
439
  uint64_t client_limit;
433
440
 
434
 
  head_sptr= (stats *)my_malloc(sizeof(stats) * iterations,
435
 
                                MYF(MY_ZEROFILL|MY_FAE|MY_WME));
 
441
  head_sptr= (stats *)malloc(sizeof(stats) * iterations);
 
442
  if (head_sptr == NULL)
 
443
  {
 
444
    fprintf(stderr,"Error allocating memory in concurrency_loop\n");
 
445
    exit(1);
 
446
  }
 
447
  memset(head_sptr, 0, sizeof(stats) * iterations);
436
448
 
437
449
  memset(&conclusion, 0, sizeof(conclusions));
438
450
 
470
482
      run_query(drizzle, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0"));
471
483
 
472
484
    if (pre_system)
473
 
      system(pre_system);
 
485
      assert(system(pre_system)!=-1);
474
486
 
475
487
    /*
476
488
      Pre statements are always run after all other logic so they can
485
497
      run_statements(drizzle, post_statements);
486
498
 
487
499
    if (post_system)
488
 
      system(post_system);
 
500
      assert(system(post_system)!=-1);
489
501
 
490
502
    /* We are finished with this run */
491
503
    if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary)
636
648
   "out what it would have done instead.",
637
649
   (char**) &opt_only_print, (char**) &opt_only_print, 0, GET_BOOL,  NO_ARG,
638
650
   0, 0, 0, 0, 0, 0},
639
 
  {"password", 'p',
 
651
  {"password", 'P',
640
652
   "Password to use when connecting to server. If password is not given it's "
641
653
   "asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
642
 
  {"port", 'P', "Port number to use for connection.", (char**) &opt_drizzle_port,
643
 
   (char**) &opt_drizzle_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
644
 
   0},
 
654
  {"port", 'p', "Port number to use for connection.",
 
655
   0, 0, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
645
656
  {"post-query", OPT_SLAP_POST_QUERY,
646
657
   "Query to run or file containing query to execute after tests have completed.",
647
658
   (char**) &user_supplied_post_statements,
700
711
static void print_version(void)
701
712
{
702
713
  printf("%s  Ver %s Distrib %s, for %s (%s)\n",my_progname, SLAP_VERSION,
703
 
         drizzle_get_client_info(),SYSTEM_TYPE,MACHINE_TYPE);
 
714
         drizzleclient_get_client_info(),SYSTEM_TYPE,MACHINE_TYPE);
704
715
}
705
716
 
706
717
 
707
718
static void usage(void)
708
719
{
709
720
  print_version();
710
 
  puts("Copyright (C) 2005 DRIZZLE AB");
 
721
  puts("Copyright (C) 2008 Sun Microsystems");
711
722
  puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\
712
723
       \nand you are welcome to modify and redistribute it under the GPL \
713
724
       license\n");
714
725
  puts("Run a query multiple times against the server\n");
715
726
  printf("Usage: %s [OPTIONS]\n",my_progname);
716
 
  print_defaults("my",load_default_groups);
 
727
  print_defaults("drizzle",load_default_groups);
717
728
  my_print_help(my_long_options);
718
729
}
719
730
 
720
 
static bool
721
 
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
722
 
               char *argument)
 
731
bool get_one_option(int optid, const struct my_option *, char *argument)
723
732
{
 
733
  char *endchar= NULL;
 
734
  uint64_t temp_drizzle_port= 0;
724
735
 
725
736
  switch(optid) {
726
737
  case 'v':
727
738
    verbose++;
728
739
    break;
729
740
  case 'p':
 
741
    temp_drizzle_port= (uint64_t) strtoul(argument, &endchar, 10);
 
742
    /* if there is an alpha character this is not a valid port */
 
743
    if (strlen(endchar) != 0)
 
744
    {
 
745
      fprintf(stderr, _("Non-integer value supplied for port.  If you are trying to enter a password please use --password instead.\n"));
 
746
      exit(1);
 
747
    }
 
748
    /* If the port number is > 65535 it is not a valid port
 
749
       This also helps with potential data loss casting unsigned long to a
 
750
       uint32_t. */
 
751
    if ((temp_drizzle_port == 0) || (temp_drizzle_port > 65535))
 
752
    {
 
753
      fprintf(stderr, _("Value supplied for port is not valid.\n"));
 
754
      exit(1);
 
755
    }
 
756
    else
 
757
    {
 
758
      opt_drizzle_port= (uint32_t) temp_drizzle_port;
 
759
    }
 
760
    break;
 
761
  case 'P':
730
762
    if (argument)
731
763
    {
732
764
      char *start= argument;
733
 
      free(opt_password);
734
 
      opt_password= my_strdup(argument,MYF(MY_FAE));
735
 
      while (*argument) *argument++= 'x';    /* Destroy argument */
 
765
      if (opt_password)
 
766
        free(opt_password);
 
767
      opt_password = strdup(argument);
 
768
      if (opt_password == NULL)
 
769
      {
 
770
        fprintf(stderr, "Memory allocation error while copying password. "
 
771
                        "Aborting.\n");
 
772
        exit(ENOMEM);
 
773
      }
 
774
      while (*argument)
 
775
      {
 
776
        /* Overwriting password with 'x' */
 
777
        *argument++= 'x';
 
778
      }
736
779
      if (*start)
737
 
        start[1]= 0;        /* Cut length of argument */
 
780
      {
 
781
        /* Cut length of argument */
 
782
        start[1]= 0;
 
783
      }
738
784
      tty_password= 0;
739
785
    }
740
786
    else
743
789
  case 'V':
744
790
    print_version();
745
791
    exit(0);
746
 
    break;
747
792
  case '?':
748
793
  case 'I':          /* Info */
749
794
    usage();
892
937
    }
893
938
 
894
939
  table_string.append(")");
895
 
  ptr= (statement *)my_malloc(sizeof(statement),
896
 
                              MYF(MY_ZEROFILL|MY_FAE|MY_WME));
897
 
  ptr->string = (char *)my_malloc(table_string.length()+1,
898
 
                                  MYF(MY_ZEROFILL|MY_FAE|MY_WME));
 
940
  ptr= (statement *)malloc(sizeof(statement));
 
941
  if (ptr == NULL)
 
942
  {
 
943
    fprintf(stderr, "Memory Allocation error in creating table\n");
 
944
    exit(1);
 
945
  }
 
946
  memset(ptr, 0, sizeof(statement));
 
947
  ptr->string = (char *)malloc(table_string.length()+1);
 
948
  if (ptr->string == NULL)
 
949
  {
 
950
    fprintf(stderr, "Memory Allocation error in creating table\n");
 
951
    exit(1);
 
952
  }
 
953
  memset(ptr->string, 0, table_string.length()+1);
899
954
  ptr->length= table_string.length()+1;
900
955
  ptr->type= CREATE_TABLE_TYPE;
901
 
  my_stpcpy(ptr->string, table_string.c_str());
 
956
  strcpy(ptr->string, table_string.c_str());
902
957
  return(ptr);
903
958
}
904
959
 
958
1013
    update_string.append(" WHERE id = ");
959
1014
 
960
1015
 
961
 
  ptr= (statement *)my_malloc(sizeof(statement),
962
 
                              MYF(MY_ZEROFILL|MY_FAE|MY_WME));
 
1016
  ptr= (statement *)malloc(sizeof(statement));
 
1017
  if (ptr == NULL)
 
1018
  {
 
1019
    fprintf(stderr, "Memory Allocation error in creating update\n");
 
1020
    exit(1);
 
1021
  }
 
1022
  memset(ptr, 0, sizeof(statement));
963
1023
 
964
 
  ptr->string= (char *)my_malloc(update_string.length() + 1,
965
 
                                 MYF(MY_ZEROFILL|MY_FAE|MY_WME));
966
1024
  ptr->length= update_string.length()+1;
 
1025
  ptr->string= (char *)malloc(ptr->length);
 
1026
  if (ptr->string == NULL)
 
1027
  {
 
1028
    fprintf(stderr, "Memory Allocation error in creating update\n");
 
1029
    exit(1);
 
1030
  }
 
1031
  memset(ptr->string, 0, ptr->length);
967
1032
  if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary)
968
1033
    ptr->type= UPDATE_TYPE_REQUIRES_PREFIX ;
969
1034
  else
970
1035
    ptr->type= UPDATE_TYPE;
971
 
  my_stpcpy(ptr->string, update_string.c_str());
 
1036
  strncpy(ptr->string, update_string.c_str(), ptr->length);
972
1037
  return(ptr);
973
1038
}
974
1039
 
1055
1120
 
1056
1121
    if (num_blob_cols_size > HUGE_STRING_LENGTH)
1057
1122
    {
1058
 
      blob_ptr= (char *)my_malloc(sizeof(char)*num_blob_cols_size,
1059
 
                                  MYF(MY_ZEROFILL|MY_FAE|MY_WME));
 
1123
      blob_ptr= (char *)malloc(sizeof(char)*num_blob_cols_size);
1060
1124
      if (!blob_ptr)
1061
1125
      {
1062
1126
        fprintf(stderr, "Memory Allocation error in creating select\n");
1063
1127
        exit(1);
1064
1128
      }
 
1129
      memset(blob_ptr, 0, sizeof(char)*num_blob_cols_size);
1065
1130
    }
1066
1131
    else
1067
1132
    {
1093
1158
 
1094
1159
  insert_string.append(")", 1);
1095
1160
 
1096
 
  if (!(ptr= (statement *)my_malloc(sizeof(statement), MYF(MY_ZEROFILL|MY_FAE|MY_WME))))
1097
 
  {
1098
 
    fprintf(stderr, "Memory Allocation error in creating select\n");
1099
 
    exit(1);
1100
 
  }
1101
 
  if (!(ptr->string= (char *)my_malloc(insert_string.length() + 1, MYF(MY_ZEROFILL|MY_FAE|MY_WME))))
1102
 
  {
1103
 
    fprintf(stderr, "Memory Allocation error in creating select\n");
1104
 
    exit(1);
1105
 
  }
 
1161
  if (!(ptr= (statement *)malloc(sizeof(statement))))
 
1162
  {
 
1163
    fprintf(stderr, "Memory Allocation error in creating select\n");
 
1164
    exit(1);
 
1165
  }
 
1166
  memset(ptr, 0, sizeof(statement));
1106
1167
  ptr->length= insert_string.length()+1;
 
1168
  if (!(ptr->string= (char *)malloc(ptr->length)))
 
1169
  {
 
1170
    fprintf(stderr, "Memory Allocation error in creating select\n");
 
1171
    exit(1);
 
1172
  }
 
1173
  memset(ptr->string, 0, ptr->length);
1107
1174
  ptr->type= INSERT_TYPE;
1108
 
  my_stpcpy(ptr->string, insert_string.c_str());
 
1175
  strcpy(ptr->string, insert_string.c_str());
1109
1176
  return(ptr);
1110
1177
}
1111
1178
 
1181
1248
      (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary))
1182
1249
    query_string.append(" WHERE id = ");
1183
1250
 
1184
 
  ptr= (statement *)my_malloc(sizeof(statement),
1185
 
                              MYF(MY_ZEROFILL|MY_FAE|MY_WME));
1186
 
  ptr->string= (char *)my_malloc(query_string.length() + 1,
1187
 
                                 MYF(MY_ZEROFILL|MY_FAE|MY_WME));
 
1251
  ptr= (statement *)malloc(sizeof(statement));
 
1252
  if (ptr == NULL)
 
1253
  {
 
1254
    fprintf(stderr, "Memory Allocation error in creating select\n");
 
1255
    exit(1);
 
1256
  }
 
1257
  memset(ptr, 0, sizeof(statement));
1188
1258
  ptr->length= query_string.length()+1;
 
1259
  ptr->string= (char *)malloc(ptr->length);
 
1260
  if (ptr->string == NULL)
 
1261
  {
 
1262
    fprintf(stderr, "Memory Allocation error in creating select\n");
 
1263
    exit(1);
 
1264
  }
 
1265
  memset(ptr->string, 0, ptr->length);
1189
1266
  if ((key) &&
1190
1267
      (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary))
1191
1268
    ptr->type= SELECT_TYPE_REQUIRES_PREFIX;
1192
1269
  else
1193
1270
    ptr->type= SELECT_TYPE;
1194
 
  my_stpcpy(ptr->string, query_string.c_str());
 
1271
  strcpy(ptr->string, query_string.c_str());
1195
1272
  return(ptr);
1196
1273
}
1197
1274
 
1203
1280
  struct stat sbuf;
1204
1281
  option_string *sql_type;
1205
1282
  unsigned int sql_type_count= 0;
 
1283
  ssize_t bytes_read= 0;
1206
1284
 
1207
1285
 
1208
1286
  if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option)))
1347
1425
    query_statements_count=
1348
1426
      parse_option(opt_auto_generate_sql_type, &query_options, ',');
1349
1427
 
1350
 
    query_statements= (statement **)my_malloc(sizeof(statement *) * query_statements_count,
1351
 
                                              MYF(MY_ZEROFILL|MY_FAE|MY_WME));
 
1428
    query_statements= (statement **)malloc(sizeof(statement *) * query_statements_count);
 
1429
    if (query_statements == NULL)
 
1430
    {
 
1431
      fprintf(stderr, "Memory Allocation error in Building Query Statements\n");
 
1432
      exit(1);
 
1433
    }
 
1434
    memset(query_statements, 0, sizeof(statement *) * query_statements_count);
1352
1435
 
1353
1436
    sql_type= query_options;
1354
1437
    do
1468
1551
        fprintf(stderr,"%s: Could not open create file\n", my_progname);
1469
1552
        exit(1);
1470
1553
      }
1471
 
      tmp_string= (char *)my_malloc(sbuf.st_size + 1,
1472
 
                                    MYF(MY_ZEROFILL|MY_FAE|MY_WME));
1473
 
      my_read(data_file, (unsigned char*) tmp_string, sbuf.st_size, MYF(0));
 
1554
      if ((uint64_t)(sbuf.st_size + 1) > SIZE_MAX)
 
1555
      {
 
1556
        fprintf(stderr, "Request for more memory than architecture supports\n");
 
1557
        exit(1);
 
1558
      }
 
1559
      tmp_string= (char *)malloc((size_t)(sbuf.st_size + 1));
 
1560
      if (tmp_string == NULL)
 
1561
      {
 
1562
        fprintf(stderr, "Memory Allocation error in option processing\n");
 
1563
        exit(1);
 
1564
      }
 
1565
      memset(tmp_string, 0, (size_t)(sbuf.st_size + 1));
 
1566
      bytes_read= read(data_file, (unsigned char*) tmp_string,
 
1567
                       (size_t)sbuf.st_size);
1474
1568
      tmp_string[sbuf.st_size]= '\0';
1475
 
      my_close(data_file,MYF(0));
 
1569
      close(data_file);
 
1570
      if (bytes_read != sbuf.st_size)
 
1571
      {
 
1572
        fprintf(stderr, "Problem reading file: read less bytes than requested\n");
 
1573
      }
1476
1574
      parse_delimiter(tmp_string, &create_statements, delimiter[0]);
1477
1575
      free(tmp_string);
1478
1576
    }
1487
1585
      query_statements_count=
1488
1586
        parse_option("default", &query_options, ',');
1489
1587
 
1490
 
      query_statements= (statement **)my_malloc(sizeof(statement *),
1491
 
                                                MYF(MY_ZEROFILL|MY_FAE|MY_WME));
 
1588
      query_statements= (statement **)malloc(sizeof(statement *) * query_statements_count);
 
1589
      if (query_statements == NULL)
 
1590
      {
 
1591
        fprintf(stderr, "Memory Allocation error in option processing\n");
 
1592
        exit(1);
 
1593
      }
 
1594
      memset(query_statements, 0, sizeof(statement *) * query_statements_count); 
1492
1595
    }
1493
1596
 
1494
1597
    if (user_supplied_query && !stat(user_supplied_query, &sbuf))
1505
1608
        fprintf(stderr,"%s: Could not open query supplied file\n", my_progname);
1506
1609
        exit(1);
1507
1610
      }
1508
 
      tmp_string= (char *)my_malloc(sbuf.st_size + 1,
1509
 
                                    MYF(MY_ZEROFILL|MY_FAE|MY_WME));
1510
 
      my_read(data_file, (unsigned char*) tmp_string, sbuf.st_size, MYF(0));
 
1611
      if ((uint64_t)(sbuf.st_size + 1) > SIZE_MAX)
 
1612
      {
 
1613
        fprintf(stderr, "Request for more memory than architecture supports\n");
 
1614
        exit(1);
 
1615
      }
 
1616
      tmp_string= (char *)malloc((size_t)(sbuf.st_size + 1));
 
1617
      if (tmp_string == NULL)
 
1618
      {
 
1619
        fprintf(stderr, "Memory Allocation error in option processing\n");
 
1620
        exit(1);
 
1621
      }
 
1622
      memset(tmp_string, 0, (size_t)(sbuf.st_size + 1));
 
1623
      bytes_read= read(data_file, (unsigned char*) tmp_string,
 
1624
                       (size_t)sbuf.st_size);
1511
1625
      tmp_string[sbuf.st_size]= '\0';
1512
 
      my_close(data_file,MYF(0));
 
1626
      close(data_file);
 
1627
      if (bytes_read != sbuf.st_size)
 
1628
      {
 
1629
        fprintf(stderr, "Problem reading file: read less bytes than requested\n");
 
1630
      }
1513
1631
      if (user_supplied_query)
1514
1632
        actual_queries= parse_delimiter(tmp_string, &query_statements[0],
1515
1633
                                        delimiter[0]);
1537
1655
      fprintf(stderr,"%s: Could not open query supplied file\n", my_progname);
1538
1656
      exit(1);
1539
1657
    }
1540
 
    tmp_string= (char *)my_malloc(sbuf.st_size + 1,
1541
 
                                  MYF(MY_ZEROFILL|MY_FAE|MY_WME));
1542
 
    my_read(data_file, (unsigned char*) tmp_string, sbuf.st_size, MYF(0));
 
1658
    if ((uint64_t)(sbuf.st_size + 1) > SIZE_MAX)
 
1659
    {
 
1660
      fprintf(stderr, "Request for more memory than architecture supports\n");
 
1661
      exit(1);
 
1662
    }
 
1663
    tmp_string= (char *)malloc((size_t)(sbuf.st_size + 1));
 
1664
    if (tmp_string == NULL)
 
1665
    {
 
1666
      fprintf(stderr, "Memory Allocation error in option processing\n");
 
1667
      exit(1);
 
1668
    }
 
1669
    memset(tmp_string, 0, (size_t)(sbuf.st_size + 1));
 
1670
    bytes_read= read(data_file, (unsigned char*) tmp_string,
 
1671
                     (size_t)sbuf.st_size);
1543
1672
    tmp_string[sbuf.st_size]= '\0';
1544
 
    my_close(data_file,MYF(0));
 
1673
    close(data_file);
 
1674
    if (bytes_read != sbuf.st_size)
 
1675
    {
 
1676
      fprintf(stderr, "Problem reading file: read less bytes than requested\n");
 
1677
    }
1545
1678
    if (user_supplied_pre_statements)
1546
1679
      (void)parse_delimiter(tmp_string, &pre_statements,
1547
1680
                            delimiter[0]);
1569
1702
      fprintf(stderr,"%s: Could not open query supplied file\n", my_progname);
1570
1703
      exit(1);
1571
1704
    }
1572
 
    tmp_string= (char *)my_malloc(sbuf.st_size + 1,
1573
 
                                  MYF(MY_ZEROFILL|MY_FAE|MY_WME));
1574
 
    my_read(data_file, (unsigned char*) tmp_string, sbuf.st_size, MYF(0));
 
1705
 
 
1706
    if ((uint64_t)(sbuf.st_size + 1) > SIZE_MAX)
 
1707
    {
 
1708
      fprintf(stderr, "Request for more memory than architecture supports\n");
 
1709
      exit(1);
 
1710
    }
 
1711
    tmp_string= (char *)malloc((size_t)(sbuf.st_size + 1));
 
1712
    if (tmp_string == NULL)
 
1713
    {
 
1714
      fprintf(stderr, "Memory Allocation error in option processing\n");
 
1715
      exit(1);
 
1716
    }
 
1717
    memset(tmp_string, 0, (size_t)(sbuf.st_size+1));
 
1718
 
 
1719
    bytes_read= read(data_file, (unsigned char*) tmp_string,
 
1720
                     (size_t)(sbuf.st_size));
1575
1721
    tmp_string[sbuf.st_size]= '\0';
1576
 
    my_close(data_file,MYF(0));
 
1722
    close(data_file);
 
1723
    if (bytes_read != sbuf.st_size)
 
1724
    {
 
1725
      fprintf(stderr, "Problem reading file: read less bytes than requested\n");
 
1726
    }
1577
1727
    if (user_supplied_post_statements)
1578
1728
      (void)parse_delimiter(tmp_string, &post_statements,
1579
1729
                            delimiter[0]);
1592
1742
    parse_option(default_engine, &engine_options, ',');
1593
1743
 
1594
1744
  if (tty_password)
1595
 
    opt_password= get_tty_password(NULL);
 
1745
    opt_password= drizzleclient_get_tty_password(NULL);
1596
1746
  return(0);
1597
1747
}
1598
1748
 
1607
1757
 
1608
1758
  if (verbose >= 3)
1609
1759
    printf("%.*s;\n", len, query);
1610
 
  return drizzle_real_query(drizzle, query, len);
 
1760
  return drizzleclient_real_query(drizzle, query, len);
1611
1761
}
1612
1762
 
1613
1763
 
1627
1777
                         strstr(engine_stmt->string, "blackhole")))
1628
1778
  {
1629
1779
    primary_keys_number_of= 1;
1630
 
    primary_keys= (char **)my_malloc((uint)(sizeof(char *) *
1631
 
                                            primary_keys_number_of),
1632
 
                                     MYF(MY_ZEROFILL|MY_FAE|MY_WME));
 
1780
    primary_keys= (char **)malloc((sizeof(char *) *
 
1781
                                  primary_keys_number_of));
 
1782
    if (primary_keys == NULL)
 
1783
    {
 
1784
      fprintf(stderr, "Memory Allocation error in option processing\n");
 
1785
      exit(1);
 
1786
    }
 
1787
    
 
1788
    memset(primary_keys, 0, (sizeof(char *) * primary_keys_number_of));
1633
1789
    /* Yes, we strdup a const string to simplify the interface */
1634
 
    primary_keys[0]= my_strdup("796c4422-1d94-102a-9d6d-00e0812d", MYF(0));
 
1790
    primary_keys[0]= strdup("796c4422-1d94-102a-9d6d-00e0812d");
 
1791
    if (primary_keys[0] == NULL)
 
1792
    {
 
1793
      fprintf(stderr, "Memory Allocation error in option processing\n");
 
1794
      exit(1);
 
1795
    }
1635
1796
  }
1636
1797
  else
1637
1798
  {
1638
1799
    if (run_query(drizzle, "SELECT id from t1", strlen("SELECT id from t1")))
1639
1800
    {
1640
1801
      fprintf(stderr,"%s: Cannot select GUID primary keys. (%s)\n", my_progname,
1641
 
              drizzle_error(drizzle));
 
1802
              drizzleclient_error(drizzle));
1642
1803
      exit(1);
1643
1804
    }
1644
1805
 
1645
 
    result= drizzle_store_result(drizzle);
1646
 
    primary_keys_number_of= drizzle_num_rows(result);
 
1806
    result= drizzleclient_store_result(drizzle);
 
1807
    uint64_t num_rows_ret= drizzleclient_num_rows(result);
 
1808
    if (num_rows_ret > SIZE_MAX)
 
1809
    {
 
1810
      fprintf(stderr, "More primary keys than than architecture supports\n");
 
1811
      exit(1);
 
1812
    }
 
1813
    primary_keys_number_of= (size_t)num_rows_ret;
1647
1814
 
1648
1815
    /* So why check this? Blackhole :) */
1649
1816
    if (primary_keys_number_of)
1651
1818
      /*
1652
1819
        We create the structure and loop and create the items.
1653
1820
      */
1654
 
      primary_keys= (char **)my_malloc((uint)(sizeof(char *) *
1655
 
                                              primary_keys_number_of),
1656
 
                                       MYF(MY_ZEROFILL|MY_FAE|MY_WME));
1657
 
      row= drizzle_fetch_row(result);
 
1821
      primary_keys= (char **)malloc(sizeof(char *) *
 
1822
                                    primary_keys_number_of);
 
1823
      if (primary_keys == NULL)
 
1824
      {
 
1825
        fprintf(stderr, "Memory Allocation error in option processing\n");
 
1826
        exit(1);
 
1827
      }
 
1828
      memset(primary_keys, 0, (size_t)(sizeof(char *) * primary_keys_number_of));
 
1829
      row= drizzleclient_fetch_row(result);
1658
1830
      for (counter= 0; counter < primary_keys_number_of;
1659
 
           counter++, row= drizzle_fetch_row(result))
1660
 
        primary_keys[counter]= my_strdup(row[0], MYF(0));
 
1831
           counter++, row= drizzleclient_fetch_row(result))
 
1832
      {
 
1833
        primary_keys[counter]= strdup(row[0]);
 
1834
        if (primary_keys[counter] == NULL)
 
1835
        {
 
1836
          fprintf(stderr, "Memory Allocation error in option processing\n");
 
1837
          exit(1);
 
1838
        }
 
1839
      }
1661
1840
    }
1662
1841
 
1663
 
    drizzle_free_result(result);
 
1842
    drizzleclient_free_result(result);
1664
1843
  }
1665
1844
 
1666
1845
  return(0);
1704
1883
  if (run_query(drizzle, query, len))
1705
1884
  {
1706
1885
    fprintf(stderr,"%s: Cannot create schema %s : %s\n", my_progname, db,
1707
 
            drizzle_error(drizzle));
 
1886
            drizzleclient_error(drizzle));
1708
1887
    exit(1);
1709
1888
  }
1710
1889
  else
1721
1900
    if (verbose >= 3)
1722
1901
      printf("%s;\n", query);
1723
1902
 
1724
 
    if (drizzle_select_db(drizzle,  db))
 
1903
    if (drizzleclient_select_db(drizzle,  db))
1725
1904
    {
1726
1905
      fprintf(stderr,"%s: Cannot select schema '%s': %s\n",my_progname, db,
1727
 
              drizzle_error(drizzle));
 
1906
              drizzleclient_error(drizzle));
1728
1907
      exit(1);
1729
1908
    }
1730
1909
    sptr->create_count++;
1737
1916
    if (run_query(drizzle, query, len))
1738
1917
    {
1739
1918
      fprintf(stderr,"%s: Cannot set default engine: %s\n", my_progname,
1740
 
              drizzle_error(drizzle));
 
1919
              drizzleclient_error(drizzle));
1741
1920
      exit(1);
1742
1921
    }
1743
1922
    sptr->create_count++;
1761
1940
      if (run_query(drizzle, buffer, strlen(buffer)))
1762
1941
      {
1763
1942
        fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
1764
 
                my_progname, (uint)ptr->length, ptr->string, drizzle_error(drizzle));
 
1943
                my_progname, (uint32_t)ptr->length, ptr->string, drizzleclient_error(drizzle));
1765
1944
        if (!opt_ignore_sql_errors)
1766
1945
          exit(1);
1767
1946
      }
1772
1951
      if (run_query(drizzle, ptr->string, ptr->length))
1773
1952
      {
1774
1953
        fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
1775
 
                my_progname, (uint)ptr->length, ptr->string, drizzle_error(drizzle));
 
1954
                my_progname, (uint32_t)ptr->length, ptr->string, drizzleclient_error(drizzle));
1776
1955
        if (!opt_ignore_sql_errors)
1777
1956
          exit(1);
1778
1957
      }
1805
1984
  if (run_query(drizzle, query, len))
1806
1985
  {
1807
1986
    fprintf(stderr,"%s: Cannot drop database '%s' ERROR : %s\n",
1808
 
            my_progname, db, drizzle_error(drizzle));
 
1987
            my_progname, db, drizzleclient_error(drizzle));
1809
1988
    exit(1);
1810
1989
  }
1811
1990
 
1826
2005
    if (run_query(drizzle, ptr->string, ptr->length))
1827
2006
    {
1828
2007
      fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
1829
 
              my_progname, (uint)ptr->length, ptr->string, drizzle_error(drizzle));
 
2008
              my_progname, (uint32_t)ptr->length, ptr->string, drizzleclient_error(drizzle));
1830
2009
      exit(1);
1831
2010
    }
1832
2011
    if (!opt_only_print)
1833
2012
    {
1834
 
      if (drizzle_field_count(drizzle))
 
2013
      if (drizzleclient_field_count(drizzle))
1835
2014
      {
1836
 
        result= drizzle_store_result(drizzle);
1837
 
        drizzle_free_result(result);
 
2015
        result= drizzleclient_store_result(drizzle);
 
2016
        drizzleclient_free_result(result);
1838
2017
      }
1839
2018
    }
1840
2019
  }
1843
2022
}
1844
2023
 
1845
2024
static int
1846
 
run_scheduler(stats *sptr, statement **stmts, uint concur, uint64_t limit)
 
2025
run_scheduler(stats *sptr, statement **stmts, uint32_t concur, uint64_t limit)
1847
2026
{
1848
 
  uint x;
1849
 
  uint y;
 
2027
  uint32_t x;
 
2028
  uint32_t y;
1850
2029
  unsigned int real_concurrency;
1851
2030
  struct timeval start_time, end_time;
1852
2031
  option_string *sql_type;
1884
2063
    while (options_loop--)
1885
2064
      for (x= 0; x < concur; x++)
1886
2065
      {
1887
 
        con= (thread_context *)my_malloc(sizeof(thread_context), MYF(0));
 
2066
        con= (thread_context *)malloc(sizeof(thread_context));
 
2067
        if (con == NULL)
 
2068
        {
 
2069
          fprintf(stderr, "Memory Allocation error in scheduler\n");
 
2070
          exit(1);
 
2071
        }
1888
2072
        con->stmt= stmts[y];
1889
2073
        con->limit= limit;
1890
2074
 
1955
2139
 
1956
2140
pthread_handler_t timer_thread(void *p)
1957
2141
{
1958
 
  uint *timer_length= (uint *)p;
 
2142
  uint32_t *timer_length= (uint32_t *)p;
1959
2143
  struct timespec abstime;
1960
2144
 
1961
2145
 
2054
2238
        if (run_query(&drizzle, buffer, length))
2055
2239
        {
2056
2240
          fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
2057
 
                  my_progname, (uint)length, buffer, drizzle_error(&drizzle));
 
2241
                  my_progname, (uint32_t)length, buffer, drizzleclient_error(&drizzle));
2058
2242
          exit(1);
2059
2243
        }
2060
2244
      }
2064
2248
      if (run_query(&drizzle, ptr->string, ptr->length))
2065
2249
      {
2066
2250
        fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
2067
 
                my_progname, (uint)ptr->length, ptr->string, drizzle_error(&drizzle));
 
2251
                my_progname, (uint32_t)ptr->length, ptr->string, drizzleclient_error(&drizzle));
2068
2252
        exit(1);
2069
2253
      }
2070
2254
    }
2073
2257
    {
2074
2258
      do
2075
2259
      {
2076
 
        if (drizzle_field_count(&drizzle))
 
2260
        if (drizzleclient_field_count(&drizzle))
2077
2261
        {
2078
 
          result= drizzle_store_result(&drizzle);
2079
 
          while ((row = drizzle_fetch_row(result)))
 
2262
          result= drizzleclient_store_result(&drizzle);
 
2263
          while ((row = drizzleclient_fetch_row(result)))
2080
2264
            counter++;
2081
 
          drizzle_free_result(result);
 
2265
          drizzleclient_free_result(result);
2082
2266
        }
2083
 
      } while(drizzle_next_result(&drizzle) == 0);
 
2267
      } while(drizzleclient_next_result(&drizzle) == 0);
2084
2268
    }
2085
2269
    queries++;
2086
2270
 
2134
2318
  char *end_ptr;
2135
2319
  option_string **sptr= stmt;
2136
2320
  option_string *tmp;
2137
 
  uint length= strlen(origin);
2138
 
  uint count= 0; /* We know that there is always one */
 
2321
  uint32_t length= strlen(origin);
 
2322
  uint32_t count= 0; /* We know that there is always one */
2139
2323
 
2140
2324
  end_ptr= (char *)origin + length;
2141
2325
 
2142
 
  tmp= *sptr= (option_string *)my_malloc(sizeof(option_string),
2143
 
                                         MYF(MY_ZEROFILL|MY_FAE|MY_WME));
 
2326
  tmp= *sptr= (option_string *)malloc(sizeof(option_string));
 
2327
  if (tmp == NULL)
 
2328
  {
 
2329
    fprintf(stderr,"Error allocating memory while parsing options\n");
 
2330
    exit(1);
 
2331
  }
 
2332
  memset(tmp, 0, sizeof(option_string));
2144
2333
 
2145
2334
  for (begin_ptr= (char *)origin;
2146
2335
       begin_ptr != end_ptr;
2160
2349
    }
2161
2350
    else
2162
2351
    {
2163
 
      size_t length= strlen(begin_ptr);
2164
 
      memcpy(buffer, begin_ptr, length);
 
2352
      size_t begin_len= strlen(begin_ptr);
 
2353
      memcpy(buffer, begin_ptr, begin_len);
2165
2354
      begin_ptr= end_ptr;
2166
2355
    }
2167
2356
 
2173
2362
 
2174
2363
      /* Move past the : and the first string */
2175
2364
      tmp->option_length= strlen(buffer_ptr);
2176
 
      tmp->option= my_strndup(buffer_ptr, (uint)tmp->option_length,
2177
 
                              MYF(MY_FAE));
 
2365
      tmp->option= (char *)malloc(tmp->option_length + 1);
 
2366
      if (tmp->option == NULL)
 
2367
      {
 
2368
        fprintf(stderr,"Error allocating memory while parsing options\n");
 
2369
        exit(1);
 
2370
      }
 
2371
      memcpy(tmp->option, buffer_ptr, tmp->option_length);
 
2372
      tmp->option[tmp->option_length]= 0; 
2178
2373
    }
2179
2374
 
2180
 
    tmp->string= my_strndup(buffer, strlen(buffer), MYF(MY_FAE));
2181
2375
    tmp->length= strlen(buffer);
 
2376
    tmp->string= strdup(buffer);
 
2377
    if (tmp->string == NULL)
 
2378
    {
 
2379
      fprintf(stderr,"Error allocating memory while parsing options\n");
 
2380
      exit(1);
 
2381
    }
2182
2382
 
2183
2383
    if (isspace(*begin_ptr))
2184
2384
      begin_ptr++;
2186
2386
    count++;
2187
2387
 
2188
2388
    if (begin_ptr != end_ptr)
2189
 
      tmp->next= (option_string *)my_malloc(sizeof(option_string),
2190
 
                                            MYF(MY_ZEROFILL|MY_FAE|MY_WME));
 
2389
    {
 
2390
      tmp->next= (option_string *)malloc(sizeof(option_string));
 
2391
      if (tmp->next == NULL)
 
2392
      {
 
2393
        fprintf(stderr,"Error allocating memory while parsing options\n");
 
2394
        exit(1);
 
2395
      }
 
2396
      memset(tmp->next, 0, sizeof(option_string));
 
2397
    }
 
2398
    
2191
2399
  }
2192
2400
 
2193
2401
  return count;
2205
2413
  char *ptr= (char *)script;
2206
2414
  statement **sptr= stmt;
2207
2415
  statement *tmp;
2208
 
  uint length= strlen(script);
2209
 
  uint count= 0; /* We know that there is always one */
 
2416
  uint32_t length= strlen(script);
 
2417
  uint32_t count= 0; /* We know that there is always one */
2210
2418
 
2211
 
  for (tmp= *sptr= (statement *)my_malloc(sizeof(statement),
2212
 
                                          MYF(MY_ZEROFILL|MY_FAE|MY_WME));
 
2419
  for (tmp= *sptr= (statement *)malloc(sizeof(statement));
2213
2420
       (retstr= strchr(ptr, delm));
2214
 
       tmp->next=  (statement *)my_malloc(sizeof(statement),
2215
 
                                          MYF(MY_ZEROFILL|MY_FAE|MY_WME)),
2216
 
         tmp= tmp->next)
 
2421
       tmp->next=  (statement *)malloc(sizeof(statement)),
 
2422
       tmp= tmp->next)
2217
2423
  {
 
2424
    memset(tmp, 0, sizeof(statement));
2218
2425
    count++;
2219
 
    tmp->string= my_strndup(ptr, (uint)(retstr - ptr), MYF(MY_FAE));
2220
2426
    tmp->length= (size_t)(retstr - ptr);
 
2427
    tmp->string= (char *)malloc(tmp->length + 1);
 
2428
    if (tmp->string == NULL)
 
2429
    {
 
2430
      fprintf(stderr,"Error allocating memory while parsing delimiter\n");
 
2431
      exit(1);
 
2432
    }
 
2433
    memcpy(tmp->string, ptr, tmp->length);
 
2434
    tmp->string[tmp->length]= 0;
2221
2435
    ptr+= retstr - ptr + 1;
2222
2436
    if (isspace(*ptr))
2223
2437
      ptr++;
2225
2439
 
2226
2440
  if (ptr != script+length)
2227
2441
  {
2228
 
    tmp->string= my_strndup(ptr, (uint)((script + length) - ptr),
2229
 
                            MYF(MY_FAE));
2230
2442
    tmp->length= (size_t)((script + length) - ptr);
 
2443
    tmp->string= (char *)malloc(tmp->length + 1);
 
2444
    if (tmp->string == NULL)
 
2445
    {
 
2446
      fprintf(stderr,"Error allocating memory while parsing delimiter\n");
 
2447
      exit(1);
 
2448
    }
 
2449
    memcpy(tmp->string, ptr, tmp->length);
 
2450
    tmp->string[tmp->length]= 0;
2231
2451
    count++;
2232
2452
  }
2233
2453
 
2241
2461
  In restrospect, this is a lousy name from this function.
2242
2462
*/
2243
2463
uint
2244
 
parse_comma(const char *string, uint **range)
 
2464
parse_comma(const char *string, uint32_t **range)
2245
2465
{
2246
 
  uint count= 1,x; /* We know that there is always one */
 
2466
  unsigned int count= 1,x; /* We know that there is always one */
2247
2467
  char *retstr;
2248
2468
  char *ptr= (char *)string;
2249
 
  uint *nptr;
 
2469
  unsigned int *nptr;
2250
2470
 
2251
2471
  for (;*ptr; ptr++)
2252
2472
    if (*ptr == ',') count++;
2253
2473
 
2254
2474
  /* One extra spot for the NULL */
2255
 
  nptr= *range= (uint *)my_malloc(sizeof(uint) * (count + 1),
2256
 
                                  MYF(MY_ZEROFILL|MY_FAE|MY_WME));
 
2475
  nptr= *range= (uint32_t *)malloc(sizeof(unsigned int) * (count + 1));
 
2476
  memset(nptr, 0, sizeof(unsigned int) * (count + 1));
2257
2477
 
2258
2478
  ptr= (char *)string;
2259
2479
  x= 0;
2349
2569
           con->real_users, /* Children used max_timing */
2350
2570
           con->avg_rows  /* Queries run */
2351
2571
           );
2352
 
  my_write(csv_file, (unsigned char*) buffer, (uint)strlen(buffer), MYF(0));
 
2572
  my_write(csv_file, (unsigned char*) buffer, (uint32_t)strlen(buffer), MYF(0));
2353
2573
}
2354
2574
 
2355
2575
void
2448
2668
  if (opt_only_print)
2449
2669
    return;
2450
2670
 
2451
 
  drizzle_close(drizzle);
 
2671
  drizzleclient_close(drizzle);
2452
2672
}
2453
2673
 
2454
2674
void
2462
2682
    return;
2463
2683
 
2464
2684
  if (opt_delayed_start)
2465
 
    my_sleep(random()%opt_delayed_start);
 
2685
    usleep(random()%opt_delayed_start);
2466
2686
 
2467
 
  drizzle_create(drizzle);
 
2687
  drizzleclient_create(drizzle);
2468
2688
 
2469
2689
  if (opt_compress)
2470
 
    drizzle_options(drizzle,DRIZZLE_OPT_COMPRESS,NULL);
 
2690
    drizzleclient_options(drizzle,DRIZZLE_OPT_COMPRESS,NULL);
2471
2691
 
2472
2692
  for (x= 0; x < 10; x++)
2473
2693
  {
2474
2694
 
2475
2695
 
2476
 
    if (drizzle_connect(drizzle, host, user, opt_password,
 
2696
    if (drizzleclient_connect(drizzle, host, user, opt_password,
2477
2697
                        connect_to_schema ? create_schema_string : NULL,
2478
2698
                        opt_drizzle_port,
2479
2699
                        opt_drizzle_unix_port,
2483
2703
      connect_error= 0;
2484
2704
      break;
2485
2705
    }
2486
 
    my_sleep(connection_retry_sleep);
 
2706
    usleep(connection_retry_sleep);
2487
2707
  }
2488
2708
  if (connect_error)
2489
2709
  {
2490
2710
    fprintf(stderr,"%s: Error when connecting to server: %d %s\n",
2491
 
            my_progname, drizzle_errno(drizzle), drizzle_error(drizzle));
 
2711
            my_progname, drizzleclient_errno(drizzle), drizzleclient_error(drizzle));
2492
2712
    exit(1);
2493
2713
  }
2494
2714