summaryrefslogtreecommitdiff
path: root/sql/field_conv.cc
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2005-07-19 11:05:49 -0700
committerunknown <jimw@mysql.com>2005-07-19 11:05:49 -0700
commite9c64ae296457b04bd68945c5de12c369de71b8b (patch)
tree04692d95c000bd65df72b0a4c5c605b71afa5287 /sql/field_conv.cc
parent6ae060305541019882bcb60bf086458b010faa45 (diff)
parentabcd8b032cb4afad6640d21e08763349e116da32 (diff)
downloadmariadb-git-e9c64ae296457b04bd68945c5de12c369de71b8b.tar.gz
Merge mysql.com:/home/jimw/my/mysql-4.1-clean
into mysql.com:/home/jimw/my/mysql-5.0-clean extra/perror.c: Auto merged include/my_global.h: Auto merged mysql-test/r/ps_1general.result: Auto merged mysql-test/r/ps_2myisam.result: Auto merged mysql-test/r/ps_3innodb.result: Auto merged mysql-test/r/ps_4heap.result: Auto merged mysql-test/r/ps_5merge.result: Auto merged mysql-test/r/ps_6bdb.result: Auto merged mysql-test/r/ps_7ndb.result: Auto merged mysql-test/r/select.result: Auto merged ndb/src/mgmsrv/ConfigInfo.cpp: Auto merged ndb/src/mgmsrv/main.cpp: Auto merged sql/des_key_file.cc: Auto merged sql/field_conv.cc: Auto merged sql/item_func.cc: Auto merged sql/item_strfunc.cc: Auto merged sql/item_timefunc.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_select.cc: Auto merged tests/mysql_client_test.c: Auto merged mysql-test/t/select.test: Resolve conflicts scripts/mysqld_safe.sh: Resolve conflict sql/item.cc: Resolve conflict, don't return FIELD_TYPE_BLOB since VARCHAR can be longer in 5.0 than 4.1. sql/log_event.cc: Resolve conflict sql/mysql_priv.h: Resolve conflict sql/mysqld.cc: Remove incorrect fix (merge from 4.1) sql/sql_show.cc: Resolve conflict
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r--sql/field_conv.cc32
1 files changed, 31 insertions, 1 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 0dc82666f52..c46e1c08c8b 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -322,7 +322,34 @@ static void do_field_real(Copy_field *copy)
}
+/*
+ string copy for single byte characters set when to string is shorter than
+ from string
+*/
+
static void do_cut_string(Copy_field *copy)
+{
+ CHARSET_INFO *cs= copy->from_field->charset();
+ memcpy(copy->to_ptr,copy->from_ptr,copy->to_length);
+
+ /* Check if we loosed any important characters */
+ if (cs->cset->scan(cs,
+ copy->from_ptr + copy->to_length,
+ copy->from_ptr + copy->from_length,
+ MY_SEQ_SPACES) < copy->from_length - copy->to_length)
+ {
+ copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_WARN_DATA_TRUNCATED, 1);
+ }
+}
+
+
+/*
+ string copy for multi byte characters set when to string is shorter than
+ from string
+*/
+
+static void do_cut_string_complex(Copy_field *copy)
{ // Shorter string field
int well_formed_error;
CHARSET_INFO *cs= copy->from_field->charset();
@@ -349,6 +376,8 @@ static void do_cut_string(Copy_field *copy)
}
+
+
static void do_expand_string(Copy_field *copy)
{
CHARSET_INFO *cs= copy->from_field->charset();
@@ -550,7 +579,8 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*)
do_varstring1 : do_varstring2);
}
else if (to_length < from_length)
- return do_cut_string;
+ return (from->charset()->mbmaxlen == 1 ?
+ do_cut_string : do_cut_string_complex);
else if (to_length > from_length)
return do_expand_string;
}