diff options
Diffstat (limited to 'client/mysqltest.c')
-rw-r--r-- | client/mysqltest.c | 143 |
1 files changed, 83 insertions, 60 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c index 533713b4f43..036130f2d80 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -311,7 +311,7 @@ static int eval_result = 0; void mysql_enable_rpl_parse(MYSQL* mysql __attribute__((unused))) {} void mysql_disable_rpl_parse(MYSQL* mysql __attribute__((unused))) {} int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { return 1; } -int mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; } +my_bool mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; } #endif #define MAX_SERVER_ARGS 20 @@ -482,9 +482,9 @@ void init_parser() int hex_val(int c) { - if (isdigit(c)) + if (my_isdigit(system_charset_info,c)) return c - '0'; - else if ((c = tolower(c)) >= 'a' && c <= 'f') + else if ((c = my_tolower(system_charset_info,c)) >= 'a' && c <= 'f') return c - 'a' + 10; else return -1; @@ -594,7 +594,7 @@ VAR* var_get(const char* var_name, const char** var_name_end, my_bool raw, { const char* save_var_name = var_name, *end; end = (var_name_end) ? *var_name_end : 0; - while (isvar(*var_name) && var_name != end) + while (my_isvar(system_charset_info,*var_name) && var_name != end) ++var_name; if (var_name == save_var_name) { @@ -757,7 +757,7 @@ int do_server_op(struct st_query* q,const char* op) com_p=strmov(com_p,"_exec "); if (!*p) die("Missing server name in server_%s\n",op); - while (*p && !isspace(*p)) + while (*p && !my_isspace(system_charset_info,*p)) { *com_p++=*p++; } @@ -790,7 +790,7 @@ int do_require_version(struct st_query* q) if (!*p) die("Missing version argument in require_version\n"); ver_arg = p; - while (*p && !isspace(*p)) + while (*p && !my_isspace(system_charset_info,*p)) p++; *p = 0; ver_arg_len = p - ver_arg; @@ -820,7 +820,7 @@ int do_source(struct st_query* q) if (!*p) die("Missing file name in source\n"); name = p; - while (*p && !isspace(*p)) + while (*p && !my_isspace(system_charset_info,*p)) p++; *p = 0; @@ -1057,11 +1057,11 @@ int do_let(struct st_query* q) if (!*p) die("Missing variable name in let\n"); var_name = p; - while (*p && (*p != '=' || isspace(*p))) + while (*p && (*p != '=' || my_isspace(system_charset_info,*p))) p++; var_name_end = p; if (*p == '=') p++; - while (*p && isspace(*p)) + while (*p && my_isspace(system_charset_info,*p)) p++; var_val_start = p; return var_set(var_name, var_name_end, var_val_start, q->end); @@ -1090,8 +1090,8 @@ int do_disable_rpl_parse(struct st_query* q __attribute__((unused))) int do_sleep(struct st_query* q, my_bool real_sleep) { - char* p=q->first_argument; - while (*p && isspace(*p)) + char *p=q->first_argument; + while (*p && my_isspace(system_charset_info,*p)) p++; if (!*p) die("Missing argument in sleep\n"); @@ -1107,7 +1107,7 @@ static void get_file_name(char *filename, struct st_query* q) char* p=q->first_argument; strnmov(filename, p, FN_REFLEN); /* Remove end space */ - while (p > filename && isspace(p[-1])) + while (p > filename && my_isspace(system_charset_info,p[-1])) p--; p[0]=0; } @@ -1193,7 +1193,7 @@ static char *get_string(char **to_ptr, char **from_ptr, if (*from != ' ' && *from) die("Wrong string argument in %s\n", q->query); - while (isspace(*from)) /* Point to next string */ + while (my_isspace(system_charset_info,*from)) /* Point to next string */ from++; *to =0; /* End of string marker */ @@ -1250,8 +1250,8 @@ static void get_replace(struct st_query *q) insert_pointer_name(&to_array,to); } for (i=1,pos=word_end_chars ; i < 256 ; i++) - if (isspace(i)) - *pos++=i; + if (my_isspace(system_charset_info,i)) + *pos++= i; *pos=0; /* End pointer */ if (!(glob_replace=init_replace((char**) from_array.typelib.type_names, (char**) to_array.typelib.type_names, @@ -1287,7 +1287,7 @@ int select_connection(char *p) if (!*p) die("Missing connection name in connect\n"); name = p; - while (*p && !isspace(*p)) + while (*p && !my_isspace(system_charset_info,*p)) p++; *p = 0; @@ -1313,7 +1313,7 @@ int close_connection(struct st_query* q) if (!*p) die("Missing connection name in connect\n"); name = p; - while (*p && !isspace(*p)) + while (*p && !my_isspace(system_charset_info,*p)) p++; *p = 0; @@ -1349,11 +1349,13 @@ int close_connection(struct st_query* q) char* safe_get_param(char* str, char** arg, const char* msg) { DBUG_ENTER("safe_get_param"); - while (*str && isspace(*str)) str++; + while (*str && my_isspace(system_charset_info,*str)) + str++; *arg = str; for (; *str && *str != ',' && *str != ')' ; str++) { - if (isspace(*str)) *str = 0; + if (my_isspace(system_charset_info,*str)) + *str = 0; } if (!*str) die(msg); @@ -1635,7 +1637,7 @@ int read_line(char* buf, int size) { state = R_COMMENT; } - else if (isspace(c)) + else if (my_isspace(system_charset_info,c)) { if (c == '\n') start_lineno= ++*lineno; /* Query hasn't started yet */ @@ -1761,7 +1763,7 @@ int read_query(struct st_query** q_ptr) { expected_errno = 0; p++; - for (;isdigit(*p);p++) + for (;my_isdigit(system_charset_info,*p);p++) expected_errno = expected_errno * 10 + *p - '0'; q->expected_errno[0] = expected_errno; q->expected_errno[1] = 0; @@ -1769,25 +1771,28 @@ int read_query(struct st_query** q_ptr) } } - while (*p && isspace(*p)) p++ ; + while (*p && my_isspace(system_charset_info,*p)) + p++ ; if (*p == '@') { p++; p1 = q->record_file; - while (!isspace(*p) && + while (!my_isspace(system_charset_info,*p) && p1 < q->record_file + sizeof(q->record_file) - 1) *p1++ = *p++; *p1 = 0; } } - while (*p && isspace(*p)) p++; + while (*p && my_isspace(system_charset_info,*p)) + p++; if (!(q->query_buf=q->query=my_strdup(p,MYF(MY_WME)))) die(NullS); /* Calculate first word and first argument */ - for (p=q->query; *p && !isspace(*p) ; p++) ; + for (p=q->query; *p && !my_isspace(system_charset_info,*p) ; p++) ; q->first_word_len = (uint) (p - q->query); - while (*p && isspace(*p)) p++; + while (*p && my_isspace(system_charset_info,*p)) + p++; q->first_argument=p; q->end = strend(q->query); parser.read_lines++; @@ -2028,6 +2033,36 @@ static void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val, dynstr_append_mem(ds, val, len); } +/* + Append all results to the dynamic string separated with '\t' +*/ + +static void append_result(DYNAMIC_STRING *ds, MYSQL_RES *res) +{ + MYSQL_ROW row; + int num_fields= mysql_num_fields(res); + unsigned long *lengths; + while ((row = mysql_fetch_row(res))) + { + int i; + lengths = mysql_fetch_lengths(res); + for (i = 0; i < num_fields; i++) + { + const char *val= row[i]; + ulonglong len= lengths[i]; + if (!val) + { + val = "NULL"; + len = 4; + } + if (i) + dynstr_append_mem(ds, "\t", 1); + replace_dynstr_append_mem(ds, val, len); + } + dynstr_append_mem(ds, "\n", 1); + } +} + /* * flags control the phased/stages of query execution to be performed @@ -2038,12 +2073,7 @@ static void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val, int run_query(MYSQL* mysql, struct st_query* q, int flags) { MYSQL_RES* res = 0; - MYSQL_FIELD* fields; - MYSQL_ROW row; - int num_fields,i, error = 0; - unsigned long* lengths; - char* val; - int len; + int i, error = 0; DYNAMIC_STRING *ds; DYNAMIC_STRING ds_tmp; DYNAMIC_STRING eval_query; @@ -2152,45 +2182,37 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags) goto end; } - if (!res) - goto end; - - if (!disable_result_log) + if (!disable_result_log && res) { - fields = mysql_fetch_fields(res); - num_fields = mysql_num_fields(res); + int num_fields= mysql_num_fields(res); + MYSQL_FIELD *fields= mysql_fetch_fields(res); for (i = 0; i < num_fields; i++) { if (i) dynstr_append_mem(ds, "\t", 1); dynstr_append(ds, fields[i].name); } - dynstr_append_mem(ds, "\n", 1); + append_result(ds, res); + } - while ((row = mysql_fetch_row(res))) + /* Add all warnings to the result */ + if (!disable_result_log && mysql_warning_count(mysql)) + { + MYSQL_RES *warn_res= mysql_warnings(mysql); + if (!warn_res) + verbose_msg("Warning count is %d but didn't get any warnings\n", + mysql_warning_count(mysql)); + else { - lengths = mysql_fetch_lengths(res); - for (i = 0; i < num_fields; i++) - { - val = (char*)row[i]; - len = lengths[i]; - - if (!val) - { - val = (char*)"NULL"; - len = 4; - } - - if (i) - dynstr_append_mem(ds, "\t", 1); - replace_dynstr_append_mem(ds, val, len); - } - dynstr_append_mem(ds, "\n", 1); + dynstr_append_mem(ds, "Warnings:\n", 10); + append_result(ds, warn_res); + mysql_free_result(warn_res); } - if (glob_replace) - free_replace(); } + if (glob_replace) + free_replace(); + if (record) { if (!q->record_file[0] && !result_file) @@ -2301,7 +2323,8 @@ static void var_from_env(const char* name, const char* def_val) static void init_var_hash() { VAR* v; - if (hash_init(&var_hash, 1024, 0, 0, get_var_key, var_free, MYF(0))) + if (hash_init(&var_hash, system_charset_info, + 1024, 0, 0, get_var_key, var_free, MYF(0))) die("Variable hash initialization failed"); var_from_env("MASTER_MYPORT", "9306"); var_from_env("SLAVE_MYPORT", "9307"); |