~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/mysqltest.c

  • Committer: Brian Aker
  • Date: 2008-07-05 19:24:24 UTC
  • mfrom: (53.2.8 codestyle)
  • Revision ID: brian@tangent.org-20080705192424-3uslywtteymm7xqy
First pass of removing BIT_TYPE

Show diffs side-by-side

added added

removed removed

Lines of Context:
398
398
my_bool match_delimiter(int c, const char *delim, uint length);
399
399
void dump_result_to_reject_file(char *buf, int size);
400
400
void dump_result_to_log_file(char *buf, int size);
401
 
void dump_warning_messages();
402
 
void dump_progress();
 
401
void dump_warning_messages(void);
 
402
void dump_progress(void);
403
403
 
404
404
void do_eval(DYNAMIC_STRING *query_eval, const char *query,
405
405
             const char *query_end, my_bool pass_through_escape_chars);
410
410
static char *replace_column[MAX_COLUMNS];
411
411
static uint max_replace_column= 0;
412
412
void do_get_replace_column(struct st_command*);
413
 
void free_replace_column();
 
413
void free_replace_column(void);
414
414
 
415
415
/* For replace */
416
416
void do_get_replace(struct st_command *command);
417
 
void free_replace();
 
417
void free_replace(void);
418
418
 
419
419
/* For replace_regex */
420
420
void do_get_replace_regex(struct st_command *command);
421
 
void free_replace_regex();
422
 
 
423
 
 
424
 
