diff options
author | Alexander Barkov <bar@mariadb.org> | 2015-06-18 22:16:44 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2015-06-18 22:16:44 +0400 |
commit | 091f67738e2bede5df2001eedd4be76d9473370d (patch) | |
tree | 29e8133cc523cd670191577f6fc3b955d7e90c18 /sql/field.cc | |
parent | f5ddffd83e627cc0f6a24dfe4d8fc2e0c983bf78 (diff) | |
download | mariadb-git-091f67738e2bede5df2001eedd4be76d9473370d.tar.gz |
Removing duplicate code: Adding a protected method
Field_temporal_with_date::validate_for_get_date()
and reusing it in a few places.
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/sql/field.cc b/sql/field.cc index fe673469269..9ede072e56c 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5985,11 +5985,7 @@ bool Field_newdate::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) ltime->year= (tmp >> 9); ltime->time_type= MYSQL_TIMESTAMP_DATE; ltime->hour= ltime->minute= ltime->second= ltime->second_part= ltime->neg= 0; - if (!tmp) - return fuzzydate & TIME_NO_ZERO_DATE; - if (!ltime->month || !ltime->day) - return fuzzydate & TIME_NO_ZERO_IN_DATE; - return 0; + return validate_for_get_date(tmp, ltime, fuzzydate); } @@ -6113,11 +6109,7 @@ bool Field_datetime::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) ltime->day= (int) (part1%100); ltime->month= (int) (part1/100%100); ltime->year= (int) (part1/10000); - if (!tmp) - return fuzzydate & TIME_NO_ZERO_DATE; - if (!ltime->month || !ltime->day) - return fuzzydate & TIME_NO_ZERO_IN_DATE; - return 0; + return validate_for_get_date(tmp, ltime, fuzzydate); } int Field_datetime::cmp(const uchar *a_ptr, const uchar *b_ptr) @@ -6235,11 +6227,7 @@ bool Field_datetime_hires::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) { ulonglong packed= read_bigendian(ptr, Field_datetime_hires::pack_length()); unpack_time(sec_part_unshift(packed, dec), ltime); - if (!packed) - return fuzzydate & TIME_NO_ZERO_DATE; - if (!ltime->month || !ltime->day) - return fuzzydate & TIME_NO_ZERO_IN_DATE; - return 0; + return validate_for_get_date(packed, ltime, fuzzydate); } uint32 Field_datetime_hires::pack_length() const @@ -6282,11 +6270,7 @@ bool Field_datetimef::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) { longlong tmp= my_datetime_packed_from_binary(ptr, dec); TIME_from_longlong_datetime_packed(ltime, tmp); - if (!tmp) - return fuzzydate & TIME_NO_ZERO_DATE; - if (!ltime->month || !ltime->day) - return fuzzydate & TIME_NO_ZERO_IN_DATE; - return false; + return validate_for_get_date(tmp, ltime, fuzzydate); } |