summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-06-10 15:42:55 +0200
committerSergei Golubchik <sergii@pisem.net>2011-06-10 15:42:55 +0200
commitf1a5c49c4e9cee40d884193dd7477aff0cbffc53 (patch)
tree6d9ac661eaa5ed19834691bab35374e609f097ec /sql
parent10fedf675a1de161aec4ee09026db35400344507 (diff)
downloadmariadb-git-f1a5c49c4e9cee40d884193dd7477aff0cbffc53.tar.gz
various fixes for buildbot failures
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc17
-rw-r--r--sql/field.h2
-rw-r--r--sql/field_conv.cc8
-rw-r--r--sql/item_strfunc.cc2
-rw-r--r--sql/item_sum.cc2
-rw-r--r--sql/time.cc12
6 files changed, 16 insertions, 27 deletions
diff --git a/sql/field.cc b/sql/field.cc
index f6b30b4dee3..b424567f641 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -4624,12 +4624,7 @@ int Field_timestamp::store(double nr)
Lazy_string_double str(nr);
THD *thd= table->in_use;
- /* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */
- if (nr < 0 || nr > LONGLONG_MAX)
- nr= static_cast<double>(LONGLONG_MAX);
- longlong tmp= number_to_datetime((longlong) floor(nr),
- (nr-floor(nr))*TIME_SECOND_PART_FACTOR,
- &l_time, (thd->variables.sql_mode &
+ longlong tmp= double_to_datetime(nr, &l_time, (thd->variables.sql_mode &
MODE_NO_ZERO_DATE) |
MODE_NO_ZERO_IN_DATE, &error);
return store_TIME_with_warning(thd, &l_time, &str, error, tmp != -1);
@@ -5119,11 +5114,7 @@ int Field_temporal::store(double nr)
THD *thd= table->in_use;
Lazy_string_double str(nr);
- if (nr < 0 || nr > LONGLONG_MAX)
- nr= static_cast<double>(LONGLONG_MAX);
- longlong tmp= number_to_datetime((longlong) floor(nr),
- ((nr-floor(nr))*TIME_SECOND_PART_FACTOR),
- &ltime,
+ longlong tmp= double_to_datetime(nr, &ltime,
(TIME_FUZZY_DATE |
(thd->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE |
@@ -5231,8 +5222,8 @@ int Field_time::store(double nr)
bool neg= nr < 0;
if (neg)
nr= -nr;
- int have_smth_to_conv= !number_to_time(neg, nr,
- (nr - trunc(nr)) * TIME_SECOND_PART_FACTOR,
+ int have_smth_to_conv= !number_to_time(neg, (longlong)nr,
+ (ulong)((nr - floor(nr)) * TIME_SECOND_PART_FACTOR),
&ltime, &was_cut);
return store_TIME_with_warning(&ltime, &str, was_cut, have_smth_to_conv);
diff --git a/sql/field.h b/sql/field.h
index 535f024e2ba..02ce7a64374 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1433,7 +1433,7 @@ public:
DBUG_ASSERT(dec);
DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS);
zero_point= sec_part_shift(
- ((TIME_MAX_VALUE_SECONDS+1)*TIME_SECOND_PART_FACTOR), dec);
+ ((TIME_MAX_VALUE_SECONDS+1LL)*TIME_SECOND_PART_FACTOR), dec);
}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
uint decimals() const { return dec; }
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 38721484bf1..afc4d8252ff 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -669,11 +669,9 @@ Copy_field::get_copy_func(Field *to,Field *from)
{
/* If types are not 100 % identical then convert trough get_date() */
if (!to->eq_def(from) ||
- (((to->table->in_use->variables.sql_mode &
- (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
- MODE_INVALID_DATES))) &&
- (to->type() == MYSQL_TYPE_DATE ||
- to->type() == MYSQL_TYPE_DATETIME)))
+ ((to->table->in_use->variables.sql_mode &
+ (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE)) &&
+ mysql_type_to_time_type(to->type()) != MYSQL_TIMESTAMP_TIME))
return do_field_temporal;
/* Do binary copy */
}
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index c765571a318..453773478d8 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -4186,7 +4186,7 @@ bool Item_dyncol_get::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
return 0;
}
/* let double_to_datetime_with_warn() issue the warning message */
- val.double_value= ULONGLONG_MAX;
+ val.double_value= static_cast<double>(ULONGLONG_MAX);
/* fall_trough */
case DYN_COL_DOUBLE:
if (double_to_datetime_with_warn(val.double_value, ltime, fuzzy_date,
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 43d004e9b50..e7fe2095481 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -482,7 +482,7 @@ bool Item_sum::walk (Item_processor processor, bool walk_subquery,
Field *Item_sum::create_tmp_field(bool group, TABLE *table,
uint convert_blob_length)
{
- Field *field;
+ Field *UNINIT_VAR(field);
switch (result_type()) {
case REAL_RESULT:
field= new Field_double(max_length, maybe_null, name, decimals, TRUE);
diff --git a/sql/time.cc b/sql/time.cc
index f7127df3509..bd1ffdd4d0e 100644
--- a/sql/time.cc
+++ b/sql/time.cc
@@ -290,16 +290,16 @@ bool double_to_datetime_with_warn(double value, MYSQL_TIME *ltime,
ulong fuzzydate, const char *field_name)
{
const Lazy_string_double str(value);
- ulonglong nr;
- ulong sec_part;
bool neg= value < 0;
if (neg)
value= -value;
- nr = value > LONGLONG_MAX ? LONGLONG_MAX
- : static_cast<ulonglong>(trunc(value));
- sec_part= (ulong)((value - nr)*TIME_SECOND_PART_FACTOR);
+ if (value > LONGLONG_MAX)
+ value= static_cast<double>(LONGLONG_MAX);
+
+ longlong nr= static_cast<ulonglong>(floor(value));
+ uint sec_part= static_cast<ulong>((value - floor(value))*TIME_SECOND_PART_FACTOR);
return number_to_time_with_warn(neg, nr, sec_part, ltime, fuzzydate, &str,
field_name);
}
@@ -857,7 +857,7 @@ bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type,
{
if (usec > TIME_MAX_HOUR)
goto invalid_date;
- ltime->hour= usec;
+ ltime->hour= static_cast<uint>(usec);
ltime->day= 0;
return 0;
}