client_test.c File Reference

#include <my_global.h>
#include <my_sys.h>
#include <mysql.h>
#include <my_getopt.h>
#include <m_string.h>

Include dependency graph for client_test.c:

Include dependency graph

Classes

struct  my_tests_st
struct  st_stmt_fetch

Defines

#define VER   "2.1"
#define MAX_TEST_QUERY_LENGTH   300
#define MAX_KEY   64
#define myheader(str)
#define myheader_r(str)
#define DIE_UNLESS(expr)   ((void) ((expr) ? 0 : (die(__FILE__, __LINE__, #expr), 0)))
#define myerror(msg)   print_error(msg)
#define mysterror(stmt, msg)   print_st_error(stmt, msg)
#define myquery(RES)
#define myquery_r(r)
#define check_execute(stmt, r)
#define check_execute_r(stmt, r)
#define check_stmt(stmt)
#define check_stmt_r(stmt)
#define mytest(x)   if (!x) {myerror(NULL);DIE_UNLESS(FALSE);}
#define mytest_r(x)   if (x) {myerror(NULL);DIE_UNLESS(FALSE);}
#define MAX_RES_FIELDS   50
#define MAX_FIELD_DATA_SIZE   255
#define NUM_OF_USED_STMT   97

Typedefs

typedef st_stmt_fetch Stmt_fetch

Enumerations

enum  { MAX_COLUMN_LENGTH = 255 }

Functions

