[Groonga-mysql-commit] mroonga/mroonga [master] [wrapper] support groonga_dry_write.

Back to archive index

null+****@clear***** null+****@clear*****
2011年 10月 13日 (木) 17:07:26 JST


Kouhei Sutou	2011-10-13 08:07:26 +0000 (Thu, 13 Oct 2011)

  New Revision: 1e876113dbcedc6ed84e78438d16e510c322d097

  Log:
    [wrapper] support groonga_dry_write.

  Added files:
    test/sql/groonga_wrapper/r/dry_write_delete.result
    test/sql/groonga_wrapper/r/dry_write_insert.result
    test/sql/groonga_wrapper/r/dry_write_update.result
    test/sql/groonga_wrapper/t/dry_write_delete.test
    test/sql/groonga_wrapper/t/dry_write_insert.test
    test/sql/groonga_wrapper/t/dry_write_update.test
  Modified files:
    ha_mroonga.cc

  Modified: ha_mroonga.cc (+15 -0)
===================================================================
--- ha_mroonga.cc    2011-10-13 08:06:51 +0000 (0bcab22)
+++ ha_mroonga.cc    2011-10-13 08:07:26 +0000 (6c5b91d)
@@ -3223,6 +3223,11 @@ int ha_mroonga::wrapper_write_row_index(uchar *buf)
 
   int error = 0;
 
+  if (mrn_dry_write) {
+    DBUG_PRINT("info", ("mroonga: dry write: ha_mroonga::%s", __FUNCTION__));
+    DBUG_RETURN(error);
+  }
+
   grn_obj key;
   GRN_TEXT_INIT(&key, 0);
 
@@ -3591,6 +3596,11 @@ int ha_mroonga::wrapper_update_row_index(const uchar *old_data, uchar *new_data)
 
   int error = 0;
 
