From: Alexander Barkov Date: November 2 2011 2:11pm Subject: bzr push into mysql-trunk branch (alexander.barkov:3545 to 3547) WL#946 List-Archive: http://lists.mysql.com/commits/141703 Message-Id: <201111021411.pA2EBecg012134@bar.myoffice.izhnet.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3547 Alexander Barkov 2011-11-02 WL#946 clean-ups modified: mysys/my_getsystime.c sql/item_timefunc.h 3546 Alexander Barkov 2011-11-02 WL#946 clean-ups modified: sql-common/my_time.c sql/item_timefunc.cc sql/item_timefunc.h sql/log.cc sql/sql_class.h sql/sql_time.cc sql/sql_time.h sql/sql_yacc.yy tests/mysql_client_test.c 3545 Alexander Barkov 2011-11-02 WL#946 test clean-up modified: mysql-test/r/type_temporal_fractional.result mysql-test/suite/funcs_1/r/is_columns_is_embedded.result mysql-test/suite/opt_trace/r/subquery_ps_prot.result mysql-test/suite/parts/r/partition_datetime_innodb.result mysql-test/suite/parts/r/partition_datetime_myisam.result mysql-test/t/type_temporal_fractional.test sql/item_cmpfunc.cc sql/log_event.cc === modified file 'mysys/my_getsystime.c' --- a/mysys/my_getsystime.c 2011-02-08 15:47:33 +0000 +++ b/mysys/my_getsystime.c 2011-11-02 14:05:10 +0000 @@ -83,6 +83,8 @@ time_t my_time(myf flags) } +#define OFFSET_TO_EPOCH 116444736000000000ULL + /** Return time in microseconds. @@ -99,6 +101,7 @@ ulonglong my_micro_time() #ifdef _WIN32 ulonglong newtime; GetSystemTimeAsFileTime((FILETIME*)&newtime); + newtime-= OFFSET_TO_EPOCH; return (newtime/10); #else ulonglong newtime; @@ -132,7 +135,6 @@ ulonglong my_micro_time() */ /* Difference between GetSystemTimeAsFileTime() and now() */ -#define OFFSET_TO_EPOCH 116444736000000000ULL ulonglong my_micro_time_and_time(time_t *time_arg) { === modified file 'sql-common/my_time.c' --- a/sql-common/my_time.c 2011-11-01 11:52:24 +0000 +++ b/sql-common/my_time.c 2011-11-02 11:21:10 +0000 @@ -654,6 +654,9 @@ my_bool str_to_time(const char *str, uin for (value=0; str != end && my_isdigit(&my_charset_latin1,*str) ; str++) value=value*10L + (long) (*str - '0'); + if (value > UINT_MAX) + return 1; + /* Skip all space after 'days' */ end_of_days= str; for (; str != end && my_isspace(&my_charset_latin1, str[0]) ; str++) === modified file 'sql/item_timefunc.cc' --- a/sql/item_timefunc.cc 2011-11-01 11:52:24 +0000 +++ b/sql/item_timefunc.cc 2011-11-02 11:21:10 +0000 @@ -2988,7 +2988,7 @@ bool Item_func_add_time::val_datetime(MY days= (long) (seconds / SECONDS_IN_24H); - calc_time_from_sec(time, (long) (seconds % SECONDS_IN_24H), microseconds); + calc_time_from_sec(time, seconds % SECONDS_IN_24H, microseconds); if (!is_time) { @@ -3092,7 +3092,7 @@ bool Item_func_timediff::get_time(MYSQL_ if (l_time1.neg && (seconds || microseconds)) l_time3->neg= 1 - l_time3->neg; // Swap sign of result - calc_time_from_sec(l_time3, (long) seconds, microseconds); + calc_time_from_sec(l_time3, seconds, microseconds); adjust_time_range_with_warn(l_time3, decimals); return false; === modified file 'sql/item_timefunc.h' --- a/sql/item_timefunc.h 2011-11-01 11:52:24 +0000 +++ b/sql/item_timefunc.h 2011-11-02 14:05:10 +0000 @@ -662,8 +662,8 @@ public: */ class Item_date_literal :public Item_date_func { - MYSQL_TIME ctime; - longlong ctime_as_temporal; + MYSQL_TIME ctime; // Date value + longlong ctime_as_temporal; // Cached packed representation of ctime public: Item_date_literal(MYSQL_TIME *ltime) :Item_date_func() { @@ -711,8 +711,8 @@ public: */ class Item_time_literal :public Item_time_func { - MYSQL_TIME ctime; - longlong ctime_as_temporal; + MYSQL_TIME ctime; // Time value + longlong ctime_as_temporal; // Cached packed representation of ctime public: Item_time_literal(MYSQL_TIME *ltime, uint dec_arg) :Item_time_func() { @@ -761,8 +761,8 @@ public: */ class Item_datetime_literal :public Item_datetime_func { - MYSQL_TIME ctime; - longlong ctime_as_temporal; + MYSQL_TIME ctime; // Datetime value + longlong ctime_as_temporal; // Cached packed representation of ctime public: Item_datetime_literal(MYSQL_TIME *ltime, uint dec_arg) :Item_datetime_func() { @@ -812,8 +812,8 @@ class Item_func_curtime :public Item_tim { char buff[9*2+32]; uint buff_length; - MYSQL_TIME ctime; - longlong ctime_as_temporal; + MYSQL_TIME ctime; // TIME value + longlong ctime_as_temporal; // Cached packed representation of ctime protected: void store_now_in_TIME_tz(THD *thd, Time_zone *tz, MYSQL_TIME *now_time); /* @@ -823,7 +823,7 @@ protected: */ virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0; public: - Item_func_curtime(ulong dec_arg) :Item_time_func() { decimals= dec_arg; } + Item_func_curtime(uint8 dec_arg) :Item_time_func() { decimals= dec_arg; } longlong val_time_temporal() { DBUG_ASSERT(fixed == 1); @@ -859,8 +859,8 @@ public: class Item_func_curdate :public Item_date_func { - longlong ctime_as_longlong; // Initialized in fix_length_and_dec MYSQL_TIME ctime; // Initialized in fix_length_and_dec + longlong ctime_as_longlong; // Initialized in fix_length_and_dec protected: virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0; public: @@ -901,13 +901,13 @@ public: class Item_func_now :public Item_datetime_func { protected: - longlong ctime_as_longlong; + MYSQL_TIME ctime; // Datetime value + longlong ctime_as_longlong; // Cached packed representation of ctime char buff[20*2+32]; // +32 to make my_snprintf_{8bit|ucs2} happy uint buff_length; - MYSQL_TIME ctime; virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0; public: - Item_func_now(ulong dec_arg) :Item_datetime_func() { decimals= dec_arg; } + Item_func_now(uint8 dec_arg) :Item_datetime_func() { decimals= dec_arg; } longlong val_date_temporal() { DBUG_ASSERT(fixed == 1); @@ -948,7 +948,7 @@ public: class Item_func_sysdate_local :public Item_datetime_func { public: - Item_func_sysdate_local(ulong dec_arg) : + Item_func_sysdate_local(uint8 dec_arg) : Item_datetime_func() { decimals= dec_arg; } bool const_item() const { return 0; } const char *func_name() const { return "sysdate"; } === modified file 'sql/log.cc' --- a/sql/log.cc 2011-11-01 11:52:24 +0000 +++ b/sql/log.cc 2011-11-02 11:21:10 +0000 @@ -615,11 +615,11 @@ bool Log_to_csv_event_handler:: t.neg= 0; /* fill in query_time field */ - calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0); + calc_time_from_sec(&t, min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0); if (table->field[SQLT_FIELD_QUERY_TIME]->store_time(&t)) goto err; /* lock_time */ - calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0); + calc_time_from_sec(&t, min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0); if (table->field[SQLT_FIELD_LOCK_TIME]->store_time(&t)) goto err; /* rows_sent */ === modified file 'sql/sql_class.h' --- a/sql/sql_class.h 2011-11-01 11:52:24 +0000 +++ b/sql/sql_class.h 2011-11-02 11:21:10 +0000 @@ -1723,8 +1723,8 @@ extern "C" void my_message_sql(uint erro static inline void my_micro_time_to_timeval(ulonglong micro_time, struct timeval *tm) { - tm->tv_sec= micro_time / 1000000; - tm->tv_usec= micro_time % 1000000; + tm->tv_sec= (long) (micro_time / 1000000); + tm->tv_usec= (long) (micro_time % 1000000); } /** === modified file 'sql/sql_time.cc' --- a/sql/sql_time.cc 2011-11-01 11:52:24 +0000 +++ b/sql/sql_time.cc 2011-11-02 11:21:10 +0000 @@ -688,7 +688,7 @@ void localtime_to_TIME(MYSQL_TIME *to, s to->second= (int) from->tm_sec; } -void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds) +void calc_time_from_sec(MYSQL_TIME *to, longlong seconds, long microseconds) { long t_seconds; // to->neg is not cleared, it may already be set to a useful value @@ -696,8 +696,9 @@ void calc_time_from_sec(MYSQL_TIME *to, to->year= 0; to->month= 0; to->day= 0; - to->hour= seconds/3600L; - t_seconds= seconds%3600L; + DBUG_ASSERT(seconds < (0xFFFFFFFFLL * 3600LL)); + to->hour= (long) (seconds / 3600L); + t_seconds= (long) (seconds % 3600L); to->minute= t_seconds/60L; to->second= t_seconds%60L; to->second_part= microseconds; @@ -1520,7 +1521,7 @@ void mix_date_and_time(MYSQL_TIME *ldate DBUG_ASSERT(ldate->year > 0); days= (long) (seconds / SECONDS_IN_24H); - calc_time_from_sec(ldate, (long) (seconds % SECONDS_IN_24H), useconds); + calc_time_from_sec(ldate, seconds % SECONDS_IN_24H, useconds); get_date_from_daynr(days, &ldate->year, &ldate->month, &ldate->day); } ldate->time_type= MYSQL_TIMESTAMP_DATETIME; === modified file 'sql/sql_time.h' --- a/sql/sql_time.h 2011-11-01 11:52:24 +0000 +++ b/sql/sql_time.h 2011-11-02 11:21:10 +0000 @@ -86,7 +86,7 @@ bool calc_time_diff(const MYSQL_TIME *l_ int l_sign, longlong *seconds_out, long *microseconds_out); int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b); void localtime_to_TIME(MYSQL_TIME *to, struct tm *from); -void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds); +void calc_time_from_sec(MYSQL_TIME *to, longlong seconds, long microseconds); uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year); int calc_weekday(long daynr,bool sunday_first_day_of_week); === modified file 'sql/sql_yacc.yy' --- a/sql/sql_yacc.yy 2011-11-01 11:52:24 +0000 +++ b/sql/sql_yacc.yy 2011-11-02 11:21:10 +0000 @@ -5931,7 +5931,7 @@ func_datetime_precision: | '(' NUM ')' { int error; - $$= (longlong) my_strtoll10($2.str, NULL, &error); + $$= (ulong) my_strtoll10($2.str, NULL, &error); } ; === modified file 'tests/mysql_client_test.c' --- a/tests/mysql_client_test.c 2011-11-01 11:52:24 +0000 +++ b/tests/mysql_client_test.c 2011-11-02 11:21:10 +0000 @@ -7395,7 +7395,7 @@ static void test_temporal_param() printf("\n%lld %f '%s'\n", bigint, real, dec); /* Check values. */ - DIE_UNLESS(bigint == 20011020101100); + DIE_UNLESS(bigint == 20011020101100LL); DIE_UNLESS(real == 20011020101059.5); DIE_UNLESS(!strcmp(dec, "20011020101059.5")); No bundle (reason: useless for push emails).