Commit bf14010d authored by unknown's avatar unknown

ctype_ujis.result, ctype_ujis.test, field.cc:

  Bug#6345 Unexpected behaviour with partial indices


sql/field.cc:
  Bug#6345 Unexpected behaviour with partial indices
mysql-test/t/ctype_ujis.test:
  Bug#6345 Unexpected behaviour with partial indices
mysql-test/r/ctype_ujis.result:
  Bug#6345 Unexpected behaviour with partial indices
parent d93ff572
...@@ -126,3 +126,43 @@ Field Type Null Key Default Extra ...@@ -126,3 +126,43 @@ Field Type Null Key Default Extra
a char(1) a char(1)
b enum('あ','い') YES NULL b enum('あ','い') YES NULL
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1
(
a INTEGER NOT NULL,
b VARCHAR(50) NOT NULL DEFAULT '',
PRIMARY KEY (a),
KEY b (b(10))
) TYPE=InnoDB CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci';
INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd');
INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh');
INSERT INTO t1 (a, b) VALUES (2, 'iiijjjkkkl');
SELECT t1.* FROM t1 WHERE b='aaabbbcccddd' ORDER BY a;
a b
0 aaabbbcccddd
SELECT t1.* FROM t1 WHERE b='eeefffggghhh' ORDER BY a;
a b
1 eeefffggghhh
SELECT t1.* FROM t1 WHERE b='iiijjjkkkl' ORDER BY a;
a b
2 iiijjjkkkl
DROP TABLE t1;
CREATE TABLE t1
(
a INTEGER NOT NULL,
b VARCHAR(50) NOT NULL DEFAULT '',
PRIMARY KEY (a),
KEY b (b(10))
) TYPE=MyISAM CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci';
INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd');
INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh');
INSERT INTO t1 (a, b) VALUES (2, 'iiijjjkkkl');
SELECT t1.* FROM t1 WHERE b='aaabbbcccddd' ORDER BY a;
a b
0 aaabbbcccddd
SELECT t1.* FROM t1 WHERE b='eeefffggghhh' ORDER BY a;
a b
1 eeefffggghhh
SELECT t1.* FROM t1 WHERE b='iiijjjkkkl' ORDER BY a;
a b
2 iiijjjkkkl
DROP TABLE t1;
...@@ -83,3 +83,39 @@ CREATE TABLE t1 ( ...@@ -83,3 +83,39 @@ CREATE TABLE t1 (
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
SHOW COLUMNS FROM t1; SHOW COLUMNS FROM t1;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #6345 Unexpected behaviour with partial indices
#
--disable_warnings
CREATE TABLE t1
(
a INTEGER NOT NULL,
b VARCHAR(50) NOT NULL DEFAULT '',
PRIMARY KEY (a),
KEY b (b(10))
) TYPE=InnoDB CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci';
--enable_warnings
INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd');
INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh');
INSERT INTO t1 (a, b) VALUES (2, 'iiijjjkkkl');
SELECT t1.* FROM t1 WHERE b='aaabbbcccddd' ORDER BY a;
SELECT t1.* FROM t1 WHERE b='eeefffggghhh' ORDER BY a;
SELECT t1.* FROM t1 WHERE b='iiijjjkkkl' ORDER BY a;
DROP TABLE t1;
--disable_warnings
CREATE TABLE t1
(
a INTEGER NOT NULL,
b VARCHAR(50) NOT NULL DEFAULT '',
PRIMARY KEY (a),
KEY b (b(10))
) TYPE=MyISAM CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci';
--enable_warnings
INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd');
INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh');
INSERT INTO t1 (a, b) VALUES (2, 'iiijjjkkkl');
SELECT t1.* FROM t1 WHERE b='aaabbbcccddd' ORDER BY a;
SELECT t1.* FROM t1 WHERE b='eeefffggghhh' ORDER BY a;
SELECT t1.* FROM t1 WHERE b='iiijjjkkkl' ORDER BY a;
DROP TABLE t1;
...@@ -4401,10 +4401,14 @@ int Field_string::cmp(const char *a_ptr, const char *b_ptr) ...@@ -4401,10 +4401,14 @@ int Field_string::cmp(const char *a_ptr, const char *b_ptr)
(const uchar*) b_ptr, (const uchar*) b_ptr,
field_length); field_length);
} }
return my_strnncoll(field_charset,(const uchar*) a_ptr, field_length, uint char_len= field_length/field_charset->mbmaxlen;
(const uchar*) b_ptr, field_length); uint a_len= my_charpos(field_charset, a_ptr, a_ptr + field_length, char_len);
uint b_len= my_charpos(field_charset, b_ptr, b_ptr + field_length, char_len);
return my_strnncoll(field_charset,(const uchar*) a_ptr, a_len,
(const uchar*) b_ptr, b_len);
} }
void Field_string::sort_string(char *to,uint length) void Field_string::sort_string(char *to,uint length)
{ {
uint tmp=my_strnxfrm(field_charset, uint tmp=my_strnxfrm(field_charset,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment