~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzleslap.cc

  • Committer: Eric Day
  • Date: 2009-03-26 09:22:55 UTC
  • mto: (968.1.1 lib-merge)
  • mto: This revision was merged to the branch mainline in revision 969.
  • Revision ID: eday@oddments.org-20090326092255-m51lu07ve4trwynq
Tools mostly converted, still fixing bugs from test suite.

Show diffs side-by-side

added added

removed removed

Lines of Context:
140
140
  auto_generate_sql= false;
141
141
const char *opt_auto_generate_sql_type= "mixed";
142
142
 
143
 
static unsigned long connect_flags= CLIENT_MULTI_RESULTS |
144
 
  CLIENT_MULTI_STATEMENTS;
145
 
 
146
143
static int verbose, delimiter_length;
147
144
static uint32_t commit_rate;
148
145
static uint32_t detach_rate;
275
272
uint32_t parse_comma(const char *string, uint32_t **range);
276
273
uint32_t parse_delimiter(const char *script, statement **stmt, char delm);
277
274
uint32_t parse_option(const char *origin, option_string **stmt, char delm);
278
 
static int drop_schema(DRIZZLE *drizzle, const char *db);
 
275
static int drop_schema(drizzle_con_st *con, const char *db);
279
276
uint32_t get_random_string(char *buf, size_t size);
280
277
static statement *build_table_string(void);
281
278
static statement *build_insert_string(void);
282
279
static statement *build_update_string(void);
283
280
static statement * build_select_string(bool key);
284
 
static int generate_primary_key_list(DRIZZLE *drizzle, option_string *engine_stmt);
 
281
static int generate_primary_key_list(drizzle_con_st *con, option_string *engine_stmt);
285
282
static int drop_primary_key_list(void);
286
 
static int create_schema(DRIZZLE *drizzle, const char *db, statement *stmt,
 
283
static int create_schema(drizzle_con_st *con, const char *db, statement *stmt,
287
284
                         option_string *engine_stmt, stats *sptr);
288
285
static int run_scheduler(stats *sptr, statement **stmts, uint32_t concur,
289
286
                         uint64_t limit);
291
288
extern "C" pthread_handler_t timer_thread(void *p);
292
289
void statement_cleanup(statement *stmt);
293
290
void option_cleanup(option_string *stmt);
294
 
void concurrency_loop(DRIZZLE *drizzle, uint32_t current, option_string *eptr);
295
 
static int run_statements(DRIZZLE *drizzle, statement *stmt);
296
 
void slap_connect(DRIZZLE *drizzle, bool connect_to_schema);
297
 
void slap_close(DRIZZLE *drizzle);
298
 
static int run_query(DRIZZLE *drizzle, const char *query, int len);
 
291
void concurrency_loop(drizzle_con_st *con, uint32_t current, option_string *eptr);
 
292
static int run_statements(drizzle_con_st *con, statement *stmt);
 
293
void slap_connect(drizzle_con_st *con, bool connect_to_schema);
 
294
void slap_close(drizzle_con_st *con);
 
295
static int run_query(drizzle_con_st *con, drizzle_result_st *result, const char *query, int len);
299
296
void standard_deviation (conclusions *con, stats *sptr);
300
297
 
301
298
static const char ALPHANUMERICS[]=
317
314
 
318
315
int main(int argc, char **argv)
319
316
{
320
 
  DRIZZLE drizzle;
 
317
  drizzle_con_st con;
321
318
  option_string *eptr;
322
319
  unsigned int x;
323
320
 
353
350
    exit(1);
354
351
  }
355
352
 
356
 
  slap_connect(&drizzle, false);
 
353
  slap_connect(&con, false);
357
354
 
358
355
  pthread_mutex_init(&counter_mutex, NULL);
359
356
  pthread_cond_init(&count_threshhold, NULL);
377
374
    if (*concurrency)
378
375
    {
379
376
      for (current= concurrency; current && *current; current++)
380
 
        concurrency_loop(&drizzle, *current, eptr);
 
377
        concurrency_loop(&con, *current, eptr);
381
378
    }
382
379
    else
383
380
    {
384
381
      uint32_t infinite= 1;
385
382
      do {
386
 
        concurrency_loop(&drizzle, infinite, eptr);
 
383
        concurrency_loop(&con, infinite, eptr);
387
384
      }
388
385
      while (infinite++);
389
386
    }
390
387
 
391
388
    if (!opt_preserve)
392
 
      drop_schema(&drizzle, create_schema_string);
 
389
      drop_schema(&con, create_schema_string);
393
390
 
394
391
  } while (eptr ? (eptr= eptr->next) : 0);