void print_error (const char *msg)
void print_st_error (MYSQL_STMT *stmt, const char *msg)
void client_disconnect ()
void die (const char *file, int line, const char *expr)
MYSQL_STMT *STDCALL mysql_simple_prepare (MYSQL *mysql, const char *query)
void client_connect ()
void client_query ()
void my_print_dashes (MYSQL_RES *result)
void my_print_result_metadata (MYSQL_RES *result)
int my_process_result_set (MYSQL_RES *result)
int my_process_result (MYSQL *mysql)
int my_process_stmt_result (MYSQL_STMT *stmt)
int my_stmt_result (const char *buff)
void verify_col_data (const char *table, const char *col, const char *exp_data)
void verify_prepare_field (MYSQL_RES *result, unsigned int no, const char *name, const char *org_name, enum enum_field_types type, const char *table, const char *org_table, const char *db, unsigned long length, const char *def)
void verify_param_count (MYSQL_STMT *stmt, long exp_count)
void verify_st_affected_rows (MYSQL_STMT *stmt, ulonglong exp_count)
void verify_affected_rows (ulonglong exp_count)
void verify_field_count (MYSQL_RES *result, uint exp_count)
void execute_prepare_query (const char *query, ulonglong exp_count)
void client_store_result ()
void client_use_result ()
void fill_tables (const char **query_list, unsigned query_count)
void stmt_fetch_init (Stmt_fetch *fetch, unsigned stmt_no_arg, const char *query_arg)
int stmt_fetch_fetch_row (Stmt_fetch *fetch)
void stmt_fetch_close (Stmt_fetch *fetch)
my_bool fetch_n (const char **query_list, unsigned query_count)
my_bool thread_query (char *query)
void test_debug_example ()
void test_tran_bdb ()
void test_tran_innodb ()
void test_prepare_simple ()
void test_prepare_field_result ()
void test_prepare_syntax ()
void test_prepare ()
void test_double_compare ()
void test_null ()
void test_ps_null_param ()
void test_fetch_null ()
void test_select_version ()
void test_select_show_table ()
void test_select_direct ()
void test_select_prepare ()
void test_select ()
void test_ps_conj_select ()
void test_bug1115 ()
void test_bug1180 ()
void test_bug1644 ()
void test_select_show ()
void test_simple_update ()
void test_long_data ()
void test_long_data_str ()
void test_long_data_str1 ()
void test_long_data_bin ()
void test_simple_delete ()
void test_update ()
void test_prepare_noparam ()
void test_bind_result ()
void test_bind_result_ext ()
void test_bind_result_ext1 ()
void bind_fetch (int row_count)
void test_fetch_date ()
void test_fetch_str ()
void test_fetch_long ()
void test_fetch_short ()
void test_fetch_tiny ()
void test_fetch_bigint ()
void test_fetch_float ()
void test_fetch_double ()
void test_prepare_ext ()
void test_field_names ()
void test_warnings ()
void test_errors ()
void test_insert ()
void test_prepare_resultset ()
void test_field_flags ()
void test_stmt_close ()
void test_set_variable ()
void test_func_fields ()
void test_multi_stmt ()
void test_manual_sample ()
void test_prepare_alter ()
void test_multi_statements ()
void test_prepare_multi_statements ()
void test_store_result ()
void test_store_result1 ()
void test_store_result2 ()
void test_subselect ()
void test_bind_date_conv (uint row_count)
void test_date ()
void test_date_date ()
void test_date_time ()
void test_date_ts ()
void test_date_dt ()
void test_pure_coverage ()
void test_buffers ()
void test_open_direct ()
void test_fetch_nobuffs ()
void test_ushort_bug ()
void test_sshort_bug ()
void test_stiny_bug ()
void test_field_misc ()
void test_set_option ()
void test_prepare_grant ()
void test_frm_bug ()
void test_decimal_bug ()
void test_explain_bug ()
void test_cuted_rows ()
void test_logs ()
void test_nstmts ()
void test_fetch_seek ()
void test_fetch_offset ()
void test_fetch_column ()
void test_list_fields ()
void test_mem_overun ()
void test_free_result ()
void test_free_store_result ()
void test_sqlmode ()
void test_ts ()
void test_bug1500 ()
void test_bug1946 ()
void test_parse_error_and_bad_length ()
void test_bug2247 ()
void test_subqueries ()
void test_bad_union ()
void test_distinct ()
void test_bug2248 ()
void test_subqueries_ref ()
void test_union ()
void test_bug3117 ()
void test_join ()
void test_selecttmp ()
void test_create_drop ()
void test_rename ()
void test_do_set ()
void test_multi ()
void test_insert_select ()
void test_bind_nagative ()
void test_derived ()
void test_xjoin ()
void test_bug3035 ()
void test_union2 ()
void test_bug1664 ()
void test_order_param ()
void test_union_param ()
void test_ps_i18n ()
void test_bug3796 ()
void test_bug4026 ()
void test_bug4079 ()
void test_bug4236 ()
void test_bug4030 ()
void test_view ()
void test_view_where ()
void test_view_2where ()
void test_view_star ()
void test_view_insert ()
void test_left_join_view ()
void test_view_insert_fields ()
void test_bug5126 ()
void test_bug4231 ()
void test_bug5399 ()
void test_bug5194 ()
void test_bug5315 ()
void test_bug6049 ()
void test_bug6058 ()
void test_bug6059 ()
void test_bug6046 ()
void test_basic_cursors ()
void test_cursors_with_union ()
void test_bug6081 ()
void test_bug6096 ()
void test_datetime_ranges ()
void test_bug4172 ()
void test_conversion ()
void usage (void)
my_bool get_one_option (int optid, const struct my_option *opt __attribute__((unused)), char *argument)
void get_options (int *argc, char ***argv)
void print_test_output ()
int main (int argc, char **argv)

Variables

int opt_testcase = 0
char * opt_db = 0
char * opt_user = 0
char * opt_password = 0
char * opt_host = 0
char * opt_unix_socket = 0
unsigned int opt_port
my_bool tty_password = 0 opt_silent= 0
MYSQLmysql = 0
char query [300]
char current_db [] = "client_test_db"
unsigned int test_count = 0
unsigned int opt_count = 0
unsigned int iter_count = 0
time_t start_time
time_t end_time
double total_time
const char * default_dbug_option = "d:t:o,/tmp/client_test.trace"
const char * client_test_load_default_groups [] = { "client", 0 }
char ** defaults_argv
my_option client_test_long_options []
my_tests_st my_tests []

Define Documentation

#define check_execute stmt,
 ) 
 

Value:

{ \
if (r) \
  mysterror(stmt, NULL); \
DIE_UNLESS(r == 0);\
}

#define check_execute_r stmt,
 ) 
 

Value:

{ \
if (r) \
  mysterror(stmt, NULL); \
DIE_UNLESS(r != 0);\
}

#define check_stmt stmt   ) 
 

Value:

{ \
if ( stmt == 0) \
  myerror(NULL); \
DIE_UNLESS(stmt != 0); \
}

#define check_stmt_r stmt   ) 
 

Value:

{ \
if (stmt == 0) \
  myerror(NULL);\
DIE_UNLESS(stmt == 0);\
}

