null+****@clear*****
null+****@clear*****
2011年 12月 8日 (木) 22:36:08 JST
Kouhei Sutou 2011-12-08 13:36:08 +0000 (Thu, 08 Dec 2011)
New Revision: af02425c69b9627309657672e0ab3c3874cbfed8
Log:
[storage] support fulltext search on no primary key table. fixes #1193
Reported by Kazuhiko Shiozaki. Thanks!!!
Added files:
test/sql/suite/groonga_storage/r/fulltext_no_primary_key.result
test/sql/suite/groonga_storage/t/fulltext_no_primary_key.test
Modified files:
ha_mroonga.cc
Modified: ha_mroonga.cc (+10 -4)
===================================================================
--- ha_mroonga.cc 2011-12-08 01:05:03 +0000 (a99e429)
+++ ha_mroonga.cc 2011-12-08 13:36:08 +0000 (5fc04d2)
@@ -5525,10 +5525,16 @@ int ha_mroonga::storage_ft_read(uchar *buf)
}
GRN_BULK_REWIND(&key_buffer);
- grn_obj_get_value(ctx, key_accessor, found_record_id, &key_buffer);
- record_id = grn_table_get(ctx, grn_table,
- GRN_TEXT_VALUE(&key_buffer),
- GRN_TEXT_LEN(&key_buffer));
+ if (key_accessor) {
+ grn_obj_get_value(ctx, key_accessor, found_record_id, &key_buffer);
+ record_id = grn_table_get(ctx, grn_table,
+ GRN_TEXT_VALUE(&key_buffer),
+ GRN_TEXT_LEN(&key_buffer));
+ } else {
+ void *key;
+ grn_table_cursor_get_key(ctx, cursor, &key);
+ record_id = *((grn_id *)key);
+ }
store_to_fields_from_primary_table(buf, record_id);
DBUG_RETURN(0);
}
Added: test/sql/suite/groonga_storage/r/fulltext_no_primary_key.result (+21 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/suite/groonga_storage/r/fulltext_no_primary_key.result 2011-12-08 13:36:08 +0000 (172fd3e)
@@ -0,0 +1,21 @@
+DROP TABLE IF EXISTS diaries;
+SET NAMES UTF8;
+CREATE TABLE diaries (
+title VARCHAR(255),
+content TEXT,
+FULLTEXT INDEX (content)
+) DEFAULT CHARSET UTF8;
+SHOW CREATE TABLE diaries;
+Table Create Table
+diaries CREATE TABLE `diaries` (
+ `title` varchar(255) DEFAULT NULL,
+ `content` text,
+ FULLTEXT KEY `content` (`content`)
+) ENGINE=groonga DEFAULT CHARSET=utf8
+INSERT INTO diaries VALUES("Hello", "今日からはじめました。");
+INSERT INTO diaries VALUES("天気", "明日の富士山の天気について");
+INSERT INTO diaries VALUES("富士山", "今日も天気がよくてきれいに見える。");
+SELECT * FROM diaries WHERE MATCH(content) AGAINST("*D+ 今日 天気" IN BOOLEAN MODE);
+title content
+富士山 今日も天気がよくてきれいに見える。
+DROP TABLE diaries;
Added: test/sql/suite/groonga_storage/t/fulltext_no_primary_key.test (+39 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/suite/groonga_storage/t/fulltext_no_primary_key.test 2011-12-08 13:36:08 +0000 (7c0ab45)
@@ -0,0 +1,39 @@
+# 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 include/have_groonga.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS diaries;
+--enable_warnings
+
+SET NAMES UTF8;
+CREATE TABLE diaries (
+ title VARCHAR(255),
+ content TEXT,
+ FULLTEXT INDEX (content)
+) DEFAULT CHARSET UTF8;
+SHOW CREATE TABLE diaries;
+
+INSERT INTO diaries VALUES("Hello", "今日からはじめました。");
+INSERT INTO diaries VALUES("天気", "明日の富士山の天気について");
+INSERT INTO diaries VALUES("富士山", "今日も天気がよくてきれいに見える。");
+
+SELECT * FROM diaries WHERE MATCH(content) AGAINST("*D+ 今日 天気" IN BOOLEAN MODE);
+
+DROP TABLE diaries;
+
+--source include/have_groonga_deinit.inc