Commit 0da2df24 authored by Michael Widenius's avatar Michael Widenius

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.
parent 3565a470
......@@ -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());
}
......
......@@ -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
{
......
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -21,9 +21,6 @@
#ifdef DBUG_OFF
#undef DBUG_OFF
#endif
#ifndef SAFEMALLOC
#define SAFEMALLOC
#endif
#include "heapdef.h" /* Because of hp_find_block */
#include <signal.h>
......@@ -319,7 +316,8 @@ int main(int argc, char *argv[])
if (!silent)
printf("- Read last key - delete - prev - prev - opt_delete - prev -> first\n");
if (heap_rlast(file,record3,0)) goto err;
if (heap_rprev(file,record))
goto err;
if (heap_delete(file,record3)) goto err;
key_check-=atoi((char*) record3);
key1[atoi((char*) record+keyinfo[0].seg[0].start)]--;
......@@ -526,7 +524,7 @@ int main(int argc, char *argv[])
}
ant=0;
for (error=heap_rlast(file,record,0) ;
for (error=heap_rprev(file,record) ;
! error ;
error=heap_rprev(file,record))
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment