Commit 70a3abf2 authored by unknown's avatar unknown

Bug #5832 SELECT doesn't return records in some cases

parent 48ff8f4d
...@@ -1260,3 +1260,27 @@ a length(a) char_length(a) ...@@ -1260,3 +1260,27 @@ a length(a) char_length(a)
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 510 255 ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 510 255
drop table t1; drop table t1;
SET NAMES latin1; SET NAMES latin1;
CREATE TABLE t1 (
id int unsigned NOT NULL auto_increment,
list_id smallint unsigned NOT NULL,
term TEXT NOT NULL,
PRIMARY KEY(id),
INDEX(list_id, term(4))
) ENGINE=BDB CHARSET=utf8;
INSERT INTO t1 SET list_id = 1, term = "letterc";
INSERT INTO t1 SET list_id = 1, term = "letterb";
INSERT INTO t1 SET list_id = 1, term = "lettera";
INSERT INTO t1 SET list_id = 1, term = "letterd";
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterc");
id
1
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterb");
id
2
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera");
id
3
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd");
id
4
DROP TABLE t1;
...@@ -726,3 +726,27 @@ length(subject) ...@@ -726,3 +726,27 @@ length(subject)
3 3
432 432
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (
id int unsigned NOT NULL auto_increment,
list_id smallint unsigned NOT NULL,
term TEXT NOT NULL,
PRIMARY KEY(id),
INDEX(list_id, term(4))
) ENGINE=MYISAM CHARSET=utf8;
INSERT INTO t1 SET list_id = 1, term = "letterc";
INSERT INTO t1 SET list_id = 1, term = "letterb";
INSERT INTO t1 SET list_id = 1, term = "lettera";
INSERT INTO t1 SET list_id = 1, term = "letterd";
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterc");
id
1
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterb");
id
2
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera");
id
3
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd");
id
4
DROP TABLE t1;
...@@ -909,3 +909,23 @@ insert into t1 values (@a); ...@@ -909,3 +909,23 @@ insert into t1 values (@a);
select a, length(a), char_length(a) from t1; select a, length(a), char_length(a) from t1;
drop table t1; drop table t1;
SET NAMES latin1; SET NAMES latin1;
#
# Bug #5832 SELECT doesn't return records in some cases
#
CREATE TABLE t1 (
id int unsigned NOT NULL auto_increment,
list_id smallint unsigned NOT NULL,
term TEXT NOT NULL,
PRIMARY KEY(id),
INDEX(list_id, term(4))
) ENGINE=BDB CHARSET=utf8;
INSERT INTO t1 SET list_id = 1, term = "letterc";
INSERT INTO t1 SET list_id = 1, term = "letterb";
INSERT INTO t1 SET list_id = 1, term = "lettera";
INSERT INTO t1 SET list_id = 1, term = "letterd";
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterc");
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterb");
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera");
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd");
DROP TABLE t1;
...@@ -572,3 +572,23 @@ INSERT INTO t1 VALUES ('aaa','bbb'); ...@@ -572,3 +572,23 @@ INSERT INTO t1 VALUES ('aaa','bbb');
SELECT length(subject) FROM t1; SELECT length(subject) FROM t1;
SELECT length(subject) FROM t1 ORDER BY 1; SELECT length(subject) FROM t1 ORDER BY 1;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #5832 SELECT doesn't return records in some cases
#
CREATE TABLE t1 (
id int unsigned NOT NULL auto_increment,
list_id smallint unsigned NOT NULL,
term TEXT NOT NULL,
PRIMARY KEY(id),
INDEX(list_id, term(4))
) ENGINE=MYISAM CHARSET=utf8;
INSERT INTO t1 SET list_id = 1, term = "letterc";
INSERT INTO t1 SET list_id = 1, term = "letterb";
INSERT INTO t1 SET list_id = 1, term = "lettera";
INSERT INTO t1 SET list_id = 1, term = "letterd";
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterc");
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterb");
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera");
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd");
DROP TABLE t1;
...@@ -5077,6 +5077,11 @@ void Field_blob::get_key_image(char *buff,uint length, ...@@ -5077,6 +5077,11 @@ void Field_blob::get_key_image(char *buff,uint length,
} }
#endif /*HAVE_SPATIAL*/ #endif /*HAVE_SPATIAL*/
get_ptr(&blob);
uint char_length= length / cs->mbmaxlen;
char_length= my_charpos(cs, blob, blob + length, char_length);
set_if_smaller(length, char_length);
if ((uint32) length > blob_length) if ((uint32) length > blob_length)
{ {
/* /*
...@@ -5087,7 +5092,6 @@ void Field_blob::get_key_image(char *buff,uint length, ...@@ -5087,7 +5092,6 @@ void Field_blob::get_key_image(char *buff,uint length,
length=(uint) blob_length; length=(uint) blob_length;
} }
int2store(buff,length); int2store(buff,length);
get_ptr(&blob);
memcpy(buff+HA_KEY_BLOB_LENGTH, blob, length); memcpy(buff+HA_KEY_BLOB_LENGTH, blob, length);
} }
...@@ -5103,6 +5107,10 @@ int Field_blob::key_cmp(const byte *key_ptr, uint max_key_length) ...@@ -5103,6 +5107,10 @@ int Field_blob::key_cmp(const byte *key_ptr, uint max_key_length)
char *blob1; char *blob1;
uint blob_length=get_length(ptr); uint blob_length=get_length(ptr);
memcpy_fixed(&blob1,ptr+packlength,sizeof(char*)); memcpy_fixed(&blob1,ptr+packlength,sizeof(char*));
CHARSET_INFO *cs= charset();
uint char_length= max_key_length / cs->mbmaxlen;
char_length= my_charpos(cs, blob1, blob1+blob_length, char_length);
set_if_smaller(blob_length, char_length);
return Field_blob::cmp(blob1,min(blob_length, max_key_length), return Field_blob::cmp(blob1,min(blob_length, max_key_length),
(char*) key_ptr+HA_KEY_BLOB_LENGTH, (char*) key_ptr+HA_KEY_BLOB_LENGTH,
uint2korr(key_ptr)); uint2korr(key_ptr));
......
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