null+****@clear*****
null+****@clear*****
2012年 2月 14日 (火) 15:14:26 JST
Kouhei Sutou 2012-02-14 15:14:26 +0900 (Tue, 14 Feb 2012) New Revision: a48d5ecbd1da344371540088efc479b8b7714635 Log: really support temporary table. fixes #1267 We use absolute path for DB name and DB path for temporary table instead of empty DB name and DB path. Added files: test/sql/suite/mroonga_storage/r/temporary_table.result test/sql/suite/mroonga_storage/t/temporary_table.test test/sql/suite/mroonga_wrapper/r/temporary_table.result test/sql/suite/mroonga_wrapper/t/temporary_table.test Modified files: mrn_sys.c Modified: mrn_sys.c (+19 -10) =================================================================== --- mrn_sys.c 2012-02-14 04:24:11 +0900 (b66e0d2) +++ mrn_sys.c 2012-02-14 15:14:26 +0900 (db6549f) @@ -1,3 +1,4 @@ +/* -*- c-basic-offset: 2 -*- */ /* Copyright(C) 2010 Tetsuro IKEDA Copyright(C) 2011-2012 Kentoku SHIBA @@ -83,37 +84,45 @@ int mrn_hash_remove(grn_ctx *ctx, grn_hash *hash, const char *key) } /** - * "./${db}/${table}" ==> "${db}.mrn" - * "./${db}/" ==> "${db}.mrn" + * "./${db}/${table}" ==> "${db}.mrn" + * "./${db}/" ==> "${db}.mrn" + * "/tmp/mysql-test/var/tmp/mysqld.1/#sql27c5_1_0" ==> + * "/tmp/mysql-test/var/tmp/mysqld.1/#sql27c5_1_0.mrn" */ char *mrn_db_path_gen(const char *arg, char *dest) { - int i=2, j=0, len; - if (arg[0] == '.') { + if (strncmp(arg, "./", 2) == 0) { + int i = 2, j = 0, len; len = strlen(arg); while (arg[i] != '/' && i < len) { dest[j++] = arg[i++]; } + dest[j] = '\0'; + } else { + strcpy(dest, arg); } - dest[j] = '\0'; strcat(dest, MRN_DB_FILE_SUFFIX); return dest; } /** - * "./${db}/${table}" ==> "${db}" - * "./${db}/" ==> "${db}" + * "./${db}/${table}" ==> "${db}" + * "./${db}/" ==> "${db}" + * "/tmp/mysql-test/var/tmp/mysqld.1/#sql27c5_1_0" ==> + * "/tmp/mysql-test/var/tmp/mysqld.1/#sql27c5_1_0" */ char *mrn_db_name_gen(const char *arg, char *dest) { - int i=2, j=0, len; - if (arg[0] == '.') { + if (strncmp(arg, "./", 2) == 0) { + int i = 2, j = 0, len; len = strlen(arg); while (arg[i] != '/' && i < len) { dest[j++] = arg[i++]; } + dest[j] = '\0'; + } else { + strcpy(dest, arg); } - dest[j] = '\0'; return dest; } Added: test/sql/suite/mroonga_storage/r/temporary_table.result (+21 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/mroonga_storage/r/temporary_table.result 2012-02-14 15:14:26 +0900 (5bfae4f) @@ -0,0 +1,21 @@ +DROP TEMPORARY TABLE IF EXISTS diaries; +CREATE TEMPORARY TABLE diaries ( +id INT PRIMARY KEY AUTO_INCREMENT, +title TEXT +) DEFAULT CHARSET=UTF8; +SHOW CREATE TABLE diaries; +Table Create Table +diaries CREATE TEMPORARY TABLE `diaries` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `title` text, + PRIMARY KEY (`id`) +) ENGINE=mroonga DEFAULT CHARSET=utf8 +INSERT INTO diaries (title) VALUES ("clear day"); +INSERT INTO diaries (title) VALUES ("rainy day"); +INSERT INTO diaries (title) VALUES ("cloudy day"); +SELECT * FROM diaries; +id title +1 clear day +2 rainy day +3 cloudy day +DROP TEMPORARY TABLE diaries; Added: test/sql/suite/mroonga_storage/t/temporary_table.test (+37 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/mroonga_storage/t/temporary_table.test 2012-02-14 15:14:26 +0900 (97210be) @@ -0,0 +1,37 @@ +# 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_mroonga.inc + +--disable_warnings +DROP TEMPORARY TABLE IF EXISTS diaries; +--enable_warnings + +CREATE TEMPORARY TABLE diaries ( + id INT PRIMARY KEY AUTO_INCREMENT, + title TEXT +) DEFAULT CHARSET=UTF8; +SHOW CREATE TABLE diaries; + +INSERT INTO diaries (title) VALUES ("clear day"); +INSERT INTO diaries (title) VALUES ("rainy day"); +INSERT INTO diaries (title) VALUES ("cloudy day"); + +SELECT * FROM diaries; + +DROP TEMPORARY TABLE diaries; + +--source include/have_mroonga_deinit.inc Added: test/sql/suite/mroonga_wrapper/r/temporary_table.result (+21 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/mroonga_wrapper/r/temporary_table.result 2012-02-14 15:14:26 +0900 (780628c) @@ -0,0 +1,21 @@ +DROP TEMPORARY TABLE IF EXISTS diaries; +CREATE TEMPORARY 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 TEMPORARY TABLE `diaries` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `title` text, + PRIMARY KEY (`id`) +) ENGINE=mroonga DEFAULT CHARSET=utf8 COMMENT='ENGINE "InnoDB"' +INSERT INTO diaries (title) VALUES ("clear day"); +INSERT INTO diaries (title) VALUES ("rainy day"); +INSERT INTO diaries (title) VALUES ("cloudy day"); +SELECT * FROM diaries; +id title +1 clear day +2 rainy day +3 cloudy day +DROP TEMPORARY TABLE diaries; Added: test/sql/suite/mroonga_wrapper/t/temporary_table.test (+37 -0) 100644 =================================================================== --- /dev/null +++ test/sql/suite/mroonga_wrapper/t/temporary_table.test 2012-02-14 15:14:26 +0900 (bc2aae6) @@ -0,0 +1,37 @@ +# 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_mroonga.inc + +--disable_warnings +DROP TEMPORARY TABLE IF EXISTS diaries; +--enable_warnings + +CREATE TEMPORARY 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 ("clear day"); +INSERT INTO diaries (title) VALUES ("rainy day"); +INSERT INTO diaries (title) VALUES ("cloudy day"); + +SELECT * FROM diaries; + +DROP TEMPORARY TABLE diaries; + +--source include/have_mroonga_deinit.inc