diff options
author | Sergei Golubchik <sergii@pisem.net> | 2011-03-17 14:13:03 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2011-03-17 14:13:03 +0100 |
commit | 1ac6371a48a71835d532fda6d986855312bf0dc2 (patch) | |
tree | f3a8de34f4bf0c331723a999dedc78e87be4b9bb /sql | |
parent | 8f6cb92581e6640cba8cd7b47cf94e4270e73650 (diff) | |
download | mariadb-git-1ac6371a48a71835d532fda6d986855312bf0dc2.tar.gz |
* fix for ALTER TABLE ... MODIFY timestamp->timestamp.
Use dedicated do_field_temporal() for Copy_field.
* check_time_range() needs to know TIME's precision to use the
correct max value.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 2 | ||||
-rw-r--r-- | sql/field_conv.cc | 12 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 4 |
3 files changed, 14 insertions, 4 deletions
diff --git a/sql/field.cc b/sql/field.cc index f32f7d3c214..16b250ed63c 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5348,7 +5348,7 @@ int Field_time::store_time(MYSQL_TIME *ltime, timestamp_type time_type) Lazy_string_time str(ltime); int was_cut= 0; - int have_smth_to_conv= !check_time_range(&l_time, &was_cut); + int have_smth_to_conv= !check_time_range(&l_time, decimals(), &was_cut); return store_TIME_with_warning(&l_time, &str, was_cut, have_smth_to_conv); } diff --git a/sql/field_conv.cc b/sql/field_conv.cc index a4fca6f8ad7..e4da3f114ef 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -365,6 +365,14 @@ static void do_field_decimal(Copy_field *copy) } +static void do_field_temporal(Copy_field *copy) +{ + MYSQL_TIME ltime; + copy->from_field->get_date(<ime, TIME_FUZZY_DATE); + copy->to_field->store_time(<ime, ltime.time_type); +} + + /** string copy for single byte characters set when to string is shorter than from string. @@ -559,7 +567,7 @@ void Copy_field::set(uchar *to,Field *from) /* To do: - If 'save\ is set to true and the 'from' is a blob field, do_copy is set to + If 'save' is set to true and the 'from' is a blob field, do_copy is set to do_save_blob rather than do_conv_blob. The only differences between them appears to be: @@ -657,6 +665,8 @@ Copy_field::get_copy_func(Field *to,Field *from) return do_field_int; if (to->result_type() == DECIMAL_RESULT) return do_field_decimal; + if (to->cmp_type() == TIME_RESULT) + return do_field_temporal; // Check if identical fields if (from->result_type() == STRING_RESULT) { diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 1575c1345af..b27e9d72cfc 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2482,7 +2482,7 @@ bool Item_func_add_time::get_date(MYSQL_TIME *ltime, uint fuzzy_date) MYSQL_TIME copy= *ltime; Lazy_string_time str(©); - check_time_range(ltime, &was_cut); + check_time_range(ltime, decimals, &was_cut); if (was_cut) make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, &str, MYSQL_TIMESTAMP_TIME, NullS); @@ -2561,7 +2561,7 @@ bool Item_func_timediff::get_date(MYSQL_TIME *ltime, uint fuzzy_date) goto null_date; *ltime= l_time3; - check_time_range(ltime, &was_cut); + check_time_range(ltime, decimals, &was_cut); if (was_cut) make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, |