null+****@clear*****
null+****@clear*****
2012年 5月 20日 (日) 00:26:42 JST
Kouhei Sutou 2012-05-20 00:26:42 +0900 (Sun, 20 May 2012) New Revision: 66600a6c5d1679f5209f1e3c430df4e8ccc1496f Log: Add mroonga_match_escalation_threshold system variable Added files: lib/mrn_match_escalation_threshold_scope.cpp lib/mrn_match_escalation_threshold_scope.hpp test/sql/suite/mroonga_storage/r/match_escalation_threshold_global.result test/sql/suite/mroonga_storage/r/match_escalation_threshold_session.result test/sql/suite/mroonga_storage/t/match_escalation_threshold_global.test test/sql/suite/mroonga_storage/t/match_escalation_threshold_session.test test/sql/suite/mroonga_wrapper/r/match_escalation_threshold_global.result test/sql/suite/mroonga_wrapper/r/match_escalation_threshold_session.result test/sql/suite/mroonga_wrapper/t/match_escalation_threshold_global.test test/sql/suite/mroonga_wrapper/t/match_escalation_threshold_session.test Modified files: doc/source/reference.rst ha_mroonga.cpp lib/libmrn_no_mysql_sources.am Modified: doc/source/reference.rst (+67 -0) =================================================================== --- doc/source/reference.rst 2012-05-19 21:23:24 +0900 (d003794) +++ doc/source/reference.rst 2012-05-20 00:26:42 +0900 (40c35b3) @@ -302,6 +302,73 @@ Here is an example SQL to disable optimization:: +-----------------------------+-------+ 1 row in set (0.00 sec) +mroonga_match_escalation_threshold +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The threshold to determin whether search method is escalated. See +`search specification for groonga +<http://groonga.org/docs/spec/search.html>`_ about search method +escalation. + +The default value is the same as groonga's default value. It's 0 for +the default installation. The dafault value can be configured in +my.cnf or by ``SET GLOBAL mroonga_match_escalation_threshold = +THRESHOLD;``. Because this variable's scope is both global and +session. + +Here is an example to use -1 as a threshold to determin whether search +method is escalated. -1 means that never escalated. + +.. code-block:: sql + :linenos: + + SET GLOBAL mroonga_match_escalation_threshold = -1; + +Here is an another example to show behavior change by the variable +value. + +.. code-block:: sql + :linenos: + + CREATE TABLE diaries ( + id INT PRIMARY KEY AUTO_INCREMENT, + title TEXT, + tags TEXT, + FULLTEXT INDEX tags_index (tags) COMMENT 'parser "TokenDelimit"' + ) ENGINE=mroonga DEFAULT CHARSET=UTF8; + + -- Test data + INSERT INTO diaries (title, tags) VALUES ("Hello groonga!", "groonga install"); + INSERT INTO diaries (title, tags) VALUES ("Hello mroonga!", "mroonga install"); + + -- Matches all records that have "install" tag. + SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("install" IN BOOLEAN MODE); + -- id title tags + -- 1 Hello groonga! groonga install + -- 2 Hello mroonga! mroonga install + + -- Matches no records by "gr" tag search because no "gr" tag is used. + -- But matches a record that has "groonga" tag because search + -- method is escalated and prefix search with "gr" is used. + -- The default threshold is 0. It means that no records are matched then + -- search method is escalated. + SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); + -- id title tags + -- 1 Hello groonga! groonga install + + -- Disables escalation. + SET mroonga_match_escalation_threshold = -1; + -- No records are matched. + SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); + -- id title tags + + -- Enables escalation again. + SET mroonga_match_escalation_threshold = 0; + -- Matches a record by prefix search with "gr". + SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); + -- id title tags + -- 1 Hello groonga! groonga install + List of status variables ------------------------ Modified: ha_mroonga.cpp (+14 -0) =================================================================== --- ha_mroonga.cpp 2012-05-19 21:23:24 +0900 (54f191b) +++ ha_mroonga.cpp 2012-05-20 00:26:42 +0900 (e0eb01a) @@ -47,6 +47,7 @@ #include <mrn_index_table_name.hpp> #include <mrn_debug_column_access.hpp> #include <mrn_auto_increment_value_lock.hpp> +#include <mrn_match_escalation_threshold_scope.hpp> #define MRN_SHORT_TEXT_SIZE (1 << 12) // 4Kbytes #define MRN_TEXT_SIZE (1 << 16) // 64Kbytes @@ -741,6 +742,16 @@ static MYSQL_THDVAR_BOOL( true /* default */ ); +static MYSQL_THDVAR_LONGLONG(match_escalation_threshold, + PLUGIN_VAR_RQCMDARG, + "The threshold to determin whether search method is escalated", + NULL, + NULL, + grn_get_default_match_escalation_threshold(), + -1, + LONGLONG_MAX, + 0); + static MYSQL_SYSVAR_STR(default_wrapper_engine, mrn_default_wrapper_engine, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "The default engine for wrapper mode", @@ -769,6 +780,7 @@ static struct st_mysql_sys_var *mrn_system_variables[] = MYSQL_SYSVAR(default_parser), MYSQL_SYSVAR(dry_write), MYSQL_SYSVAR(enable_optimization), + MYSQL_SYSVAR(match_escalation_threshold), MYSQL_SYSVAR(default_wrapper_engine), MYSQL_SYSVAR(libgroonga_version), MYSQL_SYSVAR(version), @@ -6742,6 +6754,8 @@ struct st_mrn_ft_info *ha_mroonga::generic_ft_init_ext_select(uint flags, if (fast_order_limit) { generic_ft_init_ext_add_conditions_fast_order_limit(info, expression); } + longlong escalation_threshold = THDVAR(ha_thd(), match_escalation_threshold); + mrn::MatchEscalationThresholdScope scope(info->ctx, escalation_threshold); grn_table_select(info->ctx, info->table, expression, info->result, GRN_OP_OR); } Modified: lib/libmrn_no_mysql_sources.am (+5 -3) =================================================================== --- lib/libmrn_no_mysql_sources.am 2012-05-19 21:23:24 +0900 (d6fbf04) +++ lib/libmrn_no_mysql_sources.am 2012-05-20 00:26:42 +0900 (e60d79a) @@ -1,3 +1,5 @@ -libmrn_no_mysql_la_SOURCES = \ - mrn_path_mapper.cpp \ - mrn_path_mapper.hpp +libmrn_no_mysql_la_SOURCES = \ + mrn_path_mapper.cpp \ + mrn_path_mapper.hpp \ + mrn_match_escalation_threshold_scope.cpp \ + mrn_match_escalation_threshold_scope.hpp Added: lib/mrn_match_escalation_threshold_scope.cpp (+33 -0) 100644 =================================================================== --- /dev/null +++ lib/mrn_match_escalation_threshold_scope.cpp 2012-05-20 00:26:42 +0900 (f02b2f3) @@ -0,0 +1,33 @@ +/* -*- c-basic-offset: 2 -*- */ +/* + Copyright(C) 2012 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 +*/ + +#include "mrn_match_escalation_threshold_scope.hpp" + +namespace mrn { + MatchEscalationThresholdScope::MatchEscalationThresholdScope( + grn_ctx *ctx, long long int threshold) + : ctx_(ctx), + original_threshold_(grn_ctx_get_match_escalation_threshold(ctx_)) { + grn_ctx_set_match_escalation_threshold(ctx_, threshold); + } + + MatchEscalationThresholdScope::~MatchEscalationThresholdScope() { + grn_ctx_set_match_escalation_threshold(ctx_, original_threshold_); + } +} Added: lib/mrn_match_escalation_threshold_scope.hpp (+35 -0) 100644 =================================================================== --- /dev/null +++ lib/mrn_match_escalation_threshold_scope.hpp 2012-05-20 00:26:42 +0900 (77c91a0) @@ -0,0 +1,35 @@ +/* -*- c-basic-offset: 2 -*- */ +/* + Copyright(C) 2012 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 +*/ + +#ifndef MRN_MATCH_ESCALATION_THRESHOLD_SCOPE_HPP_ +#define MRN_MATCH_ESCALATION_THRESHOLD_SCOPE_HPP_ + +#include <groonga.h> + +namespace mrn { + class MatchEscalationThresholdScope { + grn_ctx *ctx_; + long long int original_threshold_; + public: + MatchEscalationThresholdScope(grn_ctx *ctx, long long int threshold); + ~MatchEscalationThresholdScope(); + }; +} + +#endif // MRN_MATCH_ESCALATION_THRESHOLD_SCOPE_HPP_ Added: test/sql/suite/mroonga_storage/r/match_escalation_threshold_global.result (+33 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/mroonga_storage/r/match_escalation_threshold_global.result 2012-05-20 00:26:42 +0900 (4754978) @@ -0,0 +1,33 @@ +DROP TABLE IF EXISTS diaries; +SET GLOBAL mroonga_match_escalation_threshold = -1; +CREATE TABLE diaries ( +id INT PRIMARY KEY AUTO_INCREMENT, +title TEXT, +tags TEXT, +FULLTEXT INDEX tags_index (tags) COMMENT 'parser "TokenDelimit"' +) DEFAULT CHARSET=UTF8; +SHOW CREATE TABLE diaries; +Table Create Table +diaries CREATE TABLE `diaries` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `title` text, + `tags` text, + PRIMARY KEY (`id`), + FULLTEXT KEY `tags_index` (`tags`) COMMENT 'parser "TokenDelimit"' +) ENGINE=mroonga DEFAULT CHARSET=utf8 +INSERT INTO diaries (title, tags) VALUES ("Hello groonga!", "groonga install"); +INSERT INTO diaries (title, tags) VALUES ("Hello mroonga!", "mroonga install"); +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("install" IN BOOLEAN MODE); +id title tags +1 Hello groonga! groonga install +2 Hello mroonga! mroonga install +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); +id title tags +SET GLOBAL mroonga_match_escalation_threshold = 0; +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); +id title tags +SET mroonga_match_escalation_threshold = 0; +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); +id title tags +1 Hello groonga! groonga install +DROP TABLE diaries; Added: test/sql/suite/mroonga_storage/r/match_escalation_threshold_session.result (+33 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/mroonga_storage/r/match_escalation_threshold_session.result 2012-05-20 00:26:42 +0900 (0da2fb4) @@ -0,0 +1,33 @@ +DROP TABLE IF EXISTS diaries; +CREATE TABLE diaries ( +id INT PRIMARY KEY AUTO_INCREMENT, +title TEXT, +tags TEXT, +FULLTEXT INDEX tags_index (tags) COMMENT 'parser "TokenDelimit"' +) DEFAULT CHARSET=UTF8; +SHOW CREATE TABLE diaries; +Table Create Table +diaries CREATE TABLE `diaries` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `title` text, + `tags` text, + PRIMARY KEY (`id`), + FULLTEXT KEY `tags_index` (`tags`) COMMENT 'parser "TokenDelimit"' +) ENGINE=mroonga DEFAULT CHARSET=utf8 +INSERT INTO diaries (title, tags) VALUES ("Hello groonga!", "groonga install"); +INSERT INTO diaries (title, tags) VALUES ("Hello mroonga!", "mroonga install"); +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("install" IN BOOLEAN MODE); +id title tags +1 Hello groonga! groonga install +2 Hello mroonga! mroonga install +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); +id title tags +1 Hello groonga! groonga install +SET mroonga_match_escalation_threshold = -1; +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); +id title tags +SET mroonga_match_escalation_threshold = 0; +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); +id title tags +1 Hello groonga! groonga install +DROP TABLE diaries; Added: test/sql/suite/mroonga_storage/t/match_escalation_threshold_global.test (+55 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/mroonga_storage/t/match_escalation_threshold_global.test 2012-05-20 00:26:42 +0900 (b96101e) @@ -0,0 +1,55 @@ +# Copyright(C) 2012 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_fulltext_index_comment.inc +--source include/have_mroonga.inc + +--disable_warnings +DROP TABLE IF EXISTS diaries; +--enable_warnings + +# MySQL <= 5.5 reports wrong a warning. :< +# It has been fixed in MySQL >= 5.6 and MariaDB >= 5.3. +--disable_warnings +SET GLOBAL mroonga_match_escalation_threshold = -1; +--enable_warnings + +CREATE TABLE diaries ( + id INT PRIMARY KEY AUTO_INCREMENT, + title TEXT, + tags TEXT, + FULLTEXT INDEX tags_index (tags) COMMENT 'parser "TokenDelimit"' +) DEFAULT CHARSET=UTF8; +SHOW CREATE TABLE diaries; + +INSERT INTO diaries (title, tags) VALUES ("Hello groonga!", "groonga install"); +INSERT INTO diaries (title, tags) VALUES ("Hello mroonga!", "mroonga install"); + + +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("install" IN BOOLEAN MODE); + +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); + +SET GLOBAL mroonga_match_escalation_threshold = 0; +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); + +SET mroonga_match_escalation_threshold = 0; +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); + + +DROP TABLE diaries; + +--source include/have_mroonga_deinit.inc Added: test/sql/suite/mroonga_storage/t/match_escalation_threshold_session.test (+53 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/mroonga_storage/t/match_escalation_threshold_session.test 2012-05-20 00:26:42 +0900 (2f6f810) @@ -0,0 +1,53 @@ +# Copyright(C) 2012 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_fulltext_index_comment.inc +--source include/have_mroonga.inc + +--disable_warnings +DROP TABLE IF EXISTS diaries; +--enable_warnings + +CREATE TABLE diaries ( + id INT PRIMARY KEY AUTO_INCREMENT, + title TEXT, + tags TEXT, + FULLTEXT INDEX tags_index (tags) COMMENT 'parser "TokenDelimit"' +) DEFAULT CHARSET=UTF8; +SHOW CREATE TABLE diaries; + +INSERT INTO diaries (title, tags) VALUES ("Hello groonga!", "groonga install"); +INSERT INTO diaries (title, tags) VALUES ("Hello mroonga!", "mroonga install"); + + +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("install" IN BOOLEAN MODE); + +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); + +# MySQL <= 5.5 reports wrong a warning. :< +# It has been fixed in MySQL >= 5.6 and MariaDB >= 5.3. +--disable_warnings +SET mroonga_match_escalation_threshold = -1; +--enable_warnings +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); + +SET mroonga_match_escalation_threshold = 0; +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); + + +DROP TABLE diaries; + +--source include/have_mroonga_deinit.inc Added: test/sql/suite/mroonga_wrapper/r/match_escalation_threshold_global.result (+33 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/mroonga_wrapper/r/match_escalation_threshold_global.result 2012-05-20 00:26:42 +0900 (f1a38fb) @@ -0,0 +1,33 @@ +DROP TABLE IF EXISTS diaries; +SET GLOBAL mroonga_match_escalation_threshold = -1; +CREATE TABLE diaries ( +id INT PRIMARY KEY AUTO_INCREMENT, +title TEXT, +tags TEXT, +FULLTEXT INDEX tags_index (tags) COMMENT 'parser "TokenDelimit"' +) DEFAULT CHARSET=UTF8 COMMENT='ENGINE "InnoDB"'; +SHOW CREATE TABLE diaries; +Table Create Table +diaries CREATE TABLE `diaries` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `title` text, + `tags` text, + PRIMARY KEY (`id`), + FULLTEXT KEY `tags_index` (`tags`) COMMENT 'parser "TokenDelimit"' +) ENGINE=mroonga DEFAULT CHARSET=utf8 COMMENT='ENGINE "InnoDB"' +INSERT INTO diaries (title, tags) VALUES ("Hello groonga!", "groonga install"); +INSERT INTO diaries (title, tags) VALUES ("Hello mroonga!", "mroonga install"); +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("install" IN BOOLEAN MODE); +id title tags +1 Hello groonga! groonga install +2 Hello mroonga! mroonga install +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); +id title tags +SET GLOBAL mroonga_match_escalation_threshold = 0; +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); +id title tags +SET mroonga_match_escalation_threshold = 0; +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); +id title tags +1 Hello groonga! groonga install +DROP TABLE diaries; Added: test/sql/suite/mroonga_wrapper/r/match_escalation_threshold_session.result (+33 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/mroonga_wrapper/r/match_escalation_threshold_session.result 2012-05-20 00:26:42 +0900 (87fac9d) @@ -0,0 +1,33 @@ +DROP TABLE IF EXISTS diaries; +CREATE TABLE diaries ( +id INT PRIMARY KEY AUTO_INCREMENT, +title TEXT, +tags TEXT, +FULLTEXT INDEX tags_index (tags) COMMENT 'parser "TokenDelimit"' +) DEFAULT CHARSET=UTF8 COMMENT='ENGINE "InnoDB"'; +SHOW CREATE TABLE diaries; +Table Create Table +diaries CREATE TABLE `diaries` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `title` text, + `tags` text, + PRIMARY KEY (`id`), + FULLTEXT KEY `tags_index` (`tags`) COMMENT 'parser "TokenDelimit"' +) ENGINE=mroonga DEFAULT CHARSET=utf8 COMMENT='ENGINE "InnoDB"' +INSERT INTO diaries (title, tags) VALUES ("Hello groonga!", "groonga install"); +INSERT INTO diaries (title, tags) VALUES ("Hello mroonga!", "mroonga install"); +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("install" IN BOOLEAN MODE); +id title tags +1 Hello groonga! groonga install +2 Hello mroonga! mroonga install +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); +id title tags +1 Hello groonga! groonga install +SET mroonga_match_escalation_threshold = -1; +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); +id title tags +SET mroonga_match_escalation_threshold = 0; +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); +id title tags +1 Hello groonga! groonga install +DROP TABLE diaries; Added: test/sql/suite/mroonga_wrapper/t/match_escalation_threshold_global.test (+56 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/mroonga_wrapper/t/match_escalation_threshold_global.test 2012-05-20 00:26:42 +0900 (83fbf03) @@ -0,0 +1,56 @@ +# Copyright(C) 2012 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_innodb.inc +--source include/have_fulltext_index_comment.inc +--source include/have_mroonga.inc + +--disable_warnings +DROP TABLE IF EXISTS diaries; +--enable_warnings + +# MySQL <= 5.5 reports wrong a warning. :< +# It has been fixed in MySQL >= 5.6 and MariaDB >= 5.3. +--disable_warnings +SET GLOBAL mroonga_match_escalation_threshold = -1; +--enable_warnings + +CREATE TABLE diaries ( + id INT PRIMARY KEY AUTO_INCREMENT, + title TEXT, + tags TEXT, + FULLTEXT INDEX tags_index (tags) COMMENT 'parser "TokenDelimit"' +) DEFAULT CHARSET=UTF8 COMMENT='ENGINE "InnoDB"'; +SHOW CREATE TABLE diaries; + +INSERT INTO diaries (title, tags) VALUES ("Hello groonga!", "groonga install"); +INSERT INTO diaries (title, tags) VALUES ("Hello mroonga!", "mroonga install"); + + +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("install" IN BOOLEAN MODE); + +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); + +SET GLOBAL mroonga_match_escalation_threshold = 0; +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); + +SET mroonga_match_escalation_threshold = 0; +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); + + +DROP TABLE diaries; + +--source include/have_mroonga_deinit.inc Added: test/sql/suite/mroonga_wrapper/t/match_escalation_threshold_session.test (+54 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/mroonga_wrapper/t/match_escalation_threshold_session.test 2012-05-20 00:26:42 +0900 (4e86d6d) @@ -0,0 +1,54 @@ +# Copyright(C) 2012 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_innodb.inc +--source include/have_fulltext_index_comment.inc +--source include/have_mroonga.inc + +--disable_warnings +DROP TABLE IF EXISTS diaries; +--enable_warnings + +CREATE TABLE diaries ( + id INT PRIMARY KEY AUTO_INCREMENT, + title TEXT, + tags TEXT, + FULLTEXT INDEX tags_index (tags) COMMENT 'parser "TokenDelimit"' +) DEFAULT CHARSET=UTF8 COMMENT='ENGINE "InnoDB"'; +SHOW CREATE TABLE diaries; + +INSERT INTO diaries (title, tags) VALUES ("Hello groonga!", "groonga install"); +INSERT INTO diaries (title, tags) VALUES ("Hello mroonga!", "mroonga install"); + + +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("install" IN BOOLEAN MODE); + +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); + +# MySQL <= 5.5 reports wrong a warning. :< +# It has been fixed in MySQL >= 5.6 and MariaDB >= 5.3. +--disable_warnings +SET mroonga_match_escalation_threshold = -1; +--enable_warnings +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); + +SET mroonga_match_escalation_threshold = 0; +SELECT * FROM diaries WHERE MATCH (tags) AGAINST ("gr" IN BOOLEAN MODE); + + +DROP TABLE diaries; + +--source include/have_mroonga_deinit.inc