mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
Removing duplicate code: Adding a protected method
Field_temporal_with_date::validate_for_get_date() and reusing it in a few places.
This commit is contained in:
parent
f5ddffd83e
commit
091f67738e
2 changed files with 13 additions and 20 deletions
24
sql/field.cc
24
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1681,6 +1681,15 @@ protected:
|
|||
int store_TIME_with_warning(MYSQL_TIME *ltime, const ErrConv *str,
|
||||
int was_cut, int have_smth_to_conv);
|
||||
virtual void store_TIME(MYSQL_TIME *ltime) = 0;
|
||||
bool validate_for_get_date(bool not_zero_date, const MYSQL_TIME *ltime,
|
||||
ulonglong fuzzydate)
|
||||
{
|
||||
if (!not_zero_date)
|
||||
return fuzzydate & TIME_NO_ZERO_DATE;
|
||||
if (!ltime->month || !ltime->day)
|
||||
return fuzzydate & TIME_NO_ZERO_IN_DATE;
|
||||
return false;
|
||||
}
|
||||
public:
|
||||
Field_temporal_with_date(uchar *ptr_arg, uint32 len_arg,
|
||||
uchar *null_ptr_arg, uchar null_bit_arg,
|
||||
|
|
Loading…
Add table
Reference in a new issue