null+****@clear*****
null+****@clear*****
2011年 11月 27日 (日) 12:22:22 JST
Kouhei Sutou 2011-11-27 03:22:22 +0000 (Sun, 27 Nov 2011) New Revision: 803cddd924ee93095ce2d8c360c0ad69b1104206 Log: [wrapper][test] add tests for alter table. refs #1168 Added files: test/sql/suite/groonga_wrapper/r/alter_table_add_column.result test/sql/suite/groonga_wrapper/r/alter_table_change_engine.result test/sql/suite/groonga_wrapper/r/alter_table_fulltext.result test/sql/suite/groonga_wrapper/r/alter_table_rename_table.result test/sql/suite/groonga_wrapper/t/alter_table_add_column.test test/sql/suite/groonga_wrapper/t/alter_table_change_engine.test test/sql/suite/groonga_wrapper/t/alter_table_fulltext.test test/sql/suite/groonga_wrapper/t/alter_table_rename_table.test Added: test/sql/suite/groonga_wrapper/r/alter_table_add_column.result (+37 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/groonga_wrapper/r/alter_table_add_column.result 2011-11-27 03:22:22 +0000 (7aa44d9) @@ -0,0 +1,37 @@ +DROP TABLE IF EXISTS diaries; +CREATE TABLE diaries ( +id INT PRIMARY KEY AUTO_INCREMENT, +title TEXT +) 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, + PRIMARY KEY (`id`) +) ENGINE=groonga DEFAULT CHARSET=utf8 COMMENT='ENGINE "InnoDB"' +INSERT INTO diaries (title) VALUES ("survey"); +SELECT * FROM diaries; +id title +1 survey +ALTER TABLE diaries ADD COLUMN body TEXT; +UPDATE diaries SET body = "will start groonga!"; +SELECT * FROM diaries; +id title body +1 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; +id title body +1 survey will start groonga! +2 groonga (1) starting groonga... +3 groonga (2) started groonga. +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`) +) ENGINE=groonga AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='ENGINE "InnoDB"' +DROP TABLE diaries; Added: test/sql/suite/groonga_wrapper/r/alter_table_change_engine.result (+49 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/groonga_wrapper/r/alter_table_change_engine.result 2011-11-27 03:22:22 +0000 (f5b2fa3) @@ -0,0 +1,49 @@ +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) +) ENGINE MyISAM 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=MyISAM DEFAULT CHARSET=utf8 +INSERT INTO diaries (title, body) VALUES ("survey", "will start groonga!"); +INSERT INTO diaries (title, body) VALUES ("groonga (1)", "starting groonga..."); +SELECT * FROM diaries +WHERE MATCH(title) AGAINST("survey" IN BOOLEAN MODE) AND +MATCH(body) AGAINST("groonga" IN BOOLEAN MODE); +id title body +1 survey will start groonga! +ALTER TABLE diaries ENGINE = groonga COMMENT = 'ENGINE "InnoDB"'; +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 AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='ENGINE "InnoDB"' +SELECT * FROM diaries +WHERE MATCH(title) AGAINST("survey" IN BOOLEAN MODE) AND +MATCH(body) AGAINST("groonga" IN BOOLEAN MODE); +id title body +1 survey will start groonga! +INSERT INTO diaries (title, body) VALUES ("groonga (2)", "started groonga."); +SELECT * FROM diaries +WHERE MATCH(title) AGAINST("groonga" IN BOOLEAN MODE) AND +MATCH(body) AGAINST("groonga" IN BOOLEAN MODE); +id title body +2 groonga (1) starting groonga... +3 groonga (2) started groonga. +DROP TABLE diaries; Added: test/sql/suite/groonga_wrapper/r/alter_table_fulltext.result (+52 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/groonga_wrapper/r/alter_table_fulltext.result 2011-11-27 03:22:22 +0000 (9a6d80f) @@ -0,0 +1,52 @@ +DROP TABLE IF EXISTS diaries; +CREATE TABLE diaries ( +id INT PRIMARY KEY AUTO_INCREMENT, +title TEXT, +FULLTEXT INDEX title_index (title) +) 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, + PRIMARY KEY (`id`), + FULLTEXT KEY `title_index` (`title`) +) ENGINE=groonga DEFAULT CHARSET=utf8 COMMENT='ENGINE "InnoDB"' +INSERT INTO diaries (title) VALUES ("survey"); +SELECT * FROM diaries; +id title +1 survey +ALTER TABLE diaries ADD COLUMN body TEXT; +UPDATE diaries SET body = "will start groonga!"; +SELECT * FROM diaries; +id title body +1 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; +id title body +1 survey will start groonga! +2 groonga (1) starting groonga... +3 groonga (2) started groonga. +ALTER TABLE diaries ADD FULLTEXT INDEX body_index (body); +SELECT * FROM diaries +WHERE MATCH(title) AGAINST("survey") AND +MATCH(body) AGAINST("groonga"); +id title body +1 survey will start groonga! +SELECT * FROM diaries +WHERE MATCH(title) AGAINST("groonga") AND +MATCH(body) AGAINST("starting"); +id title body +2 groonga (1) starting groonga... +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 AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='ENGINE "InnoDB"' +DROP TABLE diaries; Added: test/sql/suite/groonga_wrapper/r/alter_table_rename_table.result (+45 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/groonga_wrapper/r/alter_table_rename_table.result 2011-11-27 03:22:22 +0000 (75b7247) @@ -0,0 +1,45 @@ +DROP TABLE IF EXISTS diaries, memos; +CREATE TABLE diaries ( +id INT PRIMARY KEY AUTO_INCREMENT, +title TEXT, +body TEXT, +FULLTEXT INDEX title_index (title), +FULLTEXT INDEX body_index (body) +) 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, + `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!"); +SELECT * FROM diaries; +id title body +1 survey will start groonga! +SELECT * FROM diaries +WHERE MATCH(title) AGAINST("groonga") AND +MATCH(body) AGAINST("starting"); +id title body +ALTER TABLE diaries RENAME memos; +SELECT * FROM memos; +id title body +1 survey will start groonga! +SELECT * FROM memos +WHERE MATCH(title) AGAINST("groonga") AND +MATCH(body) AGAINST("starting"); +id title body +SHOW CREATE TABLE memos; +Table Create Table +memos CREATE TABLE `memos` ( + `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 AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='ENGINE "InnoDB"' +DROP TABLE memos; Added: test/sql/suite/groonga_wrapper/t/alter_table_add_column.test (+44 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/groonga_wrapper/t/alter_table_add_column.test 2011-11-27 03:22:22 +0000 (2e7ca46) @@ -0,0 +1,44 @@ +# 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 +) DEFAULT CHARSET UTF8 COMMENT = 'ENGINE "InnoDB"'; +SHOW CREATE TABLE diaries; + +INSERT INTO diaries (title) VALUES ("survey"); +SELECT * FROM diaries; + +ALTER TABLE diaries ADD COLUMN body TEXT; +UPDATE diaries SET body = "will start groonga!"; +SELECT * FROM diaries; + +INSERT INTO diaries (title, body) values ("groonga (1)", "starting groonga..."); +INSERT INTO diaries (title, body) values ("groonga (2)", "started groonga."); +SELECT * FROM diaries; + +SHOW CREATE TABLE diaries; + +DROP TABLE diaries; + +--source include/have_groonga_deinit.inc Added: test/sql/suite/groonga_wrapper/t/alter_table_change_engine.test (+53 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/groonga_wrapper/t/alter_table_change_engine.test 2011-11-27 03:22:22 +0000 (dbdafd3) @@ -0,0 +1,53 @@ +# 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) +) ENGINE MyISAM 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..."); +SELECT * FROM diaries + WHERE MATCH(title) AGAINST("survey" IN BOOLEAN MODE) AND + MATCH(body) AGAINST("groonga" IN BOOLEAN MODE); + +ALTER TABLE diaries ENGINE = groonga COMMENT = 'ENGINE "InnoDB"'; +SHOW CREATE TABLE diaries; + +SELECT * FROM diaries + WHERE MATCH(title) AGAINST("survey" IN BOOLEAN MODE) AND + MATCH(body) AGAINST("groonga" IN BOOLEAN MODE); + +INSERT INTO diaries (title, body) VALUES ("groonga (2)", "started groonga."); + +SELECT * FROM diaries + WHERE MATCH(title) AGAINST("groonga" IN BOOLEAN MODE) AND + MATCH(body) AGAINST("groonga" IN BOOLEAN MODE); + +DROP TABLE diaries; + +--source include/have_groonga_deinit.inc Added: test/sql/suite/groonga_wrapper/t/alter_table_fulltext.test (+55 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/groonga_wrapper/t/alter_table_fulltext.test 2011-11-27 03:22:22 +0000 (7cb9268) @@ -0,0 +1,55 @@ +# 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, + FULLTEXT INDEX title_index (title) +) DEFAULT CHARSET UTF8 COMMENT = 'ENGINE "InnoDB"'; +SHOW CREATE TABLE diaries; + +INSERT INTO diaries (title) VALUES ("survey"); +SELECT * FROM diaries; + +ALTER TABLE diaries ADD COLUMN body TEXT; +UPDATE diaries SET body = "will start groonga!"; +SELECT * FROM diaries; + +INSERT INTO diaries (title, body) values ("groonga (1)", "starting groonga..."); +INSERT INTO diaries (title, body) values ("groonga (2)", "started groonga."); +SELECT * FROM diaries; + +ALTER TABLE diaries ADD FULLTEXT INDEX body_index (body); + +SELECT * FROM diaries + WHERE MATCH(title) AGAINST("survey") AND + MATCH(body) AGAINST("groonga"); + +SELECT * FROM diaries + WHERE MATCH(title) AGAINST("groonga") AND + MATCH(body) AGAINST("starting"); + +SHOW CREATE TABLE diaries; + +DROP TABLE diaries; + +--source include/have_groonga_deinit.inc Added: test/sql/suite/groonga_wrapper/t/alter_table_rename_table.test (+48 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/groonga_wrapper/t/alter_table_rename_table.test 2011-11-27 03:22:22 +0000 (fba4138) @@ -0,0 +1,48 @@ +# 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, memos; +--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) +) DEFAULT CHARSET UTF8 COMMENT = 'ENGINE "InnoDB"'; +SHOW CREATE TABLE diaries; + +INSERT INTO diaries (title, body) VALUES ("survey", "will start groonga!"); +SELECT * FROM diaries; +SELECT * FROM diaries + WHERE MATCH(title) AGAINST("groonga") AND + MATCH(body) AGAINST("starting"); + +ALTER TABLE diaries RENAME memos; +SELECT * FROM memos; +SELECT * FROM memos + WHERE MATCH(title) AGAINST("groonga") AND + MATCH(body) AGAINST("starting"); + +SHOW CREATE TABLE memos; + +DROP TABLE memos; + +--source include/have_groonga_deinit.inc