From 14912660c39354c366419d65899bc95061d63e6e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Sep 2005 23:10:51 +0500 Subject: [PATCH 01/10] Bug#13046: LIKE pattern matching using prefix index doesn't return correct result item_cmpfunc.cc: Use charset of LIKE to decide whether to use 8bit or Unicode "escape" value. But use charset of "escape" to scan escape character. strings/ctype-xxx.c: We cannot reduce "end" pointer using charpos(), because of possible escape characters in the string. Limit the loop using count of written characters instead. ctype_like_escape.inc: new file mysql-test/t/ctype_xxx: mysql-test/r/ctype_xxx: Adding test case. strings/ctype-big5.c: Bug#13046: LIKE pattern matching using prefix index doesn't return correct result We cannot change "end" pointer using charpos(), because of possible escape characters. Use limit by count of written characters instead. strings/ctype-cp932.c: Bug#13046: LIKE pattern matching using prefix index doesn't return correct result We cannot change "end" pointer using charpos(), because of possible escape characters. Use limit by count of written characters instead strings/ctype-gbk.c: Bug#13046: LIKE pattern matching using prefix index doesn't return correct result We cannot change "end" pointer using charpos(), because of possible escape characters. Use limit by count of written characters instead strings/ctype-mb.c: Bug#13046: LIKE pattern matching using prefix index doesn't return correct result We cannot change "end" pointer using charpos(), because of possible escape characters. Use limit by count of written characters instead strings/ctype-simple.c: Bug#13046: LIKE pattern matching using prefix index doesn't return correct result We cannot change "end" pointer using charpos(), because of possible escape characters. Use limit by count of written characters instead strings/ctype-sjis.c: Bug#13046: LIKE pattern matching using prefix index doesn't return correct result We cannot change "end" pointer using charpos(), because of possible escape characters. Use limit by count of written characters instead strings/ctype-tis620.c: Bug#13046: LIKE pattern matching using prefix index doesn't return correct result We cannot change "end" pointer using charpos(), because of possible escape characters. Use limit by count of written characters instead strings/ctype-ucs2.c: Bug#13046: LIKE pattern matching using prefix index doesn't return correct result We cannot change "end" pointer using charpos(), because of possible escape characters. Use limit by count of written characters instead mysql-test/t/ctype_big5.test: Adding test case. mysql-test/t/ctype_cp932.test: Adding test case. mysql-test/t/ctype_gbk.test: Adding test case. mysql-test/t/ctype_latin1.test: Adding test case. mysql-test/t/ctype_sjis.test: Adding test case. mysql-test/t/ctype_tis620.test: Adding test case. mysql-test/t/ctype_uca.test: Adding test case. mysql-test/t/ctype_ucs.test: Adding test case. mysql-test/t/ctype_ujis.test: Adding test case. mysql-test/t/ctype_utf8.test: Adding test case. mysql-test/r/ctype_big5.result: Adding test case. mysql-test/r/ctype_cp932.result: Adding test case. mysql-test/r/ctype_gbk.result: Adding test case. mysql-test/r/ctype_latin1.result: Adding test case. mysql-test/r/ctype_sjis.result: Adding test case. mysql-test/r/ctype_tis620.result: Adding test case. mysql-test/r/ctype_uca.result: Adding test case. mysql-test/r/ctype_ucs.result: Adding test case. mysql-test/r/ctype_ujis.result: Adding test case. mysql-test/r/ctype_utf8.result: Adding test case. sql/item_cmpfunc.cc: More fixes. --- mysql-test/include/ctype_like_escape.inc | 18 ++++++ mysql-test/r/ctype_big5.result | 36 ++++++++++++ mysql-test/r/ctype_cp932.result | 36 ++++++++++++ mysql-test/r/ctype_gbk.result | 36 ++++++++++++ mysql-test/r/ctype_latin1.result | 36 ++++++++++++ mysql-test/r/ctype_sjis.result | 36 ++++++++++++ mysql-test/r/ctype_tis620.result | 36 ++++++++++++ mysql-test/r/ctype_uca.result | 18 ++++++ mysql-test/r/ctype_ucs.result | 36 ++++++++++++ mysql-test/r/ctype_ujis.result | 36 ++++++++++++ mysql-test/r/ctype_utf8.result | 36 ++++++++++++ mysql-test/t/ctype_big5.test | 2 + mysql-test/t/ctype_cp932.test | 2 + mysql-test/t/ctype_gbk.test | 2 + mysql-test/t/ctype_latin1.test | 2 + mysql-test/t/ctype_sjis.test | 2 + mysql-test/t/ctype_tis620.test | 2 + mysql-test/t/ctype_uca.test | 1 + mysql-test/t/ctype_ucs.test | 2 + mysql-test/t/ctype_ujis.test | 2 + mysql-test/t/ctype_utf8.test | 2 + sql/item_cmpfunc.cc | 5 +- strings/ctype-big5.c | 15 +++-- strings/ctype-cp932.c | 11 ++-- strings/ctype-gbk.c | 15 +++-- strings/ctype-mb.c | 17 ++---- strings/ctype-simple.c | 11 +--- strings/ctype-sjis.c | 11 ++-- strings/ctype-tis620.c | 71 +----------------------- strings/ctype-ucs2.c | 6 +- 30 files changed, 418 insertions(+), 123 deletions(-) create mode 100644 mysql-test/include/ctype_like_escape.inc diff --git a/mysql-test/include/ctype_like_escape.inc b/mysql-test/include/ctype_like_escape.inc new file mode 100644 index 00000000000..ac97fbaa1a0 --- /dev/null +++ b/mysql-test/include/ctype_like_escape.inc @@ -0,0 +1,18 @@ +# +# Bugs: #13046: +# LIKE pattern matching using prefix index doesn't return correct result +# +select @@collation_connection; +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +-- should return ab_def +select c1 as c1u from t1 where c1 like 'ab\_def'; +-- should return ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +drop table t1; diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result index 01b59b93b52..a31289775fe 100644 --- a/mysql-test/r/ctype_big5.result +++ b/mysql-test/r/ctype_big5.result @@ -89,6 +89,24 @@ select c1 from t1 where c1 like 'abcde111%' order by c1; c1 abcde111 drop table t1; +select @@collation_connection; +@@collation_connection +big5_chinese_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; SET collation_connection='big5_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -121,6 +139,24 @@ select c1 from t1 where c1 like 'abcde111%' order by c1; c1 abcde111 drop table t1; +select @@collation_connection; +@@collation_connection +big5_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; SET NAMES big5; CREATE TABLE t1 (a text) character set big5; INSERT INTO t1 VALUES (''); diff --git a/mysql-test/r/ctype_cp932.result b/mysql-test/r/ctype_cp932.result index d8221a58b9e..8763055647c 100644 --- a/mysql-test/r/ctype_cp932.result +++ b/mysql-test/r/ctype_cp932.result @@ -8624,6 +8624,24 @@ select c1 from t1 where c1 like 'abcde111%' order by c1; c1 abcde111 drop table t1; +select @@collation_connection; +@@collation_connection +cp932_japanese_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; SET collation_connection='cp932_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -8656,3 +8674,21 @@ select c1 from t1 where c1 like 'abcde111%' order by c1; c1 abcde111 drop table t1; +select @@collation_connection; +@@collation_connection +cp932_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; diff --git a/mysql-test/r/ctype_gbk.result b/mysql-test/r/ctype_gbk.result index 1a9dea28429..aaffe692126 100644 --- a/mysql-test/r/ctype_gbk.result +++ b/mysql-test/r/ctype_gbk.result @@ -89,6 +89,24 @@ select c1 from t1 where c1 like 'abcde111%' order by c1; c1 abcde111 drop table t1; +select @@collation_connection; +@@collation_connection +gbk_chinese_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; SET collation_connection='gbk_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -121,6 +139,24 @@ select c1 from t1 where c1 like 'abcde111%' order by c1; c1 abcde111 drop table t1; +select @@collation_connection; +@@collation_connection +gbk_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; SET NAMES gbk; CREATE TABLE t1 (a text) character set gbk; INSERT INTO t1 VALUES (0xA3A0),(0xA1A1); diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result index 95fca1575ef..0fbdc8ac63c 100644 --- a/mysql-test/r/ctype_latin1.result +++ b/mysql-test/r/ctype_latin1.result @@ -315,6 +315,24 @@ latin1_swedish_ci 6109 latin1_swedish_ci 61 latin1_swedish_ci 6120 drop table t1; +select @@collation_connection; +@@collation_connection +latin1_swedish_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; SET collation_connection='latin1_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -325,6 +343,24 @@ latin1_bin 6109 latin1_bin 61 latin1_bin 6120 drop table t1; +select @@collation_connection; +@@collation_connection +latin1_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; CREATE TABLE a (a int); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'a (a int)' at line 1 SELECT 'a' as str; diff --git a/mysql-test/r/ctype_sjis.result b/mysql-test/r/ctype_sjis.result index e6669c63621..d1976a516d2 100644 --- a/mysql-test/r/ctype_sjis.result +++ b/mysql-test/r/ctype_sjis.result @@ -103,6 +103,24 @@ select c1 from t1 where c1 like 'abcde111%' order by c1; c1 abcde111 drop table t1; +select @@collation_connection; +@@collation_connection +sjis_japanese_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; SET collation_connection='sjis_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -135,6 +153,24 @@ select c1 from t1 where c1 like 'abcde111%' order by c1; c1 abcde111 drop table t1; +select @@collation_connection; +@@collation_connection +sjis_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; SET NAMES sjis; SELECT HEX('@\\') FROM DUAL; HEX('@_\') diff --git a/mysql-test/r/ctype_tis620.result b/mysql-test/r/ctype_tis620.result index 6d8bfe74c4b..9d13d7cd34b 100644 --- a/mysql-test/r/ctype_tis620.result +++ b/mysql-test/r/ctype_tis620.result @@ -2947,6 +2947,24 @@ tis620_thai_ci 6109 tis620_thai_ci 61 tis620_thai_ci 6120 drop table t1; +select @@collation_connection; +@@collation_connection +tis620_thai_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; SET collation_connection='tis620_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -2957,3 +2975,21 @@ tis620_bin 6109 tis620_bin 61 tis620_bin 6120 drop table t1; +select @@collation_connection; +@@collation_connection +tis620_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index c6e803904a3..91ee427efb4 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -2396,3 +2396,21 @@ utf8_unicode_ci 6109 utf8_unicode_ci 61 utf8_unicode_ci 6120 drop table t1; +select @@collation_connection; +@@collation_connection +utf8_unicode_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 6d00f13737d..619ad750ff3 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -587,6 +587,24 @@ ucs2_general_ci 00610009 ucs2_general_ci 0061 ucs2_general_ci 00610020 drop table t1; +select @@collation_connection; +@@collation_connection +ucs2_general_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; SET NAMES latin1; SET collation_connection='ucs2_bin'; create table t1 select repeat('a',4000) a; @@ -598,6 +616,24 @@ ucs2_bin 00610009 ucs2_bin 0061 ucs2_bin 00610020 drop table t1; +select @@collation_connection; +@@collation_connection +ucs2_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; select hex(substr(_ucs2 0x00e400e50068,1)); hex(substr(_ucs2 0x00e400e50068,1)) 00E400E50068 diff --git a/mysql-test/r/ctype_ujis.result b/mysql-test/r/ctype_ujis.result index dec1baf4a4b..c86cbe9ce53 100644 --- a/mysql-test/r/ctype_ujis.result +++ b/mysql-test/r/ctype_ujis.result @@ -2239,6 +2239,24 @@ select c1 from t1 where c1 like 'abcde111%' order by c1; c1 abcde111 drop table t1; +select @@collation_connection; +@@collation_connection +ujis_japanese_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; SET collation_connection='ujis_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -2271,3 +2289,21 @@ select c1 from t1 where c1 like 'abcde111%' order by c1; c1 abcde111 drop table t1; +select @@collation_connection; +@@collation_connection +ujis_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 9f2d7eac700..aeea574ef6c 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -842,6 +842,24 @@ utf8_general_ci 6109 utf8_general_ci 61 utf8_general_ci 6120 drop table t1; +select @@collation_connection; +@@collation_connection +utf8_general_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; SET collation_connection='utf8_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -852,6 +870,24 @@ utf8_bin 6109 utf8_bin 61 utf8_bin 6120 drop table t1; +select @@collation_connection; +@@collation_connection +utf8_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; CREATE TABLE t1 ( user varchar(255) NOT NULL default '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1; diff --git a/mysql-test/t/ctype_big5.test b/mysql-test/t/ctype_big5.test index 73d9f06042c..1788dce755b 100644 --- a/mysql-test/t/ctype_big5.test +++ b/mysql-test/t/ctype_big5.test @@ -15,9 +15,11 @@ SET NAMES big5; SET collation_connection='big5_chinese_ci'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc +-- source include/ctype_like_escape.inc SET collation_connection='big5_bin'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc +-- source include/ctype_like_escape.inc # # Bugs#9357: TEXT columns break string with special word in BIG5 charset. diff --git a/mysql-test/t/ctype_cp932.test b/mysql-test/t/ctype_cp932.test index 8e6c53af095..d6c3c226140 100644 --- a/mysql-test/t/ctype_cp932.test +++ b/mysql-test/t/ctype_cp932.test @@ -427,8 +427,10 @@ DROP table t1; SET collation_connection='cp932_japanese_ci'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc +-- source include/ctype_like_escape.inc SET collation_connection='cp932_bin'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc +-- source include/ctype_like_escape.inc # End of 4.1 tests diff --git a/mysql-test/t/ctype_gbk.test b/mysql-test/t/ctype_gbk.test index 2210891454e..5eeade96186 100644 --- a/mysql-test/t/ctype_gbk.test +++ b/mysql-test/t/ctype_gbk.test @@ -15,9 +15,11 @@ SET NAMES gbk; SET collation_connection='gbk_chinese_ci'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc +-- source include/ctype_like_escape.inc SET collation_connection='gbk_bin'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc +-- source include/ctype_like_escape.inc # # Bug#11987 mysql will truncate the text when diff --git a/mysql-test/t/ctype_latin1.test b/mysql-test/t/ctype_latin1.test index 1b83373da29..8953aaecaf8 100644 --- a/mysql-test/t/ctype_latin1.test +++ b/mysql-test/t/ctype_latin1.test @@ -64,8 +64,10 @@ select 'a' regexp 'A' collate latin1_bin; SET collation_connection='latin1_swedish_ci'; -- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc SET collation_connection='latin1_bin'; -- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc # # Bug#8041 diff --git a/mysql-test/t/ctype_sjis.test b/mysql-test/t/ctype_sjis.test index 252f0a0b6c8..1d807b5e9a8 100644 --- a/mysql-test/t/ctype_sjis.test +++ b/mysql-test/t/ctype_sjis.test @@ -67,9 +67,11 @@ drop table t1; SET collation_connection='sjis_japanese_ci'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc +-- source include/ctype_like_escape.inc SET collation_connection='sjis_bin'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc +-- source include/ctype_like_escape.inc # Check parsing of string literals in SJIS with multibyte characters that # have an embedded \ in them. (Bug #8303) diff --git a/mysql-test/t/ctype_tis620.test b/mysql-test/t/ctype_tis620.test index d649828eda3..c49540de24b 100644 --- a/mysql-test/t/ctype_tis620.test +++ b/mysql-test/t/ctype_tis620.test @@ -155,7 +155,9 @@ DROP TABLE t1; SET collation_connection='tis620_thai_ci'; -- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc SET collation_connection='tis620_bin'; -- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc # End of 4.1 tests diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test index 9d81aa74e90..2300abca69d 100644 --- a/mysql-test/t/ctype_uca.test +++ b/mysql-test/t/ctype_uca.test @@ -455,5 +455,6 @@ drop table t1; SET collation_connection='utf8_unicode_ci'; -- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc # End of 4.1 tests diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 4a5c80bed6e..2c9e71ddff5 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -370,9 +370,11 @@ drop table t1; SET collation_connection='ucs2_general_ci'; -- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc SET NAMES latin1; SET collation_connection='ucs2_bin'; -- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc # # Bug#10344 Some string functions fail for UCS2 diff --git a/mysql-test/t/ctype_ujis.test b/mysql-test/t/ctype_ujis.test index 88386500c9f..bf74371510b 100644 --- a/mysql-test/t/ctype_ujis.test +++ b/mysql-test/t/ctype_ujis.test @@ -1146,8 +1146,10 @@ DROP TABLE t1; SET collation_connection='ujis_japanese_ci'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc +-- source include/ctype_like_escape.inc SET collation_connection='ujis_bin'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc +-- source include/ctype_like_escape.inc # End of 4.1 tests diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 0cdda648899..23824a58dab 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -685,8 +685,10 @@ drop table t1; SET collation_connection='utf8_general_ci'; -- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc SET collation_connection='utf8_bin'; -- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc # # Bug #7874 CONCAT() gives wrong results mixing diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 74eed7fa41a..c4d3d6f7ab4 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2443,9 +2443,9 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref) String *escape_str= escape_item->val_str(&tmp_value1); if (escape_str) { - CHARSET_INFO *cs= cmp.cmp_collation.collation; - if (use_mb(cs)) + if (use_mb(cmp_collation.collation)) { + CHARSET_INFO *cs= escape_str->charset(); my_wc_t wc; int rc= cs->cset->mb_wc(cs, &wc, (const uchar*) escape_str->ptr(), @@ -2460,6 +2460,7 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref) code instead of Unicode code as "escape" argument. Convert to "cs" if charset of escape differs. */ + CHARSET_INFO *cs= cmp_collation.collation; uint32 unused; if (escape_str->needs_conversion(escape_str->length(), escape_str->charset(), cs, &unused)) diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 76a4e197405..08b0ff009ee 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -392,16 +392,12 @@ static my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)), uint res_length, char *min_str,char *max_str, uint *min_length,uint *max_length) { - const char *end; + const char *end= ptr + ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; - uint charlen= my_charpos(cs, ptr, ptr+ptr_length, res_length/cs->mbmaxlen); + uint charlen= res_length / cs->mbmaxlen; - if (charlen < ptr_length) - ptr_length= charlen; - end= ptr + ptr_length; - - for (; ptr != end && min_str != min_end ; ptr++) + for (; ptr != end && min_str != min_end && charlen > 0; ptr++, charlen--) { if (ptr+1 != end && isbig5code(ptr[0],ptr[1])) { @@ -412,7 +408,10 @@ static my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)), if (*ptr == escape && ptr+1 != end) { ptr++; /* Skip escape */ - *min_str++= *max_str++ = *ptr; + if (isbig5code(ptr[0], ptr[1])) + *min_str++= *max_str++ = *ptr++; + if (min_str < min_end) + *min_str++= *max_str++= *ptr; continue; } if (*ptr == w_one) /* '_' in SQL */ diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index e476130b706..63f95a28037 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -322,16 +322,13 @@ static my_bool my_like_range_cp932(CHARSET_INFO *cs __attribute__((unused)), uint res_length, char *min_str,char *max_str, uint *min_length,uint *max_length) { - const char *end; + const char *end= ptr + ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; - uint charlen= my_charpos(cs, ptr, ptr+ptr_length, res_length/cs->mbmaxlen); + uint charlen= res_length / cs->mbmaxlen; - if (charlen < ptr_length) - ptr_length= charlen; - end= ptr + ptr_length; - - while (ptr < end && min_str < min_end) { + for ( ; ptr < end && min_str < min_end && charlen > 0 ; charlen--) + { if (ismbchar_cp932(cs, ptr, end)) { *min_str++ = *max_str++ = *ptr++; if (min_str < min_end) diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index 82c76b8ee96..b5b86984794 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -2705,16 +2705,12 @@ static my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)), uint res_length, char *min_str,char *max_str, uint *min_length,uint *max_length) { - const char *end; + const char *end= ptr + ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; - uint charlen= my_charpos(cs, ptr, ptr+ptr_length, res_length/cs->mbmaxlen); + uint charlen= res_length / cs->mbmaxlen; - if (charlen < ptr_length) - ptr_length= charlen; - end= ptr + ptr_length; - - for (; ptr != end && min_str != min_end ; ptr++) + for (; ptr != end && min_str != min_end && charlen > 0; ptr++, charlen--) { if (ptr+1 != end && isgbkcode(ptr[0],ptr[1])) { @@ -2725,7 +2721,10 @@ static my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)), if (*ptr == escape && ptr+1 != end) { ptr++; /* Skip escape */ - *min_str++= *max_str++ = *ptr; + if (isgbkcode(ptr[0], ptr[1])) + *min_str++= *max_str++ = *ptr; + if (min_str < min_end) + *min_str++= *max_str++= *ptr; continue; } if (*ptr == w_one) /* '_' in SQL */ diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 4b22f158284..eb032759d25 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -502,17 +502,13 @@ my_bool my_like_range_mb(CHARSET_INFO *cs, char *min_str,char *max_str, uint *min_length,uint *max_length) { - const char *end; + const char *end= ptr + ptr_length; char *min_org= min_str; char *min_end= min_str + res_length; char *max_end= max_str + res_length; - uint charlen= my_charpos(cs, ptr, ptr+ptr_length, res_length/cs->mbmaxlen); + uint charlen= res_length / cs->mbmaxlen; - if (charlen < ptr_length) - ptr_length= charlen; - end= ptr + ptr_length; - - for (; ptr != end && min_str != min_end ; ptr++) + for (; ptr != end && min_str != min_end && charlen > 0 ; ptr++, charlen--) { if (*ptr == escape && ptr+1 != end) { @@ -522,14 +518,8 @@ my_bool my_like_range_mb(CHARSET_INFO *cs, } if (*ptr == w_one || *ptr == w_many) /* '_' and '%' in SQL */ { - charlen= my_charpos(cs, min_org, min_str, res_length/cs->mbmaxlen); - - if (charlen < (uint) (min_str - min_org)) - min_str= min_org + charlen; - /* Write min key */ *min_length= (uint) (min_str - min_org); - *max_length= res_length; do { *min_str++= (char) cs->min_sort_char; @@ -540,6 +530,7 @@ my_bool my_like_range_mb(CHARSET_INFO *cs, representation of the max_sort_char character, and copy it into max_str in a loop. */ + *max_length= res_length; pad_max_char(cs, max_str, max_end); return 0; } diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index af673b78254..efddab621f2 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -997,17 +997,12 @@ my_bool my_like_range_simple(CHARSET_INFO *cs, char *min_str,char *max_str, uint *min_length,uint *max_length) { - const char *end; + const char *end= ptr + ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; -#ifdef USE_MB - uint charlen= my_charpos(cs, ptr, ptr+ptr_length, res_length/cs->mbmaxlen); - if (charlen < ptr_length) - ptr_length= charlen; -#endif - end= ptr + ptr_length; + uint charlen= res_length / cs->mbmaxlen; - for (; ptr != end && min_str != min_end ; ptr++) + for (; ptr != end && min_str != min_end && charlen > 0 ; ptr++, charlen--) { if (*ptr == escape && ptr+1 != end) { diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 4342fc670df..da79f1796b8 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -322,16 +322,13 @@ static my_bool my_like_range_sjis(CHARSET_INFO *cs __attribute__((unused)), uint res_length, char *min_str,char *max_str, uint *min_length,uint *max_length) { - const char *end; + const char *end= ptr + ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; - uint charlen= my_charpos(cs, ptr, ptr+ptr_length, res_length/cs->mbmaxlen); + uint charlen= res_length / cs->mbmaxlen; - if (charlen < ptr_length) - ptr_length= charlen; - end= ptr + ptr_length; - - while (ptr < end && min_str < min_end) { + for ( ; ptr < end && min_str < min_end && charlen > 0 ; charlen--) + { if (ismbchar_sjis(cs, ptr, end)) { *min_str++ = *max_str++ = *ptr++; if (min_str < min_end) diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 208168bb946..dcb0e0525b4 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -641,71 +641,6 @@ int my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)), } - -/* - Convert SQL LIKE string to C string - - Arg: String, its length, escape character, resource length, - minimal string and maximum string - Ret: Always 0 - - IMPLEMENTATION - We just copy this function from opt_range.cc. No need to convert to - thai2sortable string. min_str and max_str will be use for comparison and - converted there. - - RETURN VALUES - 0 -*/ - -#define max_sort_chr ((char) 255) - -static -my_bool my_like_range_tis620(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr, uint ptr_length, - pbool escape, pbool w_one, pbool w_many, - uint res_length, char *min_str, char *max_str, - uint *min_length, uint *max_length) -{ - const char *end=ptr+ptr_length; - char *min_org=min_str; - char *min_end=min_str+res_length; - - for (; ptr != end && min_str != min_end ; ptr++) - { - if (*ptr == escape && ptr+1 != end) - { - ptr++; /* Skip escape */ - *min_str++ = *max_str++ = *ptr; - continue; - } - if (*ptr == w_one) /* '_' in SQL */ - { - *min_str++='\0'; /* This should be min char */ - *max_str++=max_sort_chr; - continue; - } - if (*ptr == w_many) /* '%' in SQL */ - { - *min_length= (uint) (min_str - min_org); - *max_length=res_length; - do - { - *min_str++ = 0; - *max_str++ = max_sort_chr; - } while (min_str != min_end); - return 0; - } - *min_str++= *max_str++ = *ptr; - } - *min_length= *max_length = (uint) (min_str - min_org); - - while (min_str != min_end) - *min_str++ = *max_str++ = ' '; /* Because of key compression */ - return 0; -} - - static unsigned short cs_to_uni[256]={ 0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0008,0x0009,0x000A,0x000B,0x000C,0x000D,0x000E,0x000F, @@ -914,7 +849,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_tis620, my_strnncollsp_tis620, my_strnxfrm_tis620, - my_like_range_tis620, + my_like_range_simple, my_wildcmp_8bit, /* wildcmp */ my_strcasecmp_8bit, my_instr_simple, /* QQ: To be fixed */ @@ -974,7 +909,7 @@ CHARSET_INFO my_charset_tis620_thai_ci= 1, /* mbminlen */ 1, /* mbmaxlen */ 0, /* min_sort_char */ - 0, /* max_sort_char */ + 255, /* max_sort_char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, &my_collation_ci_handler @@ -1002,7 +937,7 @@ CHARSET_INFO my_charset_tis620_bin= 1, /* mbminlen */ 1, /* mbmaxlen */ 0, /* min_sort_char */ - 0, /* max_sort_char */ + 255, /* max_sort_char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, &my_collation_8bit_bin_handler diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 2761e781724..56c05635300 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1426,10 +1426,12 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs, const char *end=ptr+ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; + uint charlen= res_length / cs->mbmaxlen; - for (; ptr + 1 < end && min_str + 1 < min_end ; ptr+=2) + for ( ; ptr + 1 < end && min_str + 1 < min_end && charlen > 0 + ; ptr+=2, charlen--) { - if (ptr[0] == '\0' && ptr[1] == escape && ptr+2 < end) + if (ptr[0] == '\0' && ptr[1] == escape && ptr + 1 < end) { ptr+=2; /* Skip escape */ *min_str++= *max_str++ = ptr[0]; From 8d31718c5b4fe27fbed8dddf034d595ed7cee9ed Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 3 Oct 2005 00:05:50 +0300 Subject: [PATCH 02/10] os0sync.c: Add diagnostic code to track an assertion failure of 0 == pthread_mutex_destroy(); this was reported on the MySQL mailing list Sept 23, 2005 innobase/os/os0sync.c: Add diagnostic code to track an assertion failure of 0 == pthread_mutex_destroy(); this was reported on the MySQL mailing list Sept 23, 2005 --- innobase/os/os0sync.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/innobase/os/os0sync.c b/innobase/os/os0sync.c index 18d92af5054..4ad9473fe66 100644 --- a/innobase/os/os0sync.c +++ b/innobase/os/os0sync.c @@ -631,7 +631,21 @@ os_fast_mutex_free( DeleteCriticalSection((LPCRITICAL_SECTION) fast_mutex); #else - ut_a(0 == pthread_mutex_destroy(fast_mutex)); + int ret; + + ret = pthread_mutex_destroy(fast_mutex); + + if (ret != 0) { + ut_print_timestamp(stderr); + fprintf(stderr, +" InnoDB: error: return value %lu when calling\n" +"InnoDB: pthread_mutex_destroy().\n", (ulint)ret); + fprintf(stderr, +"InnoDB: Byte contents of the pthread mutex at %p:\n", fast_mutex); + ut_print_buf(stderr, (const byte*)fast_mutex, + sizeof(os_fast_mutex_t)); + fprintf(stderr, "\n"); + } #endif if (os_sync_mutex_inited) { /* When freeing the last mutexes, we have From 19dffd265e0e6b63572d226310cb3b9d17555fc5 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 3 Oct 2005 16:24:47 +0200 Subject: [PATCH 03/10] Move -ansi flag from global_warnings to cxx_warnings BUILD/SETUP.sh: ansi glags should only be set for C++ compilation --- BUILD/SETUP.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index 91633139c9c..54546d632c8 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -43,10 +43,10 @@ AM_MAKEFLAGS="-j 4" # The following warning flag will give too many warnings: # -Wshadow -Wunused -Winline (The later isn't usable in C++ as # __attribute()__ doesn't work with gnu C++) -global_warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -ansi" +global_warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings" #debug_extra_warnings="-Wuninitialized" c_warnings="$global_warnings -Wunused" -cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor" +cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -ansi" base_max_configs="--with-innodb --with-berkeley-db --with-ndbcluster --with-archive-storage-engine --with-raid --with-openssl --with-raid --with-vio" max_leave_isam_configs="--with-innodb --with-berkeley-db --with-ndbcluster --with-archive-storage-engine --with-raid --with-openssl --with-raid --with-vio --with-embedded-server" From 9595cc332d5333eb6a361ec668351309831999c6 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 3 Oct 2005 17:46:27 +0300 Subject: [PATCH 04/10] InnoDB: Display an error message in /* */ comments in SHOW CREATE TABLE if a temporary file cannot be created. (Bug #13002) sql/ha_innodb.cc: ha_innobase::get_foreign_key_create_info(): Display an error message to the user if a temporary file cannot be created. --- sql/ha_innodb.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 3ae56f13478..d994c76fb3f 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -4458,8 +4458,8 @@ ha_innobase::get_foreign_key_create_info(void) fclose(file); } else { /* unable to create temporary file */ - str = my_malloc(1, MYF(0)); - str[0] = 0; + str = my_strdup( +"/* Error: cannot display foreign key constraints */", MYF(0)); } return(str); From e4470578411b9afe207e11fd8781560317d11365 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 Oct 2005 10:54:58 +0200 Subject: [PATCH 05/10] Windows compilation fix: Added typecast (const char* to char *) --- client/mysql.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysql.cc b/client/mysql.cc index e73d627d67a..d82d29a9a54 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -993,7 +993,7 @@ static int read_lines(bool execute_commands) unsigned long clen; do { - line= my_cgets(tmpbuf.ptr(), tmpbuf.alloced_length()-1, &clen); + line= my_cgets((char *) tmpbuf.ptr(), tmpbuf.alloced_length()-1, &clen); buffer.append(line, clen); /* if we got buffer fully filled than there is a chance that From 068a15bb287d7fea7bcfc6bcb4e4ade9b15e8c3f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Oct 2005 17:33:39 +0500 Subject: [PATCH 06/10] item_cmpfunc.cc: wrong variable. sql/item_cmpfunc.cc: wrong variable. --- sql/item_cmpfunc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 009e31c8665..7f50e5d0163 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2443,7 +2443,7 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref) String *escape_str= escape_item->val_str(&tmp_value1); if (escape_str) { - if (use_mb(cmp_collation.collation)) + if (use_mb(cmp.cmp_collation.collation)) { CHARSET_INFO *cs= escape_str->charset(); my_wc_t wc; From e484fdf5bf24e90e311342a2144d5654b3b8df40 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Oct 2005 14:35:41 +0200 Subject: [PATCH 07/10] Revert BUILD/SETUP.sh: Remov -ansi flag --- BUILD/SETUP.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index 54546d632c8..3f8a9ccaf22 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -46,7 +46,7 @@ AM_MAKEFLAGS="-j 4" global_warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings" #debug_extra_warnings="-Wuninitialized" c_warnings="$global_warnings -Wunused" -cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -ansi" +cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor" base_max_configs="--with-innodb --with-berkeley-db --with-ndbcluster --with-archive-storage-engine --with-raid --with-openssl --with-raid --with-vio" max_leave_isam_configs="--with-innodb --with-berkeley-db --with-ndbcluster --with-archive-storage-engine --with-raid --with-openssl --with-raid --with-vio --with-embedded-server" From 6efe60124c999b0346c593f72bf844a37728d22e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Oct 2005 09:44:25 +0200 Subject: [PATCH 08/10] ndb - prelim perl scripts to autotest BitKeeper/deleted/.del-ndb_range_bounds.pl~ff7e47a35fb44c74: Delete: mysql-test/ndb/ndb_range_bounds.pl --- mysql-test/ndb/ndb_range_bounds.pl | 138 ------------------ ndb/test/sql/test_create_drop.pl | 179 +++++++++++++++++++++++ ndb/test/sql/test_range_bounds.pl | 218 +++++++++++++++++++++++++++++ 3 files changed, 397 insertions(+), 138 deletions(-) delete mode 100644 mysql-test/ndb/ndb_range_bounds.pl create mode 100644 ndb/test/sql/test_create_drop.pl create mode 100644 ndb/test/sql/test_range_bounds.pl diff --git a/mysql-test/ndb/ndb_range_bounds.pl b/mysql-test/ndb/ndb_range_bounds.pl deleted file mode 100644 index 75b7f8a33e1..00000000000 --- a/mysql-test/ndb/ndb_range_bounds.pl +++ /dev/null @@ -1,138 +0,0 @@ -# -# test range scan bounds -# output to mysql-test/t/ndb_range_bounds.test -# -# give option --all to generate all cases -# - -use strict; -use integer; -use Getopt::Long; - -my $opt_all = 0; -my $opt_cnt = 5; -GetOptions("all" => \$opt_all, "cnt=i" => \$opt_cnt) - or die "options are: --all --cnt=N"; - -my $table = 't'; - -print < 1, - 'exp' => '9 = 9', - 'cnt' => scalar @$val, - }; -} - -sub mkone ($$$\@) { - my($col, $op, $key, $val) = @_; - my $cnt = scalar cut($op, $key, @$val); - return { - 'exp' => "$col $op $key", - 'cnt' => $cnt, - }; -} - -sub mktwo ($$$$$\@) { - my($col, $op1, $key1, $op2, $key2, $val) = @_; - my $cnt = scalar cut($op2, $key2, cut($op1, $key1, @$val)); - return { - 'exp' => "$col $op1 $key1 and $col $op2 $key2", - 'cnt' => $cnt, - }; -} - -sub mkall ($$$\@) { - my($col, $key1, $key2, $val) = @_; - my @a = (); - my $p = mkdummy(@$val); - push(@a, $p) if $opt_all; - my @ops = qw(< <= = >= >); - for my $op (@ops) { - my $p = mkone($col, $op, $key1, @$val); - push(@a, $p) if $opt_all || $p->{cnt} != 0; - } - my @ops1 = $opt_all ? @ops : qw(= >= >); - my @ops2 = $opt_all ? @ops : qw(<= <); - for my $op1 (@ops1) { - for my $op2 (@ops2) { - my $p = mktwo($col, $op1, $key1, $op2, $key2, @$val); - push(@a, $p) if $opt_all || $p->{cnt} != 0; - } - } - return \@a; -} - -for my $nn ("bcd", "") { - my %nn; - for my $x (qw(b c d)) { - $nn{$x} = $nn =~ /$x/ ? "not null" : "null"; - } - print <{cnt} * @val * @val; - print "select count(*) - $cnt1 from $table"; - print " where $p1->{exp};\n"; - for my $p2 (@$a2) { - my $cnt2 = $p1->{cnt} * $p2->{cnt} * @val; - print "select count(*) - $cnt2 from $table"; - print " where $p1->{exp} and $p2->{exp};\n"; - for my $p3 (@$a3) { - my $cnt3 = $p1->{cnt} * $p2->{cnt} * $p3->{cnt}; - print "select count(*) - $cnt3 from $table"; - print " where $p1->{exp} and $p2->{exp} and $p3->{exp};\n"; - } - } - } - print <; +@schemafiles or die "no schemafiles in $datadir"; + +my $dsn; +$dsn = "dbi:mysql:test:localhost;port=38100"; + +# this works better for me +my $cnf = $ENV{MYSQL_HOME} . "/var/my.cnf"; +$dsn = "dbi:mysql:database=test;host=localhost;mysql_read_default_file=$cnf"; + +my $dbh; +$dbh = DBI->connect($dsn, 'root', undef, { RaiseError => 0, PrintError => 0 }); +$dbh or die $DBI::errstr; + +# mgm commands + +my $mgm = undef; + +sub mgmconnect { + $mgm = IO::Socket::INET->new( + Proto => "tcp", + PeerHost => $mgmhost, + PeerPort => $mgmport); + $mgm or die "connect to mgm failed: $!"; + $mgm->autoflush(1); +}; + +mgmconnect(); +warn "connected to mgm $mgmhost $mgmport\n"; + +my $nodeinfo = {}; + +sub getnodeinfo { + $nodeinfo = {}; + $mgm->print("get status\n"); + $mgm->print("\n"); + while (defined($_ = $mgm->getline)) { + /^node\s+status/ && last; + } + while (defined($_ = $mgm->getline)) { + /^\s*$/ && last; + /^node\.(\d+)\.(\w+):\s*(\S+)/ && ($nodeinfo->{$1}{$2} = $3); + } +} + +getnodeinfo(); + +my @dbnode = (); +for my $n (keys %$nodeinfo) { + my $p = $nodeinfo->{$n}; + ($p->{type} eq 'NDB') && push(@dbnode, $n); +} +@dbnode = sort { $a <=> $b } @dbnode; +@dbnode or die "mgm error, found no db nodes"; +warn "db nodes: @dbnode\n"; + +sub restartnode { + my($n, $initialstart) = @_; + warn "restart node $n initialstart=$initialstart\n"; + $mgm->print("restart node\n"); + $mgm->print("node: $n\n"); + $mgm->print("initialstart: $initialstart\n"); + $mgm->print("\n"); + while (1) { + sleep 5; + getnodeinfo(); + my $status = $nodeinfo->{$n}{status}; + my $sp = $nodeinfo->{$n}{startphase}; + warn "node $n status: $status sp: $sp\n"; + last if $status eq 'STARTED'; + } +} + +sub restartall { + warn "restart all\n"; + $mgm->print("restart all\n"); + $mgm->print("\n"); + while (1) { + sleep 5; + getnodeinfo(); + my $ok = 1; + for my $n (@dbnode) { + my $status = $nodeinfo->{$n}{status}; + my $sp = $nodeinfo->{$n}{startphase}; + warn "node $n status: $status sp: $sp\n"; + $ok = 0 if $status ne 'STARTED'; + } + last if $ok; + } +} + +# the sql stuff + +my $maxtab = 300; +my @tab = (); + +sub create { + my($n) = @_; + my $sql = "create table t$n (a int primary key, b varchar(20), key (b)) engine=ndb"; + warn "create t$n\n"; + $dbh->do($sql) or die "$sql\n$DBI::errstr"; +} + +sub drop { + my($n) = @_; + my $sql = "drop table t$n"; + warn "drop t$n\n"; + $dbh->do($sql) or die "$sql\n$DBI::errstr"; +} + +sub dropall { + for my $n (0..($maxtab-1)) { + my $sql = "drop table if exists t$n"; + $dbh->do($sql) or die "$sql\n$DBI::errstr"; + } +} + +sub createdrop { + my $n = int(rand($maxtab)); + if (! $tab[$n]) { + create($n); + $tab[$n] = 1; + } else { + drop($n); + $tab[$n] = 0; + } +} + +sub checkschemafiles { + system("printSchemaFile -ce @schemafiles"); + $? == 0 or die "schemafiles check failed"; +} + +sub randomrestart { + my($k) = @_; + my $s = int(rand(500)); + if ($s < 2) { + my $i = $k % scalar(@dbnode); + my $n = $dbnode[$i]; + my $initialstart = ($s < 1 ? 0 : 1); + restartnode($n, $initialstart); + return 1; + } + if ($s < 3) { + restartall(); + return 1; + } + return 0; +} + +# deterministic +srand(1); + +warn "drop any old tables\n"; +dropall(); + +my $loop = 1000000; +for my $k (0..($loop-1)) { + warn "$k\n"; + createdrop(); + checkschemafiles(); + if (randomrestart($k)) { + checkschemafiles(); + } +} + +$dbh->disconnect or die $DBI::errstr; + +# vim: set sw=2: diff --git a/ndb/test/sql/test_range_bounds.pl b/ndb/test/sql/test_range_bounds.pl new file mode 100644 index 00000000000..abe1ea28298 --- /dev/null +++ b/ndb/test/sql/test_range_bounds.pl @@ -0,0 +1,218 @@ +# +# test range scan bounds +# give option --all to test all cases +# set MYSQL_HOME to installation top +# + +use strict; +use integer; +use Getopt::Long; +use DBI; + +my $opt_all = 0; +my $opt_cnt = 5; +my $opt_verbose = 0; +GetOptions("all" => \$opt_all, "cnt=i" => \$opt_cnt, "verbose" => \$opt_verbose) + or die "options are: --all --cnt=N --verbose"; + +my $mysql_home = $ENV{MYSQL_HOME}; +defined($mysql_home) or die "no MYSQL_HOME"; +my $dsn = "dbi:mysql:database=test;host=localhost;mysql_read_default_file=$mysql_home/var/my.cnf"; +my $opts = { RaiseError => 0, PrintError => 0, AutoCommit => 1, }; + +my $dbh; +my $sth; +my $sql; + +$dbh = DBI->connect($dsn, "root", undef, $opts) or die $DBI::errstr; + +my $table = 't'; + +$sql = "drop table if exists $table"; +$dbh->do($sql) or die $DBI::errstr; + +sub cut ($$$) { + my($op, $key, $val) = @_; + $op = '==' if $op eq '='; + my(@w) = @$val; + eval "\@w = grep(\$_ $op $key, \@w)"; + $@ and die $@; + return [ @w ]; +} + +sub mkdummy ($) { + my ($val) = @_; + return { + 'dummy' => 1, + 'exp' => '9 = 9', + 'res' => $val, + }; +} + +sub mkone ($$$$) { + my($col, $op, $key, $val) = @_; + my $res = cut($op, $key, $val); + return { + 'exp' => "$col $op $key", + 'res' => $res, + }; +} + +sub mktwo ($$$$$$) { + my($col, $op1, $key1, $op2, $key2, $val) = @_; + my $res = cut($op2, $key2, cut($op1, $key1, $val)); + return { + 'exp' => "$col $op1 $key1 and $col $op2 $key2", + 'res' => $res, + }; +} + +sub mkall ($$$$) { + my($col, $key1, $key2, $val) = @_; + my @a = (); + my $p = mkdummy($val); + push(@a, $p) if $opt_all; + my @ops = qw(< <= = >= >); + for my $op (@ops) { + my $p = mkone($col, $op, $key1, $val); + push(@a, $p) if $opt_all || @{$p->{res}} != 0; + } + my @ops1 = $opt_all ? @ops : qw(= >= >); + my @ops2 = $opt_all ? @ops : qw(<= <); + for my $op1 (@ops1) { + for my $op2 (@ops2) { + my $p = mktwo($col, $op1, $key1, $op2, $key2, $val); + push(@a, $p) if $opt_all || @{$p->{res}} != 0; + } + } + warn scalar(@a)." cases\n" if $opt_verbose; + return \@a; +} + +my $casecnt = 0; + +sub verify ($$$) { + my($sql, $ord, $res) = @_; + warn "$sql\n" if $opt_verbose; + $sth = $dbh->prepare($sql) or die "prepare: $sql: $DBI::errstr"; + $sth->execute() or die "execute: $sql: $DBI::errstr"; + # + # BUG: execute can return success on error so check again + # + $sth->err and die "execute: $sql: $DBI::errstr"; + my @out = (); + for my $b (@{$res->[0]}) { + for my $c (@{$res->[1]}) { + for my $d (@{$res->[2]}) { + push(@out, [$b, $c, $d]); + } + } + } + if ($ord) { + @out = sort { + $ord * ($a->[0] - $b->[0]) || + $ord * ($a->[1] - $b->[1]) || + $ord * ($a->[2] - $b->[2]) || + 0 + } @out; + } + my $cnt = scalar @out; + my $n = 0; + while (1) { + my $row = $sth->fetchrow_arrayref; + $row || last; + @$row == 3 or die "bad row: $sql: @$row"; + for my $v (@$row) { + $v =~ s/^\s+|\s+$//g; + $v =~ /^\d+$/ or die "bad value: $sql: $v"; + } + if ($ord) { + my $out = $out[$n]; + $row->[0] == $out->[0] && + $row->[1] == $out->[1] && + $row->[2] == $out->[2] or + die "$sql: row $n: got row @$row != @$out"; + } + $n++; + } + $sth->err and die "fetch: $sql: $DBI::errstr"; + $n == $cnt or die "verify: $sql: got row count $n != $cnt"; + $casecnt++; +} + +for my $nn ("bcd", "") { + my %nn; + for my $x (qw(b c d)) { + $nn{$x} = $nn =~ /$x/ ? "not null" : "null"; + } + warn "create table\n"; + $sql = <do($sql) or die $DBI::errstr; + warn "insert\n"; + $sql = "insert into $table values(?, ?, ?, ?)"; + $sth = $dbh->prepare($sql) or die $DBI::errstr; + my @val = (0..($opt_cnt-1)); + my $v0 = 0; + for my $v1 (@val) { + for my $v2 (@val) { + for my $v3 (@val) { + $sth->bind_param(1, $v0) or die $DBI::errstr; + $sth->bind_param(2, $v1) or die $DBI::errstr; + $sth->bind_param(3, $v2) or die $DBI::errstr; + $sth->bind_param(4, $v3) or die $DBI::errstr; + $sth->execute or die $DBI::errstr; + $v0++; + } + } + } + warn "generate cases\n"; + my $key1 = 1; + my $key2 = 3; + my $a1 = mkall('b', $key1, $key2, \@val); + my $a2 = mkall('c', $key1, $key2, \@val); + my $a3 = mkall('d', $key1, $key2, \@val); + warn "select\n"; + for my $ord (0, +1, -1) { + my $orderby = + $ord == 0 ? "" : + $ord == +1 ? " order by b, c, d" : + $ord == -1 ? " order by b desc, c desc, d desc" : die "not here"; + for my $p1 (@$a1) { + my $res = [ $p1->{res}, \@val, \@val ]; + $sql = "select b, c, d from $table" . + " where $p1->{exp}" . + $orderby; + verify($sql, $ord, $res); + for my $p2 (@$a2) { + my $res = [ $p1->{res}, $p2->{res}, \@val ]; + $sql = "select b, c, d from $table" . + " where $p1->{exp} and $p2->{exp}" . + $orderby; + verify($sql, $ord, $res); + for my $p3 (@$a3) { + my $res = [ $p1->{res}, $p2->{res}, $p3->{res} ]; + $sql = "select b, c, d from $table" . + " where $p1->{exp} and $p2->{exp} and $p3->{exp}" . + $orderby; + verify($sql, $ord, $res); + } + } + } + } + warn "drop table\n"; + $sql = "drop table $table"; + $dbh->do($sql) or die $DBI::errstr; +} + +warn "verified $casecnt cases\n"; +warn "done\n"; + +# vim: set sw=2: From e6ec5794f64617dda0cfdeb4bae422cff6d81950 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Oct 2005 15:26:59 +0500 Subject: [PATCH 09/10] item_cmpfunc.cc: Wrong variable. sql/item_cmpfunc.cc: Wrong variable. --- sql/item_cmpfunc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 7f50e5d0163..2c76c7ec7b3 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2460,7 +2460,7 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref) code instead of Unicode code as "escape" argument. Convert to "cs" if charset of escape differs. */ - CHARSET_INFO *cs= cmp_collation.collation; + CHARSET_INFO *cs= cmp.cmp_collation.collation; uint32 unused; if (escape_str->needs_conversion(escape_str->length(), escape_str->charset(), cs, &unused)) From 970150d14e83b74e66cd61b9f77aa9c378a94ec7 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Oct 2005 19:05:34 +0200 Subject: [PATCH 10/10] don't "init" binlog if opt_bin_log is not set (bug#13791 - mysqld crashes at startup in TC_LOG_MMAP::open) --- sql/log.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index f352a38c393..8e9555cc9b2 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -66,7 +66,7 @@ handlerton binlog_hton = { NULL, /* rollback_by_xid */ NULL, /* create_cursor_read_view */ NULL, /* set_cursor_read_view */ - NULL, /* close_cursor_read_view */ + NULL, /* close_cursor_read_view */ HTON_NO_FLAGS }; @@ -78,7 +78,7 @@ handlerton binlog_hton = { bool binlog_init() { - return false; + return !opt_bin_log; } static int binlog_close_connection(THD *thd)