395
392
 
403
400
  pthread_mutex_destroy(&timer_alarm_mutex);
404
401
  pthread_cond_destroy(&timer_alarm_threshold);
405
402
 
406
 
  slap_close(&drizzle);
 
403
  slap_close(&con);
407
404
 
408
405
  /* now free all the strings we created */
409
406
  if (opt_password)
430
427
  return 0;
431
428
}
432
429
 
433
 
void concurrency_loop(DRIZZLE *drizzle, uint32_t current, option_string *eptr)
 
430
void concurrency_loop(drizzle_con_st *con, uint32_t current, option_string *eptr)
434
431
{
435
432
  unsigned int x;
436
433
  stats *head_sptr;
463
460
      data in the table.
464
461
    */
465
462
    if (opt_preserve == false)
466
 
      drop_schema(drizzle, create_schema_string);
 
463
      drop_schema(con, create_schema_string);
467
464
 
468
465
    /* First we create */
469
466
    if (create_statements)
470
 
      create_schema(drizzle, create_schema_string, create_statements, eptr, sptr);
 
467
      create_schema(con, create_schema_string, create_statements, eptr, sptr);
471
468
 
472
469
    /*
473
470
      If we generated GUID we need to build a list of them from creation that
476
473
    if (verbose >= 2)
477
474
      printf("Generating primary key list\n");
478
475
    if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary)
479
 
      generate_primary_key_list(drizzle, eptr);
 
476
      generate_primary_key_list(con, eptr);
480
477
 
481
478
    if (commit_rate)
482
 
      run_query(drizzle, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0"));
 
479
      run_query(con, NULL, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0"));
483
480
 
484
481
    if (pre_system)
485
482
      assert(system(pre_system)!=-1);
489
486
      correct/adjust any item that they want.
490
487
    */
491
488
    if (pre_statements)
492
 
      run_statements(drizzle, pre_statements);
 
489
      run_statements(con, pre_statements);
493
490
 
494
491
    run_scheduler(sptr, query_statements, current, client_limit);
495
492
 
496
493
    if (post_statements)
497
 
      run_statements(drizzle, post_statements);
 
494
      run_statements(con, post_statements);
498
495
 
499
496
    if (post_system)
500
497
      assert(system(post_system)!=-1);
711
708
static void print_version(void)
712
709
{
713
710
  printf("%s  Ver %s Distrib %s, for %s (%s)\n",my_progname, SLAP_VERSION,
714
 
         drizzleclient_get_client_info(),SYSTEM_TYPE,MACHINE_TYPE);
 
711
         drizzle_version(),SYSTEM_TYPE,MACHINE_TYPE);
715
712
}
716
713
 
717
714
 
1742
1739
    parse_option(default_engine, &engine_options, ',');
1743
1740
 
1744
1741
  if (tty_password)
1745
 
    opt_password= drizzleclient_get_tty_password(NULL);
 
1742
    opt_password= client_get_tty_password(NULL);
1746
1743
  return(0);
1747
1744
}
1748
1745
 
1749
1746
 
1750
 
static int run_query(DRIZZLE *drizzle, const char *query, int len)
 
1747
static int run_query(drizzle_con_st *con, drizzle_result_st *result,
 
1748
                     const char *query, int len)
