Navigation Menu

Skip to content

Commit

Permalink
fix for char index
Browse files Browse the repository at this point in the history
  • Loading branch information
Kentoku committed Oct 30, 2012
1 parent f04e752 commit b759e81
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ha_mroonga.cpp
Expand Up @@ -9618,6 +9618,13 @@ int ha_mroonga::storage_encode_key(Field *field, const uchar *key,
break;
#endif
case MYSQL_TYPE_STRING:
{
const char *val = (const char *)ptr;
int len = strlen(val);
memcpy(buf, val, len);
*size = len;
break;
}
case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_BLOB:
{
Expand Down
9 changes: 9 additions & 0 deletions test/sql/suite/mroonga/storage/index/primary/r/char.result
@@ -0,0 +1,9 @@
drop table if exists t1;
create table t1 (c1 char(10) primary key);
insert into t1 values('abcdefghij');
insert into t1 values('klmnopqrst');
insert into t1 values('uvwxyz0123');
select c1 from t1 force index(PRIMARY) where c1 = 'abcdefghij';
c1
abcdefghij
drop table t1;
30 changes: 30 additions & 0 deletions test/sql/suite/mroonga/storage/index/primary/t/char.test
@@ -0,0 +1,30 @@
# Copyright(C) 2012 Kentoku SHIBA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

--source include/have_mroonga.inc

--disable_warnings
drop table if exists t1;
--enable_warnings

create table t1 (c1 char(10) primary key);
insert into t1 values('abcdefghij');
insert into t1 values('klmnopqrst');
insert into t1 values('uvwxyz0123');
select c1 from t1 force index(PRIMARY) where c1 = 'abcdefghij';
drop table t1;

--source include/have_mroonga_deinit.inc

0 comments on commit b759e81

Please sign in to comment.