summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/include/ctype_common.inc9
-rw-r--r--mysql-test/r/ctype_big5.result11
-rw-r--r--mysql-test/r/ctype_euckr.result11
-rw-r--r--mysql-test/r/ctype_gb2312.result11
-rw-r--r--mysql-test/r/ctype_gbk.result11
-rw-r--r--mysql-test/r/ctype_uca.result11
-rw-r--r--strings/ctype-big5.c4
-rw-r--r--strings/ctype-euc_kr.c4
-rw-r--r--strings/ctype-gb2312.c4
-rw-r--r--strings/ctype-sjis.c4
10 files changed, 71 insertions, 9 deletions
diff --git a/mysql-test/include/ctype_common.inc b/mysql-test/include/ctype_common.inc
index 202c508a9c9..9ee0a40c8ce 100644
--- a/mysql-test/include/ctype_common.inc
+++ b/mysql-test/include/ctype_common.inc
@@ -51,6 +51,15 @@ SELECT c1 as want1result from t1 where c1 like 'locatio%';
SELECT c1 as want1result from t1 where c1 like 'location%';
DROP TABLE t1;
+#
+# Bug #31070: crash during conversion of charsets
+#
+create table t1 (a set('a') not null);
+insert into t1 values (),();
+select cast(a as char(1)) from t1;
+select a sounds like a from t1;
+drop table t1;
+
DROP DATABASE d1;
# Restore settings
USE test;
diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result
index 6d318a445f5..485b6ec00ae 100644
--- a/mysql-test/r/ctype_big5.result
+++ b/mysql-test/r/ctype_big5.result
@@ -52,6 +52,17 @@ SELECT c1 as want1result from t1 where c1 like 'location%';
want1result
location
DROP TABLE t1;
+create table t1 (a set('a') not null);
+insert into t1 values (),();
+select cast(a as char(1)) from t1;
+cast(a as char(1))
+
+
+select a sounds like a from t1;
+a sounds like a
+1
+1
+drop table t1;
DROP DATABASE d1;
USE test;
SET character_set_server= @safe_character_set_server;
diff --git a/mysql-test/r/ctype_euckr.result b/mysql-test/r/ctype_euckr.result
index 6017bc07763..2d9f8d217e6 100644
--- a/mysql-test/r/ctype_euckr.result
+++ b/mysql-test/r/ctype_euckr.result
@@ -52,6 +52,17 @@ SELECT c1 as want1result from t1 where c1 like 'location%';
want1result
location
DROP TABLE t1;
+create table t1 (a set('a') not null);
+insert into t1 values (),();
+select cast(a as char(1)) from t1;
+cast(a as char(1))
+
+
+select a sounds like a from t1;
+a sounds like a
+1
+1
+drop table t1;
DROP DATABASE d1;
USE test;
SET character_set_server= @safe_character_set_server;
diff --git a/mysql-test/r/ctype_gb2312.result b/mysql-test/r/ctype_gb2312.result
index 314c336bab9..04c318e83a8 100644
--- a/mysql-test/r/ctype_gb2312.result
+++ b/mysql-test/r/ctype_gb2312.result
@@ -52,6 +52,17 @@ SELECT c1 as want1result from t1 where c1 like 'location%';
want1result
location
DROP TABLE t1;
+create table t1 (a set('a') not null);
+insert into t1 values (),();
+select cast(a as char(1)) from t1;
+cast(a as char(1))
+
+
+select a sounds like a from t1;
+a sounds like a
+1
+1
+drop table t1;
DROP DATABASE d1;
USE test;
SET character_set_server= @safe_character_set_server;
diff --git a/mysql-test/r/ctype_gbk.result b/mysql-test/r/ctype_gbk.result
index 3f5d8b0d8c6..bc717736e3e 100644
--- a/mysql-test/r/ctype_gbk.result
+++ b/mysql-test/r/ctype_gbk.result
@@ -52,6 +52,17 @@ SELECT c1 as want1result from t1 where c1 like 'location%';
want1result
location
DROP TABLE t1;
+create table t1 (a set('a') not null);
+insert into t1 values (),();
+select cast(a as char(1)) from t1;
+cast(a as char(1))
+
+
+select a sounds like a from t1;
+a sounds like a
+1
+1
+drop table t1;
DROP DATABASE d1;
USE test;
SET character_set_server= @safe_character_set_server;
diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result
index 889702e380c..8a4f0fd3698 100644
--- a/mysql-test/r/ctype_uca.result
+++ b/mysql-test/r/ctype_uca.result
@@ -2587,6 +2587,17 @@ SELECT c1 as want1result from t1 where c1 like 'location%';
want1result
location
DROP TABLE t1;
+create table t1 (a set('a') not null);
+insert into t1 values (),();
+select cast(a as char(1)) from t1;
+cast(a as char(1))
+
+
+select a sounds like a from t1;
+a sounds like a
+1
+1
+drop table t1;
DROP DATABASE d1;
USE test;
SET character_set_server= @safe_character_set_server;
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c
index 8bbbcac63e4..44b9951657d 100644
--- a/strings/ctype-big5.c
+++ b/strings/ctype-big5.c
@@ -6271,12 +6271,12 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)),
my_wc_t *pwc,const uchar *s,const uchar *e)
{
- int hi=s[0];
+ int hi;
if (s >= e)
return MY_CS_TOOSMALL;
- if (hi<0x80)
+ if ((hi= s[0]) < 0x80)
{
pwc[0]=hi;
return 1;
diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c
index abaa8f1a516..0a67d4c0a54 100644
--- a/strings/ctype-euc_kr.c
+++ b/strings/ctype-euc_kr.c
@@ -8613,12 +8613,12 @@ my_mb_wc_euc_kr(CHARSET_INFO *cs __attribute__((unused)),
my_wc_t *pwc, const uchar *s, const uchar *e)
{
- int hi=s[0];
+ int hi;
if (s >= e)
return MY_CS_TOOSMALL;
- if (hi<0x80)
+ if ((hi= s[0]) < 0x80)
{
pwc[0]=hi;
return 1;
diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c
index 811394878d6..267299ace7f 100644
--- a/strings/ctype-gb2312.c
+++ b/strings/ctype-gb2312.c
@@ -5664,12 +5664,10 @@ my_mb_wc_gb2312(CHARSET_INFO *cs __attribute__((unused)),
my_wc_t *pwc, const uchar *s, const uchar *e){
int hi;
- hi=(int) s[0];
-
if (s >= e)
return MY_CS_TOOSMALL;
- if (hi<0x80)
+ if ((hi= s[0]) < 0x80)
{
pwc[0]=hi;
return 1;
diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c
index 6a7c7d7c0a0..fa00919692f 100644
--- a/strings/ctype-sjis.c
+++ b/strings/ctype-sjis.c
@@ -4526,12 +4526,12 @@ mb:
static int
my_mb_wc_sjis(CHARSET_INFO *cs __attribute__((unused)),
my_wc_t *pwc, const uchar *s, const uchar *e){
- int hi=s[0];
+ int hi;
if (s >= e)
return MY_CS_TOOSMALL;
- if (hi < 0x80)
+ if ((hi= s[0]) < 0x80)
{
pwc[0]=hi;
return 1;