~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/mysqltest.cc

  • Committer: Brian Aker
  • Date: 2008-07-15 06:45:16 UTC
  • Revision ID: brian@tangent.org-20080715064516-fnbq7kowh7w57bxj
Merge Monty's code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
static bool tty_password= 0;
72
72
static bool opt_mark_progress= 0;
73
73
static bool parsing_disabled= 0;
74
 
static bool display_result_vertically= FALSE,
75
 
  display_metadata= FALSE, display_result_sorted= FALSE;
 
74
static bool display_result_vertically= false,
 
75
  display_metadata= false, display_result_sorted= false;
76
76
static bool disable_query_log= 0, disable_result_log= 0;
77
77
static bool disable_warnings= 0;
78
78
static bool disable_info= 1;
736
736
      if (ptr > start)
737
737
      {
738
738
        init_dynamic_string(arg->ds, 0, ptr-start, 32);
739
 
        do_eval(arg->ds, start, ptr, FALSE);
 
739
        do_eval(arg->ds, start, ptr, false);
740
740
      }
741
741
      else
742
742
      {
754
754
    case ARG_REST:
755
755
      start= ptr;
756
756
      init_dynamic_string(arg->ds, 0, command->query_len, 256);
757
 
      do_eval(arg->ds, start, command->end, FALSE);
 
757
      do_eval(arg->ds, start, command->end, false);
758
758
      command->last_argument= command->end;
759
759
      break;
760
760
 
1837
1837
 
1838
1838
  /* Eval the query, thus replacing all environment variables */
1839
1839
  init_dynamic_string(&ds_query, 0, (end - query) + 32, 256);
1840
 
  do_eval(&ds_query, query, end, FALSE);
 
1840
  do_eval(&ds_query, query, end, false);
1841
1841
 
1842
1842
  if (mysql_real_query(mysql, ds_query.str, ds_query.length))
1843
1843
    die("Error running query '%s': %d %s", ds_query.str,
1912
1912
  static DYNAMIC_STRING ds_col;
1913
1913
  static DYNAMIC_STRING ds_row;
1914
1914
  const struct command_arg query_get_value_args[] = {
1915
 
    {"query", ARG_STRING, TRUE, &ds_query, "Query to run"},
1916
 
    {"column name", ARG_STRING, TRUE, &ds_col, "Name of column"},
1917
 
    {"row number", ARG_STRING, TRUE, &ds_row, "Number for row"}
 
1915
    {"query", ARG_STRING, true, &ds_query, "Query to run"},
 
1916
    {"column name", ARG_STRING, true, &ds_col, "Name of column"},
 
1917
    {"row number", ARG_STRING, true, &ds_row, "Number for row"}
1918
1918
  };
1919
1919
 
1920
1920
 
2114
2114
{
2115
2115
  static DYNAMIC_STRING ds_filename;
2116
2116
  const struct command_arg source_args[] = {
2117
 
    { "filename", ARG_STRING, TRUE, &ds_filename, "File to source" }
 
2117
    { "filename", ARG_STRING, true, &ds_filename, "File to source" }
2118
2118
  };
2119
2119
 
2120
2120
 
2418
2418
  int error;
2419
2419
  static DYNAMIC_STRING ds_filename;
2420
2420
  const struct command_arg rm_args[] = {
2421
 
    { "filename", ARG_STRING, TRUE, &ds_filename, "File to delete" }
 
2421
    { "filename", ARG_STRING, true, &ds_filename, "File to delete" }
2422
2422
  };
2423
2423
 
2424
2424
 
2451
2451
  static DYNAMIC_STRING ds_from_file;
2452
2452
  static DYNAMIC_STRING ds_to_file;
2453
2453
  const struct command_arg copy_file_args[] = {
2454
 
    { "from_file", ARG_STRING, TRUE, &ds_from_file, "Filename to copy from" },
2455
 
    { "to_file", ARG_STRING, TRUE, &ds_to_file, "Filename to copy to" }
 
2454
    { "from_file", ARG_STRING, true, &ds_from_file, "Filename to copy from" },
 
2455
    { "to_file", ARG_STRING, true, &ds_to_file, "Filename to copy to" }
2456
2456
  };
2457
2457
 
2458
2458
 
2487
2487
  static DYNAMIC_STRING ds_mode;
2488
2488
  static DYNAMIC_STRING ds_file;
2489
2489
  const struct command_arg chmod_file_args[] = {
2490
 
    { "mode", ARG_STRING, TRUE, &ds_mode, "Mode of file(octal) ex. 0660"}, 
2491
 
    { "filename", ARG_STRING, TRUE, &ds_file, "Filename of file to modify" }
 
2490
    { "mode", ARG_STRING, true, &ds_mode, "Mode of file(octal) ex. 0660"}, 
 
2491
    { "filename", ARG_STRING, true, &ds_file, "Filename of file to modify" }
2492
2492
  };
2493
2493
 
2494
2494
 
2524
2524
  int error;
2525
2525
  static DYNAMIC_STRING ds_filename;
2526
2526
  const struct command_arg file_exist_args[] = {
2527
 
    { "filename", ARG_STRING, TRUE, &ds_filename, "File to check if it exist" }
 
2527
    { "filename", ARG_STRING, true, &ds_filename, "File to check if it exist" }
2528
2528
  };
2529
2529
 
2530
2530
 
2555
2555
  int error;
2556
2556
  static DYNAMIC_STRING ds_dirname;
2557
2557
  const struct command_arg mkdir_args[] = {
2558
 
    {"dirname", ARG_STRING, TRUE, &ds_dirname, "Directory to create"}
 
2558
    {"dirname", ARG_STRING, true, &ds_dirname, "Directory to create"}
2559
2559
  };
2560
2560
 
2561
2561
 
2584
2584
  int error;
2585
2585
  static DYNAMIC_STRING ds_dirname;
2586
2586
  const struct command_arg rmdir_args[] = {
2587
 
    {"dirname", ARG_STRING, TRUE, &ds_dirname, "Directory to remove"}
 
2587
    {"dirname", ARG_STRING, true, &ds_dirname, "Directory to remove"}
2588
2588
  };
2589
2589
 
2590
2590
 
2672
2672
  static DYNAMIC_STRING ds_filename;
2673
2673
  static DYNAMIC_STRING ds_delimiter;
2674
2674
  const struct command_arg write_file_args[] = {
2675
 
    { "filename", ARG_STRING, TRUE, &ds_filename, "File to write to" },
2676
 
    { "delimiter", ARG_STRING, FALSE, &ds_delimiter, "Delimiter to read until" }
 
2675
    { "filename", ARG_STRING, true, &ds_filename, "File to write to" },
 
2676
    { "delimiter", ARG_STRING, false, &ds_delimiter, "Delimiter to read until" }
2677
2677
  };
2678
2678
 
2679
2679
 
2732
2732
 
2733
2733
static void do_write_file(struct st_command *command)
2734
2734
{
2735
 
  do_write_file_command(command, FALSE);
 
2735
  do_write_file_command(command, false);
2736
2736
}
2737
2737
 
2738
2738
 
2763
2763
 
2764
2764
static void do_append_file(struct st_command *command)
2765
2765
{
2766
 
  do_write_file_command(command, TRUE);
 
2766
  do_write_file_command(command, true);
2767
2767
}
2768
2768
 
2769
2769
 
2783
2783
{
2784
2784
  static DYNAMIC_STRING ds_filename;
2785
2785
  const struct command_arg cat_file_args[] = {
2786
 
    { "filename", ARG_STRING, TRUE, &ds_filename, "File to read from" }
 
2786
    { "filename", ARG_STRING, true, &ds_filename, "File to read from" }
2787
2787
  };
2788
2788
 
2789
2789
 
2818
2818
  static DYNAMIC_STRING ds_filename;
2819
2819
  static DYNAMIC_STRING ds_filename2;
2820
2820
  const struct command_arg diff_file_args[] = {
2821
 
    { "file1", ARG_STRING, TRUE, &ds_filename, "First file to diff" },
2822
 
    { "file2", ARG_STRING, TRUE, &ds_filename2, "Second file to diff" }
 
2821
    { "file1", ARG_STRING, true, &ds_filename, "First file to diff" },
 
2822
    { "file2", ARG_STRING, true, &ds_filename2, "Second file to diff" }
2823
2823
  };
2824
2824
 
2825
2825
 
2914
2914
  /* static keyword to make the NetWare compiler happy. */
2915
2915
  static DYNAMIC_STRING ds_user, ds_passwd, ds_db;
2916
2916
  const struct command_arg change_user_args[] = {
2917
 
    { "user", ARG_STRING, FALSE, &ds_user, "User to connect as" },
2918
 
    { "password", ARG_STRING, FALSE, &ds_passwd, "Password used when connecting" },
2919
 
    { "database", ARG_STRING, FALSE, &ds_db, "Database to select after connect" },
 
2917
    { "user", ARG_STRING, false, &ds_user, "User to connect as" },
 
2918
    { "password", ARG_STRING, false, &ds_passwd, "Password used when connecting" },
 
2919
    { "database", ARG_STRING, false, &ds_db, "Database to select after connect" },
2920
2920
  };
2921
2921
 
2922
2922
 
2975
2975
  static DYNAMIC_STRING ds_script;
2976
2976
  static DYNAMIC_STRING ds_delimiter;
2977
2977
  const struct command_arg perl_args[] = {
2978
 
    { "delimiter", ARG_STRING, FALSE, &ds_delimiter, "Delimiter to read until" }
 
2978
    { "delimiter", ARG_STRING, false, &ds_delimiter, "Delimiter to read until" }
2979
2979
  };
2980
2980
 
2981
2981
 
3056
3056
 
3057
3057
 
3058
3058
  init_dynamic_string(&ds_echo, "", command->query_len, 256);
3059
 
  do_eval(&ds_echo, command->first_argument, command->end, FALSE);
 
3059
  do_eval(&ds_echo, command->first_argument, command->end, false);
3060
3060
  dynstr_append_mem(&ds_res, ds_echo.str, ds_echo.length);
3061
3061
  dynstr_append_mem(&ds_res, "\n", 1);
3062
3062
  dynstr_free(&ds_echo);
3236
3236
  while (*p && my_isspace(charset_info,*p))
3237
3237
    p++;
3238
3238
 
3239
 
  do_eval(&let_rhs_expr, p, command->end, FALSE);
 
3239
  do_eval(&let_rhs_expr, p, command->end, false);
3240
3240
 
3241
3241
  command->last_argument= command->end;
3242
3242
  /* Assign var_val to var_name */
3842
3842
  static DYNAMIC_STRING ds_sock;
3843
3843
  static DYNAMIC_STRING ds_options;
3844
3844
  const struct command_arg connect_args[] = {
3845
 
    { "connection name", ARG_STRING, TRUE, &ds_connection_name, "Name of the connection" },
3846
 
    { "host", ARG_STRING, TRUE, &ds_host, "Host to connect to" },
3847
 
    { "user", ARG_STRING, FALSE, &ds_user, "User to connect as" },
3848
 
    { "passsword", ARG_STRING, FALSE, &ds_password, "Password used when connecting" },
3849
 
    { "database", ARG_STRING, FALSE, &ds_database, "Database to select after connect" },
3850
 
    { "port", ARG_STRING, FALSE, &ds_port, "Port to connect to" },
3851
 
    { "socket", ARG_STRING, FALSE, &ds_sock, "Socket to connect with" },
3852
 
    { "options", ARG_STRING, FALSE, &ds_options, "Options to use while connecting" }
 
3845
    { "connection name", ARG_STRING, true, &ds_connection_name, "Name of the connection" },
 
3846
    { "host", ARG_STRING, true, &ds_host, "Host to connect to" },
 
3847
    { "user", ARG_STRING, false, &ds_user, "User to connect as" },
 
3848
    { "passsword", ARG_STRING, false, &ds_password, "Password used when connecting" },
 
3849
    { "database", ARG_STRING, false, &ds_database, "Database to select after connect" },
 
3850
    { "port", ARG_STRING, false, &ds_port, "Port to connect to" },
 
3851
    { "socket", ARG_STRING, false, &ds_sock, "Socket to connect with" },
 
3852
    { "options", ARG_STRING, false, &ds_options, "Options to use while connecting" }
3853
3853
  };
3854
3854
 
3855
3855
 
4047
4047
    /* Inner block should be ignored too */
4048
4048
    cur_block++;
4049
4049
    cur_block->cmd= cmd;
4050
 
    cur_block->ok= FALSE;
 
4050
    cur_block->ok= false;
4051
4051
    return;
4052
4052
  }
4053
4053
 
4059
4059
  /* Check for !<expr> */
4060
4060
  if (*expr_start == '!')
4061
4061
  {
4062
 
    not_expr= TRUE;
 
4062
    not_expr= true;
4063
4063
    expr_start++; /* Step past the '!' */
4064
4064
  }
4065
4065
  /* Find ending ')' */
4079
4079
  /* Define inner block */
4080
4080
  cur_block++;
4081
4081
  cur_block->cmd= cmd;
4082
 
  cur_block->ok= (v.int_val ? TRUE : FALSE);
 
4082
  cur_block->ok= (v.int_val ? true : false);
4083
4083
 
4084
4084
  if (not_expr)
4085
4085
    cur_block->ok = !cur_block->ok;
4870
4870
 
4871
4871
void str_to_file(const char *fname, char *str, int size)
4872
4872
{
4873
 
  str_to_file2(fname, str, size, FALSE);
 
4873
  str_to_file2(fname, str, size, false);
4874
4874
}
4875
4875
 
4876
4876
 
5405
5405
  if (command->type == Q_EVAL)
5406
5406
  {
5407
5407
    init_dynamic_string(&eval_query, "", command->query_len+256, 1024);
5408
 
    do_eval(&eval_query, command->query, command->end, FALSE);
 
5408
    do_eval(&eval_query, command->query, command->end, false);
5409
5409
    query = eval_query.str;
5410
5410
    query_len = eval_query.length;
5411
5411
  }
5643
5643
  block_stack_end=
5644
5644
    block_stack + (sizeof(block_stack)/sizeof(struct st_block)) - 1;
5645
5645
  cur_block= block_stack;
5646
 
  cur_block->ok= TRUE; /* Outer block should always be executed */
 
5646
  cur_block->ok= true; /* Outer block should always be executed */
5647
5647
  cur_block->cmd= cmd_none;
5648
5648
 
5649
5649
  my_init_dynamic_array(&q_lines, sizeof(struct st_command*), 1024, 1024);
5778
5778
        do_delimiter(command);
5779
5779
        break;
5780
5780
      case Q_DISPLAY_VERTICAL_RESULTS:
5781
 
        display_result_vertically= TRUE;
 
5781
        display_result_vertically= true;
5782
5782
        break;
5783
5783
      case Q_DISPLAY_HORIZONTAL_RESULTS:
5784
 
        display_result_vertically= FALSE;
 
5784
        display_result_vertically= false;
5785
5785
        break;
5786
5786
      case Q_SORTED_RESULT:
5787
5787
        /*
5788
5788
          Turn on sorting of result set, will be reset after next
5789
5789
          command
5790
5790
        */
5791
 
        display_result_sorted= TRUE;
 
5791
        display_result_sorted= true;
5792
5792
        break;
5793
5793
      case Q_LET: do_let(command); break;
5794
5794
      case Q_EVAL_RESULT:
5987
5987
      free_all_replace();
5988
5988
 
5989
5989
      /* Also reset "sorted_result" */
5990
 
      display_result_sorted= FALSE;
 
5990
      display_result_sorted= false;
5991
5991
    }
5992
5992
    last_command_executed= command_executed;
5993
5993