#define DIE_UNLESS expr   )     ((void) ((expr) ? 0 : (die(__FILE__, __LINE__, #expr), 0)))
 

#define MAX_FIELD_DATA_SIZE   255
 

#define MAX_KEY   64
 

#define MAX_RES_FIELDS   50
 

#define MAX_TEST_QUERY_LENGTH   300
 

#define myerror msg   )     print_error(msg)
 

#define myheader str   ) 
 

Value:

if (opt_silent < 2) \
{ \
  fprintf(stdout, "\n\n#####################################\n"); \
  fprintf(stdout, "%d of (%d/%d): %s", test_count++, iter_count, \
                                     opt_count, str); \
  fprintf(stdout, "  \n#####################################\n"); \
}

#define myheader_r str   ) 
 

Value:

if (!opt_silent) \
{ \
  fprintf(stdout, "\n\n#####################################\n"); \
  fprintf(stdout, "%s", str); \
  fprintf(stdout, "  \n#####################################\n"); \
}

#define myquery RES   ) 
 

Value:

{ \
  int r= (RES);                                \
  if (r) \
    myerror(NULL); \
  DIE_UNLESS(r == 0); \
}

#define myquery_r  ) 
 

Value:

{ \
if (r) \
  myerror(NULL); \
DIE_UNLESS(r != 0); \
}

#define mysterror stmt,
msg   )     print_st_error(stmt, msg)
 

#define mytest x   )     if (!x) {myerror(NULL);DIE_UNLESS(FALSE);}
 

#define mytest_r x   )     if (x) {myerror(NULL);DIE_UNLESS(FALSE);}
 

#define NUM_OF_USED_STMT   97
 

#define VER   "2.1"
 


Typedef Documentation

typedef struct st_stmt_fetch Stmt_fetch
 


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
MAX_COLUMN_LENGTH 
00842 { MAX_COLUMN_LENGTH= 255 };


Function Documentation

void bind_fetch int  row_count  )  [static]
 

