summaryrefslogtreecommitdiff
path: root/sql/field_conv.cc
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2005-08-16 22:13:43 +0400
committerunknown <evgen@moonbone.local>2005-08-16 22:13:43 +0400
commit06ebdbb7859ebdfa1d3ba97a45bf74224619b384 (patch)
treec660002eb3724b212902c96101d676ea79f70656 /sql/field_conv.cc
parent219c84faba28171cc04608f826703f5c031d70bc (diff)
downloadmariadb-git-06ebdbb7859ebdfa1d3ba97a45bf74224619b384.tar.gz
Fix bug #11398 Bug in field_conv() results in wrong result of join with index
When copying varchar fields with field_conv() it's not taken into account that length_bytes of source and destination fields may be different. This results in saving wrong data in field and making wrong key later. Added check so if fields are varchar and have different length_bytes they are not copied by memcpy(). sql/field_conv.cc: Fix bug #11398 Bug in field_conv() results in wrong result of join with index mysql-test/t/select.test: Test case for bug #11398 Bug in field_conv() results in wrong result of join with index mysql-test/r/select.result: Test case for bug #11398 Bug in field_conv() results in wrong result of join with index
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r--sql/field_conv.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index fc7347ef9af..40f3ff85c58 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -640,7 +640,10 @@ void field_conv(Field *to,Field *from)
(!(to->table->in_use->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) ||
to->type() != FIELD_TYPE_DATE &&
- to->type() != FIELD_TYPE_DATETIME))
+ to->type() != FIELD_TYPE_DATETIME) &&
+ (from->real_type() != MYSQL_TYPE_VARCHAR ||
+ ((Field_varstring*)from)->length_bytes ==
+ ((Field_varstring*)to)->length_bytes))
{ // Identical fields
#ifdef HAVE_purify
/* This may happen if one does 'UPDATE ... SET x=x' */