summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authormonty@narttu.mysql.fi <>2003-11-04 14:09:03 +0200
committermonty@narttu.mysql.fi <>2003-11-04 14:09:03 +0200
commitf763d4c31d0c6aa4496c6682e4e329a19384606e (patch)
tree07ce6a4f792ac489b079759afb3cc65847ca0cb0 /sql
parent4e4725377d27ff0101788fd7ed89670614ed8294 (diff)
downloadmariadb-git-f763d4c31d0c6aa4496c6682e4e329a19384606e.tar.gz
Removed some warnings reported by valgrind
After merge fixes. Now code compiles, but there is still some valgrind warnings that needs to be fixed
Diffstat (limited to 'sql')
-rw-r--r--sql/item_strfunc.cc38
-rw-r--r--sql/log_event.cc4
-rw-r--r--sql/protocol.cc2
-rw-r--r--sql/spatial.cc1
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/time.cc20
-rw-r--r--sql/unireg.cc1
7 files changed, 38 insertions, 30 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 310faae8380..5579c0f0bea 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -2645,46 +2645,46 @@ String *Item_func_compress::val_str(String *str)
}
buffer.length((uint32)new_size + 4);
-
return &buffer;
}
+
String *Item_func_uncompress::val_str(String *str)
{
String *res= args[0]->val_str(str);
- if (!res)
- {
- null_value= 1;
- return 0;
- }
- if (res->is_empty()) return res;
-
- ulong new_size= uint4korr(res->c_ptr()) & 0x3FFFFFFF;
- int err= Z_OK;
+ ulong new_size;
+ int err;
uint code;
+ if (!res)
+ goto err;
+ if (res->is_empty())
+ return res;
+
+ new_size= uint4korr(res->ptr()) & 0x3FFFFFFF;
if (new_size > current_thd->variables.max_allowed_packet)
{
push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_TOO_BIG_FOR_UNCOMPRESS,
ER(ER_TOO_BIG_FOR_UNCOMPRESS),
current_thd->variables.max_allowed_packet);
- null_value= 0;
- return 0;
+ goto err;
}
+ if (buffer.realloc((uint32)new_size))
+ goto err;
- buffer.realloc((uint32)new_size);
-
- if ((err= uncompress((Byte*)buffer.c_ptr(), &new_size,
- ((const Bytef*)res->c_ptr())+4,res->length())) == Z_OK)
+ if ((err= uncompress((Byte*)buffer.ptr(), &new_size,
+ ((const Bytef*)res->ptr())+4,res->length())) == Z_OK)
{
- buffer.length((uint32)new_size);
+ buffer.length((uint32) new_size);
return &buffer;
}
- code= err==Z_BUF_ERROR ? ER_ZLIB_Z_BUF_ERROR :
- err==Z_MEM_ERROR ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_DATA_ERROR;
+ code= ((err == Z_BUF_ERROR) ? ER_ZLIB_Z_BUF_ERROR :
+ ((err == Z_MEM_ERROR) ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_DATA_ERROR));
push_warning(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR,code,ER(code));
+
+err:
null_value= 1;
return 0;
}
diff --git a/sql/log_event.cc b/sql/log_event.cc
index c0fd781cede..d0dc0a83b11 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -835,7 +835,7 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
error_code(thd_arg->killed ? ER_SERVER_SHUTDOWN: thd_arg->net.last_errno),
thread_id(thd_arg->thread_id),
/* save the original thread id; we already know the server id */
- slave_proxy_id(thd_arg->slave_proxy_id)
+ slave_proxy_id(thd_arg->variables.pseudo_thread_id)
{
time_t end_time;
time(&end_time);
@@ -1357,7 +1357,7 @@ Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex,
enum enum_duplicates handle_dup,
bool using_trans)
:Log_event(thd_arg, 0, using_trans), thread_id(thd_arg->thread_id),
- slave_proxy_id(thd_arg->slave_proxy_id),
+ slave_proxy_id(thd_arg->variables.pseudo_thread_id),
num_fields(0),fields(0),
field_lens(0),field_block_len(0),
table_name(table_name_arg ? table_name_arg : ""),
diff --git a/sql/protocol.cc b/sql/protocol.cc
index d7a745d371d..8ba3cdec8e0 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -496,7 +496,7 @@ bool Protocol::send_fields(List<Item> *list, uint flag)
if (thd->client_capabilities & CLIENT_PROTOCOL_41)
{
- if (prot.store("std", 3, cs, thd_charset) ||
+ if (prot.store("def", 3, cs, thd_charset) ||
prot.store(field.db_name, (uint) strlen(field.db_name),
cs, thd_charset) ||
prot.store(field.table_name, (uint) strlen(field.table_name),
diff --git a/sql/spatial.cc b/sql/spatial.cc
index 00db94a07d6..d19429fdd9c 100644
--- a/sql/spatial.cc
+++ b/sql/spatial.cc
@@ -1258,6 +1258,7 @@ int GMultiPolygon::geometry_n(uint32 num, String *result) const
uint32 n_polygons;
const char *data= m_data, *polygon_n;
LINT_INIT(polygon_n);
+
if (no_data(data, 4))
return 1;
n_polygons= uint4korr(data);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 6b43c2f796e..4fcd6504a2f 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -400,7 +400,7 @@ bool THD::store_globals()
By default 'slave_proxy_id' is 'thread_id'. They may later become different
if this is the slave SQL thread.
*/
- slave_proxy_id= thread_id;
+ variables.pseudo_thread_id= thread_id;
return 0;
}
diff --git a/sql/time.cc b/sql/time.cc
index 4f2a2a23910..3fa00fc683b 100644
--- a/sql/time.cc
+++ b/sql/time.cc
@@ -335,10 +335,12 @@ static char time_separator=':';
RETURN VALUES
TIMESTAMP_NONE String wasn't a timestamp, like
- [DD [HH:[MM:[SS]]]].fraction
+ [DD [HH:[MM:[SS]]]].fraction.
+ l_time is not changed.
TIMESTAMP_DATE DATE string (YY MM and DD parts ok)
- TIMESTAMP_DATETIME Full timestamp
- TIMESTAMP_DATETIME_ERROR Timestamp with wrong values
+ TIMESTAMP_DATETIME Full timestamp
+ TIMESTAMP_DATETIME_ERROR Timestamp with wrong values.
+ All elements in l_time is set to 0
*/
#define MAX_DATE_PARTS 8
@@ -409,9 +411,9 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags)
if (pos == end)
{
if (flags & TIME_DATETIME_ONLY)
- return TIMESTAMP_NONE; // Can't be a full datetime
+ DBUG_RETURN(TIMESTAMP_NONE); // Can't be a full datetime
/* Date field. Set hour, minutes and seconds to 0 */
- date[0]= date[1]= date[2]= date[3]= 0;
+ date[0]= date[1]= date[2]= date[3]= date[4]= 0;
start_loop= 5; // Start with first date part
}
}
@@ -535,7 +537,7 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags)
if (format_position[7] != (uchar) 255)
{
if (l_time->hour > 12)
- DBUG_RETURN(TIMESTAMP_DATETIME_ERROR);
+ goto err;
l_time->hour= l_time->hour%12 + add_hours;
}
}
@@ -574,7 +576,7 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags)
}
if (not_zero_date)
current_thd->cuted_fields++;
- DBUG_RETURN(TIMESTAMP_DATETIME_ERROR);
+ goto err;
}
if (str != end && current_thd->count_cuted_fields)
{
@@ -590,6 +592,10 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags)
DBUG_RETURN(l_time->time_type=
(number_of_fields <= 3 ? TIMESTAMP_DATE : TIMESTAMP_DATETIME));
+
+err:
+ bzero((char*) l_time, sizeof(*l_time));
+ DBUG_RETURN(TIMESTAMP_DATETIME_ERROR);
}
diff --git a/sql/unireg.cc b/sql/unireg.cc
index e93e290bd4c..fc948ddd5a6 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -305,6 +305,7 @@ static uint pack_keys(uchar *keybuff,uint key_count,KEY *keyinfo)
{
keybuff[0]=(uchar) key_count;
keybuff[1]=(uchar) key_parts;
+ keybuff[2]= keybuff[3]= 0;
}
length=(uint) (pos-keyname_pos);
int2store(keybuff+4,length);