1751
1749
{
 
1750
  drizzle_return_t ret;
 
1751
  drizzle_result_st result_buffer;
 
1752
 
1752
1753
  if (opt_only_print)
1753
1754
  {
1754
1755
    printf("%.*s;\n", len, query);
1757
1758
 
1758
1759
  if (verbose >= 3)
1759
1760
    printf("%.*s;\n", len, query);
1760
 
  return drizzleclient_real_query(drizzle, query, len);
 
1761
 
 
1762
  if (result == NULL)
 
1763
    result= &result_buffer;
 
1764
 
 
1765
  result= drizzle_query(con, result, query, len, &ret);
 
1766
 
 
1767
  if (ret == DRIZZLE_RETURN_OK)
 
1768
    ret= drizzle_result_buffer(result);
 
1769
 
 
1770
  if (result == &result_buffer)
 
1771
    drizzle_result_free(result);
 
1772
    
 
1773
  return ret;
1761
1774
}
1762
1775
 
1763
1776
 
1764
1777
static int
1765
 
generate_primary_key_list(DRIZZLE *drizzle, option_string *engine_stmt)
 
1778
generate_primary_key_list(drizzle_con_st *con, option_string *engine_stmt)
1766
1779
{
1767
 
  DRIZZLE_RES *result;
1768
 
  DRIZZLE_ROW row;
 
1780
  drizzle_result_st result;
 
1781
  drizzle_row_t row;
1769
1782
  uint64_t counter;
1770
1783
 
1771
1784
 
1796
1809
  }
1797
1810
  else
1798
1811
  {
1799
 
    if (run_query(drizzle, "SELECT id from t1", strlen("SELECT id from t1")))
 
1812
    if (run_query(con, &result, "SELECT id from t1", strlen("SELECT id from t1")))
1800
1813
    {
1801
1814
      fprintf(stderr,"%s: Cannot select GUID primary keys. (%s)\n", my_progname,
1802
 
              drizzleclient_error(drizzle));
 
1815
              drizzle_con_error(con));
1803
1816
      exit(1);
1804
1817
    }
1805
1818
 
1806
 
    result= drizzleclient_store_result(drizzle);
1807
 
    uint64_t num_rows_ret= drizzleclient_num_rows(result);
 
1819
    uint64_t num_rows_ret= drizzle_result_row_count(&result);
1808
1820
    if (num_rows_ret > SIZE_MAX)
1809
1821
    {
1810
1822
      fprintf(stderr, "More primary keys than than architecture supports\n");
1826
1838
        exit(1);
1827
1839
      }
1828
1840
      memset(primary_keys, 0, (size_t)(sizeof(char *) * primary_keys_number_of));
1829
 
      row= drizzleclient_fetch_row(result);
 
1841
      row= drizzle_row_next(&result);
1830
1842
      for (counter= 0; counter < primary_keys_number_of;
1831
 
           counter++, row= drizzleclient_fetch_row(result))
 
1843
           counter++, row= drizzle_row_next(&result))
1832
1844
      {
1833
1845
        primary_keys[counter]= strdup(row[0]);
1834
1846
        if (primary_keys[counter] == NULL)
1839
1851
      }
1840
1852
    }
1841
1853
 
1842
 
    drizzleclient_free_result(result);
 
1854
    drizzle_result_free(&result);
1843
1855
  }
1844
1856
 
1845
1857
  return(0);
1862
1874
}
1863
1875
 
1864
1876
static int
1865
 
create_schema(DRIZZLE *drizzle, const char *db, statement *stmt,
 
1877
create_schema(drizzle_con_st *con, const char *db, statement *stmt,
1866
1878
              option_string *engine_stmt, stats *sptr)
1867
1879
{
1868
1880
  char query[HUGE_STRING_LENGTH];
1880
1892
  if (verbose >= 2)
1881
1893
    printf("Loading Pre-data\n");
1882
1894
 
1883
 
  if (run_query(drizzle, query, len))
 
1895
  if (run_query(con, NULL, query, len))
1884
1896
  {
1885
1897
    fprintf(stderr,"%s: Cannot create schema %s : %s\n", my_progname, db,
1886
 
            drizzleclient_error(drizzle));
 
1898
            drizzle_con_error(con));
1887
1899
    exit(1);
1888
1900
  }
1889
1901
  else
1897
1909
  }
1898
1910
  else
1899
1911
  {
 
1912
    drizzle_result_st result;
 
1913
    drizzle_return_t ret;
 
1914
 
1900
1915
    if (verbose >= 3)
1901
1916
      printf("%s;\n", query);
1902
1917
 
1903
 
    if (drizzleclient_select_db(drizzle,  db))
 
1918
    if (drizzle_select_db(con,  &result, db, &ret) == NULL ||
 
1919
        ret != DRIZZLE_RETURN_OK)
1904
1920
    {
1905
1921
      fprintf(stderr,"%s: Cannot select schema '%s': %s\n",my_progname, db,
1906
 
              drizzleclient_error(drizzle));
 
1922
              ret == DRIZZLE_RETURN_ERROR_CODE ?
 
1923
              drizzle_result_error(&result) : drizzle_con_error(con));
1907
1924
      exit(1);
1908
1925
    }
 
1926
    drizzle_result_free(&result);
