summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/item_cmpfunc.cc14
-rw-r--r--sql/item_cmpfunc.h6
-rw-r--r--sql/item_func.cc2
-rw-r--r--sql/item_timefunc.h1
-rw-r--r--sql/my_decimal.cc2
-rw-r--r--sql/mysql_priv.h4
6 files changed, 15 insertions, 14 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 3fd925c1182..c5de0b3df08 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -810,11 +810,11 @@ Arg_comparator::can_compare_as_dates(Item *a, Item *b, ulonglong *const_value)
obtained value
*/
-ulonglong
+longlong
get_time_value(THD *thd, Item ***item_arg, Item **cache_arg,
Item *warn_item, bool *is_null)
{
- ulonglong value;
+ longlong value;
Item *item= **item_arg;
MYSQL_TIME ltime;
@@ -826,7 +826,7 @@ get_time_value(THD *thd, Item ***item_arg, Item **cache_arg,
else
{
*is_null= item->get_time(&ltime);
- value= !*is_null ? TIME_to_ulonglong_datetime(&ltime) : 0;
+ value= !*is_null ? (longlong) TIME_to_ulonglong_datetime(&ltime) : 0;
}
/*
Do not cache GET_USER_VAR() function as its const_item() may return TRUE
@@ -951,11 +951,11 @@ void Arg_comparator::set_datetime_cmp_func(Item **a1, Item **b1)
obtained value
*/
-ulonglong
+longlong
get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
Item *warn_item, bool *is_null)
{
- ulonglong value= 0;
+ longlong value= 0;
String buf, *str= 0;
Item *item= **item_arg;
@@ -993,7 +993,7 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
enum_field_types f_type= warn_item->field_type();
timestamp_type t_type= f_type ==
MYSQL_TYPE_DATE ? MYSQL_TIMESTAMP_DATE : MYSQL_TIMESTAMP_DATETIME;
- value= get_date_from_str(thd, str, t_type, warn_item->name, &error);
+ value= (longlong) get_date_from_str(thd, str, t_type, warn_item->name, &error);
/*
If str did not contain a valid date according to the current
SQL_MODE, get_date_from_str() has already thrown a warning,
@@ -1047,7 +1047,7 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
int Arg_comparator::compare_datetime()
{
bool a_is_null, b_is_null;
- ulonglong a_value, b_value;
+ longlong a_value, b_value;
/* Get DATE/DATETIME/TIME value of the 'a' item. */
a_value= (*get_value_func)(thd, &a, &a_cache, *b, &a_is_null);
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 2bf39e6da8d..c2227fa04e0 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -42,8 +42,8 @@ class Arg_comparator: public Sql_alloc
bool is_nulls_eq; // TRUE <=> compare for the EQUAL_FUNC
enum enum_date_cmp_type { CMP_DATE_DFLT= 0, CMP_DATE_WITH_DATE,
CMP_DATE_WITH_STR, CMP_STR_WITH_DATE };
- ulonglong (*get_value_func)(THD *thd, Item ***item_arg, Item **cache_arg,
- Item *warn_item, bool *is_null);
+ longlong (*get_value_func)(THD *thd, Item ***item_arg, Item **cache_arg,
+ Item *warn_item, bool *is_null);
public:
DTCollation cmp_collation;
@@ -1012,7 +1012,7 @@ public:
*/
class cmp_item_datetime :public cmp_item
{
- ulonglong value;
+ longlong value;
public:
THD *thd;
/* Item used for issuing warnings. */
diff --git a/sql/item_func.cc b/sql/item_func.cc
index e117adc3cd0..32768d09e96 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2267,7 +2267,7 @@ uint Item_func_min_max::cmp_datetimes(ulonglong *value)
{
Item **arg= args + i;
bool is_null;
- ulonglong res= get_datetime_value(thd, &arg, 0, datetime_item, &is_null);
+ longlong res= get_datetime_value(thd, &arg, 0, datetime_item, &is_null);
if ((null_value= args[i]->null_value))
return 0;
if (i == 0 || (res < min_max ? cmp_sign : -cmp_sign) > 0)
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index cfcf5fab080..99240b1c759 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -429,6 +429,7 @@ public:
{
return save_time_in_field(field);
}
+ bool result_as_longlong() { return TRUE; }
};
diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc
index 651ff22d198..208ddefb890 100644
--- a/sql/my_decimal.cc
+++ b/sql/my_decimal.cc
@@ -214,7 +214,7 @@ my_decimal *date2my_decimal(MYSQL_TIME *ltime, my_decimal *dec)
date = (ltime->year*100L + ltime->month)*100L + ltime->day;
if (ltime->time_type > MYSQL_TIMESTAMP_DATE)
date= ((date*100L + ltime->hour)*100L+ ltime->minute)*100L + ltime->second;
- if (int2my_decimal(E_DEC_FATAL_ERROR, date, FALSE, dec))
+ if (int2my_decimal(E_DEC_FATAL_ERROR, ltime->neg ? -date : date, FALSE, dec))
return dec;
if (ltime->second_part)
{
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index d11f2838e3a..0e257eef149 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -2174,8 +2174,8 @@ void make_date(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
void make_time(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
String *str);
int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b);
-ulonglong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
- Item *warn_item, bool *is_null);
+longlong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
+ Item *warn_item, bool *is_null);
int test_if_number(char *str,int *res,bool allow_wildcards);
void change_byte(uchar *,uint,char,char);