03601 {
03602   MYSQL_STMT   *stmt;
03603   int          rc, i, count= row_count;
03604   int32        data[10];
03605   int8         i8_data;
03606   int16        i16_data;
03607   int32        i32_data;
03608   longlong     i64_data;
03609   float        f_data;
03610   double       d_data;
03611   char         s_data[10];
03612   ulong        length[10];
03613   MYSQL_BIND   bind[7];
03614   my_bool      is_null[7];
03615 
03616   stmt= mysql_simple_prepare(mysql, "INSERT INTO test_bind_fetch VALUES "
03617                                     "(?, ?, ?, ?, ?, ?, ?)");
03618   check_stmt(stmt);
03619 
03620   verify_param_count(stmt, 7);
03621 
03622   /* Always bzero all members of bind parameter */
03623   bzero((char*) bind, sizeof(bind));
03624 
03625   for (i= 0; i < (int) array_elements(bind); i++)
03626   {
03627     bind[i].buffer_type= MYSQL_TYPE_LONG;
03628     bind[i].buffer= (void *) &data[i];
03629   }
03630   rc= mysql_stmt_bind_param(stmt, bind);
03631   check_execute(stmt, rc);
03632 
03633   while (count--)
03634   {
03635     rc= 10+count;
03636     for (i= 0; i < (int) array_elements(bind); i++)
03637     {
03638       data[i]= rc+i;
03639       rc+= 12;
03640     }
03641     rc= mysql_stmt_execute(stmt);
03642     check_execute(stmt, rc);
03643   }
03644 
03645   rc= mysql_commit(mysql);
03646   myquery(rc);
03647 
03648   mysql_stmt_close(stmt);
03649 
03650   rc= my_stmt_result("SELECT * FROM test_bind_fetch");
03651   DIE_UNLESS(row_count == rc);
03652 
03653   stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_bind_fetch");
03654   check_stmt(stmt);
03655 
03656   for (i= 0; i < (int) array_elements(bind); i++)
03657   {
03658     bind[i].buffer= (void *) &data[i];
03659     bind[i].length= &length[i];
03660     bind[i].is_null= &is_null[i];
03661   }
03662 
03663   bind[0].buffer_type= MYSQL_TYPE_TINY;
03664   bind[0].buffer= (void *)&i8_data;
03665 
03666   bind[1].buffer_type= MYSQL_TYPE_SHORT;
03667   bind[1].buffer= (void *)&i16_data;
03668 
03669   bind[2].buffer_type= MYSQL_TYPE_LONG;
03670   bind[2].buffer= (void *)&i32_data;
03671 
03672   bind[3].buffer_type= MYSQL_TYPE_LONGLONG;
03673   bind[3].buffer= (void *)&i64_data;
03674 
03675   bind[4].buffer_type= MYSQL_TYPE_FLOAT;
03676   bind[4].buffer= (void *)&f_data;
03677 
03678   bind[5].buffer_type= MYSQL_TYPE_DOUBLE;
03679   bind[5].buffer= (void *)&d_data;
03680 
03681   bind[6].buffer_type= MYSQL_TYPE_STRING;
03682   bind[6].buffer= (void *)&s_data;
03683   bind[6].buffer_length= sizeof(s_data);
03684 
03685   rc= mysql_stmt_bind_result(stmt, bind);
03686   check_execute(stmt, rc);
03687 
03688   rc= mysql_stmt_execute(stmt);
03689   check_execute(stmt, rc);
03690 
03691   rc= mysql_stmt_store_result(stmt);
03692   check_execute(stmt, rc);
03693 
03694   while (row_count--)
03695   {
03696     rc= mysql_stmt_fetch(stmt);
03697     check_execute(stmt, rc);
03698 
03699     if (!opt_silent)
03700     {
03701       fprintf(stdout, "\n");
03702       fprintf(stdout, "\n tiny     : %ld(%lu)", (ulong) i8_data, length[0]);
03703       fprintf(stdout, "\n short    : %ld(%lu)", (ulong) i16_data, length[1]);
03704       fprintf(stdout, "\n int      : %ld(%lu)", (ulong) i32_data, length[2]);
03705       fprintf(stdout, "\n longlong : %ld(%lu)", (ulong) i64_data, length[3]);
03706       fprintf(stdout, "\n float    : %f(%lu)",  f_data,  length[4]);
03707       fprintf(stdout, "\n double   : %g(%lu)",  d_data,  length[5]);
03708       fprintf(stdout, "\n char     : %s(%lu)",  s_data,  length[6]);
03709     }
03710     rc= 10+row_count;
03711 
03712     /* TINY */
03713     DIE_UNLESS((int) i8_data == rc);
03714     DIE_UNLESS(length[0] == 1);
03715     rc+= 13;
03716 
03717     /* SHORT */
03718     DIE_UNLESS((int) i16_data == rc);
03719     DIE_UNLESS(length[1] == 2);
03720     rc+= 13;
03721 
03722     /* LONG */
03723     DIE_UNLESS((int) i32_data == rc);
03724     DIE_UNLESS(length[2] == 4);
03725     rc+= 13;
03726 
03727     /* LONGLONG */
03728     DIE_UNLESS((int) i64_data == rc);
03729     DIE_UNLESS(length[3] == 8);
03730     rc+= 13;
03731 
03732     /* FLOAT */
03733     DIE_UNLESS((int)f_data == rc);
03734     DIE_UNLESS(length[4] == 4);
03735     rc+= 13;
03736 
03737     /* DOUBLE */
03738     DIE_UNLESS((int)d_data == rc);
03739     DIE_UNLESS(length[5] == 8);
03740     rc+= 13;
03741 
03742     /* CHAR */
03743     {
03744       char buff[20];
03745       long len= my_sprintf(buff, (buff, "%d", rc));
03746       DIE_UNLESS(strcmp(s_data, buff) == 0);
03747       DIE_UNLESS(length[6] == (ulong) len);
03748     }
03749   }
03750   rc= mysql_stmt_fetch(stmt);
03751   DIE_UNLESS(rc == MYSQL_NO_DATA);
03752 
03753   mysql_stmt_close(stmt);
03754 }

void client_connect  )  [static]
 

