Skip to content

Commit 497ee33

Browse files
committed
MDEV-21497 Make Field_time, Field_datetime, Field_timestamp abstract
- Making classes Field_time, Field_datetime, Field_timestamp abstract - Adding instantiable Field_time0, Field_datetime0, Field_timestamp0 classes - Removing redundant cast in field_conv.cc, item_timefunc.cc, sp.cc in calls for set_time() and get_timestamp() - Replacing store_TIME() to store_timestamp() in log.cc and removing redundant cast
1 parent cc3135c commit 497ee33

File tree

6 files changed

+133
-105
lines changed

6 files changed

+133
-105
lines changed

sql/field.cc

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5026,16 +5026,16 @@ int Field_timestamp::save_in_field(Field *to)
50265026
return to->store_timestamp_dec(Timeval(ts, sec_part), decimals());
50275027
}
50285028

5029-
my_time_t Field_timestamp::get_timestamp(const uchar *pos,
5030-
ulong *sec_part) const
5029+
my_time_t Field_timestamp0::get_timestamp(const uchar *pos,
5030+
ulong *sec_part) const
50315031
{
50325032
DBUG_ASSERT(marked_for_read());
50335033
*sec_part= 0;
50345034
return sint4korr(pos);
50355035
}
50365036

50375037

5038-
bool Field_timestamp::val_native(Native *to)
5038+
bool Field_timestamp0::val_native(Native *to)
50395039
{
50405040
DBUG_ASSERT(marked_for_read());
50415041
my_time_t sec= (my_time_t) sint4korr(ptr);
@@ -5200,12 +5200,6 @@ int Field_timestamp::store_native(const Native &value)
52005200
}
52015201

52025202

5203-
double Field_timestamp::val_real(void)
5204-
{
5205-
return (double) Field_timestamp::val_int();
5206-
}
5207-
5208-
52095203
longlong Field_timestamp::val_int(void)
52105204
{
52115205
MYSQL_TIME ltime;
@@ -5309,15 +5303,15 @@ bool Field_timestamp::get_date(MYSQL_TIME *ltime, date_mode_t fuzzydate)
53095303
}
53105304

53115305

5312-
bool Field_timestamp::send_binary(Protocol *protocol)
5306+
bool Field_timestamp0::send_binary(Protocol *protocol)
53135307
{
53145308
MYSQL_TIME ltime;
5315-
Field_timestamp::get_date(&ltime, date_mode_t(0));
5309+
Field_timestamp0::get_date(&ltime, date_mode_t(0));
53165310
return protocol->store(&ltime, 0);
53175311
}
53185312

53195313

5320-
int Field_timestamp::cmp(const uchar *a_ptr, const uchar *b_ptr) const
5314+
int Field_timestamp0::cmp(const uchar *a_ptr, const uchar *b_ptr) const
53215315
{
53225316
int32 a,b;
53235317
a=sint4korr(a_ptr);
@@ -5326,7 +5320,7 @@ int Field_timestamp::cmp(const uchar *a_ptr, const uchar *b_ptr) const
53265320
}
53275321

53285322

5329-
void Field_timestamp::sort_string(uchar *to,uint length __attribute__((unused)))
5323+
void Field_timestamp0::sort_string(uchar *to,uint length __attribute__((unused)))
53305324
{
53315325
to[0] = ptr[3];
53325326
to[1] = ptr[2];
@@ -5348,7 +5342,7 @@ void Field_timestamp::sql_type(String &res) const
53485342
}
53495343

53505344

