summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--innobase/os/os0sync.c16
-rw-r--r--mysql-test/include/ctype_like_escape.inc18
-rw-r--r--mysql-test/r/ctype_big5.result36
-rw-r--r--mysql-test/r/ctype_gbk.result36
-rw-r--r--mysql-test/r/ctype_latin1.result36
-rw-r--r--mysql-test/r/ctype_sjis.result36
-rw-r--r--mysql-test/r/ctype_tis620.result36
-rw-r--r--mysql-test/r/ctype_uca.result18
-rw-r--r--mysql-test/r/ctype_ucs.result36
-rw-r--r--mysql-test/r/ctype_ujis.result36
-rw-r--r--mysql-test/r/ctype_utf8.result36
-rw-r--r--mysql-test/t/ctype_big5.test2
-rw-r--r--mysql-test/t/ctype_gbk.test2
-rw-r--r--mysql-test/t/ctype_latin1.test2
-rw-r--r--mysql-test/t/ctype_sjis.test2
-rw-r--r--mysql-test/t/ctype_tis620.test2
-rw-r--r--mysql-test/t/ctype_uca.test1
-rw-r--r--mysql-test/t/ctype_ucs.test2
-rw-r--r--mysql-test/t/ctype_ujis.test2
-rw-r--r--mysql-test/t/ctype_utf8.test2
-rw-r--r--ndb/test/sql/test_create_drop.pl179
-rw-r--r--ndb/test/sql/test_range_bounds.pl (renamed from mysql-test/ndb/ndb_range_bounds.pl)0
-rw-r--r--sql/ha_innodb.cc3
-rw-r--r--sql/item_cmpfunc.cc5
-rw-r--r--strings/ctype-big5.c15
-rw-r--r--strings/ctype-gbk.c15
-rw-r--r--strings/ctype-mb.c11
-rw-r--r--strings/ctype-simple.c11
-rw-r--r--strings/ctype-sjis.c11
-rw-r--r--strings/ctype-tis620.c77
-rw-r--r--strings/ctype-ucs2.c6
31 files changed, 572 insertions, 118 deletions
diff --git a/innobase/os/os0sync.c b/innobase/os/os0sync.c
index 356d7c8c163..487e8f40a39 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
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_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 5734f7cac86..dae694cf3d5 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 e2805e41f3a..4b245c69d2a 100644
--- a/mysql-test/r/ctype_uca.result
+++ b/mysql-test/r/ctype_uca.result
@@ -2506,6 +2506,24 @@ 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;
CREATE TABLE t1 (id int, a varchar(30) character set utf8);
INSERT INTO t1 VALUES (1, _ucs2 0x01310069), (2, _ucs2 0x01310131);
INSERT INTO t1 VALUES (3, _ucs2 0x00690069), (4, _ucs2 0x01300049);
diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result
index 4bc2ed0fdc8..65b5a1cbba8 100644
--- a/mysql-test/r/ctype_ucs.result
+++ b/mysql-test/r/ctype_ucs.result
@@ -595,6 +595,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;
@@ -606,6 +624,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 0fee6fc3456..15de93440fc 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,6 +2289,24 @@ 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;
DROP TABLE IF EXISTS t1, t2;
DROP PROCEDURE IF EXISTS sp1;
set names ujis;
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
index 8e10e97d49d..1695f1c67e8 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_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 43ef0cc8755..6d8713f4910 100644
--- a/mysql-test/t/ctype_uca.test
+++ b/mysql-test/t/ctype_uca.test
@@ -456,6 +456,7 @@ 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 668edb3fafe..626c7e0e1b6 100644
--- a/mysql-test/t/ctype_ucs.test
+++ b/mysql-test/t/ctype_ucs.test
@@ -372,9 +372,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 7730fd0db6d..c1d6c67387b 100644
--- a/mysql-test/t/ctype_ujis.test
+++ b/mysql-test/t/ctype_ujis.test
@@ -1146,9 +1146,11 @@ 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
--disable_warnings
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
index b009e13874f..8194dbdb438 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/ndb/test/sql/test_create_drop.pl b/ndb/test/sql/test_create_drop.pl
new file mode 100644
index 00000000000..7f62898b3d1
--- /dev/null
+++ b/ndb/test/sql/test_create_drop.pl
@@ -0,0 +1,179 @@
+use strict;
+use IO::Socket;
+use DBI;
+
+# mgm info
+my $mgmhost = "localhost";
+my $mgmport = 38101;
+
+# location of ndb_x_fs
+my $datadir = "c2";
+my @schemafiles = <$datadir/ndb_*_fs/D[12]/DBDICT/P0.SchemaLog>;
+@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/mysql-test/ndb/ndb_range_bounds.pl b/ndb/test/sql/test_range_bounds.pl
index abe1ea28298..abe1ea28298 100644
--- a/mysql-test/ndb/ndb_range_bounds.pl
+++ b/ndb/test/sql/test_range_bounds.pl
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 85f26425099..e8e1ef5169b 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -5770,7 +5770,8 @@ ha_innobase::get_foreign_key_create_info(void)
fclose(file);
} else {
/* unable to create temporary file */
- str = my_malloc(1, MYF(MY_ZEROFILL));
+ str = my_strdup(
+"/* Error: cannot display foreign key constraints */", MYF(0));
}
return(str);
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 85ba8ff794d..138ebaaf9a5 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2958,9 +2958,9 @@ bool Item_func_like::fix_fields(THD *thd, 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.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(),
@@ -2975,6 +2975,7 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref)
code instead of Unicode code as "escape" argument.
Convert to "cs" if charset of escape differs.
*/
+ CHARSET_INFO *cs= cmp.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 5069a1dc082..8b50388e4ef 100644
--- a/strings/ctype-big5.c
+++ b/strings/ctype-big5.c
@@ -401,16 +401,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]))
{
@@ -421,7 +417,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-gbk.c b/strings/ctype-gbk.c
index 5c220a285dd..e3a76359eaa 100644
--- a/strings/ctype-gbk.c
+++ b/strings/ctype-gbk.c
@@ -2714,16 +2714,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]))
{
@@ -2734,7 +2730,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 6f171c03845..a3e10ba7650 100644
--- a/strings/ctype-mb.c
+++ b/strings/ctype-mb.c
@@ -523,17 +523,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)
{
@@ -567,6 +563,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 208c38edd30..d25b9e4d9cf 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -1034,17 +1034,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 c0a395b5792..2ed21a40edd 100644
--- a/strings/ctype-sjis.c
+++ b/strings/ctype-sjis.c
@@ -330,16 +330,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 2003eaa0789..762f6d2dfb6 100644
--- a/strings/ctype-tis620.c
+++ b/strings/ctype-tis620.c
@@ -648,77 +648,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 */
- {
- /*
- Calculate length of keys:
- 'a\0\0... is the smallest possible string when we have space expand
- a\ff\ff... is the biggest possible string
- */
- *min_length= ((cs->state & MY_CS_BINSORT) ? (uint) (min_str - min_org) :
- res_length);
- *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,
@@ -928,7 +857,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler =
my_strnncollsp_tis620,
my_strnxfrm_tis620,
my_strnxfrmlen_simple,
- my_like_range_tis620,
+ my_like_range_simple,
my_wildcmp_8bit, /* wildcmp */
my_strcasecmp_8bit,
my_instr_simple, /* QQ: To be fixed */
@@ -992,7 +921,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
@@ -1023,7 +952,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 41ab055d2de..c389f2e7f75 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -1450,10 +1450,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];