Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mroonga/mroonga
Browse files Browse the repository at this point in the history
  • Loading branch information
Kentoku committed Sep 25, 2011
2 parents b84574b + 607cbc0 commit e74d1d2
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
20 changes: 19 additions & 1 deletion ha_mroonga.cc
Expand Up @@ -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,
Expand Down Expand Up @@ -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[] =
Expand Down
31 changes: 31 additions & 0 deletions test/sql/groonga_storage/r/fulltext_parser_default.result
@@ -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;
38 changes: 38 additions & 0 deletions test/sql/groonga_storage/t/fulltext_parser_default.test
@@ -0,0 +1,38 @@
# Copyright(C) 2011 Kouhei Sutou <kou@clear-code.com>
#
# 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

0 comments on commit e74d1d2

Please sign in to comment.