diff options
author | unknown <msvensson@pilot.blaudden> | 2007-05-16 10:44:59 +0200 |
---|---|---|
committer | unknown <msvensson@pilot.blaudden> | 2007-05-16 10:44:59 +0200 |
commit | b5e4f54a53d3bdb06af48956bbeabcefdb1447aa (patch) | |
tree | 890ba335add713d8bf248138165188b29e09cded /sql/time.cc | |
parent | 7703b67659aabeeed53a2b78495ded9ddee9024d (diff) | |
download | mariadb-git-b5e4f54a53d3bdb06af48956bbeabcefdb1447aa.tar.gz |
Backport of TIME->MYSQL_TIME / Y2K fixset
Made year 2000 handling more uniform
Removed year 2000 handling out from calc_days()
The above removes some bugs in date/datetimes with year between 0 and 200
Now we get a note when we insert a datetime value into a date column
For default values to CREATE, don't give errors for warning level NOTE
Fixed some compiler failures
Added library ws2_32 for windows compilation (needed if we want to compile with IOCP support)
Removed duplicate typedef TIME and replaced it with MYSQL_TIME
Better (more complete) fix for: Bug#21103 "DATE column not compared as DATE"
Fixed properly Bug#18997 "DATE_ADD and DATE_SUB perform year2K autoconversion magic on 4-digit year value"
Fixed Bug#23093 "Implicit conversion of 9912101 to date does not match cast(9912101 as date)"
include/my_time.h:
Removed not used define YY_MAGIC_BELOW
Added prototype for year_2000_handling()
mysql-test/r/date_formats.result:
Updated results (fixed bug in date_format() with year < 99
mysql-test/r/func_sapdb.result:
Added more testing of make_date()
mysql-test/r/ps_2myisam.result:
Now we get a note when we insert a datetime value into a date column
mysql-test/r/ps_3innodb.result:
Now we get a note when we insert a datetime value into a date column
mysql-test/r/ps_4heap.result:
Now we get a note when we insert a datetime value into a date column
mysql-test/r/ps_5merge.result:
Now we get a note when we insert a datetime value into a date column
mysql-test/r/ps_7ndb.result:
Now we get a note when we insert a datetime value into a date column
mysql-test/r/strict.result:
zero-year in str_to_date() throws warning in strict
mysql-test/r/type_date.result:
Added test for date conversions
mysql-test/r/type_datetime.result:
Added testcase for datetime to date conversion.
mysql-test/t/date_formats.test:
Added testing of dates < 200
mysql-test/t/func_sapdb.test:
More testing of makedate()
mysql-test/t/type_date.test:
Added test for date conversions
mysql-test/t/type_datetime.test:
Added testcase for datetime to date conversion
sql/field.cc:
Give note if we insert a datetime value in a date field
Don't give notes if we are doing internal test conversions (like from convert_constant_item())
More documentation (store functions can now return '3' to inform that the function did return a NOTE (not warning or error))
Revert some changes in Field_newdate::store() to get more optimal code
Field::set_warning() will now ignore notes if CHECK_FIELD_IGNORE is set.
New parameters to make_truncated_value_warning()
sql/field.h:
Give note if we insert a datetime value in a date field
Don't give notes if we are doing internal test conversions (like from convert_constant_item())
More documentation (store functions can now return '3' to inform that the function did return a NOTE (not warning or error))
Revert some changes in Field_newdate::store() to get more optimal code
Field::set_warning() will now ignore notes if CHECK_FIELD_IGNORE is set.
New parameters to make_truncated_value_warning()
sql/item.cc:
Give note if we insert a datetime value in a date field
Don't give notes if we are doing internal test conversions (like from convert_constant_item())
More documentation (store functions can now return '3' to inform that the function did return a NOTE (not warning or error))
Revert some changes in Field_newdate::store() to get more optimal code
Field::set_warning() will now ignore notes if CHECK_FIELD_IGNORE is set.
New parameters to make_truncated_value_warning()
sql/item.h:
TIME -> MYSQL_TIME
sql/item_cmpfunc.cc:
Don't print notes in convert_constant_item()
sql/item_func.h:
TIME -> MYSQL_TIME
sql/item_timefunc.cc:
New parameters to make_truncated_value_warning()
Moved year 2000 handling out from calc_days()
sql/item_timefunc.h:
TIME -> MYSQL_TIME
sql/my_decimal.cc:
TIME -> MYSQL_TIME
sql/my_decimal.h:
TIME -> MYSQL_TIME
sql/mysql_priv.h:
Added error level to make_truncated_value_warning()
sql/protocol.cc:
TIME -> MYSQL_TIME
sql/protocol.h:
TIME -> MYSQL_TIME
sql/sp.cc:
TIME -> MYSQL_TIME
sql/sql_base.cc:
Make testing of result value of save_in_field() uniform
sql/sql_class.h:
TIME -> MYSQL_TIME
sql/sql_show.cc:
TIME -> MYSQL_TIME
sql/structs.h:
TIME -> MYSQL_TIME
sql/time.cc:
Added error level to make_truncated_value_warning()
sql/tztime.cc:
TIME -> MYSQL_TIME
sql/tztime.h:
TIME -> MYSQL_TIME
sql/unireg.cc:
For default values to CREATE, don't give errors for warning level NOTE
(Fixed failed CREATE when we give a datetime value to a date field)
sql-common/my_time.c:
Added year_2000_handling()
Removed year 2000 handling from calc_daynr()
Diffstat (limited to 'sql/time.cc')
-rw-r--r-- | sql/time.cc | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/sql/time.cc b/sql/time.cc index a46f2fc237d..b4a8b047998 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -61,7 +61,7 @@ int calc_weekday(long daynr,bool sunday_first_day_of_week) next week is week 1. */ -uint calc_week(TIME *l_time, uint week_behaviour, uint *year) +uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year) { uint days; ulong daynr=calc_daynr(l_time->year,l_time->month,l_time->day); @@ -179,7 +179,7 @@ ulong convert_month_to_period(ulong month) /* - Convert a timestamp string to a TIME value and produce a warning + Convert a timestamp string to a MYSQL_TIME value and produce a warning if string was truncated during conversion. NOTE @@ -187,7 +187,7 @@ ulong convert_month_to_period(ulong month) */ timestamp_type -str_to_datetime_with_warn(const char *str, uint length, TIME *l_time, +str_to_datetime_with_warn(const char *str, uint length, MYSQL_TIME *l_time, uint flags) { int was_cut; @@ -200,13 +200,14 @@ str_to_datetime_with_warn(const char *str, uint length, TIME *l_time, MODE_NO_ZERO_DATE))), &was_cut); if (was_cut || ts_type <= MYSQL_TIMESTAMP_ERROR) - make_truncated_value_warning(current_thd, str, length, ts_type, NullS); + make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + str, length, ts_type, NullS); return ts_type; } /* - Convert a datetime from broken-down TIME representation to corresponding + Convert a datetime from broken-down MYSQL_TIME representation to corresponding TIMESTAMP value. SYNOPSIS @@ -222,7 +223,7 @@ str_to_datetime_with_warn(const char *str, uint length, TIME *l_time, 0 - t contains datetime value which is out of TIMESTAMP range. */ -my_time_t TIME_to_timestamp(THD *thd, const TIME *t, my_bool *in_dst_time_gap) +my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *in_dst_time_gap) { my_time_t timestamp; @@ -241,20 +242,20 @@ my_time_t TIME_to_timestamp(THD *thd, const TIME *t, my_bool *in_dst_time_gap) /* - Convert a time string to a TIME struct and produce a warning + Convert a time string to a MYSQL_TIME struct and produce a warning if string was cut during conversion. NOTE See str_to_time() for more info. */ bool -str_to_time_with_warn(const char *str, uint length, TIME *l_time) +str_to_time_with_warn(const char *str, uint length, MYSQL_TIME *l_time) { int warning; bool ret_val= str_to_time(str, length, l_time, &warning); if (ret_val || warning) - make_truncated_value_warning(current_thd, str, length, - MYSQL_TIMESTAMP_TIME, NullS); + make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + str, length, MYSQL_TIMESTAMP_TIME, NullS); return ret_val; } @@ -263,7 +264,7 @@ str_to_time_with_warn(const char *str, uint length, TIME *l_time) Convert a system time structure to TIME */ -void localtime_to_TIME(TIME *to, struct tm *from) +void localtime_to_TIME(MYSQL_TIME *to, struct tm *from) { to->neg=0; to->second_part=0; @@ -275,7 +276,7 @@ void localtime_to_TIME(TIME *to, struct tm *from) to->second= (int) from->tm_sec; } -void calc_time_from_sec(TIME *to, long seconds, long microseconds) +void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds) { long t_seconds; to->hour= seconds/3600L; @@ -644,7 +645,7 @@ const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format, MySQL doesn't support comparing of date/time/datetime strings that are not in arbutary order as dates are compared as strings in some context) - This functions don't check that given TIME structure members are + This functions don't check that given MYSQL_TIME structure members are in valid range. If they are not, return value won't reflect any valid date either. Additionally, make_time doesn't take into account time->day member: it's assumed that days have been converted @@ -652,7 +653,7 @@ const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format, ****************************************************************************/ void make_time(const DATE_TIME_FORMAT *format __attribute__((unused)), - const TIME *l_time, String *str) + const MYSQL_TIME *l_time, String *str) { uint length= (uint) my_time_to_str(l_time, (char*) str->ptr()); str->length(length); @@ -661,7 +662,7 @@ void make_time(const DATE_TIME_FORMAT *format __attribute__((unused)), void make_date(const DATE_TIME_FORMAT *format __attribute__((unused)), - const TIME *l_time, String *str) + const MYSQL_TIME *l_time, String *str) { uint length= (uint) my_date_to_str(l_time, (char*) str->ptr()); str->length(length); @@ -670,7 +671,7 @@ void make_date(const DATE_TIME_FORMAT *format __attribute__((unused)), void make_datetime(const DATE_TIME_FORMAT *format __attribute__((unused)), - const TIME *l_time, String *str) + const MYSQL_TIME *l_time, String *str) { uint length= (uint) my_datetime_to_str(l_time, (char*) str->ptr()); str->length(length); @@ -678,7 +679,8 @@ void make_datetime(const DATE_TIME_FORMAT *format __attribute__((unused)), } -void make_truncated_value_warning(THD *thd, const char *str_val, +void make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, + const char *str_val, uint str_length, timestamp_type time_type, const char *field_name) { @@ -710,7 +712,7 @@ void make_truncated_value_warning(THD *thd, const char *str_val, cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff), ER(ER_TRUNCATED_WRONG_VALUE), type_str, str.c_ptr()); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + push_warning(thd, level, ER_TRUNCATED_WRONG_VALUE, warn_buff); } |