summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2014-06-04 21:53:15 +0400
committerAlexander Barkov <bar@mariadb.org>2014-06-04 21:53:15 +0400
commit284479c085f005a705d31e37e9cd85bb670d615e (patch)
tree044868e9c5a27a60750f3389ca63763f2bbc1ef0 /sql/field.cc
parent55bfabf9715c15df16adb4a3e8880deb4943df2b (diff)
parent661daf16f11ffa879ffb005008b6e73f6744e0ad (diff)
downloadmariadb-git-284479c085f005a705d31e37e9cd85bb670d615e.tar.gz
Merge 5.3->5.5
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc27
1 files changed, 21 insertions, 6 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 903c7a2653a..52a490921b8 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -4576,7 +4576,7 @@ int Field_timestamp::store(longlong nr, bool unsigned_val)
{
MYSQL_TIME l_time;
int error;
- ErrConvInteger str(nr);
+ ErrConvInteger str(nr, unsigned_val);
THD *thd= table->in_use;
/* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */
@@ -4952,6 +4952,17 @@ int Field_temporal::store_TIME_with_warning(MYSQL_TIME *ltime,
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
+#if MARIADB_VERSION_ID < 1000000
+ /*
+ Check if the YYYYMMDD part was truncated.
+ Translate a note into a warning.
+ In MariaDB-10.0 we have a better warnings/notes handling,
+ so this code is not needed.
+ */
+ if (was_cut & MYSQL_TIME_NOTE_TRUNCATED)
+ was_cut|= MYSQL_TIME_WARN_TRUNCATED;
+#endif
+
if (was_cut == 0 &&
have_smth_to_conv == 0 &&
mysql_type_to_time_type(type()) != MYSQL_TIMESTAMP_TIME) // special case: zero date
@@ -5042,7 +5053,7 @@ int Field_temporal::store(longlong nr, bool unsigned_val)
MYSQL_TIME ltime;
longlong tmp;
THD *thd= table->in_use;
- ErrConvInteger str(nr);
+ ErrConvInteger str(nr, unsigned_val);
tmp= number_to_datetime(nr, 0, &ltime, (thd->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE |
@@ -5140,7 +5151,7 @@ int Field_time::store(double nr)
bool neg= nr < 0;
if (neg)
nr= -nr;
- int have_smth_to_conv= !number_to_time(neg, (longlong)nr,
+ int have_smth_to_conv= !number_to_time(neg, (ulonglong) nr,
(ulong)((nr - floor(nr)) * TIME_SECOND_PART_FACTOR),
&ltime, &was_cut);
@@ -5151,9 +5162,12 @@ int Field_time::store(double nr)
int Field_time::store(longlong nr, bool unsigned_val)
{
MYSQL_TIME ltime;
- ErrConvInteger str(nr);
+ ErrConvInteger str(nr, unsigned_val);
int was_cut;
- int have_smth_to_conv= !number_to_time(nr < 0, nr < 0 ? -nr : nr,
+ if (nr < 0 && unsigned_val)
+ nr= 99991231235959LL + 1;
+ int have_smth_to_conv= !number_to_time(nr < 0,
+ (ulonglong) (nr < 0 ? -nr : nr),
0, &ltime, &was_cut);
return store_TIME_with_warning(&ltime, &str, was_cut, have_smth_to_conv);
@@ -5520,7 +5534,8 @@ bool Field_year::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
int tmp= (int) ptr[0];
if (tmp || field_length != 4)
tmp+= 1900;
- return int_to_datetime_with_warn(tmp * 10000, ltime, fuzzydate, field_name);
+ return int_to_datetime_with_warn(false, tmp * 10000,
+ ltime, fuzzydate, field_name);
}