summaryrefslogtreecommitdiff
path: root/client/mysqltest.cc
diff options
context:
space:
mode:
authorAlexander Nozdrin <alik@sun.com>2010-01-11 19:42:35 +0300
committerAlexander Nozdrin <alik@sun.com>2010-01-11 19:42:35 +0300
commit5d61829b29e5e7aa1d4300fa7ca39b2d1f5f03ee (patch)
tree075b8ef8beba8e92cf57b60fa10790616e99ecd6 /client/mysqltest.cc
parent724caa519d92a02760de520153261a841ee626d6 (diff)
downloadmariadb-git-5d61829b29e5e7aa1d4300fa7ca39b2d1f5f03ee.tar.gz
Backporting revision from mysql-6.0-codebase-bugfixing.
Original revision: ------------------------------------------------------------ revno: 3789.1.9 revision-id: serg@mysql.com-20091229134448-phe834ukzmi0k2e3 parent: serg@mysql.com-20091227081418-bgfg952gzumn1k3h committer: Sergei Golubchik <serg@mysql.com> branch nick: 6.0-codebase timestamp: Tue 2009-12-29 14:44:48 +0100 message: better fix for Bug#48758 mysqltest crashes on sys_vars.collation_server_basic in gcov builds use setenv instead of putenv ------------------------------------------------------------
Diffstat (limited to 'client/mysqltest.cc')
-rw-r--r--client/mysqltest.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 43107d838ee..9c5e7d9f466 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -72,6 +72,10 @@
#define QUERY_SEND_FLAG 1
#define QUERY_REAP_FLAG 2
+#ifndef HAVE_SETENV
+#error implement our portable setenv replacement in mysys
+#endif
+
enum {
OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION,
OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
@@ -216,7 +220,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 */
@@ -1941,7 +1944,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;
}
@@ -2069,20 +2071,18 @@ 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));
+ char oldc= v->name[v->name_len];
+ if (oldc)
+ v->name[v->name_len]= 0; // setenv() expects \0-terminated strings
+ setenv(v->name, v->str_val, 1); // v->str_val is always \0-terminated
+ if (oldc)
+ v->name[v->name_len]= oldc;
}
DBUG_VOID_RETURN;
}