00221 {
00222   int  rc;
00223   myheader_r("client_connect");
00224 
00225   if (!opt_silent)
00226     fprintf(stdout, "\n Establishing a connection to '%s' ...",
00227             opt_host ? opt_host : "");
00228 
00229   if (!(mysql= mysql_init(NULL)))
00230   {
00231     opt_silent= 0;
00232     myerror("mysql_init() failed");
00233     exit(1);
00234   }
00235 
00236   if (!(mysql_real_connect(mysql, opt_host, opt_user,
00237                            opt_password, opt_db ? opt_db:"test", opt_port,
00238                            opt_unix_socket, 0)))
00239   {
00240     opt_silent= 0;
00241     myerror("connection failed");
00242     mysql_close(mysql);
00243     fprintf(stdout, "\n Check the connection options using --help or -?\n");
00244     exit(1);
00245   }
00246 
00247   if (!opt_silent)
00248     fprintf(stdout, " OK");
00249 
00250   /* set AUTOCOMMIT to ON*/
00251   mysql_autocommit(mysql, TRUE);
00252 
00253   if (!opt_silent)
00254     fprintf(stdout, "\n Creating a test database '%s' ...", current_db);
00255   strxmov(query, "CREATE DATABASE IF NOT EXISTS ", current_db, NullS);
00256 
00257   rc= mysql_query(mysql, query);
00258   myquery(rc);
00259 
00260   strxmov(query, "USE ", current_db, NullS);
00261   rc= mysql_query(mysql, query);
00262   myquery(rc);
00263 
00264   if (!opt_silent)
00265     fprintf(stdout, " OK");
00266 }

void client_disconnect  )  [static]
 

00272 {
00273   myheader_r("client_disconnect");
00274 
00275   if (mysql)
00276   {
00277     if (!opt_silent)
00278       fprintf(stdout, "\n dropping the test database '%s' ...", current_db);
00279     strxmov(query, "DROP DATABASE IF EXISTS ", current_db, NullS);
00280 
00281     mysql_query(mysql, query);
00282     if (!opt_silent)
00283       fprintf(stdout, " OK");
00284 
00285     if (!opt_silent)
00286       fprintf(stdout, "\n closing the connection ...");
00287     mysql_close(mysql);
00288     fprintf(stdout, " OK\n");
00289   }
00290 }

void client_query  )  [static]
 

00296 {
00297   int rc;
00298 
00299   myheader("client_query");
00300 
00301   rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
00302   myquery(rc);
00303 
00304   rc= mysql_query(mysql, "CREATE TABLE t1("
00305                          "id int primary key auto_increment, "
00306                          "name varchar(20))");
00307   myquery(rc);
00308 
00309   rc= mysql_query(mysql, "CREATE TABLE t1(id int, name varchar(20))");
00310   myquery_r(rc);
00311 
00312   rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('mysql')");
00313   myquery(rc);
00314 
00315   rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('monty')");
00316   myquery(rc);
00317 
00318   rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('venu')");
00319   myquery(rc);
00320 
00321   rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('deleted')");
00322   myquery(rc);
00323 
00324   rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('deleted')");
00325   myquery(rc);
00326 
00327   rc= mysql_query(mysql, "UPDATE t1 SET name= 'updated' "
00328                           "WHERE name= 'deleted'");
00329   myquery(rc);
00330 
00331   rc= mysql_query(mysql, "UPDATE t1 SET id= 3 WHERE name= 'updated'");
00332   myquery_r(rc);
00333 
00334   myquery(mysql_query(mysql, "drop table t1"));
00335 }

void client_store_result  )  [static]
 

00779 {
00780   MYSQL_RES *result;
00781   int       rc;
00782 
00783   myheader("client_store_result");
00784 
00785   rc= mysql_query(mysql, "SELECT * FROM t1");
00786   myquery(rc);
00787 
00788   /* get the result */
00789   result= mysql_store_result(mysql);
00790   mytest(result);
00791 
00792   (void) my_process_result_set(result);
00793   mysql_free_result(result);
00794 }

void client_use_result  )  [static]
 

00800 {
00801   MYSQL_RES *result;
00802   int       rc;
00803   myheader("client_use_result");
00804 
00805   rc= mysql_query(mysql, "SELECT * FROM t1");
00806   myquery(rc);
00807 
00808   /* get the result */
00809   result= mysql_use_result(mysql);
00810   mytest(result);
00811 
00812   (void) my_process_result_set(result);
00813   mysql_free_result(result);
00814 }

void die const char *  file,
int  line,
const char *  expr
 

00104 {
00105   fprintf(stderr, "%s:%d: check failed: '%s'\n", file, line, expr);
00106   abort();
00107 }

void execute_prepare_query const char *  query,
ulonglong  exp_count
[static]
 

