diff options
author | Bjorn Munch <bjorn.munch@oracle.com> | 2010-12-09 20:32:47 +0100 |
---|---|---|
committer | Bjorn Munch <bjorn.munch@oracle.com> | 2010-12-09 20:32:47 +0100 |
commit | 50d1f9f36830dc4f52a8db283dafc2753d1e6b01 (patch) | |
tree | ae0d05766d5dbcce0e57d4524de1d2195519bf53 /client | |
parent | 0137e02899949d714723c537ed23b51e7f5b1a75 (diff) | |
parent | 100882710733dc355805e22234c56914ad86add2 (diff) | |
download | mariadb-git-50d1f9f36830dc4f52a8db283dafc2753d1e6b01.tar.gz |
merge from 5.1-mtr
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqltest.cc | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc index e0575a1d638..0764020fc92 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -73,6 +73,10 @@ #define QUERY_SEND_FLAG 1 #define QUERY_REAP_FLAG 2 +#ifndef HAVE_SETENV +static int setenv(const char *name, const char *value, int overwrite); +#endif + enum { OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION, OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL, @@ -219,7 +223,6 @@ typedef struct int alloced_len; int int_dirty; /* do not update string if int is updated until first read */ int alloced; - char *env_s; } VAR; /*Perl/shell-like variable registers */ @@ -1088,8 +1091,8 @@ void handle_command_error(struct st_command *command, uint error) int i; if (command->abort_on_error) - die("command \"%.*s\" failed with error %d", - command->first_word_len, command->query, error); + die("command \"%.*s\" failed with error %d. my_errno=%d", + command->first_word_len, command->query, error, my_errno); i= match_expected_error(command, error, NULL); @@ -1100,8 +1103,8 @@ void handle_command_error(struct st_command *command, uint error) DBUG_VOID_RETURN; } if (command->expected_errors.count > 0) - die("command \"%.*s\" failed with wrong error: %d", - command->first_word_len, command->query, error); + die("command \"%.*s\" failed with wrong error: %d. my_errno=%d", + command->first_word_len, command->query, error, my_errno); } else if (command->expected_errors.err[0].type == ERR_ERRNO && command->expected_errors.err[0].code.errnum != 0) @@ -1962,7 +1965,7 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val, val_len = strlen(val) ; val_alloc_len = val_len + 16; /* room to grow */ if (!(tmp_var=v) && !(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var) - + name_len+1, MYF(MY_WME)))) + + name_len+2, MYF(MY_WME)))) die("Out of memory"); tmp_var->name = (name) ? (char*) tmp_var + sizeof(*tmp_var) : 0; @@ -1971,7 +1974,12 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val, if (!(tmp_var->str_val = (char*)my_malloc(val_alloc_len+1, MYF(MY_WME)))) die("Out of memory"); - memcpy(tmp_var->name, name, name_len); + if (name) + { + memcpy(tmp_var->name, name, name_len); + tmp_var->name[name_len]= 0; + } + if (val) { memcpy(tmp_var->str_val, val, val_len); @@ -1982,7 +1990,6 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val, tmp_var->alloced_len = val_alloc_len; tmp_var->int_val = (val) ? atoi(val) : 0; tmp_var->int_dirty = 0; - tmp_var->env_s = 0; return tmp_var; } @@ -2110,20 +2117,15 @@ void var_set(const char *var_name, const char *var_name_end, if (env_var) { - char buf[1024], *old_env_s= v->env_s; if (v->int_dirty) { sprintf(v->str_val, "%d", v->int_val); v->int_dirty= 0; v->str_val_len= strlen(v->str_val); } - my_snprintf(buf, sizeof(buf), "%.*s=%.*s", - v->name_len, v->name, - v->str_val_len, v->str_val); - if (!(v->env_s= my_strdup(buf, MYF(MY_WME)))) - die("Out of memory"); - putenv(v->env_s); - my_free(old_env_s, MYF(MY_ALLOW_ZERO_PTR)); + /* setenv() expects \0-terminated strings */ + DBUG_ASSERT(v->name[v->name_len] == 0); + setenv(v->name, v->str_val, 1); } DBUG_VOID_RETURN; } @@ -7644,6 +7646,16 @@ void init_re(void) int match_re(my_regex_t *re, char *str) { + while (my_isspace(charset_info, *str)) + str++; + if (str[0] == '/' && str[1] == '*') + { + char *comm_end= strstr (str, "*/"); + if (! comm_end) + die("Statement is unterminated comment"); + str= comm_end + 2; + } + int err= my_regexec(re, str, (size_t)0, NULL, 0); if (err == 0) @@ -9908,3 +9920,18 @@ void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING *ds_input) delete_dynamic(&lines); DBUG_VOID_RETURN; } + +#ifndef HAVE_SETENV +static int setenv(const char *name, const char *value, int overwrite) +{ + size_t buflen= strlen(name) + strlen(value) + 2; + char *envvar= (char *)malloc(buflen); + if(!envvar) + return ENOMEM; + strcpy(envvar, name); + strcat(envvar, "="); + strcat(envvar, value); + putenv(envvar); + return 0; +} +#endif |