From: Date: November 5 2006 7:44pm Subject: bk commit into 5.1 tree (holyfoot:1.2324) BUG#19491 List-Archive: http://lists.mysql.com/commits/14859 X-Bug: 19491 Message-Id: <20061105184445.E73C470001B@deer.myoffice.izhnet.ru> Below is the list of changes that have just been committed into a local 5.1 repository of hf. When hf does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2006-11-05 22:44:37+04:00, holyfoot@stripped +4 -0 bug #19491 5.1-related fixes include/my_time.h@stripped, 2006-11-05 22:44:33+04:00, holyfoot@stripped +2 -0 check_date can be used outside my_time.cc sql-common/my_time.c@stripped, 2006-11-05 22:44:34+04:00, holyfoot@stripped +1 -1 check_date can be used outside sql/field.cc@stripped, 2006-11-05 22:44:34+04:00, holyfoot@stripped +30 -1 Field_newdate fixed sql/item_timefunc.h@stripped, 2006-11-05 22:44:34+04:00, holyfoot@stripped +2 -21 merging fixes # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: holyfoot # Host: deer.(none) # Root: /home/hf/work/19491/my51-19491 --- 1.347/sql/field.cc 2006-11-05 22:44:45 +04:00 +++ 1.348/sql/field.cc 2006-11-05 22:44:45 +04:00 @@ -4926,7 +4926,7 @@ int Field_time::store_time(TIME *ltime, (ltime->minute * 100 + ltime->second); if (ltime->neg) tmp= -tmp; - return Field_time::store((longlong) tmp, TRUE); + return Field_time::store((longlong) tmp, FALSE); } @@ -5537,7 +5537,22 @@ int Field_newdate::store_time(TIME *ltim long tmp; int error= 0; if (type == MYSQL_TIMESTAMP_DATE || type == MYSQL_TIMESTAMP_DATETIME) + { tmp=ltime->year*16*32+ltime->month*32+ltime->day; + + if ((my_bool)check_date(ltime, tmp, + (TIME_FUZZY_DATE | + (current_thd->variables.sql_mode & + (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | + MODE_INVALID_DATES))), &error)) + { + char buff[12]; + String str(buff, sizeof(buff), &my_charset_latin1); + make_date((DATE_TIME_FORMAT *) 0, ltime, &str); + set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, + str.ptr(), str.length(), MYSQL_TIMESTAMP_DATE, 1); + } + } else { tmp=0; @@ -5752,8 +5767,22 @@ int Field_datetime::store_time(TIME *lti structure always fit into DATETIME range. */ if (type == MYSQL_TIMESTAMP_DATE || type == MYSQL_TIMESTAMP_DATETIME) + { tmp=((ltime->year*10000L+ltime->month*100+ltime->day)*LL(1000000)+ (ltime->hour*10000L+ltime->minute*100+ltime->second)); + if ((my_bool)check_date(ltime, tmp, + (TIME_FUZZY_DATE | + (current_thd->variables.sql_mode & + (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | + MODE_INVALID_DATES))), &error)) + { + char buff[12]; + String str(buff, sizeof(buff), &my_charset_latin1); + make_datetime((DATE_TIME_FORMAT *) 0, ltime, &str); + set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, + str.ptr(), str.length(), MYSQL_TIMESTAMP_DATETIME, 1); + } + } else { tmp=0; --- 1.76/sql/item_timefunc.h 2006-11-05 22:44:45 +04:00 +++ 1.77/sql/item_timefunc.h 2006-11-05 22:44:45 +04:00 @@ -360,7 +360,6 @@ public: decimals=0; max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; } - int save_in_field(Field *to, bool no_conversions); Field *tmp_table_field(TABLE *table) { return tmp_table_field_from_field_type(table, 0); @@ -416,9 +415,9 @@ public: decimals=0; max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; } - Field *tmp_table_field(TABLE *t_arg) + Field *tmp_table_field(TABLE *table) { - return (new Field_time(maybe_null, name, t_arg, &my_charset_bin)); + return tmp_table_field_from_field_type(table, 0); } my_decimal *val_decimal(my_decimal *decimal_value) { @@ -446,10 +445,6 @@ public: longlong val_int() { DBUG_ASSERT(fixed == 1); return value; } String *val_str(String *str); void fix_length_and_dec(); - Field *tmp_table_field(TABLE *table) - { - return tmp_table_field_from_field_type(table, 0); - } /* Abstract method that defines which time zone is used for conversion. Converts time current time in my_time_t representation to broken-down @@ -890,10 +885,6 @@ public: decimals=0; max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; } - Field *tmp_table_field(TABLE *table) - { - return tmp_table_field_from_field_type(table, 0); - } longlong val_int(); bool check_partition_func_processor(byte *int_arg) {return FALSE;} my_decimal *val_decimal(my_decimal *decimal_value) @@ -901,10 +892,6 @@ public: DBUG_ASSERT(fixed == 1); return val_decimal_from_date(decimal_value); } - int save_in_field(Field *field, bool no_conversions) - { - return save_date_in_field(field); - } }; @@ -968,12 +955,6 @@ public: :Item_str_timefunc(a, b ,c) {} String *val_str(String *str); const char *func_name() const { return "maketime"; } - enum_field_types field_type() const { return MYSQL_TYPE_TIME; } - void fix_length_and_dec() - { - decimals=0; - max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; - } bool check_partition_func_processor(byte *int_arg) {return FALSE;} }; --- 1.15/include/my_time.h 2006-11-05 22:44:45 +04:00 +++ 1.16/include/my_time.h 2006-11-05 22:44:45 +04:00 @@ -57,6 +57,8 @@ typedef long my_time_t; #define TIME_NO_ZERO_DATE (TIME_NO_ZERO_IN_DATE*2) #define TIME_INVALID_DATES (TIME_NO_ZERO_DATE*2) +my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, + ulong flags, int *was_cut); enum enum_mysql_timestamp_type str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, uint flags, int *was_cut); --- 1.22/sql-common/my_time.c 2006-11-05 22:44:45 +04:00 +++ 1.23/sql-common/my_time.c 2006-11-05 22:44:45 +04:00 @@ -76,7 +76,7 @@ uint calc_days_in_year(uint year) 1 error */ -static my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, +my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, ulong flags, int *was_cut) { if (not_zero_date)