1909
1927
    sptr->create_count++;
1910
1928
  }
1911
1929
 
1913
1931
  {
1914
1932
    len= snprintf(query, HUGE_STRING_LENGTH, "set storage_engine=`%s`",
1915
1933
                  engine_stmt->string);
1916
 
    if (run_query(drizzle, query, len))
 
1934
    if (run_query(con, NULL, query, len))
1917
1935
    {
1918
1936
      fprintf(stderr,"%s: Cannot set default engine: %s\n", my_progname,
1919
 
              drizzleclient_error(drizzle));
 
1937
              drizzle_con_error(con));
1920
1938
      exit(1);
1921
1939
    }
1922
1940
    sptr->create_count++;
1937
1955
 
1938
1956
      snprintf(buffer, HUGE_STRING_LENGTH, "%s %s", ptr->string,
1939
1957
               engine_stmt->option);
1940
 
      if (run_query(drizzle, buffer, strlen(buffer)))
 
1958
      if (run_query(con, NULL, buffer, strlen(buffer)))
1941
1959
      {
1942
1960
        fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
1943
 
                my_progname, (uint32_t)ptr->length, ptr->string, drizzleclient_error(drizzle));
 
1961
                my_progname, (uint32_t)ptr->length, ptr->string, drizzle_con_error(con));
1944
1962
        if (!opt_ignore_sql_errors)
1945
1963
          exit(1);
1946
1964
      }
1948
1966
    }
1949
1967
    else
1950
1968
    {
1951
 
      if (run_query(drizzle, ptr->string, ptr->length))
 
1969
      if (run_query(con, NULL, ptr->string, ptr->length))
1952
1970
      {
1953
1971
        fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
1954
 
                my_progname, (uint32_t)ptr->length, ptr->string, drizzleclient_error(drizzle));
 
1972
                my_progname, (uint32_t)ptr->length, ptr->string, drizzle_con_error(con));
1955
1973
        if (!opt_ignore_sql_errors)
1956
1974
          exit(1);
1957
1975
      }
1974
1992
}
1975
1993
 
1976
1994
static int
1977
 
drop_schema(DRIZZLE *drizzle, const char *db)
 
1995
drop_schema(drizzle_con_st *con, const char *db)
1978
1996
{
1979
1997
  char query[HUGE_STRING_LENGTH];
1980
1998
  int len;
1981
1999
 
1982
2000
  len= snprintf(query, HUGE_STRING_LENGTH, "DROP SCHEMA IF EXISTS `%s`", db);
1983
2001
 
1984
 
  if (run_query(drizzle, query, len))
 
2002
  if (run_query(con, NULL, query, len))
1985
2003
  {
1986
2004
    fprintf(stderr,"%s: Cannot drop database '%s' ERROR : %s\n",
1987
 
            my_progname, db, drizzleclient_error(drizzle));
 
2005
            my_progname, db, drizzle_con_error(con));
1988
2006
    exit(1);
1989
2007
  }
1990
2008
 
1994
2012
}
1995
2013
 
1996
2014
static int
1997
 
run_statements(DRIZZLE *drizzle, statement *stmt)
 
2015
run_statements(drizzle_con_st *con, statement *stmt)
1998
2016
{
1999
2017
  statement *ptr;
2000
 
  DRIZZLE_RES *result;
2001
 
 
2002
2018
 
2003
2019
  for (ptr= stmt; ptr && ptr->length; ptr= ptr->next)
2004
2020
  {
2005
 
    if (run_query(drizzle, ptr->string, ptr->length))
 
2021
    if (run_query(con, NULL, ptr->string, ptr->length))
2006
2022
    {
2007
2023
      fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
2008
 
              my_progname, (uint32_t)ptr->length, ptr->string, drizzleclient_error(drizzle));
 
2024
              my_progname, (uint32_t)ptr->length, ptr->string, drizzle_con_error(con));
2009
2025
      exit(1);
2010
2026
    }
2011
 
    if (!opt_only_print)
2012
 
    {
2013
 
      if (drizzleclient_field_count(drizzle))
2014
 
      {
2015
 
        result= drizzleclient_store_result(drizzle);
2016
 
        drizzleclient_free_result(result);
2017
 
      }
2018
 
    }
2019
2027
  }
2020
2028
 
2021
2029
  return(0);
2172
2180
  uint64_t counter= 0, queries;
2173
2181
  uint64_t detach_counter;