void free_all_replace(){
 
421
void free_replace_regex(void);
 
422
 
 
423
 
 
424
void free_all_replace(void);
 
425
 
 
426
 
 
427
void free_all_replace(void){
425
428
  free_replace();
426
429
  free_replace_regex();
427
430
  free_replace_column();
711
714
};
712
715
 
713
716
 
714
 
void check_command_args(struct st_command *command,
715
 
                        const char *arguments,
716
 
                        const struct command_arg *args,
717
 
                        int num_args, const char delimiter_arg)
 
717
static void check_command_args(struct st_command *command,
 
718
                               const char *arguments,
 
719
                               const struct command_arg *args,
 
720
                               int num_args, const char delimiter_arg)
718
721
{
719
722
  int i;
720
723
  const char *ptr= arguments;
787
790
}
788
791
 
789
792
 
790
 
void handle_command_error(struct st_command *command, uint error)
 
793
static void handle_command_error(struct st_command *command, uint error)
791
794
{
792
795
  DBUG_ENTER("handle_command_error");
793
796
  DBUG_PRINT("enter", ("error: %d", error));
825
828
}
826
829
 
827
830
 
828
 
void close_connections()
 
831
static void close_connections(void)
829
832
{
830
833
  DBUG_ENTER("close_connections");
831
834
  for (--next_con; next_con >= connections; --next_con)
839
842
}
840
843
 
841
844
 
842
 
void close_files()
 
845
static void close_files(void)
843
846
{
844
847
  DBUG_ENTER("close_files");
845
848
  for (; cur_file >= file_stack; cur_file--)
856
859
}
857
860
 
858
861
 
859
 
void free_used_memory()
 
862
static void free_used_memory(void)
860
863
{
861
864
  uint i;
862
865
  DBUG_ENTER("free_used_memory");
1025
1028
}
1026
1029
 
1027
1030
 
1028
 
void abort_not_in_this_version()
1029
 
{
1030
 
  die("Not available in this version of mysqltest");
1031
 
}
1032
 
 
1033
 
 
1034
 
void deprecated(struct st_command *command)
1035
 
{
1036
 
  die("'%.*s'has been deprecated",
1037
 
      command->first_word_len, command->query);
1038
 
}
1039
 
 
1040
 
 
1041
1031
void verbose_msg(const char *fmt, ...)
1042
1032
{
1043
1033
  va_list args;
1123
1113
 
1124
1114
*/
1125
1115
 
1126
 
void cat_file(DYNAMIC_STRING* ds, const char* filename)
 
1116
static void cat_file(DYNAMIC_STRING* ds, const char* filename)
1127
1117
{
1128
1118
  int fd;
1129
1119
  uint len;
1260
1250
 
1261
1251
*/
1262
1252
 
1263
 
void show_diff(DYNAMIC_STRING* ds,
1264
 
               const char* filename1, const char* filename2)
 
1253
static void show_diff(DYNAMIC_STRING* ds,
 
1254
                      const char* filename1, const char* filename2)
1265
1255
{
1266
1256
 
1267
1257
  DYNAMIC_STRING ds_tmp;
1352
1342
 
1353
1343
*/
1354
1344
 
1355
 
int compare_files2(File fd, const char* filename2)
 
1345
static int compare_files2(File fd, const char* filename2)
1356
1346
{
1357
1347
  int error= RESULT_OK;
1358
1348
  File fd2;
1413
1403
 
1414
1404
*/
1415
1405
 
1416
 
int compare_files(const char* filename1, const char* filename2)
 
1406
static int compare_files(const char* filename1, const char* filename2)
1417
1407
{
1418
1408
  File fd;
1419
1409
  int error;
1441
1431
  See 'compare_files2'
1442
1432
*/
1443
1433
 
1444
 
int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
 
1434
static int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
1445
1435
{
1446
1436
  int error;
1447
1437
  File fd;
1488
1478
 
1489
1479
*/
1490
1480
 
1491
 
void check_result(DYNAMIC_STRING* ds)
 
1481
static void check_result(DYNAMIC_STRING* ds)
1492
1482
{
1493
1483
  const char* mess= "Result content mismatch\n";
1494
1484
 
1558
1548
 
1559
1549
*/
1560
1550
 
1561
 
void check_require(DYNAMIC_STRING* ds, const char *fname)
 
1551
static void check_require(DYNAMIC_STRING* ds, const char *fname)
1562
1552
{
1563
1553
  DBUG_ENTER("check_require");
1564
1554
 
1741
1731
}
1742
1732
 
1743
1733
 
1744
 
VAR *var_obtain(const char *name, int len)
 
1734
static VAR *var_obtain(const char *name, int len)
1745
1735
{
1746
1736
  VAR* v;
1747
1737
  if ((v = (VAR*)hash_search(&var_hash, (const uchar *) name, len)))
1758
1748
  environment variable will be updated
1759
1749
*/
1760
1750
 
1761
 
void var_set(const char *var_name, const char *var_name_end,
1762
 
             const char *var_val, const char *var_val_end)
 
1751
static void var_set(const char *var_name, const char *var_name_end,
 
1752
                    const char *var_val, const char *var_val_end)
1763
1753
{
1764
1754
  int digit, env_var= 0;
1765
1755
  VAR *v;
1805
1795
}
1806
1796
 
1807
1797
 
1808
 
void var_set_string(const char* name, const char* value)
 
1798
static void var_set_string(const char* name, const char* value)
1809
1799
{
1810
1800
  var_set(name, name + strlen(name), value, value + strlen(value));
1811
1801
}
1812
1802
 
1813
1803
 
1814
 
void var_set_int(const char* name, int value)
 
1804
static void var_set_int(const char* name, int value)
1815
1805
{
1816
1806
  char buf[21];
1817
1807
  my_snprintf(buf, sizeof(buf), "%d", value);
1824
1814
  statement in the mysqltest builtin variable $mysql_errno
1825
1815
*/
1826
1816
 
1827
 
void var_set_errno(int sql_errno)
 
1817
static void var_set_errno(int sql_errno)
1828
1818
{
1829
1819
  var_set_int("$mysql_errno", sql_errno);
1830
1820
}
1835
1825
  of the currently connected server
1836
1826
*/
1837
1827
 
1838
 
void var_set_mysql_get_server_version(MYSQL* mysql)
 
1828
static void var_set_mysql_get_server_version(MYSQL* mysql)
1839
1829
{
1840
1830
  var_set_int("$mysql_get_server_version", mysql_get_server_version(mysql));
1841
1831
}
1864
1854
 
1865
1855
*/
1866
1856
 
1867
 
void var_query_set(VAR *var, const char *query, const char** query_end)
 
1857
static void var_query_set(VAR *var, const char *query, const char** query_end)
1868
1858
{
1869
1859
  char *end = (char*)((query_end && *query_end) ?
1870
1860
                      *query_end : query + strlen(query));
1946
1936
 
1947
1937
*/
1948
1938
 
1949
 
void var_set_query_get_value(struct st_command *command, VAR *var)
 
1939
static void var_set_query_get_value(struct st_command *command, VAR *var)
1950
1940
{
1951
1941
  long row_no;
1952
1942
  int col_no= -1;
1957
1947
  static DYNAMIC_STRING ds_col;
1958
1948
  static DYNAMIC_STRING ds_row;
1959
1949
  const struct command_arg query_get_value_args[] = {
1960
 
    "query", ARG_STRING, TRUE, &ds_query, "Query to run",
1961
 
    "column name", ARG_STRING, TRUE, &ds_col, "Name of column",
1962
 
    "row number", ARG_STRING, TRUE, &ds_row, "Number for row"
 
1950
    {"query", ARG_STRING, TRUE, &ds_query, "Query to run"},
 
1951
    {"column name", ARG_STRING, TRUE, &ds_col, "Name of column"},
 
1952
    {"row number", ARG_STRING, TRUE, &ds_row, "Number for row"}
1963
1953
  };
1964
1954
 
1965
1955
  DBUG_ENTER("var_set_query_get_value");
2047
2037
}
2048
2038
 
2049
2039
 
2050
 
void var_copy(VAR *dest, VAR *src)
 
2040
static void var_copy(VAR *dest, VAR *src)
2051
2041
{
2052
2042
  dest->int_val= src->int_val;
2053
2043
  dest->int_dirty= src->int_dirty;
2130
2120
}
2131
2121
 
2132
2122
 
2133
 
int open_file(const char *name)
 
2123
static int open_file(const char *name)
2134
2124
{
2135
2125
  char buff[FN_REFLEN];
2136
2126
  DBUG_ENTER("open_file");
2170
2160
 
2171
2161
*/
2172
2162
 
2173
 
void do_source(struct st_command *command)
 
2163
static void do_source(struct st_command *command)
2174
2164
{
2175
2165
  static DYNAMIC_STRING ds_filename;
2176
2166
  const struct command_arg source_args[] = {
2199
2189
}
2200
2190
 
2201
2191
 
2202
 
FILE* my_popen(DYNAMIC_STRING *ds_cmd, const char *mode)
 
2192
static FILE* my_popen(DYNAMIC_STRING *ds_cmd, const char *mode)
2203
2193
{
2204
2194
  return popen(ds_cmd->str, mode);
2205
2195
}
2268
2258
  mysqltest commmand(s) like "remove_file" for that
2269
2259
*/
2270
2260
 
2271
 
void do_exec(struct st_command *command)
 
2261
static void do_exec(struct st_command *command)
2272
2262
{
2273
2263
  int error;
2274
2264
  char buf[512];
2388
2378
 
2389
2379
*/
2390
2380
 
2391
 
int do_modify_var(struct st_command *command,
2392
 
                  enum enum_operator operator)
 
2381
static int do_modify_var(struct st_command *command,
 
2382
                         enum enum_operator operator)
2393
2383
{
2394
2384
  const char *p= command->first_argument;
2395
2385
  VAR* v;
2427
2417
 
2428
2418
*/
2429
2419
 
2430
 
int my_system(DYNAMIC_STRING* ds_cmd)
 
2420
static int my_system(DYNAMIC_STRING* ds_cmd)
2431
2421
{
2432
2422
  return system(ds_cmd->str);
2433
2423
}
2446
2436
 
2447
2437
*/
2448
2438
 
2449
 
void do_system(struct st_command *command)
 
2439
static void do_system(struct st_command *command)
2450
2440
{
2451
2441
  DYNAMIC_STRING ds_cmd;
2452
2442
  DBUG_ENTER("do_system");
2488
2478
  Remove the file <file_name>
2489
2479
*/
2490
2480
 
2491
 
void do_remove_file(struct st_command *command)
 
2481
static void do_remove_file(struct st_command *command)
2492
2482
{
2493
2483
  int error;
2494
2484
  static DYNAMIC_STRING ds_filename;
2521
2511
  NOTE! Will fail if <to_file> exists
2522
2512
*/
2523
2513
 
2524
 
void do_copy_file(struct st_command *command)
 
2514
static void do_copy_file(struct st_command *command)
2525
2515
{
2526
2516
  int error;
2527
2517
  static DYNAMIC_STRING ds_from_file;
2558
2548
 
2559
2549
*/
2560
2550
 
2561
 
void do_chmod_file(struct st_command *command)
 
2551
static void do_chmod_file(struct st_command *command)
2562
2552
{
2563
2553
  long mode= 0;
2564
2554
  static DYNAMIC_STRING ds_mode;
2597
2587
  Check if file <file_name> exists
2598
2588
*/
2599
2589
 
2600
 
void do_file_exist(struct st_command *command)
 
2590
static void do_file_exist(struct st_command *command)
2601
2591
{
2602
2592
  int error;
2603
2593
  static DYNAMIC_STRING ds_filename;
2629
2619
  Create the directory <dir_name>
2630
2620
*/
2631
2621
 
2632
 
void do_mkdir(struct st_command *command)
 
2622
static void do_mkdir(struct st_command *command)
2633
2623
{
2634
2624
  int error;
2635
2625
  static DYNAMIC_STRING ds_dirname;
2636
2626
  const struct command_arg mkdir_args[] = {
2637
 
    "dirname", ARG_STRING, TRUE, &ds_dirname, "Directory to create"
 
2627
    {"dirname", ARG_STRING, TRUE, &ds_dirname, "Directory to create"}
2638
2628
  };
2639
2629
  DBUG_ENTER("do_mkdir");
2640
2630
 
2659
2649
  Remove the empty directory <dir_name>
2660
2650
*/
2661
2651
 
2662
 
void do_rmdir(struct st_command *command)
 
2652
static void do_rmdir(struct st_command *command)
2663
2653
{
2664
2654
  int error;
2665
2655
  static DYNAMIC_STRING ds_dirname;
2666
2656
  const struct command_arg rmdir_args[] = {
2667
 
    "dirname", ARG_STRING, TRUE, &ds_dirname, "Directory to remove"
 
2657
    {"dirname", ARG_STRING, TRUE, &ds_dirname, "Directory to remove"}
2668
2658
  };
2669
2659
  DBUG_ENTER("do_rmdir");
2670
2660
 
2690
2680
  happen for any tests in the test suite.
2691
2681
*/
2692
2682
 
2693
 
int my_getc(FILE *file)
 
2683
static int my_getc(FILE *file)
2694
2684
{
2695
2685
  if (line_buffer_pos == line_buffer)
2696
2686
    return fgetc(file);
2698
2688
}
2699
2689
 
2700
2690
 
2701
 
void my_ungetc(int c)
 
2691
static void my_ungetc(int c)
2702
2692
{
2703
2693
  *line_buffer_pos++= (char) c;
2704
2694
}
2705
2695
 
2706
2696
 
2707
 
void read_until_delimiter(DYNAMIC_STRING *ds,
2708
 
                          DYNAMIC_STRING *ds_delimiter)
 
2697
static void read_until_delimiter(DYNAMIC_STRING *ds,
 
2698
                                 DYNAMIC_STRING *ds_delimiter)
2709
2699
{
2710
2700
  char c;
2711
2701
  DBUG_ENTER("read_until_delimiter");
2753
2743
}
2754
2744
 
2755
2745
 
2756
 
void do_write_file_command(struct st_command *command, my_bool append)
 
2746
static void do_write_file_command(struct st_command *command, my_bool append)
2757
2747
{
2758
2748
  static DYNAMIC_STRING ds_content;
2759
2749
  static DYNAMIC_STRING ds_filename;
2818
2808
 
2819
2809
*/
2820
2810
 
2821
 
void do_write_file(struct st_command *command)
 
2811
static void do_write_file(struct st_command *command)
2822
2812
{
2823
2813
  do_write_file_command(command, FALSE);
2824
2814
}
2849
2839
 
2850
2840
*/
2851
2841
 
2852
 
void do_append_file(struct st_command *command)
 
2842
static void do_append_file(struct st_command *command)
2853
2843
{
2854
2844
  do_write_file_command(command, TRUE);
2855
2845
}
2867
2857
 
2868
2858
*/
2869
2859
 
2870
 
void do_cat_file(struct st_command *command)
 
2860
static void do_cat_file(struct st_command *command)
2871
2861
{
2872
2862
  static DYNAMIC_STRING ds_filename;
2873
2863
  const struct command_arg cat_file_args[] = {
2902
2892
 
2903
2893
*/
2904
2894
 
2905
 
void do_diff_files(struct st_command *command)
 
2895
static void do_diff_files(struct st_command *command)
2906
2896
{
2907
2897
  int error= 0;
2908
2898
  static DYNAMIC_STRING ds_filename;
2934
2924
}
2935
2925
 
2936
2926
 
2937
 
struct st_connection * find_connection_by_name(const char *name)
 
2927
static struct st_connection * find_connection_by_name(const char *name)
2938
2928
{
2939
2929
  struct st_connection *con;
2940
2930
  for (con= connections; con < next_con; con++)
2958
2948
 
2959
2949
*/
2960
2950
 
2961
 
void do_send_quit(struct st_command *command)
 
2951
static void do_send_quit(struct st_command *command)
2962
2952
{
2963
2953
  char *p= command->first_argument, *name;
2964
2954
  struct st_connection *con;
3001
2991
 
3002
2992
*/
3003
2993
 
3004
 
void do_change_user(struct st_command *command)
 
2994
static void do_change_user(struct st_command *command)
3005
2995
{
3006
2996
  MYSQL *mysql = &cur_con->mysql;
3007
2997
  /* static keyword to make the NetWare compiler happy. */
3061
3051
  Default <delimiter> is EOF
3062
3052
*/
3063
3053
 
3064
 
void do_perl(struct st_command *command)
 
3054
static void do_perl(struct st_command *command)
3065
3055
{
3066
3056
  int error;
3067
3057
  File fd;
3153
3143
  Print "Some text" plus $<var_name> to result file
3154
3144
*/
3155
3145
 
3156
 
int do_echo(struct st_command *command)
 
3146
static int do_echo(struct st_command *command)
3157
3147
{
3158
3148
  DYNAMIC_STRING ds_echo;
3159
3149
  DBUG_ENTER("do_echo");
3168
3158
}
3169
3159
 
3170
3160
 
3171
 
void do_wait_for_slave_to_stop(struct st_command *c __attribute__((unused)))
 
3161
static void
 
3162
do_wait_for_slave_to_stop(struct st_command *c __attribute__((unused)))
3172
3163
{
3173
3164
  static int SLAVE_POLL_INTERVAL= 300000;
3174
3165
  MYSQL* mysql = &cur_con->mysql;
3197
3188
}
3198
3189
 
3199
3190
 
3200
 
void do_sync_with_master2(long offset)
 
3191
static void do_sync_with_master2(long offset)
3201
3192
{
3202
3193
  MYSQL_RES *res;
3203
3194
  MYSQL_ROW row;
3245
3236
}
3246
3237
 
3247
3238
 
3248
 
void do_sync_with_master(struct st_command *command)
 
3239
static void do_sync_with_master(struct st_command *command)
3249
3240
{
3250
3241
  long offset= 0;
3251
3242
  char *p= command->first_argument;
3268
3259
  when ndb binlog is on, this call will wait until last updated epoch
3269
3260
  (locally in the mysqld) has been received into the binlog
3270
3261
*/
3271
 
int do_save_master_pos()
 
3262
static int do_save_master_pos(void)
3272
3263
{
3273
3264
  MYSQL_RES *res;
3274
3265
  MYSQL_ROW row;
3448
3439
  Program will die if error detected
3449
3440
*/
3450
3441
 
3451
 
void do_let(struct st_command *command)
 
3442
static void do_let(struct st_command *command)
3452
3443
{
3453
3444
  char *p= command->first_argument;
3454
3445
  char *var_name, *var_name_end;
3509
3500
  used for cpu-independent delays.
3510
3501
*/
3511
3502
 
3512
 
int do_sleep(struct st_command *command, my_bool real_sleep)
 
3503
static int do_sleep(struct st_command *command, my_bool real_sleep)
3513
3504
{
3514
3505
  int error= 0;
3515
3506
  char *p= command->first_argument;
3542
3533
}
3543
3534
 
3544
3535
 
3545
 
void do_get_file_name(struct st_command *command,
 
3536
static void do_get_file_name(struct st_command *command,
3546
3537
                      char* dest, uint dest_max_len)
3547
3538
{
3548
3539
  char *p= command->first_argument, *name;
3558
3549
}
3559
3550
 
3560
3551
 
3561
 
void do_set_charset(struct st_command *command)
 
3552
static void do_set_charset(struct st_command *command)
3562
3553
{
3563
3554
  char *charset_name= command->first_argument;
3564
3555
  char *p;
3592
3583
  { 0, 0 }
3593
3584
};
3594
3585
 
3595
 
uint get_errcode_from_name(char *error_name, char *error_end)
 
3586
static uint get_errcode_from_name(char *error_name, char *error_end)
3596
3587
{
3597
3588
  /* SQL error as string */
3598
3589
  st_error *e= global_error_names;
3629
3620
 
3630
3621
 
3631
3622
 
3632
 
void do_get_errcodes(struct st_command *command)
 
3623
static void do_get_errcodes(struct st_command *command)
3633
3624
{
3634
3625
  struct st_match_err *to= saved_expected_errors.err;
3635
3626
  char *p= command->first_argument;
3754
3745
  If string is a '$variable', return the value of the variable.
3755
3746
*/
3756
3747
 
3757
 
char *get_string(char **to_ptr, char **from_ptr,
3758
 
                 struct st_command *command)
 
3748
static char *get_string(char **to_ptr, char **from_ptr,
 
3749
                        struct st_command *command)
3759
3750
{
3760
3751
  char c, sep;
3761
3752
  char *to= *to_ptr, *from= *from_ptr, *start=to;
3827
3818
}
3828
3819
 
3829
3820
 
3830
 
void set_reconnect(MYSQL* mysql, int val)
 
3821
static void set_reconnect(MYSQL* mysql, int val)
3831
3822
{
3832
3823
  my_bool reconnect= val;
3833
3824
  DBUG_ENTER("set_reconnect");
3841
3832
}
3842
3833
 
3843
3834
 
3844
 
int select_connection_name(const char *name)
 
3835
static int select_connection_name(const char *name)
3845
3836
{
3846
3837
  DBUG_ENTER("select_connection_name");
3847
3838
  DBUG_PRINT("enter",("name: '%s'", name));
3856
3847
}
3857
3848
 
3858
3849
 
3859
 
int select_connection(struct st_command *command)
 
3850
static int select_connection(struct st_command *command)
3860
3851
{
3861
3852
  char *name;
3862
3853
  char *p= command->first_argument;
3874
3865
}
3875
3866
 
3876
3867
 
3877
 
void do_close_connection(struct st_command *command)
 
3868
static void do_close_connection(struct st_command *command)
3878
3869
{
3879
3870
  char *p= command->first_argument, *name;
3880
3871
  struct st_connection *con;
3949
3940
 
3950
3941
*/
3951
3942
 
3952
 
void safe_connect(MYSQL* mysql, const char *name, const char *host,
 
3943
static void safe_connect(MYSQL* mysql, const char *name, const char *host,
3953
3944
                  const char *user, const char *pass, const char *db,
3954
3945
                  int port)
3955
3946
{
4015
4006
 
4016
4007
*/
4017
4008
 
4018
 
int connect_n_handle_errors(struct st_command *command,
 
4009
static int connect_n_handle_errors(struct st_command *command,
4019
4010
                            MYSQL* con, const char* host,
4020
4011
                            const char* user, const char* pass,
4021
4012
                            const char* db, int port, const char* sock)
4089
4080
 
4090
4081
*/
4091
4082
 
4092
 
void do_connect(struct st_command *command)
 
4083
static void do_connect(struct st_command *command)
4093
4084
{
4094
4085
  int con_port= opt_port;
4095
4086
  char *con_options;
4242
4233
}
4243
4234
 
4244
4235
 
4245
 
int do_done(struct st_command *command)
 
4236
static int do_done(struct st_command *command)
4246
4237
{
4247
4238
  /* Check if empty block stack */
4248
4239
  if (cur_block == block_stack)
4295
4286
 
4296
4287
*/
4297
4288
 
4298
 
void do_block(enum block_cmd cmd, struct st_command* command)
 
4289
static void do_block(enum block_cmd cmd, struct st_command* command)
4299
4290
{
4300
4291
  char *p= command->first_argument;
4301
4292
  const char *expr_start, *expr_end;
4362
4353
}
4363
4354
 
4364
4355
 
4365
 
void do_delimiter(struct st_command* command)
 
4356
static void do_delimiter(struct st_command* command)
4366
4357
{
4367
4358
  char* p= command->first_argument;
4368
4359
  DBUG_ENTER("do_delimiter");
4407
4398
}
4408
4399
 
4409
4400
 
4410
 
my_bool end_of_query(int c)
 
4401
static my_bool end_of_query(int c)
4411
4402
{
4412
4403
  return match_delimiter(c, delimiter, delimiter_length);
4413
4404
}
4437
4428
 
4438
4429
*/
4439
4430
 
4440
 
int read_line(char *buf, int size)
 
4431
static int read_line(char *buf, int size)
4441
4432
{
4442
4433
  char c, last_quote= 0;
4443
4434
  char *p= buf, *buf_end= buf + size - 1;
4637
4628
 
4638
4629
*/
4639
4630
 
4640
 
void convert_to_format_v1(char* query)
 
4631
static void convert_to_format_v1(char* query)
4641
4632
{
4642
4633
  int last_c_was_quote= 0;
4643
4634
  char *p= query, *to= query;
4684
4675
  suspicious things and generate warnings.
4685
4676
*/
4686
4677
 
4687
 
void scan_command_for_warnings(struct st_command *command)
 
4678
static void scan_command_for_warnings(struct st_command *command)
4688
4679
{
4689
4680
  const char *ptr= command->query;
4690
4681
  DBUG_ENTER("scan_command_for_warnings");
4733
4724
  switching between different delimiters
4734
4725
*/
4735
4726
 
4736
 
void check_eol_junk_line(const char *line)
 
4727
static void check_eol_junk_line(const char *line)
4737
4728
{
4738
4729
  const char *p= line;
4739
4730
  DBUG_ENTER("check_eol_junk_line");
4753
4744
  DBUG_VOID_RETURN;
4754
4745
}
4755
4746
 
4756
 
void check_eol_junk(const char *eol)
 
4747
static void check_eol_junk(const char *eol)
4757
4748
{
4758
4749
  const char *p= eol;
4759
4750
  DBUG_ENTER("check_eol_junk");
4805
4796
#define MAX_QUERY (256*1024*2) /* 256K -- a test in sp-big is >128K */
4806
4797
static char read_command_buf[MAX_QUERY];
4807
4798
 
4808
 
int read_command(struct st_command** command_ptr)
 
4799
static int read_command(struct st_command** command_ptr)
4809
4800
{
4810
4801
  char *p= read_command_buf;
4811
4802
  struct st_command* command;
4959
4950
 
4960
4951
#include <help_start.h>
4961
4952
 
4962
 
void print_version(void)
 
4953
static void print_version(void)
4963
4954
{
4964
4955
  printf("%s  Ver %s Distrib %s, for %s (%s)\n",my_progname,MTEST_VERSION,
4965
4956
         MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
4966
4957
}
4967
4958
 
4968
 
void usage()
 
4959
static void usage(void)
4969
4960
{
4970
4961
  print_version();
4971
4962
  printf("MySQL AB, by Sasha, Matt, Monty & Jani\n");
4985
4976
  embedded_server_args[]
4986
4977
*/
4987
4978
 
4988
 
void read_embedded_server_arguments(const char *name)
 
4979
static void read_embedded_server_arguments(const char *name)
4989
4980
{
4990
4981
  char argument[1024],buff[FN_REFLEN], *str=0;
4991
4982
  FILE *file;
5111
5102
}
5112
5103
 
5113
5104
 
5114
 
int parse_args(int argc, char **argv)
 
5105
static int parse_args(int argc, char **argv)
5115
5106
{
5116
5107
  load_defaults("my",load_default_groups,&argc,&argv);
5117
5108
  default_argv= argv;
5218
5209
              ds_warning_messages.str, ds_warning_messages.length);
5219
5210
}
5220
5211
 
5221
 
void check_regerr(my_regex_t* r, int err)
 
5212
static void check_regerr(my_regex_t* r, int err)
5222
5213
{
5223
5214
  char err_buf[1024];
5224
5215
 
5233
5224
  Append the result for one field to the dynamic string ds
5234
5225
*/
5235
5226
 
5236
 
void append_field(DYNAMIC_STRING *ds, uint col_idx, MYSQL_FIELD* field,
5237
 
                  const char* val, ulonglong len, my_bool is_null)
 
5227
static void append_field(DYNAMIC_STRING *ds, uint col_idx, MYSQL_FIELD* field,
 
5228
                         const char* val, ulonglong len, my_bool is_null)
5238
5229
{
5239
5230
  if (col_idx < max_replace_column && replace_column[col_idx])
5240
5231
  {
5268
5259
  Values may be converted with 'replace_column'
5269
5260
*/
5270
5261
 
5271
 
void append_result(DYNAMIC_STRING *ds, MYSQL_RES *res)
 
5262
static void append_result(DYNAMIC_STRING *ds, MYSQL_RES *res)
5272
5263
{
5273
5264
  MYSQL_ROW row;
5274
5265
  uint num_fields= mysql_num_fields(res);
5292
5283
  Append metadata for fields to output
5293
5284
*/
5294
5285
 
5295
 
void append_metadata(DYNAMIC_STRING *ds,
5296
 
                     MYSQL_FIELD *field,
5297
 
                     uint num_fields)
 
5286
static void append_metadata(DYNAMIC_STRING *ds,
 
5287
                            MYSQL_FIELD *field,
 
5288
                            uint num_fields)
5298
5289
{
5299
5290
  MYSQL_FIELD *field_end;
5300
5291
  dynstr_append(ds,"Catalog\tDatabase\tTable\tTable_alias\tColumn\t"
5344
5335
  Append affected row count and other info to output
5345
5336
*/
5346
5337
 
5347
 
void append_info(DYNAMIC_STRING *ds, ulonglong affected_rows,
5348
 
                 const char *info)
 
5338
static void append_info(DYNAMIC_STRING *ds, ulonglong affected_rows,
 
5339
                        const char *info)
5349
5340
{
5350
5341
  char buf[40], buff2[21];
5351
5342
  sprintf(buf,"affected rows: %s\n", llstr(affected_rows, buff2));
5363
5354
  Display the table headings with the names tab separated
5364
5355
*/
5365
5356
 
5366
 
void append_table_headings(DYNAMIC_STRING *ds,
5367
 
                           MYSQL_FIELD *field,
5368
 
                           uint num_fields)
 
5357
static void append_table_headings(DYNAMIC_STRING *ds,
 
5358
                                  MYSQL_FIELD *field,
 
5359
                                  uint num_fields)
5369
5360
{
5370
5361
  uint col_idx;
5371
5362
  for (col_idx= 0; col_idx < num_fields; col_idx++)
5384
5375
  Number of warnings appended to ds
5385
5376
*/
5386
5377
 
5387
 
int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql)
 
5378
static int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql)
5388
5379
{
5389
5380
  uint count;
5390
5381
  MYSQL_RES *warn_res;
5429
5420
    ds          output buffer where to store result form query
5430
5421
*/
5431
5422
 
5432
 
void run_query_normal(struct st_connection *cn, struct st_command *command,
5433
 
                      int flags, char *query, int query_len,
5434
 
                      DYNAMIC_STRING *ds, DYNAMIC_STRING *ds_warnings)
 
5423
static void run_query_normal(struct st_connection *cn,
 
5424
                             struct st_command *command,
 
5425
                             int flags, char *query, int query_len,
 
5426
                             DYNAMIC_STRING *ds, DYNAMIC_STRING *ds_warnings)
5435
5427
{
5436
5428
  MYSQL_RES *res= 0;
5437
5429
  MYSQL *mysql= &cn->mysql;
5699
5691
}
5700
5692
 
5701
5693
 
5702
 
 
5703
 
/*
5704
 
  Create a util connection if one does not already exists
5705
 
  and use that to run the query
5706
 
  This is done to avoid implict commit when creating/dropping objects such
5707
 
  as view, sp etc.
5708
 
*/
5709
 
 
5710
 
int util_query(MYSQL* org_mysql, const char* query){
5711
 
 
5712
 
  MYSQL* mysql;
5713
 
  DBUG_ENTER("util_query");
5714
 
 
5715
 
  if(!(mysql= cur_con->util_mysql))
5716
 
  {
5717
 
    int opt_protocol= MYSQL_PROTOCOL_TCP;
5718
 
    DBUG_PRINT("info", ("Creating util_mysql"));
5719
 
    if (!(mysql= mysql_init(mysql)))
5720
 
      die("Failed in mysql_init()");
5721
 
    mysql_options(mysql, MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
5722
 
 
5723
 
    /* enable local infile, in non-binary builds often disabled by default */
5724
 
    mysql_options(mysql, MYSQL_OPT_LOCAL_INFILE, 0);
5725
 
    safe_connect(mysql, "util", org_mysql->host, org_mysql->user,
5726
 
                 org_mysql->passwd, org_mysql->db, org_mysql->port);
5727
 
 
5728
 
    cur_con->util_mysql= mysql;
5729
 
  }
5730
 
 
5731
 
  return mysql_query(mysql, query);
5732
 
}
5733
 
 
5734
 
 
5735
 
 
5736
5694
/*
5737
5695
  Run query
5738
5696
 
5746
5704
  is on the result will be read - for regular query, both bits must be on
5747
5705
*/
5748
5706
 
5749
 
void run_query(struct st_connection *cn, struct st_command *command, int flags)
 
5707
static void run_query(struct st_connection *cn, 
 
5708
                      struct st_command *command,
 
5709
                      int flags)
5750
5710
{
5751
5711
  DYNAMIC_STRING *ds;
5752
5712
  DYNAMIC_STRING *save_ds= NULL;
5859
5819
 
5860
5820
/****************************************************************************/
5861
5821
 
5862
 
void get_command_type(struct st_command* command)
 
5822
static void get_command_type(struct st_command* command)
5863
5823
{
5864
5824
  char save;
5865
5825
  uint type;
5947
5907
 
5948
5908
*/
5949
5909
 
5950
 
void mark_progress(struct st_command* command __attribute__((unused)),
5951
 
                   int line)
 
5910
static void mark_progress(struct st_command* command __attribute__((unused)),
 
5911
                          int line)
5952
5912
{
5953
5913
  char buf[32], *end;
5954
5914
  ulonglong timer= timer_now();
6764
6724
  Returns: st_replace_regex struct with pairs of substitutions
6765
6725
*/
6766
6726
 
6767
 
struct st_replace_regex* init_replace_regex(char* expr)
 
6727
static struct st_replace_regex* init_replace_regex(char* expr)
6768
6728
{
6769
6729
  struct st_replace_regex* res;
6770
6730
  char* buf,*expr_end;
6864
6824
  in one pass
6865
6825
*/
6866
6826
 
6867
 
int multi_reg_replace(struct st_replace_regex* r,char* val)
 
6827
static int multi_reg_replace(struct st_replace_regex* r,char* val)
6868
6828
{
6869
6829
  uint i;
6870
6830
  char* in_buf, *out_buf;
7195
7155
static uint found_sets=0;
7196
7156
 
7197
7157
 
7198
 
uint replace_len(char * str)
 
7158
static uint replace_len(char * str)
7199
7159
{
7200
7160
  uint len=0;
7201
7161
  while (*str)