~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/mysqlslap.c

  • Committer: Patrick
  • Date: 2008-07-11 18:54:31 UTC
  • mto: This revision was merged to the branch mainline in revision 144.
  • Revision ID: patg@localhost.localdomain-20080711185431-lfklbyfanqi3z7sc
All DBUG_x removed from client/

Show diffs side-by-side

added added

removed removed

Lines of Context:
592
592
        "Generate CSV output to named file or to stdout if no file is named.",
593
593
    (char**) &opt_csv_str, (char**) &opt_csv_str, 0, GET_STR, 
594
594
    OPT_ARG, 0, 0, 0, 0, 0, 0},
595
 
#ifdef DBUG_OFF
596
 
  {"debug", '#', "This is a non-debug version. Catch this and exit.",
597
 
   0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
598
 
#else
599
 
  {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.",
600
 
    (char**) &default_dbug_option, (char**) &default_dbug_option, 0, GET_STR,
601
 
    OPT_ARG, 0, 0, 0, 0, 0, 0},
602
 
#endif
603
595
  {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.",
604
596
   (char**) &debug_check_flag, (char**) &debug_check_flag, 0,
605
597
   GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
743
735
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
744
736
               char *argument)
745
737
{
746
 
  DBUG_ENTER("get_one_option");
 
738
 
747
739
  switch(optid) {
748
740
  case 'v':
749
741
    verbose++;
762
754
    else
763
755
      tty_password= 1;
764
756
    break;
765
 
  case '#':
766
 
    DBUG_PUSH(argument ? argument : default_dbug_option);
767
 
    debug_check_flag= 1;
768
 
    break;
769
757
  case 'V':
770
758
    print_version();
771
759
    exit(0);
775
763
    usage();
776
764
    exit(0);
777
765
  }
778
 
  DBUG_RETURN(0);
 
766
  return(0);
779
767
}
780
768
 
781
769
 
784
772
{
785
773
  char *buf_ptr= buf;
786
774
  size_t x;
787
 
  DBUG_ENTER("get_random_string");
 
775
 
788
776
  for (x= size; x > 0; x--)
789
777
    *buf_ptr++= ALPHANUMERICS[random() % ALPHANUMERICS_SIZE];
790
 
  DBUG_RETURN(buf_ptr - buf);
 
778
  return(buf_ptr - buf);
791
779
}
792
780
 
793
781
 
804
792
  unsigned int        col_count;
805
793
  statement *ptr;
806
794
  DYNAMIC_STRING table_string;
807
 
  DBUG_ENTER("build_table_string");
808
 
 
809
 
  DBUG_PRINT("info", ("num int cols %u num char cols %u",
810
 
                      num_int_cols, num_char_cols));
811
795
 
812
796
  init_dynamic_string(&table_string, "", HUGE_STRING_LENGTH, HUGE_STRING_LENGTH);
813
797
 
930
914
  ptr->type= CREATE_TABLE_TYPE;
931
915
  strmov(ptr->string, table_string.str);
932
916
  dynstr_free(&table_string);
933
 
  DBUG_RETURN(ptr);
 
917
  return(ptr);
934
918
}
935
919
 
936
920
/*
946
930
  unsigned int        col_count;
947
931
  statement *ptr;
948
932
  DYNAMIC_STRING update_string;
949
 
  DBUG_ENTER("build_update_string");
 
933
 
950
934
 
951
935
  init_dynamic_string(&update_string, "", HUGE_STRING_LENGTH, HUGE_STRING_LENGTH);
952
936
 
1002
986
    ptr->type= UPDATE_TYPE;
1003
987
  strmov(ptr->string, update_string.str);
1004
988
  dynstr_free(&update_string);
1005
 
  DBUG_RETURN(ptr);
 
989
  return(ptr);
1006
990
}
1007
991
 
1008
992
 
1019
1003
  unsigned int        col_count;
1020
1004
  statement *ptr;
1021
1005
  DYNAMIC_STRING insert_string;
1022
 
  DBUG_ENTER("build_insert_string");
 
1006
 
1023
1007
 
1024
1008
  init_dynamic_string(&insert_string, "", HUGE_STRING_LENGTH, HUGE_STRING_LENGTH);
1025
1009
 
1142
1126
  strmov(ptr->string, insert_string.str);
1143
1127
  dynstr_free(&insert_string);
1144
1128
 
1145
 
  DBUG_RETURN(ptr);
 
1129
  return(ptr);
1146
1130
}
1147
1131
 
1148
1132
 
1159
1143
  unsigned int        col_count;
1160
1144
  statement *ptr;
1161
1145
  static DYNAMIC_STRING query_string;
1162
 
  DBUG_ENTER("build_select_string");
 
1146
 
1163
1147
 
1164
1148
  init_dynamic_string(&query_string, "", HUGE_STRING_LENGTH, HUGE_STRING_LENGTH);
1165
1149
 
1230
1214
    ptr->type= SELECT_TYPE;
1231
1215
  strmov(ptr->string, query_string.str);
1232
1216
  dynstr_free(&query_string);
1233
 
  DBUG_RETURN(ptr);
 
1217
  return(ptr);
1234
1218
}
1235
1219
 
1236
1220
static int
1242
1226
  option_string *sql_type;
1243
1227
  unsigned int sql_type_count= 0;
1244
1228
 
1245
 
  DBUG_ENTER("get_options");
 
1229
 
1246
1230
  if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option)))
1247
1231
    exit(ho_error);
1248
1232
  if (debug_info_flag)
1631
1615
 
1632
1616
  if (tty_password)
1633
1617
    opt_password= get_tty_password(NullS);
1634
 
  DBUG_RETURN(0);
 
1618
  return(0);
1635
1619
}
1636
1620
 
1637
1621
 
1655
1639
  MYSQL_RES *result;
1656
1640
  MYSQL_ROW row;
1657
1641
  unsigned long long counter;
1658
 
  DBUG_ENTER("generate_primary_key_list");
 
1642
 
1659
1643
 
1660
1644
  /* 
1661
1645
    Blackhole is a special case, this allows us to test the upper end 
1701
1685
    mysql_free_result(result);
1702
1686
  }
1703
1687
 
1704
 
  DBUG_RETURN(0);
 
1688
  return(0);
1705
1689
}
1706
1690
 
1707
1691
static int
1730
1714
  int len;
1731
1715
  ulonglong count;
1732
1716
  struct timeval start_time, end_time;
1733
 
  DBUG_ENTER("create_schema");
 
1717
 
1734
1718
 
1735
1719
  gettimeofday(&start_time, NULL);
1736
1720
 
1829
1813
 
1830
1814
  sptr->create_timing= timedif(end_time, start_time);
1831
1815
 
1832
 
  DBUG_RETURN(0);
 
1816
  return(0);
1833
1817
}
1834
1818
 
1835
1819
static int
1837
1821
{
1838
1822
  char query[HUGE_STRING_LENGTH];
1839
1823
  int len;
1840
 
  DBUG_ENTER("drop_schema");
 
1824
 
1841
1825
  len= snprintf(query, HUGE_STRING_LENGTH, "DROP SCHEMA IF EXISTS `%s`", db);
1842
1826
 
1843
1827
  if (run_query(mysql, query, len))
1849
1833
 
1850
1834
 
1851
1835
 
1852
 
  DBUG_RETURN(0);
 
1836
  return(0);
1853
1837
}
1854
1838
 
1855
1839
static int
1857
1841
{
1858
1842
  statement *ptr;
1859
1843
  MYSQL_RES *result;
1860
 
  DBUG_ENTER("run_statements");
 
1844
 
1861
1845
 
1862
1846
  for (ptr= stmt; ptr && ptr->length; ptr= ptr->next)
1863
1847
  {
1877
1861
    }
1878
1862
  }
1879
1863
 
1880
 
  DBUG_RETURN(0);
 
1864
  return(0);
1881
1865
}
1882
1866
 
1883
1867
static int
1891
1875
  thread_context *con;
1892
1876
  pthread_t mainthread;            /* Thread descriptor */
