summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc23
-rw-r--r--sql/item.h9
-rw-r--r--sql/item_sum.h8
-rw-r--r--sql/item_timefunc.cc2
4 files changed, 32 insertions, 10 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 2dabb8e26ef..11a9e88bdd6 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -503,6 +503,22 @@ Item *Item_field::get_tmp_table_item(THD *thd)
}
+/*
+ Create an item from a string we KNOW points to a valid longlong/ulonglong
+ end \0 terminated number string
+*/
+
+Item_int::Item_int(const char *str_arg, uint length)
+{
+ char *end_ptr= (char*) str_arg + length;
+ int error;
+ value= my_strtoll10(str_arg, &end_ptr, &error);
+ max_length= (uint) (end_ptr - str_arg);
+ name= (char*) str_arg;
+ fixed= 1;
+}
+
+
String *Item_int::val_str(String *str)
{
// following assert is redundant, because fixed=1 assigned in constructor
@@ -519,6 +535,13 @@ void Item_int::print(String *str)
}
+Item_uint::Item_uint(const char *str_arg, uint length):
+ Item_int(str_arg, length)
+{
+ unsigned_flag= 1;
+}
+
+
String *Item_uint::val_str(String *str)
{
// following assert is redundant, because fixed=1 assigned in constructor
diff --git a/sql/item.h b/sql/item.h
index 780e2fcadac..99a0516e439 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -456,10 +456,7 @@ public:
#endif
Item_int(const char *str_arg,longlong i,uint length) :value(i)
{ max_length=length; name=(char*) str_arg; fixed= 1; }
- Item_int(const char *str_arg) :
- value(str_arg[0] == '-' ? strtoll(str_arg,(char**) 0,10) :
- (longlong) strtoull(str_arg,(char**) 0,10))
- { max_length= (uint) strlen(str_arg); name=(char*) str_arg; fixed= 1; }
+ Item_int(const char *str_arg, uint length=64);
enum Type type() const { return INT_ITEM; }
enum Item_result result_type () const { return INT_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
@@ -479,9 +476,7 @@ public:
class Item_uint :public Item_int
{
public:
- Item_uint(const char *str_arg, uint length) :
- Item_int(str_arg, (longlong) strtoull(str_arg, (char**) 0,10), length)
- { unsigned_flag= 1; }
+ Item_uint(const char *str_arg, uint length);
Item_uint(uint32 i) :Item_int((longlong) i, 10)
{ unsigned_flag= 1; }
double val()
diff --git a/sql/item_sum.h b/sql/item_sum.h
index d7753303f55..4cded41a9f6 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -735,8 +735,12 @@ class Item_func_group_concat : public Item_sum
}
longlong val_int()
{
- String *res; res=val_str(&str_value);
- return res ? strtoll(res->c_ptr(),(char**) 0,10) : (longlong) 0;
+ String *res;
+ char *end_ptr;
+ int error;
+ res= val_str(&str_value);
+ end_ptr= (char*) res->ptr()+ res->length();
+ return res ? my_strtoll10(res->ptr(), &end_ptr, &error) : (longlong) 0;
}
String* val_str(String* str);
Item *copy_or_same(THD* thd);
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 0c0b5265db7..e8848243812 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -1666,7 +1666,7 @@ bool Item_date_add_interval::get_date(TIME *ltime, uint fuzzy_date)
days--;
sec+= 3600*LL(24);
}
- ltime->second_part= microseconds;
+ ltime->second_part= (uint) microseconds;
ltime->second= (uint) (sec % 60);
ltime->minute= (uint) (sec/60 % 60);
ltime->hour= (uint) (sec/3600);