2174
2182
  unsigned int commit_counter;
2175
 
  DRIZZLE drizzle;
2176
 
  DRIZZLE_RES *result;
2177
 
  DRIZZLE_ROW row;
 
2183
  drizzle_con_st con;
 
2184
  drizzle_result_st result;
 
2185
  drizzle_row_t row;
2178
2186
  statement *ptr;
2179
 
  thread_context *con= (thread_context *)p;
 
2187
  thread_context *ctx= (thread_context *)p;
2180
2188
 
2181
2189
  pthread_mutex_lock(&sleeper_mutex);
2182
2190
  while (master_wakeup)
2185
2193
  }
2186
2194
  pthread_mutex_unlock(&sleeper_mutex);
2187
2195
 
2188
 
  slap_connect(&drizzle, true);
 
2196
  slap_connect(&con, true);
2189
2197
 
2190
2198
  if (verbose >= 3)
2191
2199
    printf("connected!\n");
2193
2201
 
2194
2202
  commit_counter= 0;
2195
2203
  if (commit_rate)
2196
 
    run_query(&drizzle, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0"));
 
2204
    run_query(&con, NULL, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0"));
2197
2205
 
2198
2206
limit_not_met:
2199
 
  for (ptr= con->stmt, detach_counter= 0;
 
2207
  for (ptr= ctx->stmt, detach_counter= 0;
2200
2208
       ptr && ptr->length;
2201
2209
       ptr= ptr->next, detach_counter++)
2202
2210
  {
2203
2211
    if (!opt_only_print && detach_rate && !(detach_counter % detach_rate))
2204
2212
    {
2205
 
      slap_close(&drizzle);
2206
 
      slap_connect(&drizzle, true);
 
2213
      slap_close(&con);
 
2214
      slap_connect(&con, true);
2207
2215
    }
2208
2216
 
2209
2217
    /*
2235
2243
        length= snprintf(buffer, HUGE_STRING_LENGTH, "%.*s '%s'",
2236
2244
                         (int)ptr->length, ptr->string, key);
2237
2245
 
2238
 
        if (run_query(&drizzle, buffer, length))
 
2246
        if (run_query(&con, &result, buffer, length))
2239
2247
        {
2240
2248
          fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
2241
 
                  my_progname, (uint32_t)length, buffer, drizzleclient_error(&drizzle));
 
2249
                  my_progname, (uint32_t)length, buffer, drizzle_con_error(&con));
2242
2250
          exit(1);
2243
2251
        }
2244
2252
      }
2245
2253
    }
2246
2254
    else
2247
2255
    {
2248
 
      if (run_query(&drizzle, ptr->string, ptr->length))
 
2256
      if (run_query(&con, &result, ptr->string, ptr->length))
2249
2257
      {
2250
2258
        fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
2251
 
                my_progname, (uint32_t)ptr->length, ptr->string, drizzleclient_error(&drizzle));
 
2259
                my_progname, (uint32_t)ptr->length, ptr->string, drizzle_con_error(&con));
2252
2260
        exit(1);
2253
2261
      }
2254
2262
    }
2255
2263
 
2256
2264
    if (!opt_only_print)
2257
2265
    {
2258
 
      do
2259
 
      {
2260
 
        if (drizzleclient_field_count(&drizzle))
2261
 
        {
2262
 
          result= drizzleclient_store_result(&drizzle);
2263
 
          while ((row = drizzleclient_fetch_row(result)))
2264
 
            counter++;
2265
 
          drizzleclient_free_result(result);
2266
 
        }
2267
 
      } while(drizzleclient_next_result(&drizzle) == 0);
 
2266
      while ((row = drizzle_row_next(&result)))
 
2267
        counter++;
 
2268
      drizzle_result_free(&result);
2268
2269
    }
2269
2270
    queries++;
2270
2271
 
2271
2272
    if (commit_rate && (++commit_counter == commit_rate))
2272
2273
    {
2273
2274
      commit_counter= 0;
2274
 
      run_query(&drizzle, "COMMIT", strlen("COMMIT"));
 
2275
      run_query(&con, NULL, "COMMIT", strlen("COMMIT"));
2275
2276
    }
2276
2277
 
2277
2278
    /* If the timer is set, and the alarm is not active then end */
2279
2280
      goto end;
2280
2281
 
2281
2282
    /* If limit has been reached, and we are not in a timer_alarm just end */
2282
 
    if (con->limit && queries == con->limit && timer_alarm == false)
 
2283
    if (ctx->limit && queries == ctx->limit && timer_alarm == false)
2283
2284
      goto end;
2284
2285
  }
2285
2286
 
2286
2287
  if (opt_timer_length && timer_alarm == true)
2287
2288
    goto limit_not_met;
2288
2289
 
2289
 
  if (con->limit && queries < con->limit)
 
2290
  if (ctx->limit && queries < ctx->limit)
2290
2291
    goto limit_not_met;
2291
2292
 
2292
2293
 
2293
2294
end:
2294
2295
  if (commit_rate)
2295
 
    run_query(&drizzle, "COMMIT", strlen("COMMIT"));
 
2296
    run_query(&con, NULL, "COMMIT", strlen("COMMIT"));
2296
2297
 
2297
 
  slap_close(&drizzle);
 
2298
  slap_close(&con);
2298
2299
 
2299
2300
  pthread_mutex_lock(&counter_mutex);
2300
2301
  thread_counter--;
2301
2302
  pthread_cond_signal(&count_threshhold);
2302
2303
  pthread_mutex_unlock(&counter_mutex);
2303
2304
 
2304
 
  free(con);
 
2305
  free(ctx);
2305
2306
 
2306
2307
  return(0);
2307
2308
}
2663
2664
}
2664
2665
 
2665
2666
void
2666
 
slap_close(DRIZZLE *drizzle)
 
2667
slap_close(drizzle_con_st *con)
2667
2668
{
2668
2669
  if (opt_only_print)
2669
2670
    return;
2670
2671
 
2671
 
  drizzleclient_close(drizzle);
 
2672
  drizzle_free(drizzle_con_drizzle(con));
2672
2673
}
2673
2674
 
2674
2675
void
2675
 
slap_connect(DRIZZLE *drizzle, bool connect_to_schema)
 
2676
slap_connect(drizzle_con_st *con, bool connect_to_schema)
2676
2677
{
2677
2678
  /* Connect to server */
2678
2679
  static uint32_t connection_retry_sleep= 100000; /* Microseconds */
2679
2680
  int x, connect_error= 1;
 
2681
  drizzle_return_t ret;
 
2682
  drizzle_st *drizzle;
2680
2683
 
2681
2684
  if (opt_only_print)
2682
2685
    return;
2684
2687
  if (opt_delayed_start)
2685
2688
    usleep(random()%opt_delayed_start);
2686
2689
 
2687
 
  drizzleclient_create(drizzle);
2688
 
 
2689
 
  if (opt_compress)
2690
 
    drizzleclient_options(drizzle,DRIZZLE_OPT_COMPRESS,NULL);
 
2690
  if ((drizzle= drizzle_create(NULL)) == NULL ||
 
2691
      drizzle_con_add_tcp(drizzle, con, host, opt_drizzle_port, user,
 
2692
                          opt_password,
 
2693
                          connect_to_schema ? create_schema_string : NULL,
 
2694
                          DRIZZLE_CON_NONE) == NULL)
 
2695
  {
 
2696
    fprintf(stderr,"%s: Error creating drizzle object\n", my_progname);
 
2697
    exit(1);
 
2698
  }
2691
2699
 
2692
2700
  for (x= 0; x < 10; x++)
2693
2701
  {
2694
 
 
2695
 
 
2696
 
    if (drizzleclient_connect(drizzle, host, user, opt_password,
2697
 
                        connect_to_schema ? create_schema_string : NULL,
2698
 
                        opt_drizzle_port,
2699
 
                        opt_drizzle_unix_port,
2700
 
                        connect_flags))
 
2702
    if ((ret= drizzle_con_connect(con)) == DRIZZLE_RETURN_OK)
2701
2703
    {
2702
2704
      /* Connect suceeded */
2703
2705
      connect_error= 0;
2707
2709
  }
2708
2710
  if (connect_error)
2709
2711
  {
2710
 
    fprintf(stderr,"%s: Error when connecting to server: %d %s\n",
2711
 
            my_progname, drizzleclient_errno(drizzle), drizzleclient_error(drizzle));
 
2712
    fprintf(stderr,"%s: Error when connecting to server: %d %s\n", my_progname,
 
2713
            ret, drizzle_con_error(con));
2712
2714
    exit(1);
2713
2715
  }
2714
2716