+  if (mrn_dry_write) {
+    DBUG_PRINT("info", ("mroonga: dry write: ha_mroonga::%s", __FUNCTION__));
+    DBUG_RETURN(error);
+  }
+
   KEY key_info = table->key_info[table_share->primary_key];
   GRN_BULK_REWIND(&key_buffer);
   key_copy((uchar *)(GRN_TEXT_VALUE(&key_buffer)),
@@ -3926,6 +3936,11 @@ int ha_mroonga::wrapper_delete_row_index(const uchar *buf)
 
   int error = 0;
 
+  if (mrn_dry_write) {
+    DBUG_PRINT("info", ("mroonga: dry write: ha_mroonga::%s", __FUNCTION__));
+    DBUG_RETURN(error);
+  }
+
   grn_id record_id;
   error = wrapper_get_record_id((uchar *)buf, &record_id,
                                 "failed to get record ID "

  Added: test/sql/groonga_wrapper/r/dry_write_delete.result (+53 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/groonga_wrapper/r/dry_write_delete.result    2011-10-13 08:07:26 +0000 (7a5f591)
@@ -0,0 +1,53 @@
+drop table if exists diaries;
+create table diaries (
+id int primary key auto_increment,
+body text,
+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,
+  `body` text,
+  PRIMARY KEY (`id`),
+  FULLTEXT KEY `body_index` (`body`)
+) ENGINE=groonga DEFAULT CHARSET=utf8 COMMENT='engine "innodb"'
+insert into diaries (body) values ("will start groonga!");
+insert into diaries (body) values ("starting groonga...");
+insert into diaries (body) values ("started groonga.");
+select * from diaries;
+id	body
+1	will start groonga!
+2	starting groonga...
+3	started groonga.
+set global groonga_dry_write=true;
+delete from diaries where id = 2;
+select * from diaries;
+id	body
+1	will start groonga!
+3	started groonga.
+select * from diaries where match (body) against ("starting");
+id	body
+select * from diaries where match (body) against ("started");
+id	body
+3	started groonga.
+set global groonga_dry_write=false;
+delete from diaries where id = 3;
+select * from diaries;
+id	body
+1	will start groonga!
+select * from diaries where match (body) against ("starting");
+id	body
+select * from diaries where match (body) against ("started");
+id	body
+insert into diaries (id, body) values (2, "sleeping...");
+select * from diaries;
+id	body
+1	will start groonga!
+2	sleeping...
+select * from diaries where match (body) against ("starting");
+id	body
+2	sleeping...
+select * from diaries where match (body) against ("started");
+id	body
+drop table diaries;

  Added: test/sql/groonga_wrapper/r/dry_write_insert.result (+42 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/groonga_wrapper/r/dry_write_insert.result    2011-10-13 08:07:26 +0000 (7f78059)
@@ -0,0 +1,42 @@
+drop table if exists diaries;
+create table diaries (
+id int primary key auto_increment,
+body text,
+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,
+  `body` text,
+  PRIMARY KEY (`id`),
+  FULLTEXT KEY `body_index` (`body`)
+) ENGINE=groonga DEFAULT CHARSET=utf8 COMMENT='engine "innodb"'
+insert into diaries (body) values ("will start groonga!");
+select * from diaries;
+id	body
+1	will start groonga!
+select * from diaries where match (body) against ("groonga");
+id	body
+1	will start groonga!
+set global groonga_dry_write=true;
+insert into diaries (body) values ("starting groonga...");
+select * from diaries;
+id	body
+1	will start groonga!
+2	starting groonga...
+select * from diaries where match (body) against ("groonga");
+id	body
+1	will start groonga!
+set global groonga_dry_write=false;
+insert into diaries (body) values ("started groonga.");
+select * from diaries;
+id	body
+1	will start groonga!
+2	starting groonga...
+3	started groonga.
+select * from diaries where match (body) against ("groonga");
+id	body
+1	will start groonga!
+3	started groonga.
+drop table diaries;

  Added: test/sql/groonga_wrapper/r/dry_write_update.result (+39 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/groonga_wrapper/r/dry_write_update.result    2011-10-13 08:07:26 +0000 (96c3f0f)
@@ -0,0 +1,39 @@
+drop table if exists diaries;
+create table diaries (
+id int primary key auto_increment,
+body text,
+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,
+  `body` text,
+  PRIMARY KEY (`id`),
+  FULLTEXT KEY `body_index` (`body`)
+) ENGINE=groonga DEFAULT CHARSET=utf8 COMMENT='engine "innodb"'
+insert into diaries (body) values ("will start groonga!");
+set global groonga_dry_write=true;
+update diaries set body = "starting groonga..." where id = 1;
+select * from diaries;
+id	body
+1	starting groonga...
+select * from diaries where match (body) against ("will");
+id	body
+1	starting groonga...
+select * from diaries where match (body) against ("starting");
+id	body
+set global groonga_dry_write=false;
+update diaries set body = "started groonga." where id = 1;
+select * from diaries;
+id	body
+1	started groonga.
+select * from diaries where match (body) against ("will");
+id	body
+1	started groonga.
+select * from diaries where match (body) against ("starting");
+id	body
+select * from diaries where match (body) against ("started");
+id	body
+1	started groonga.
+drop table diaries;

  Added: test/sql/groonga_wrapper/t/dry_write_delete.test (+54 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/groonga_wrapper/t/dry_write_delete.test    2011-10-13 08:07:26 +0000 (b543dfe)
@@ -0,0 +1,54 @@
+# 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 suite/groonga_include/groonga_init.inc
+
+--disable_warnings
+drop table if exists diaries;
+--enable_warnings
+
+create table diaries (
+  id int primary key auto_increment,
+  body text,
+  fulltext index body_index (body)
+) default charset utf8 COMMENT = 'engine "innodb"';
+show create table diaries;
+
+insert into diaries (body) values ("will start groonga!");
+insert into diaries (body) values ("starting groonga...");
+insert into diaries (body) values ("started groonga.");
+select * from diaries;
+
+set global groonga_dry_write=true;
+delete from diaries where id = 2;
+select * from diaries;
+select * from diaries where match (body) against ("starting");
+select * from diaries where match (body) against ("started");
+
+set global groonga_dry_write=false;
+delete from diaries where id = 3;
+select * from diaries;
+select * from diaries where match (body) against ("starting");
+select * from diaries where match (body) against ("started");
+
+insert into diaries (id, body) values (2, "sleeping...");
+select * from diaries;
+select * from diaries where match (body) against ("starting");
+select * from diaries where match (body) against ("started");
+
+drop table diaries;
+
+--source suite/groonga_include/groonga_deinit.inc

  Added: test/sql/groonga_wrapper/t/dry_write_insert.test (+46 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/groonga_wrapper/t/dry_write_insert.test    2011-10-13 08:07:26 +0000 (bd4ff7e)
@@ -0,0 +1,46 @@
+# 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 suite/groonga_include/groonga_init.inc
+
+--disable_warnings
+drop table if exists diaries;
+--enable_warnings
+
+create table diaries (
+  id int primary key auto_increment,
+  body text,
+  fulltext index body_index (body)
+) default charset utf8 COMMENT = 'engine "innodb"';
+show create table diaries;
+
+insert into diaries (body) values ("will start groonga!");
+select * from diaries;
+select * from diaries where match (body) against ("groonga");
+
+set global groonga_dry_write=true;
+insert into diaries (body) values ("starting groonga...");
+select * from diaries;
+select * from diaries where match (body) against ("groonga");
+
+set global groonga_dry_write=false;
+insert into diaries (body) values ("started groonga.");
+select * from diaries;
+select * from diaries where match (body) against ("groonga");
+
+drop table diaries;
+
+--source suite/groonga_include/groonga_deinit.inc

  Added: test/sql/groonga_wrapper/t/dry_write_update.test (+47 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/groonga_wrapper/t/dry_write_update.test    2011-10-13 08:07:26 +0000 (5b6f68f)
@@ -0,0 +1,47 @@
+# 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 suite/groonga_include/groonga_init.inc
+
+--disable_warnings
+drop table if exists diaries;
+--enable_warnings
+
+create table diaries (
+  id int primary key auto_increment,
+  body text,
+  fulltext index body_index (body)
+) default charset utf8 COMMENT = 'engine "innodb"';
+show create table diaries;
+
+insert into diaries (body) values ("will start groonga!");
+
+set global groonga_dry_write=true;
+update diaries set body = "starting groonga..." where id = 1;
+select * from diaries;
+select * from diaries where match (body) against ("will");
+select * from diaries where match (body) against ("starting");
+
+set global groonga_dry_write=false;
+update diaries set body = "started groonga." where id = 1;
+select * from diaries;
+select * from diaries where match (body) against ("will");
+select * from diaries where match (body) against ("starting");
+select * from diaries where match (body) against ("started");
+
+drop table diaries;
+
+--source suite/groonga_include/groonga_deinit.inc




Groonga-mysql-commit メーリングリストの案内
Back to archive index