null+****@clear*****
null+****@clear*****
2011年 9月 25日 (日) 15:46:23 JST
Kouhei Sutou 2011-09-25 06:46:23 +0000 (Sun, 25 Sep 2011) New Revision: 607cbc02f8fb375c1d190a4f3c3cb5e18b30d017 Log: support groonga_default_parser update by set. refs #592 Added files: test/sql/groonga_storage/r/fulltext_parser_default.result test/sql/groonga_storage/t/fulltext_parser_default.test Modified files: ha_mroonga.cc Modified: ha_mroonga.cc (+19 -1) =================================================================== --- ha_mroonga.cc 2011-09-25 06:27:59 +0000 (5c10f47) +++ ha_mroonga.cc 2011-09-25 06:46:23 +0000 (9931be5) @@ -124,6 +124,7 @@ FILE *mrn_logfile = NULL; int mrn_logfile_opened = 0; grn_log_level mrn_log_level_default = GRN_LOG_DEFAULT_LEVEL; ulong mrn_log_level = (ulong) mrn_log_level_default; +char mrn_default_parser_name[MRN_MAX_KEY_SIZE]; char *mrn_default_parser; static void mrn_logger_func(int level, const char *time, const char *title, @@ -230,11 +231,28 @@ static MYSQL_SYSVAR_ENUM(log_level, mrn_log_level, (ulong) mrn_log_level, &mrn_log_level_typelib); +static void mrn_default_parser_update(THD *thd, struct st_mysql_sys_var *var, + void *var_ptr, const void *save) +{ + MRN_DBUG_ENTER_FUNCTION(); + const char *new_value = *((const char **)save); + const char *old_value = mrn_default_parser; + grn_ctx ctx; + grn_ctx_init(&ctx, 0); + GRN_LOG(&ctx, GRN_LOG_NOTICE, + "default tokenizer changed from '%s' to '%s'", + old_value, new_value); + grn_ctx_fin(&ctx); + strcpy(mrn_default_parser_name, new_value); + mrn_default_parser = mrn_default_parser_name; + DBUG_VOID_RETURN; +} + static MYSQL_SYSVAR_STR(default_parser, mrn_default_parser, PLUGIN_VAR_RQCMDARG, "default fulltext parser", NULL, - NULL, + mrn_default_parser_update, MRN_TOKENIZER_DEFAULT); struct st_mysql_sys_var *mrn_system_variables[] = Added: test/sql/groonga_storage/r/fulltext_parser_default.result (+31 -0) 100644 =================================================================== --- /dev/null +++ test/sql/groonga_storage/r/fulltext_parser_default.result 2011-09-25 06:46:23 +0000 (ab6d1d6) @@ -0,0 +1,31 @@ +drop table if exists diaries; +set global groonga_default_parser=TokenBigramSplitSymbolAlphaDigit; +create table diaries ( +id int primary key auto_increment, +body text, +fulltext index body_index (body) +) default charset utf8; +show create table diaries; +Table Create Table +diaries CREATE TABLE `diaries` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `body` text, + PRIMARY KEY (`id`), + FULLTEXT KEY `body_index` (`body`) +) ENGINE=groonga DEFAULT CHARSET=utf8 +insert into diaries (body) values ("will start groonga!"); +insert into diaries (body) values ("starting groonga..."); +insert into diaries (body) values ("started groonga."); +insert into diaries (body) values ("finished groonga."); +select * from diaries; +id body +1 will start groonga! +2 starting groonga... +3 started groonga. +4 finished groonga. +select * from diaries where match(body) against("start"); +id body +1 will start groonga! +2 starting groonga... +3 started groonga. +drop table diaries; Added: test/sql/groonga_storage/t/fulltext_parser_default.test (+38 -0) 100644 =================================================================== --- /dev/null +++ test/sql/groonga_storage/t/fulltext_parser_default.test 2011-09-25 06:46:23 +0000 (268daae) @@ -0,0 +1,38 @@ +# 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 diaries; +--enable_warnings + +set global groonga_default_parser=TokenBigramSplitSymbolAlphaDigit; +create table diaries ( + id int primary key auto_increment, + body text, + fulltext index body_index (body) +) default charset utf8; +show create table diaries; +insert into diaries (body) values ("will start groonga!"); +insert into diaries (body) values ("starting groonga..."); +insert into diaries (body) values ("started groonga."); +insert into diaries (body) values ("finished groonga."); +select * from diaries; +select * from diaries where match(body) against("start"); +drop table diaries; + +--source suite/groonga_include/groonga_deinit.inc