Commit 39ef7a53 authored by unknown's avatar unknown

Merge olga.mysql.com:/home/igor/mysql-5.0-opt

into  olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug29087

parents 69f82e25 0127c1a3
...@@ -252,16 +252,16 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, ...@@ -252,16 +252,16 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
if (keyseg->flag & HA_SPACE_PACK) if (keyseg->flag & HA_SPACE_PACK)
{ {
uchar *end=pos+length; uchar *end=pos+length;
if (type != HA_KEYTYPE_NUM) if (type == HA_KEYTYPE_NUM)
{
while (end > pos && end[-1] == ' ')
end--;
}
else
{ {
while (pos < end && pos[0] == ' ') while (pos < end && pos[0] == ' ')
pos++; pos++;
} }
else if (type != HA_KEYTYPE_BINARY)
{
while (end > pos && end[-1] == ' ')
end--;
}
k_length-=length; k_length-=length;
length=(uint) (end-pos); length=(uint) (end-pos);
FIX_LENGTH(cs, pos, length, char_length); FIX_LENGTH(cs, pos, length, char_length);
......
...@@ -160,3 +160,41 @@ hex(col1) ...@@ -160,3 +160,41 @@ hex(col1)
62000000000000000000 62000000000000000000
62200000000000000000 62200000000000000000
drop table t1; drop table t1;
CREATE TABLE t1 (
a binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
index idx(a)
);
INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029087575');
INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029080707');
SELECT hex(a) FROM t1 order by a;
hex(a)
1F9480179366F2BF567E1C4B964C1EF029080707
1F9480179366F2BF567E1C4B964C1EF029082020
1F9480179366F2BF567E1C4B964C1EF029087575
EXPLAIN SELECT hex(a) FROM t1 order by a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx 20 NULL 3 Using index
SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
hex(a)
1F9480179366F2BF567E1C4B964C1EF029082020
EXPLAIN
SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref idx idx 20 const 1 Using where; Using index
SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF02908');
hex(a)
DROP TABLE t1;
CREATE TABLE t1 (
id numeric(20) NOT NULL,
lang varchar(8) NOT NULL,
msg varchar(32) NOT NULL,
PRIMARY KEY (id,lang)
);
INSERT INTO t1 VALUES (33, 'en', 'zzzzzzz');
INSERT INTO t1 VALUES (31, 'en', 'xxxxxxx');
INSERT INTO t1 VALUES (32, 'en', 'yyyyyyy');
SELECT * FROM t1 WHERE id=32;
id lang msg
32 en yyyyyyy
DROP TABLE t1;
...@@ -101,3 +101,41 @@ select hex(col1) from t1; ...@@ -101,3 +101,41 @@ select hex(col1) from t1;
insert into t1 values ('b'),('b '); insert into t1 values ('b'),('b ');
select hex(col1) from t1; select hex(col1) from t1;
drop table t1; drop table t1;
#
# Bug #29087: assertion abort for a search in a BINARY non-nullable index
# by a key with trailing spaces
#
CREATE TABLE t1 (
a binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
index idx(a)
);
INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029087575');
INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029080707');
SELECT hex(a) FROM t1 order by a;
EXPLAIN SELECT hex(a) FROM t1 order by a;
SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
EXPLAIN
SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF02908');
DROP TABLE t1;
CREATE TABLE t1 (
id numeric(20) NOT NULL,
lang varchar(8) NOT NULL,
msg varchar(32) NOT NULL,
PRIMARY KEY (id,lang)
);
INSERT INTO t1 VALUES (33, 'en', 'zzzzzzz');
INSERT INTO t1 VALUES (31, 'en', 'xxxxxxx');
INSERT INTO t1 VALUES (32, 'en', 'yyyyyyy');
SELECT * FROM t1 WHERE id=32;
DROP TABLE t1;
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