null+****@clear*****
null+****@clear*****
2011年 9月 28日 (水) 18:00:29 JST
Kouhei Sutou 2011-09-28 09:00:29 +0000 (Wed, 28 Sep 2011)
New Revision: 79c0425cf137681aded963b03622ace41d14f1dc
Log:
[test][storage] add update by last_inserted_grn_id() test.
Added files:
test/sql/groonga_storage/r/update_by_last_insert_grn_id.result
test/sql/groonga_storage/t/update_by_last_insert_grn_id.test
Added: test/sql/groonga_storage/r/update_by_last_insert_grn_id.result (+32 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/groonga_storage/r/update_by_last_insert_grn_id.result 2011-09-28 09:00:29 +0000 (e710592)
@@ -0,0 +1,32 @@
+drop table if exists memos;
+drop function if exists last_insert_grn_id;
+create function last_insert_grn_id returns integer soname 'ha_groonga.so';
+create table memos (
+_id int,
+content varchar(255),
+unique key (_id) using hash
+);
+insert into memos values (null, "今夜はさんま。");
+insert into memos values (null, "明日はgroongaをアップデート。");
+insert into memos values (null, "帰りにおだんご。");
+insert into memos values (null, "金曜日は肉の日。");
+select * from memos;
+_id content
+1 今夜はさんま。
+2 明日はgroongaをアップデート。
+3 帰りにおだんご。
+4 金曜日は肉の日。
+insert into memos values (null, "冷蔵庫に牛乳が残り1本。");
+select last_insert_grn_id();
+last_insert_grn_id()
+5
+update memos set content = "冷蔵庫に牛乳はまだたくさんある。" where _id = last_insert_grn_id();
+select * from memos;
+_id content
+1 今夜はさんま。
+2 明日はgroongaをアップデート。
+3 帰りにおだんご。
+4 金曜日は肉の日。
+5 冷蔵庫に牛乳はまだたくさんある。
+drop table memos;
+drop function last_insert_grn_id;
Added: test/sql/groonga_storage/t/update_by_last_insert_grn_id.test (+48 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/groonga_storage/t/update_by_last_insert_grn_id.test 2011-09-28 09:00:29 +0000 (c7a827c)
@@ -0,0 +1,48 @@
+# Copyright(C) 2010 Tetsuro IKEDA
+#
+# 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 suite/groonga_include/groonga_init.inc
+
+--disable_warnings
+drop table if exists memos;
+drop function if exists last_insert_grn_id;
+--enable_warnings
+
+create function last_insert_grn_id returns integer soname 'ha_groonga.so';
+
+create table memos (
+ _id int,
+ content varchar(255),
+ unique key (_id) using hash
+);
+
+insert into memos values (null, "今夜はさんま。");
+insert into memos values (null, "明日はgroongaをアップデート。");
+insert into memos values (null, "帰りにおだんご。");
+insert into memos values (null, "金曜日は肉の日。");
+
+select * from memos;
+
+insert into memos values (null, "冷蔵庫に牛乳が残り1本。");
+select last_insert_grn_id();
+update memos set content = "冷蔵庫に牛乳はまだたくさんある。" where _id = last_insert_grn_id();
+
+select * from memos;
+
+drop table memos;
+drop function last_insert_grn_id;
+
+--source suite/groonga_include/groonga_deinit.inc