00755 {
00756   MYSQL_STMT *stmt;
00757   ulonglong  affected_rows;
00758   int        rc;
00759 
00760   stmt= mysql_simple_prepare(mysql, query);
00761   check_stmt(stmt);
00762 
00763   rc= mysql_stmt_execute(stmt);
00764   myquery(rc);
00765 
00766   affected_rows= mysql_stmt_affected_rows(stmt);
00767   if (!opt_silent)
00768     fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)",
00769             affected_rows, exp_count);
00770 
00771   DIE_UNLESS(affected_rows == exp_count);
00772   mysql_stmt_close(stmt);
00773 }

my_bool fetch_n const char **  query_list,
unsigned  query_count
 

00974 {
00975   unsigned open_statements= query_count;
00976   int rc, error_count= 0;
00977   Stmt_fetch *fetch_array= (Stmt_fetch*) calloc(1, sizeof(Stmt_fetch) *
00978                                                   query_count);
00979   Stmt_fetch *fetch;
00980   DBUG_ENTER("fetch_n");
00981 
00982   for (fetch= fetch_array; fetch < fetch_array + query_count; ++fetch)
00983   {
00984     /* Init will exit(1) in case of error */
00985     stmt_fetch_init(fetch, fetch - fetch_array,
00986                     query_list[fetch - fetch_array]);
00987   }
00988 
00989   while (open_statements)
00990   {
00991     for (fetch= fetch_array; fetch < fetch_array + query_count; ++fetch)
00992     {
00993       if (fetch->is_open && (rc= stmt_fetch_fetch_row(fetch)))
00994       {
00995         open_statements--;
00996         /*
00997           We try to fetch from the rest of the statements in case of
00998           error
00999         */
01000         if (rc != MYSQL_NO_DATA)
01001         {
01002           fprintf(stderr,
01003                   "Got error reading rows from statement %d,\n"
01004                   "query is: %s,\n"
01005                   "error message: %s", fetch - fetch_array, fetch->query,
01006                   mysql_stmt_error(fetch->handle));
01007           error_count++;
01008         }
01009       }
01010     }
01011   }
01012   if (error_count)
01013     fprintf(stderr, "Fetch FAILED");
01014   else
01015   {
01016     unsigned total_row_count= 0;
01017     for (fetch= fetch_array; fetch < fetch_array + query_count; ++fetch)
01018       total_row_count+= fetch->row_count;
01019     if (!opt_silent)
01020       printf("Success, total rows fetched: %d\n", total_row_count);
01021   }
01022   for (fetch= fetch_array; fetch < fetch_array + query_count; ++fetch)
01023     stmt_fetch_close(fetch);
01024   free(fetch_array);
01025   DBUG_RETURN(error_count != 0);
01026 }

void fill_tables const char **  query_list,
unsigned  query_count
 

00823 {
00824   int rc;
00825   const char **query;
00826   DBUG_ENTER("fill_tables");
00827   for (query= query_list; query < query_list + query_count;
00828        ++query)
00829   {
00830     rc= mysql_query(mysql, *query);
00831     myquery(rc);
00832   }
00833   DBUG_VOID_RETURN;
00834 }

my_bool get_one_option int  optid,
const struct my_option *opt   __attribute__((unused)),
char *  argument
[static]
 

12243 {
12244   switch (optid) {
12245   case '#':
12246     DBUG_PUSH(argument ? argument : default_dbug_option);
12247     break;
12248   case 'c':
12249     opt_testcase = 1;
12250     break;
12251   case 'p':
12252     if (argument)
12253     {
12254       char *start=argument;
12255       my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
12256       opt_password= my_strdup(argument, MYF(MY_FAE));
12257       while (*argument) *argument++= 'x';               /* Destroy argument */
12258       if (*start)
12259         start[1]=0;
12260     }
12261     else
12262       tty_password= 1;
12263     break;
12264   case 's':
12265     if (argument == disabled_my_option)
12266       opt_silent= 0;
12267     else
12268       opt_silent++;
12269     break;
12270   case 'T':
12271     {
12272       struct my_tests_st *fptr;
12273       
12274       printf("All possible test names:\n\n");
12275       for (fptr= my_tests; fptr->name; fptr++)
12276         printf("%s\n", fptr->name);
12277       exit(0);
12278       break;
12279     }
12280   case '?':
12281   case 'I':                                     /* Info */
12282     usage();
12283     exit(0);
12284     break;
12285   }
12286   return 0;
12287 }

