From 63b2be3c8a16fd5add3699d310df3630d9c0ec75 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Dec 2006 14:26:05 +0200 Subject: [PATCH 1/2] item_func.cc: fixed a valgrind warning type_varchar.test: fixed a valgrind warning mysql-test/t/type_varchar.test: fixed a valgrind warning sql/item_func.cc: fixed a valgrind warning --- mysql-test/t/type_varchar.test | 1 + sql/item_func.cc | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mysql-test/t/type_varchar.test b/mysql-test/t/type_varchar.test index cfb6472a7b4..7b87a388c56 100644 --- a/mysql-test/t/type_varchar.test +++ b/mysql-test/t/type_varchar.test @@ -196,3 +196,4 @@ INSERT INTO t1 VALUES (10), (50), (30), ('1a'), (60), ('t'); SELECT a,(a + 0) FROM t1 ORDER BY a; SELECT a,(a DIV 2) FROM t1 ORDER BY a; SELECT a,CAST(a AS SIGNED) FROM t1 ORDER BY a; +DROP TABLE t1; diff --git a/sql/item_func.cc b/sql/item_func.cc index 6bbb199a52b..ff1ef22d36d 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -900,7 +900,8 @@ void Item_func_signed::print(String *str) longlong Item_func_signed::val_int_from_str(int *error) { - char buff[MAX_FIELD_WIDTH], *end; + char buff[MAX_FIELD_WIDTH], *end, *start; + uint32 length; String tmp(buff,sizeof(buff), &my_charset_bin), *res; longlong value; @@ -916,13 +917,21 @@ longlong Item_func_signed::val_int_from_str(int *error) return 0; } null_value= 0; - end= (char*) res->ptr()+ res->length(); - value= my_strtoll10(res->ptr(), &end, error); - if (*error > 0 || end != res->ptr()+ res->length()) + start= (char *)res->ptr(); + length= res->length(); + + end= start + length; + value= my_strtoll10(start, &end, error); + if (*error > 0 || end != start+ length) + { + char err_buff[128]; + String err_tmp(err_buff,(uint32) sizeof(err_buff), system_charset_info); + err_tmp.copy(start, length, system_charset_info); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_TRUNCATED_WRONG_VALUE, ER(ER_TRUNCATED_WRONG_VALUE), "INTEGER", - res->c_ptr()); + err_tmp.c_ptr()); + } return value; } From 818bec7fb89cdad25357f9d657bb72150fa5f06e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Dec 2006 14:29:51 +0200 Subject: [PATCH 2/2] type_varchar.result: fixed a valgrind problem mysql-test/r/type_varchar.result: fixed a valgrind problem --- mysql-test/r/type_varchar.result | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/r/type_varchar.result b/mysql-test/r/type_varchar.result index 4c1aee24642..f6c2f4d01a6 100644 --- a/mysql-test/r/type_varchar.result +++ b/mysql-test/r/type_varchar.result @@ -488,3 +488,4 @@ t 0 Warnings: Warning 1292 Truncated incorrect INTEGER value: '1a' Warning 1292 Truncated incorrect INTEGER value: 't' +DROP TABLE t1;