MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:kgeorge Date:April 7 2008 12:34pm
Subject:bk commit into 4.1 tree (gkodinov:1.2709) BUG#34949
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of kgeorge. When kgeorge does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-04-07 15:34:42+03:00, gkodinov@stripped +3 -0
  Bug#34949: Passing invalid parameter to CHAR() in an 
   ORDER BY causes MySQL to hang.
  
  The function my_strnxfrm_utf8() was not checking for
  certain error codes returned by my_utf8_uni().
  Back-ported the correct check from 5.0.

  mysql-test/r/ctype_utf8.result@stripped, 2008-04-07 15:34:41+03:00, gkodinov@stripped +31 -0
    Bug #34949: test case

  mysql-test/t/ctype_utf8.test@stripped, 2008-04-07 15:34:41+03:00, gkodinov@stripped +20 -0
    Bug #34949: test case

  strings/ctype-utf8.c@stripped, 2008-04-07 15:34:41+03:00, gkodinov@stripped +2 -2
    Bug #34949: check for 0 (means error)

diff -Nrup a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
--- a/mysql-test/r/ctype_utf8.result	2006-11-08 13:37:51 +02:00
+++ b/mysql-test/r/ctype_utf8.result	2008-04-07 15:34:41 +03:00
@@ -1449,3 +1449,34 @@ substr(Z.a,-1)	a
 3	123
 6	456
 drop table t1;
+SET CHARACTER SET utf8;
+SHOW VARIABLES LIKE 'character\_set\_%';
+Variable_name	Value
+character_set_client	utf8
+character_set_connection	latin1
+character_set_database	latin1
+character_set_results	utf8
+character_set_server	latin1
+character_set_system	utf8
+CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
+USE crashtest;
+CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8;
+INSERT INTO crashtest VALUES ('35'), ('36'), ('37');
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8);
+crash
+35
+36
+37
+INSERT INTO crashtest VALUES ('-1000');
+EXPLAIN SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	crashtest	ALL	NULL	NULL	NULL	NULL	4	Using filesort
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8);
+crash
+-1000
+35
+36
+37
+DROP TABLE crashtest;
+DROP DATABASE crashtest;
+USE test;
diff -Nrup a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
--- a/mysql-test/t/ctype_utf8.test	2006-11-08 13:37:51 +02:00
+++ b/mysql-test/t/ctype_utf8.test	2008-04-07 15:34:41 +03:00
@@ -1173,4 +1173,24 @@ explain
   select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
 select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
 drop table t1;
+
+#
+# Bug #34349: Passing invalid parameter to CHAR() in an ORDER BY causes
+# MySQL to hang
+#
+
+SET CHARACTER SET utf8;
+SHOW VARIABLES LIKE 'character\_set\_%';
+CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
+USE crashtest;
+CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8;
+INSERT INTO crashtest VALUES ('35'), ('36'), ('37');
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8);
+INSERT INTO crashtest VALUES ('-1000');
+EXPLAIN SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8);
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8);
+DROP TABLE crashtest;
+DROP DATABASE crashtest;
+USE test;
+
 # End of 4.1 tests
diff -Nrup a/strings/ctype-utf8.c b/strings/ctype-utf8.c
--- a/strings/ctype-utf8.c	2006-07-20 13:52:44 +03:00
+++ b/strings/ctype-utf8.c	2008-04-07 15:34:41 +03:00
@@ -2228,7 +2228,7 @@ static int my_strnxfrm_utf8(CHARSET_INFO
 
   while( src < se && dst < de )
   {
-    if ((res=my_utf8_uni(cs,&wc, src, se))<0)
+    if ((res=my_utf8_uni(cs,&wc, src, se))<=0)
     {
       break;
     }
@@ -2238,7 +2238,7 @@ static int my_strnxfrm_utf8(CHARSET_INFO
     plane=(wc>>8) & 0xFF;
     wc = uni_plane[plane] ? uni_plane[plane][wc & 0xFF].sort : wc;
 
-    if ((res=my_uni_utf8(cs,wc,dst,de)) <0)
+    if ((res=my_uni_utf8(cs,wc,dst,de)) <=0)
     {
       break;
     }
Thread
bk commit into 4.1 tree (gkodinov:1.2709) BUG#34949kgeorge7 Apr