From a4c3bc618bb83884a19dc157bc56d4e3d2432c22 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 6 Jan 2010 22:42:07 -0700 Subject: WL#2360 Performance schema Part IV: sql instrumentation --- client/client_priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client') diff --git a/client/client_priv.h b/client/client_priv.h index 97a8920f744..9cd151f6160 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -101,7 +101,7 @@ enum options_client /** First mysql version supporting the performance schema. */ -#define FIRST_PERFORMANCE_SCHEMA_VERSION 50600 +#define FIRST_PERFORMANCE_SCHEMA_VERSION 50599 /** Name of the performance schema database. -- cgit v1.2.1 From c06a305001bc89116a718cf0c12dd03b58cfe92a Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Mon, 11 Jan 2010 19:42:35 +0300 Subject: 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 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 ------------------------------------------------------------ --- client/mysqltest.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'client') 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; } -- cgit v1.2.1 From ba3b5a7eb660c7172da1cb4bf64abb9e9a2e0603 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Mon, 11 Jan 2010 19:43:55 +0300 Subject: Backporting revision from mysql-6.0-codebase-bugfixing. Original revision: ------------------------------------------------------------ revno: 3817 revision-id: guilhem@mysql.com-20100108092756-k0zzf4kvx9b7bh38 parent: guilhem@mysql.com-20100107101133-hrrgcdqg508runuf committer: Guilhem Bichot branch nick: mysql-6.0-codebase-bugfixing timestamp: Fri 2010-01-08 10:27:56 +0100 message: fix for BUG#50120 "Valgrind errors in any test, inside mysqltest" Problem was that as v->name[v->name_len] may be uninitialized (which is ok per se), it shouldn't be used in an if(). We remove this zero_the_char/restore_it logic by rather zero-terminating the v->name string when we create it in var_init(). ------------------------------------------------------------ --- client/mysqltest.cc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'client') diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 9c5e7d9f466..95255b59afa 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -1927,13 +1927,20 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val, + name_len+1, MYF(MY_WME)))) die("Out of memory"); - tmp_var->name = (name) ? (char*) tmp_var + sizeof(*tmp_var) : 0; + if (name != NULL) + { + tmp_var->name= reinterpret_cast(tmp_var) + sizeof(*tmp_var); + memcpy(tmp_var->name, name, name_len); + tmp_var->name[name_len]= 0; + } + else + tmp_var->name= NULL; + tmp_var->alloced = (v == 0); 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 (val) { memcpy(tmp_var->str_val, val, val_len); @@ -2077,12 +2084,9 @@ void var_set(const char *var_name, const char *var_name_end, v->int_dirty= 0; v->str_val_len= strlen(v->str_val); } - 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; + /* setenv() expects \0-terminated strings */ + DBUG_ASSERT(v->name[v->name_len] == 0); + setenv(v->name, v->str_val, 1); } DBUG_VOID_RETURN; } -- cgit v1.2.1