summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmysql-test/r/ctype_cp932.result17
-rw-r--r--mysql-test/t/ctype_cp932.test10
-rw-r--r--strings/ctype-cp932.c2
3 files changed, 28 insertions, 1 deletions
diff --git a/mysql-test/r/ctype_cp932.result b/mysql-test/r/ctype_cp932.result
index 08206a91b7b..1afceb86381 100755
--- a/mysql-test/r/ctype_cp932.result
+++ b/mysql-test/r/ctype_cp932.result
@@ -11349,3 +11349,20 @@ cp932_bin 6109
cp932_bin 61
cp932_bin 6120
drop table t1;
+create table t1 (col1 varchar(1)) character set cp932;
+insert into t1 values ('a');
+insert into t1 values ('ab');
+Warnings:
+Warning 1265 Data truncated for column 'col1' at row 1
+select * from t1;
+col1
+a
+a
+insert into t1 values ('abc');
+Warnings:
+Warning 1265 Data truncated for column 'col1' at row 1
+select * from t1;
+col1
+a
+a
+a
diff --git a/mysql-test/t/ctype_cp932.test b/mysql-test/t/ctype_cp932.test
index 3d630311b3a..082786e38af 100644
--- a/mysql-test/t/ctype_cp932.test
+++ b/mysql-test/t/ctype_cp932.test
@@ -424,3 +424,13 @@ SET collation_connection='cp932_japanese_ci';
-- source include/ctype_filesort.inc
SET collation_connection='cp932_bin';
-- source include/ctype_filesort.inc
+
+#
+# Bug#12547: Inserting long string into varchar causes table crash in cp932
+#
+create table t1 (col1 varchar(1)) character set cp932;
+insert into t1 values ('a');
+insert into t1 values ('ab');
+select * from t1;
+insert into t1 values ('abc');
+select * from t1;
diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c
index b5f36c030bd..3e5403446ce 100644
--- a/strings/ctype-cp932.c
+++ b/strings/ctype-cp932.c
@@ -5417,7 +5417,7 @@ uint my_well_formed_len_cp932(CHARSET_INFO *cs __attribute__((unused)),
{
const char *b0= b;
*error= 0;
- while (pos && b < e)
+ while (pos-- && b < e)
{
/*
Cast to int8 for extra safety.