summaryrefslogtreecommitdiff
path: root/sql/field_conv.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-06-07 18:13:02 +0200
committerSergei Golubchik <sergii@pisem.net>2011-06-07 18:13:02 +0200
commit9b98cae4cc44fa39813675b361b7aa65d129b29d (patch)
tree7f4baeea245f91006e88c62508c2859ed9390c2d /sql/field_conv.cc
parent29af1aefe914da6aca73498c077f7e37a36d7de4 (diff)
parent4d128777dde904c5f0adab9b093e854c9c580d41 (diff)
downloadmariadb-git-9b98cae4cc44fa39813675b361b7aa65d129b29d.tar.gz
merge with 5.1-micro
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r--sql/field_conv.cc36
1 files changed, 19 insertions, 17 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 2a597194a5c..38721484bf1 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -369,7 +369,7 @@ static void do_field_temporal(Copy_field *copy)
{
MYSQL_TIME ltime;
copy->from_field->get_date(&ltime, TIME_FUZZY_DATE);
- copy->to_field->store_time(&ltime, ltime.time_type);
+ copy->to_field->store_time_dec(&ltime, copy->from_field->decimals());
}
@@ -665,7 +665,7 @@ 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) // TODO; Optimize this
+ if (from->cmp_type() == TIME_RESULT)
{
/* If types are not 100 % identical then convert trough get_date() */
if (!to->eq_def(from) ||
@@ -677,7 +677,6 @@ Copy_field::get_copy_func(Field *to,Field *from)
return do_field_temporal;
/* Do binary copy */
}
-
// Check if identical fields
if (from->result_type() == STRING_RESULT)
{
@@ -690,10 +689,6 @@ Copy_field::get_copy_func(Field *to,Field *from)
to->type() == MYSQL_TYPE_VARCHAR && !to->has_charset())
return do_field_varbinary_pre50;
- /*
- If we are copying date or datetime's we have to check the dates
- if we don't allow 'all' dates.
- */
if (to->real_type() != from->real_type())
{
if (from->real_type() == MYSQL_TYPE_ENUM ||
@@ -832,7 +827,22 @@ int field_conv(Field *to,Field *from)
((Field_enum *)(to))->store_type(0);
return 0;
}
- else if ((from->result_type() == STRING_RESULT &&
+ if (from->result_type() == REAL_RESULT)
+ return to->store(from->val_real());
+ if (from->result_type() == DECIMAL_RESULT)
+ {
+ my_decimal buff;
+ return to->store_decimal(from->val_decimal(&buff));
+ }
+ if (from->cmp_type() == TIME_RESULT)
+ {
+ MYSQL_TIME ltime;
+ if (from->get_date(&ltime, TIME_FUZZY_DATE))
+ return to->reset();
+ else
+ return to->store_time_dec(&ltime, from->decimals());
+ }
+ if ((from->result_type() == STRING_RESULT &&
(to->result_type() == STRING_RESULT ||
(from->real_type() != MYSQL_TYPE_ENUM &&
from->real_type() != MYSQL_TYPE_SET))) ||
@@ -849,13 +859,5 @@ int field_conv(Field *to,Field *from)
*/
return to->store(result.c_ptr_quick(),result.length(),from->charset());
}
- else if (from->result_type() == REAL_RESULT)
- return to->store(from->val_real());
- else if (from->result_type() == DECIMAL_RESULT)
- {
- my_decimal buff;
- return to->store_decimal(from->val_decimal(&buff));
- }
- else
- return to->store(from->val_int(), test(from->flags & UNSIGNED_FLAG));
+ return to->store(from->val_int(), test(from->flags & UNSIGNED_FLAG));
}