1893
1877
  pthread_attr_t attr;          /* Thread attributes */
1894
 
  DBUG_ENTER("run_scheduler");
 
1878
 
1895
1879
 
1896
1880
  pthread_attr_init(&attr);
1897
1881
  pthread_attr_setdetachstate(&attr,
1987
1971
  sptr->real_users= real_concurrency;
1988
1972
  sptr->rows= limit;
1989
1973
 
1990
 
  DBUG_RETURN(0);
 
1974
  return(0);
1991
1975
}
1992
1976
 
1993
1977
 
1996
1980
  uint *timer_length= (uint *)p;
1997
1981
  struct timespec abstime;
1998
1982
 
1999
 
  DBUG_ENTER("timer_thread");
 
1983
 
2000
1984
 
2001
1985
  if (mysql_thread_init())
2002
1986
  {
2027
2011
  pthread_mutex_unlock(&timer_alarm_mutex);
2028
2012
 
2029
2013
  mysql_thread_end();
2030
 
  DBUG_RETURN(0);
 
2014
  return(0);
2031
2015
}
2032
2016
 
2033
2017
pthread_handler_t run_task(void *p)
2041
2025
  statement *ptr;
2042
2026
  thread_context *con= (thread_context *)p;
2043
2027
 
2044
 
  DBUG_ENTER("run_task");
2045
 
 
2046
2028
  if (mysql_thread_init())
2047
2029
  {
2048
2030
    fprintf(stderr,"%s: mysql_thread_init() failed.\n",
2050
2032
    exit(1);
2051
2033
  }
2052
2034
 
2053
 
  DBUG_PRINT("info", ("task script \"%s\"", con->stmt ? con->stmt->string : ""));
2054
 
 
2055
2035
  pthread_mutex_lock(&sleeper_mutex);
2056
2036
  while (master_wakeup)
2057
2037
  {
2059
2039
  }
2060
2040
  pthread_mutex_unlock(&sleeper_mutex);
2061
2041
 
2062
 
  DBUG_PRINT("info", ("trying to connect to host %s as user %s", host, user));
2063
 
 
2064
2042
  slap_connect(&mysql, TRUE);
2065
2043
 
2066
 
  DBUG_PRINT("info", ("connected."));
2067
2044
  if (verbose >= 3)
2068
2045
    printf("connected!\n");
2069
2046
  queries= 0;
2101
2078
          Just in case someone runs this under an experimental engine we don't
2102
2079
          want a crash so the if() is placed here.
2103
2080
        */
2104
 
        DBUG_ASSERT(primary_keys_number_of);
 
2081
        assert(primary_keys_number_of);
2105
2082
        if (primary_keys_number_of)
2106
2083
        {
2107
2084
          key_val= (unsigned int)(random() % primary_keys_number_of);
2108
2085
          key= primary_keys[key_val];
2109
2086
 
2110
 
          DBUG_ASSERT(key);
 
2087
          assert(key);
2111
2088
 
2112
2089
          length= snprintf(buffer, HUGE_STRING_LENGTH, "%.*s '%s'", 
2113
2090
                           (int)ptr->length, ptr->string, key);
2181
2158
  my_free(con, MYF(0));
2182
2159
 
2183
2160
  mysql_thread_end();
2184
 
  DBUG_RETURN(0);
 
2161
  return(0);
2185
2162
}
2186
2163
 
2187
2164
/*