From 31cffb8a7f8e21659d11d1b6cad8af5c0577323a Mon Sep 17 00:00:00 2001 From: unknown <kent@mysql.com> Date: Fri, 20 May 2005 15:17:13 +0200 Subject: [PATCH] my_vsnprintf.c, sql_select.cc, sql_delete.cc, field_conv.cc, rt_split.c: Fixes for valgrind errors and compatiblity issues by Monty myisam/rt_split.c: Fixes for valgrind errors and compatiblity issues by Monty sql/field_conv.cc: Fixes for valgrind errors and compatiblity issues by Monty sql/sql_delete.cc: Fixes for valgrind errors and compatiblity issues by Monty sql/sql_select.cc: Fixes for valgrind errors and compatiblity issues by Monty strings/my_vsnprintf.c: Fixes for valgrind errors and compatiblity issues by Monty --- myisam/rt_split.c | 17 ++++++++--------- sql/field_conv.cc | 6 +++++- sql/sql_delete.cc | 2 +- sql/sql_select.cc | 4 ++-- strings/my_vsnprintf.c | 10 ++++++++++ 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/myisam/rt_split.c b/myisam/rt_split.c index 005e86805b..7dc8576cad 100644 --- a/myisam/rt_split.c +++ b/myisam/rt_split.c @@ -257,18 +257,17 @@ int rtree_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uchar *key, int n_dim; uchar *source_cur, *cur1, *cur2; uchar *new_page; - int err_code = 0; - - uint nod_flag = mi_test_if_nod(page); - uint full_length = key_length + (nod_flag ? nod_flag : - info->s->base.rec_reflength); - - int max_keys = (mi_getint(page)-2) / (full_length); + int err_code= 0; + uint nod_flag= mi_test_if_nod(page); + uint full_length= key_length + (nod_flag ? nod_flag : + info->s->base.rec_reflength); + int max_keys= (mi_getint(page)-2) / (full_length); n_dim = keyinfo->keysegs / 2; - if (!(coord_buf= my_alloca(n_dim * 2 * sizeof(double) * (max_keys + 1 + 4) + - sizeof(SplitStruct) * (max_keys + 1)))) + if (!(coord_buf= (double*) my_alloca(n_dim * 2 * sizeof(double) * + (max_keys + 1 + 4) + + sizeof(SplitStruct) * (max_keys + 1)))) return -1; task= (SplitStruct *)(coord_buf + n_dim * 2 * (max_keys + 1 + 4)); diff --git a/sql/field_conv.cc b/sql/field_conv.cc index ae784ae029..15598e59bb 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -605,7 +605,11 @@ void field_conv(Field *to,Field *from) to->type() != FIELD_TYPE_DATE && to->type() != FIELD_TYPE_DATETIME)) { // Identical fields - memcpy(to->ptr,from->ptr,to->pack_length()); +#ifdef HAVE_purify + /* This may happen if one does 'UPDATE ... SET x=x' */ + if (to->ptr != from->ptr) +#endif + memcpy(to->ptr,from->ptr,to->pack_length()); return; } } diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index cded9e2a13..ca7bf174ab 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -48,7 +48,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, { my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0), table_list->view_db.str, table_list->view_name.str); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); thd->proc_info="init"; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9937327641..71414f8cc7 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -12655,8 +12655,10 @@ static bool setup_sum_funcs(THD *thd, Item_sum **func_ptr) Item_sum *func; DBUG_ENTER("setup_sum_funcs"); while ((func= *(func_ptr++))) + { if (func->setup(thd)) DBUG_RETURN(TRUE); + } DBUG_RETURN(FALSE); } @@ -12943,8 +12945,6 @@ bool JOIN::rollup_make_fields(List<Item> &fields_arg, List<Item> &sel_fields, */ item= item->copy_or_same(thd); ((Item_sum*) item)->make_unique(); - if (((Item_sum*) item)->setup(thd)) - return 1; *(*func)= (Item_sum*) item; (*func)++; } diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c index 4d7c17e977..935cc2d380 100644 --- a/strings/my_vsnprintf.c +++ b/strings/my_vsnprintf.c @@ -135,6 +135,16 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) to+= res_length; continue; } + else if (*fmt == 'c') /* Character parameter */ + { + register int larg; + if (to == end) + break; + larg = va_arg(ap, int); + *to++= (char) larg; + continue; + } + /* We come here on '%%', unknown code or too long parameter */ if (to == end) break; -- 2.30.9