null+****@clear*****
null+****@clear*****
2012年 5月 9日 (水) 17:23:12 JST
Kouhei Sutou 2012-05-09 17:23:12 +0900 (Wed, 09 May 2012) New Revision: 99365bbc4fb455d0652587d44d778f029425150f Log: wrapper: ignore not found keys in wrapped handler This case is caused when an connection (connection1) is inserting records in transaction and another connection (connection2) searches and founds inserting records in connction1. Because inserting records in trancation can't see in other connection. We just ignore the records. fixes #1322 [groonga-dev,00746] Reported by Takken Ishibashi. Thanks!!! Added files: test/sql/suite/mroonga_wrapper/r/fulltext_order_by_in_transaction.result test/sql/suite/mroonga_wrapper/t/fulltext_order_by_in_transaction.test Modified files: ha_mroonga.cpp Modified: ha_mroonga.cpp (+1 -1) =================================================================== --- ha_mroonga.cpp 2012-05-08 04:38:20 +0900 (90c7261) +++ ha_mroonga.cpp 2012-05-09 17:23:12 +0900 (54f191b) @@ -7298,7 +7298,7 @@ int ha_mroonga::wrapper_get_next_record(uchar *buf) } MRN_SET_BASE_SHARE_KEY(share, table->s); MRN_SET_BASE_TABLE_KEY(this, table); - } while (error == HA_ERR_END_OF_FILE); + } while (error == HA_ERR_END_OF_FILE || error == HA_ERR_KEY_NOT_FOUND); DBUG_RETURN(error); } Added: test/sql/suite/mroonga_wrapper/r/fulltext_order_by_in_transaction.result (+50 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/mroonga_wrapper/r/fulltext_order_by_in_transaction.result 2012-05-09 17:23:12 +0900 (faa778b) @@ -0,0 +1,50 @@ +DROP TABLE IF EXISTS diaries; +CREATE TABLE diaries ( +id INT PRIMARY KEY AUTO_INCREMENT, +title TEXT, +body TEXT, +FULLTEXT INDEX title_index (title), +FULLTEXT INDEX body_index (body) +) COMMENT = 'ENGINE "InnoDB"' DEFAULT CHARSET=UTF8; +SHOW CREATE TABLE diaries; +Table Create Table +diaries CREATE TABLE `diaries` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `title` text, + `body` text, + PRIMARY KEY (`id`), + FULLTEXT KEY `title_index` (`title`), + FULLTEXT KEY `body_index` (`body`) +) ENGINE=mroonga DEFAULT CHARSET=utf8 COMMENT='ENGINE "InnoDB"' +START TRANSACTION; +INSERT INTO diaries (title, body) VALUES ("survey", "will start groonga!"); +INSERT INTO diaries (title, body) VALUES ("groonga (1)", "starting groonga..."); +INSERT INTO diaries (title, body) VALUES ("groonga (2)", "started groonga."); +SELECT * FROM diaries +WHERE MATCH(body) AGAINST("groonga") +ORDER BY id; +id title body +1 survey will start groonga! +2 groonga (1) starting groonga... +3 groonga (2) started groonga. +USE test; +SELECT * FROM diaries +WHERE MATCH(body) AGAINST("groonga") +ORDER BY id; +id title body +COMMIT; +SELECT * FROM diaries +WHERE MATCH(body) AGAINST("groonga") +ORDER BY id; +id title body +1 survey will start groonga! +2 groonga (1) starting groonga... +3 groonga (2) started groonga. +SELECT * FROM diaries +WHERE MATCH(body) AGAINST("groonga") +ORDER BY id; +id title body +1 survey will start groonga! +2 groonga (1) starting groonga... +3 groonga (2) started groonga. +DROP TABLE diaries; Added: test/sql/suite/mroonga_wrapper/t/fulltext_order_by_in_transaction.test (+64 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/mroonga_wrapper/t/fulltext_order_by_in_transaction.test 2012-05-09 17:23:12 +0900 (92e82bb) @@ -0,0 +1,64 @@ +# 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_mroonga.inc + +--disable_warnings +DROP TABLE IF EXISTS diaries; +--enable_warnings + +CREATE TABLE diaries ( + id INT PRIMARY KEY AUTO_INCREMENT, + title TEXT, + body TEXT, + FULLTEXT INDEX title_index (title), + FULLTEXT INDEX body_index (body) +) COMMENT = 'ENGINE "InnoDB"' DEFAULT CHARSET=UTF8; +SHOW CREATE TABLE diaries; + +START TRANSACTION; +INSERT INTO diaries (title, body) VALUES ("survey", "will start groonga!"); +INSERT INTO diaries (title, body) VALUES ("groonga (1)", "starting groonga..."); +INSERT INTO diaries (title, body) VALUES ("groonga (2)", "started groonga."); + +SELECT * FROM diaries + WHERE MATCH(body) AGAINST("groonga") + ORDER BY id; + +CONNECT(search_connection, localhost, root); +USE test; +SELECT * FROM diaries + WHERE MATCH(body) AGAINST("groonga") + ORDER BY id; + +CONNECTION default; +COMMIT; + +CONNECTION search_connection; +SELECT * FROM diaries + WHERE MATCH(body) AGAINST("groonga") + ORDER BY id; +DISCONNECT search_connection; + +CONNECTION default; +SELECT * FROM diaries + WHERE MATCH(body) AGAINST("groonga") + ORDER BY id; + +DROP TABLE diaries; + +--source include/have_mroonga_deinit.inc