5351-
int Field_timestamp::set_time()
5345+
int Field_timestamp0::set_time()
53525346
{
53535347
set_notnull();
53545348
store_TIMESTAMP(Timestamp(get_thd()->query_start(), 0));
@@ -5808,7 +5802,7 @@ int Field_time::store_TIME_with_warning(const Time *t,
58085802
}
58095803

58105804

5811-
void Field_time::store_TIME(const MYSQL_TIME *ltime)
5805+
void Field_time0::store_TIME(const MYSQL_TIME *ltime)
58125806
{
58135807
DBUG_ASSERT(ltime->year == 0);
58145808
DBUG_ASSERT(ltime->month == 0);
@@ -5896,14 +5890,14 @@ Field *Field_time::new_key_field(MEM_ROOT *root, TABLE *new_table,
58965890
}
58975891

58985892

5899-
double Field_time::val_real(void)
5893+
double Field_time0::val_real(void)
59005894
{
59015895
DBUG_ASSERT(marked_for_read());
59025896
uint32 j= (uint32) uint3korr(ptr);
59035897
return (double) j;
59045898
}
59055899

5906-
longlong Field_time::val_int(void)
5900+
longlong Field_time0::val_int(void)
59075901
{
59085902
DBUG_ASSERT(marked_for_read());
59095903
return (longlong) sint3korr(ptr);
@@ -5952,7 +5946,7 @@ bool Field_time::check_zero_in_date_with_warn(date_mode_t fuzzydate)
59525946
DATE_FORMAT(time, "%l.%i %p")
59535947
*/
59545948

5955-
bool Field_time::get_date(MYSQL_TIME *ltime, date_mode_t fuzzydate)
5949+
bool Field_time0::get_date(MYSQL_TIME *ltime, date_mode_t fuzzydate)
59565950
{
59575951
if (check_zero_in_date_with_warn(fuzzydate))
59585952
return true;
@@ -5982,15 +5976,15 @@ bool Field_time::send_binary(Protocol *protocol)
59825976
}
59835977

59845978

5985-
int Field_time::cmp(const uchar *a_ptr, const uchar *b_ptr) const
5979+
int Field_time0::cmp(const uchar *a_ptr, const uchar *b_ptr) const
59865980
{
59875981
int32 a,b;
59885982
a=(int32) sint3korr(a_ptr);
59895983
b=(int32) sint3korr(b_ptr);
59905984
return (a < b) ? -1 : (a > b) ? 1 : 0;
59915985
}
59925986

5993-
void Field_time::sort_string(uchar *to,uint length __attribute__((unused)))
5987+
void Field_time0::sort_string(uchar *to,uint length __attribute__((unused)))
59945988
{
59955989
to[0] = (uchar) (ptr[2] ^ 128);
59965990
to[1] = ptr[1];
@@ -6695,7 +6689,7 @@ Item *Field_newdate::get_equal_const_item(THD *thd, const Context &ctx,
66956689
** Stored as a 8 byte unsigned int. Should sometimes be change to a 6 byte int.
66966690
****************************************************************************/
66976691

6698-
void Field_datetime::store_TIME(const MYSQL_TIME *ltime)
6692+
void Field_datetime0::store_TIME(const MYSQL_TIME *ltime)
66996693
{
67006694
ulonglong tmp= TIME_to_ulonglong_datetime(ltime);
67016695
int8store(ptr,tmp);
@@ -6710,20 +6704,15 @@ Field_datetime::conversion_depends_on_sql_mode(THD *thd, Item *expr) const
67106704
}
67116705

67126706

6713-
bool Field_datetime::send_binary(Protocol *protocol)
6707+
bool Field_datetime0::send_binary(Protocol *protocol)
67146708
{
67156709
MYSQL_TIME tm;
6716-
Field_datetime::get_date(&tm, date_mode_t(0));
6710+
Field_datetime0::get_date(&tm, date_mode_t(0));
67176711
return protocol->store(&tm, 0);
67186712
}
67196713

67206714

6721-
double Field_datetime::val_real(void)
6722-
{
6723-
return (double) Field_datetime::val_int();
6724-
}
6725-
6726-
longlong Field_datetime::val_int(void)
6715+
longlong Field_datetime0::val_int(void)
67276716
{
67286717
DBUG_ASSERT(marked_for_read());
67296718
longlong j;
@@ -6732,8 +6721,8 @@ longlong Field_datetime::val_int(void)
67326721
}
67336722

67346723

6735-
String *Field_datetime::val_str(String *val_buffer,
6736-
String *val_ptr __attribute__((unused)))
6724+
String *Field_datetime0::val_str(String *val_buffer,
6725+
String *val_ptr __attribute__((unused)))
67376726
{
67386727
val_buffer->alloc(field_length);
67396728
val_buffer->length(field_length);
@@ -6744,7 +6733,7 @@ String *Field_datetime::val_str(String *val_buffer,
67446733
char *pos;
67456734
int part3;
67466735

6747-
tmp= Field_datetime::val_int();
6736+
tmp= Field_datetime0::val_int();
67486737

67496738
/*
67506739
Avoid problem with slow longlong arithmetic and sprintf
@@ -6778,8 +6767,8 @@ String *Field_datetime::val_str(String *val_buffer,
67786767
return val_buffer;
67796768
}
67806769

6781-
bool Field_datetime::get_TIME(MYSQL_TIME *ltime, const uchar *pos,
6782-
date_mode_t fuzzydate) const
6770+
bool Field_datetime0::get_TIME(MYSQL_TIME *ltime, const uchar *pos,
6771+
date_mode_t fuzzydate) const
67836772
{
67846773
DBUG_ASSERT(marked_for_read());
67856774
longlong tmp= sint8korr(pos);
@@ -6800,7 +6789,7 @@ bool Field_datetime::get_TIME(MYSQL_TIME *ltime, const uchar *pos,
68006789
}
68016790

68026791

6803-
int Field_datetime::cmp(const uchar *a_ptr, const uchar *b_ptr) const
6792+
int Field_datetime0::cmp(const uchar *a_ptr, const uchar *b_ptr) const
68046793
{
68056794
longlong a,b;
68066795
a=sint8korr(a_ptr);
@@ -6809,7 +6798,7 @@ int Field_datetime::cmp(const uchar *a_ptr, const uchar *b_ptr) const
68096798
((ulonglong) a > (ulonglong) b) ? 1 : 0;
68106799
}
68116800

6812-
void Field_datetime::sort_string(uchar *to,uint length __attribute__((unused)))
6801+
void Field_datetime0::sort_string(uchar *to,uint length __attribute__((unused)))
68136802
{
68146803
to[0] = ptr[7];
68156804
to[1] = ptr[6];

0 commit comments

Comments
 (0)