null+****@clear*****
null+****@clear*****
2011年 10月 25日 (火) 19:59:25 JST
Kouhei Sutou 2011-10-25 10:59:25 +0000 (Tue, 25 Oct 2011) New Revision: d307bd54fd944cca49ad069507a8ee9cb6fac8be Log: [storage] support varchar() in multiple column index. fixes #1143 Reported by Takahiro Nagai. Thanks!!! Added files: test/sql/groonga_storage/r/multiple_column_index_varchar.result test/sql/groonga_storage/t/multiple_column_index_varchar.test Modified files: ha_mroonga.cc Modified: ha_mroonga.cc (+4 -1) =================================================================== --- ha_mroonga.cc 2011-10-25 03:24:36 +0000 (0cd6c0f) +++ ha_mroonga.cc 2011-10-25 10:59:25 +0000 (2d49d9d) @@ -686,10 +686,13 @@ static uchar *mrn_multiple_column_key_encode(KEY *key_info, data_size = 8; break; case MYSQL_TYPE_STRING: + data_type = TYPE_BYTE_SEQUENCE; + data_size = key_part.length; + break; case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_BLOB: data_type = TYPE_BYTE_SEQUENCE; - data_size = key_part.length; + data_size = HA_KEY_BLOB_LENGTH + key_part.length; break; default: data_type = TYPE_BYTE_SEQUENCE; Added: test/sql/groonga_storage/r/multiple_column_index_varchar.result (+39 -0) 100644 =================================================================== --- /dev/null +++ test/sql/groonga_storage/r/multiple_column_index_varchar.result 2011-10-25 10:59:25 +0000 (e3e23e9) @@ -0,0 +1,39 @@ +drop table if exists scores; +set names utf8; +create table scores ( +given_name varchar(30) not null, +family_name varchar(30) not null, +score int not null, +primary key property (given_name, family_name, score) +) default charset utf8; +show create table scores; +Table Create Table +scores CREATE TABLE `scores` ( + `given_name` varchar(30) NOT NULL, + `family_name` varchar(30) NOT NULL, + `score` int(11) NOT NULL, + PRIMARY KEY (`given_name`,`family_name`,`score`) +) ENGINE=groonga DEFAULT CHARSET=utf8 +insert into scores values("Taro", "Yamada", 29); +insert into scores values("Taro", "Yamada", -12); +insert into scores values("Jiro", "Yamada", 27); +insert into scores values("Taro", "Yamada", 10); +select * from scores; +given_name family_name score +Jiro Yamada 27 +Taro Yamada -12 +Taro Yamada 10 +Taro Yamada 29 +select * from scores where given_name = "Taro" and family_name = "Yamada"; +given_name family_name score +Taro Yamada -12 +Taro Yamada 10 +Taro Yamada 29 +select * from scores where given_name = "Taro" and family_name = "Yamada" and score = 29; +given_name family_name score +Taro Yamada 29 +select * from scores where given_name = "Taro" and family_name = "Yamada" and (score >= -12 and score < 29); +given_name family_name score +Taro Yamada -12 +Taro Yamada 10 +drop table scores; Added: test/sql/groonga_storage/t/multiple_column_index_varchar.test (+44 -0) 100644 =================================================================== --- /dev/null +++ test/sql/groonga_storage/t/multiple_column_index_varchar.test 2011-10-25 10:59:25 +0000 (81cc472) @@ -0,0 +1,44 @@ +# Copyright(C) 2011 Kouhei Sutou <kou****@clear*****> +# +# 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 suite/groonga_include/groonga_init.inc + +--disable_warnings +drop table if exists scores; +--enable_warnings + +set names utf8; +create table scores ( + given_name varchar(30) not null, + family_name varchar(30) not null, + score int not null, + primary key property (given_name, family_name, score) +) default charset utf8; +show create table scores; + +insert into scores values("Taro", "Yamada", 29); +insert into scores values("Taro", "Yamada", -12); +insert into scores values("Jiro", "Yamada", 27); +insert into scores values("Taro", "Yamada", 10); + +select * from scores; +select * from scores where given_name = "Taro" and family_name = "Yamada"; +select * from scores where given_name = "Taro" and family_name = "Yamada" and score = 29; +select * from scores where given_name = "Taro" and family_name = "Yamada" and (score >= -12 and score < 29); + +drop table scores; + +--source suite/groonga_include/groonga_deinit.inc