diff options
author | Sergei Golubchik <sergii@pisem.net> | 2011-06-06 20:28:15 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2011-06-06 20:28:15 +0200 |
commit | 4d128777dde904c5f0adab9b093e854c9c580d41 (patch) | |
tree | 36875e84e65be596def46c5d7ce621e60abcbdae /sql/item_timefunc.h | |
parent | c1a92f9caeb368021d5ffbe0df237ded29692c1a (diff) | |
download | mariadb-git-4d128777dde904c5f0adab9b093e854c9c580d41.tar.gz |
revert a suggested "optimization" that introduced a bug
compilation error in mysys/my_getsystime.c fixed
some redundant code removed
sec_to_time, time_to_sec, from_unixtime, unix_timestamp, @@timestamp now
use decimal, not double for numbers with a fractional part.
purge_master_logs_before_date() fixed
many bugs in corner cases fixed
mysys/my_getsystime.c:
compilation failure fixed
sql/sql_parse.cc:
don't cut corners. it backfires.
Diffstat (limited to 'sql/item_timefunc.h')
-rw-r--r-- | sql/item_timefunc.h | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index d50b0c20716..3b1f69d5383 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -306,12 +306,11 @@ public: { if (arg_count) decimals= args[0]->decimals; - if (decimals != NOT_FIXED_DEC) - set_if_smaller(decimals, TIME_SECOND_PART_DIGITS); + set_if_smaller(decimals, TIME_SECOND_PART_DIGITS); max_length=17 + (decimals ? decimals + 1 : 0); } - void find_num_type() { hybrid_type= decimals ? REAL_RESULT : INT_RESULT; } - my_decimal *decimal_op(my_decimal* buf) { DBUG_ASSERT(0); return 0; } + void find_num_type() { hybrid_type= decimals ? DECIMAL_RESULT : INT_RESULT; } + double real_op() { DBUG_ASSERT(0); return 0; } String *str_op(String *str) { DBUG_ASSERT(0); return 0; } }; @@ -338,7 +337,7 @@ public: return !has_timestamp_args(); } longlong int_op(); - double real_op(); + my_decimal *decimal_op(my_decimal* buf); }; @@ -354,7 +353,7 @@ public: } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} longlong int_op(); - double real_op(); + my_decimal *decimal_op(my_decimal* buf); }; @@ -383,6 +382,7 @@ public: { MAX_DATETIME_WIDTH, MAX_DATETIME_WIDTH, MAX_DATE_WIDTH, MAX_DATETIME_WIDTH, MIN_TIME_WIDTH }; + maybe_null= true; max_length= max_time_type_width[mysql_type_to_time_type(field_type())+2]; if (decimals) { @@ -403,9 +403,6 @@ public: Item_datefunc() :Item_temporal_func() { } Item_datefunc(Item *a) :Item_temporal_func(a) { } enum_field_types field_type() const { return MYSQL_TYPE_DATE; } - const char *func_name() const { return "date"; } - bool get_date(MYSQL_TIME *res, uint fuzzy_date) - { return get_arg0_date(res, fuzzy_date); } }; @@ -432,6 +429,7 @@ public: { store_now_in_TIME(<ime); Item_timefunc::fix_length_and_dec(); + maybe_null= false; } bool get_date(MYSQL_TIME *res, uint fuzzy_date); /* @@ -504,6 +502,7 @@ public: { store_now_in_TIME(<ime); Item_temporal_func::fix_length_and_dec(); + maybe_null= false; } bool get_date(MYSQL_TIME *res, uint fuzzy_date); virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0; @@ -623,13 +622,12 @@ class Item_func_convert_tz :public Item_temporal_func class Item_func_sec_to_time :public Item_timefunc { - bool sec_to_time(double seconds, MYSQL_TIME *ltime); + bool sec_to_time(longlong seconds, ulong sec_part, MYSQL_TIME *ltime); public: Item_func_sec_to_time(Item *item) :Item_timefunc(item) {} bool get_date(MYSQL_TIME *res, uint fuzzy_date); void fix_length_and_dec() { - maybe_null=1; decimals= args[0]->decimals; Item_timefunc::fix_length_and_dec(); } @@ -699,7 +697,6 @@ public: void print(String *str, enum_query_type query_type); void fix_length_and_dec() { - maybe_null= 1; if (decimals == NOT_FIXED_DEC) decimals= args[0]->decimals; Item_temporal_func::fix_length_and_dec(); @@ -746,12 +743,6 @@ public: Item_func_makedate(Item *a,Item *b) :Item_temporal_func(a,b) {} const char *func_name() const { return "makedate"; } enum_field_types field_type() const { return MYSQL_TYPE_DATE; } - void fix_length_and_dec() - { - /* It returns NULL when the second argument is less or equal to 0 */ - maybe_null= 1; - Item_temporal_func::fix_length_and_dec(); - } bool get_date(MYSQL_TIME *ltime, uint fuzzy_date); }; @@ -782,7 +773,6 @@ public: { decimals= max(args[0]->decimals, args[1]->decimals); Item_timefunc::fix_length_and_dec(); - maybe_null= 1; } bool get_date(MYSQL_TIME *ltime, uint fuzzy_date); }; @@ -792,9 +782,7 @@ class Item_func_maketime :public Item_timefunc public: Item_func_maketime(Item *a, Item *b, Item *c) :Item_timefunc(a, b, c) - { - maybe_null= TRUE; - } + {} const char *func_name() const { return "maketime"; } bool get_date(MYSQL_TIME *ltime, uint fuzzy_date); }; @@ -877,9 +865,4 @@ public: Item_func_last_day(Item *a) :Item_datefunc(a) {} const char *func_name() const { return "last_day"; } bool get_date(MYSQL_TIME *res, uint fuzzy_date); - void fix_length_and_dec() - { - maybe_null=1; - Item_datefunc::fix_length_and_dec(); - } }; |