diff options
author | Michael Widenius <monty@askmonty.org> | 2011-05-18 00:47:56 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-05-18 00:47:56 +0300 |
commit | 0da2df248ba5915630d04e7b7335bea409670cd6 (patch) | |
tree | 41d4764eac2461a949ddae44677bc8f484a45d8e /sql | |
parent | 3565a470bfecd49622df4a07ca051434f05230e8 (diff) | |
download | mariadb-git-0da2df248ba5915630d04e7b7335bea409670cd6.tar.gz |
Removed some alias warnings
Fixed alias bug when compiling with gcc 4.2.4 that caused subselect.test to fail
sql/item.cc:
Removed alias warnings by changing type from char * to const char*
sql/item.h:
Removed alias warnings by changing type from char * to const char*
sql/item_subselect.cc:
Fixed alias bug when compiling with gcc 4.2.4 that caused subselect.test to fail
sql/sql_string.h:
Removed alias warnings by changing type from char * to const char*
storage/heap/hp_test2.c:
Removed SAFEMALLOC to get rid of compiler error
Fixed test case as we can't anymore use heap_rlast() on a HASH key entry.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.cc | 26 | ||||
-rw-r--r-- | sql/item.h | 6 | ||||
-rw-r--r-- | sql/item_subselect.cc | 11 | ||||
-rw-r--r-- | sql/sql_string.h | 5 |
4 files changed, 30 insertions, 18 deletions
diff --git a/sql/item.cc b/sql/item.cc index ab13761167b..6ef1879b31e 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2608,18 +2608,19 @@ void Item_string::print(String *str, enum_query_type query_type) double -double_from_string_with_check (CHARSET_INFO *cs, const char *cptr, char *end) +double_from_string_with_check(CHARSET_INFO *cs, const char *cptr, + const char *end) { int error; - char *org_end; + char *end_of_num= (char*) end; double tmp; - org_end= end; - tmp= my_strntod(cs, (char*) cptr, end - cptr, &end, &error); - if (error || (end != org_end && !check_if_only_end_space(cs, end, org_end))) + tmp= my_strntod(cs, (char*) cptr, end - cptr, &end_of_num, &error); + if (error || (end != end_of_num && + !check_if_only_end_space(cs, end_of_num, end))) { char buff[80]; - strmake(buff, cptr, min(sizeof(buff)-1, (size_t) (org_end-cptr))); + strmake(buff, cptr, min(sizeof(buff)-1, (size_t) (end-cptr))); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_TRUNCATED_WRONG_VALUE, ER(ER_TRUNCATED_WRONG_VALUE), "DOUBLE", @@ -2634,26 +2635,27 @@ double Item_string::val_real() DBUG_ASSERT(fixed == 1); return double_from_string_with_check(str_value.charset(), str_value.ptr(), - (char *) str_value.ptr() + + str_value.ptr() + str_value.length()); } longlong -longlong_from_string_with_check (CHARSET_INFO *cs, const char *cptr, char *end) +longlong_from_string_with_check(CHARSET_INFO *cs, const char *cptr, + const char *end) { int err; longlong tmp; - char *org_end= end; + char *end_of_num= (char*) end; - tmp= (*(cs->cset->strtoll10))(cs, cptr, &end, &err); + tmp= (*(cs->cset->strtoll10))(cs, cptr, &end_of_num, &err); /* TODO: Give error if we wanted a signed integer and we got an unsigned one */ if (!current_thd->no_errors && (err > 0 || - (end != org_end && !check_if_only_end_space(cs, end, org_end)))) + (end != end_of_num && !check_if_only_end_space(cs, end_of_num, end)))) { push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_TRUNCATED_WRONG_VALUE, @@ -2672,7 +2674,7 @@ longlong Item_string::val_int() { DBUG_ASSERT(fixed == 1); return longlong_from_string_with_check(str_value.charset(), str_value.ptr(), - (char *) str_value.ptr()+ str_value.length()); + str_value.ptr()+ str_value.length()); } diff --git a/sql/item.h b/sql/item.h index 404004971a7..2a6d944147a 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2289,9 +2289,11 @@ private: longlong -longlong_from_string_with_check (CHARSET_INFO *cs, const char *cptr, char *end); +longlong_from_string_with_check(CHARSET_INFO *cs, const char *cptr, + const char *end); double -double_from_string_with_check (CHARSET_INFO *cs, const char *cptr, char *end); +double_from_string_with_check(CHARSET_INFO *cs, const char *cptr, + const char *end); class Item_static_string_func :public Item_string { diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 52d9407a7ac..c217d84ade3 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -82,7 +82,6 @@ void Item_subselect::init(st_select_lex *select_lex, else { SELECT_LEX *outer_select= unit->outer_select(); - DBUG_ASSERT(thd); /* do not take into account expression inside aggregate functions because they can access original table fields @@ -3563,7 +3562,15 @@ subselect_single_select_engine::change_result(Item_subselect *si, } else result= res; - return select_lex->join->change_result(result); + + /* + We can't use 'result' below as gcc 4.2.4's alias optimization + assumes that result was not changed by thd->change_item_tree(). + I tried to find a solution to make gcc happy, but could not find anything + that would not require a lot of extra code that would be harder to manage + than the current code. + */ + return select_lex->join->change_result(res); } diff --git a/sql/sql_string.h b/sql/sql_string.h index 92a896c1cae..e4cce7b5527 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -457,8 +457,9 @@ public: } }; -static inline bool check_if_only_end_space(CHARSET_INFO *cs, char *str, - char *end) +static inline bool check_if_only_end_space(CHARSET_INFO *cs, + const char *str, + const char *end) { return str+ cs->cset->scan(cs, str, end, MY_SEQ_SPACES) == end; } |