null+****@clear*****
null+****@clear*****
2011年 12月 26日 (月) 14:00:02 JST
Kouhei Sutou 2011-12-26 14:00:02 +0900 (Mon, 26 Dec 2011)
New Revision: 02f49ca34bda30fc92fe018737d182acf2a92c2a
Log:
[wrapper][test] add a test for rollbacked delete in transaction.
refs #1224
Added files:
test/sql/suite/groonga_wrapper/r/transaction_rollback_delete.result
test/sql/suite/groonga_wrapper/t/transaction_rollback_delete.test
Added: test/sql/suite/groonga_wrapper/r/transaction_rollback_delete.result (+50 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/suite/groonga_wrapper/r/transaction_rollback_delete.result 2011-12-26 14:00:02 +0900 (2d8c752)
@@ -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=groonga DEFAULT CHARSET=utf8 COMMENT='ENGINE "InnoDB"'
+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(title) AGAINST("survey") AND
+MATCH(body) AGAINST("groonga");
+id title body
+1 survey will start groonga!
+START TRANSACTION;
+DELETE FROM diaries WHERE id = 1;
+ROLLBACK;
+SELECT * FROM diaries;
+id title body
+1 survey will start groonga!
+2 groonga (1) starting groonga...
+3 groonga (2) started groonga.
+SELECT * FROM diaries
+WHERE MATCH(title) AGAINST("survey") AND
+MATCH(body) AGAINST("groonga");
+id title body
+DELETE FROM diaries WHERE id = 1;
+Warnings:
+Warning 1026 failed to get record ID for deleting from groonga: key=<>
+SELECT * FROM diaries;
+id title body
+2 groonga (1) starting groonga...
+3 groonga (2) started groonga.
+SELECT * FROM diaries
+WHERE MATCH(title) AGAINST("survey") AND
+MATCH(body) AGAINST("groonga");
+id title body
+DROP TABLE diaries;
Added: test/sql/suite/groonga_wrapper/t/transaction_rollback_delete.test (+58 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/suite/groonga_wrapper/t/transaction_rollback_delete.test 2011-12-26 14:00:02 +0900 (f9ebac3)
@@ -0,0 +1,58 @@
+# 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
+
+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;
+
+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(title) AGAINST("survey") AND
+ MATCH(body) AGAINST("groonga");
+
+START TRANSACTION;
+DELETE FROM diaries WHERE id = 1;
+ROLLBACK;
+
+SELECT * FROM diaries;
+SELECT * FROM diaries
+ WHERE MATCH(title) AGAINST("survey") AND
+ MATCH(body) AGAINST("groonga");
+
+DELETE FROM diaries WHERE id = 1;
+
+SELECT * FROM diaries;
+SELECT * FROM diaries
+ WHERE MATCH(title) AGAINST("survey") AND
+ MATCH(body) AGAINST("groonga");
+
+DROP TABLE diaries;
+
+--source include/have_groonga_deinit.inc