void get_options int *  argc,
char ***  argv
[static]
 

12290 {
12291   int ho_error;
12292 
12293   if ((ho_error= handle_options(argc, argv, client_test_long_options,
12294                                 get_one_option)))
12295     exit(ho_error);
12296 
12297   if (tty_password)
12298     opt_password= get_tty_password(NullS);
12299   return;
12300 }

int main int  argc,
char **  argv
 

we must always load meta data, even if we will only print it to stdout

check wheater we can restore the backup (right version).

12328 {
12329   struct my_tests_st *fptr;
12330 
12331   DEBUGGER_OFF;
12332   MY_INIT(argv[0]);
12333   
12334   load_defaults("my", client_test_load_default_groups, &argc, &argv);
12335   defaults_argv= argv;
12336   get_options(&argc, &argv);
12337 
12338   client_connect();       /* connect to server */
12339 
12340   total_time= 0;
12341   for (iter_count= 1; iter_count <= opt_count; iter_count++)
12342   {
12343     /* Start of tests */
12344     test_count= 1;
12345     start_time= time((time_t *)0);
12346     if (!argc)
12347     {
12348       for (fptr= my_tests; fptr->name; fptr++)
12349         (*fptr->function)();    
12350     }
12351     else
12352     {
12353       for ( ; *argv ; argv++)
12354       {
12355         for (fptr= my_tests; fptr->name; fptr++)
12356         {
12357           if (!strcmp(fptr->name, *argv))
12358           {
12359             (*fptr->function)();
12360             break;
12361           }
12362         }
12363         if (!fptr->name)
12364         {
12365           fprintf(stderr, "\n\nGiven test not found: '%s'\n", *argv);
12366           fprintf(stderr, "See legal test names with %s -T\n\nAborting!\n",
12367                   my_progname);
12368           client_disconnect();
12369           free_defaults(defaults_argv);
12370           exit(1);
12371         }
12372       }
12373     }
12374 
12375     end_time= time((time_t *)0);
12376     total_time+= difftime(end_time, start_time);
12377 
12378     /* End of tests */
12379   }
12380 
12381   client_disconnect();    /* disconnect from server */
12382   free_defaults(defaults_argv);
12383   print_test_output();
12384   my_end(0);
12385 
12386   exit(0);
12387 }

void my_print_dashes MYSQL_RES result  )  [static]
 

00341 {
00342   MYSQL_FIELD  *field;
00343   unsigned int i, j;
00344 
00345   mysql_field_seek(result, 0);
00346   fputc('\t', stdout);
00347   fputc('+', stdout);
00348 
00349   for(i= 0; i< mysql_num_fields(result); i++)
00350   {
00351     field= mysql_fetch_field(result);
00352     for(j= 0; j < field->max_length+2; j++)
00353       fputc('-', stdout);
00354     fputc('+', stdout);
00355   }
00356   fputc('\n', stdout);
00357 }

void my_print_result_metadata MYSQL_RES result  )  [static]
 

00363 {
00364   MYSQL_FIELD  *field;
00365   unsigned int i, j;
00366   unsigned int field_count;
00367 
00368   mysql_field_seek(result, 0);
00369   if (!opt_silent)
00370   {
00371     fputc('\n', stdout);
00372     fputc('\n', stdout);
00373   }
00374 
00375   field_count= mysql_num_fields(result);
00376   for(i= 0; i< field_count; i++)
00377   {
00378     field= mysql_fetch_field(result);
00379     j= strlen(field->name);
00380     if (j < field->max_length)
00381       j= field->max_length;
00382     if (j < 4 && !IS_NOT_NULL(field->flags))
00383       j= 4;
00384     field->max_length= j;
00385   }
00386   if (!opt_silent)
00387   {
00388     my_print_dashes(result);
00389     fputc('\t', stdout);
00390     fputc('|', stdout);
00391   }
00392 
00393   mysql_field_seek(result, 0);
00394   for(i= 0; i< field_count; i++)
00395   {
00396     field= mysql_fetch_field(result);
00397     if (!opt_silent)
00398       fprintf(stdout, " %-*s |", (int) field->max_length, field->name);
00399   }
00400   if (!opt_silent)
00401   {
00402     fputc('\n', stdout);
00403     my_print_dashes(result);
00404   }
00405 }

int my_process_result MYSQL mysql  )