[Groonga-mysql-commit] mroonga/mroonga [master] [storage] support delete for multiple column primary key.

Back to archive index

null+****@clear***** null+****@clear*****
2011年 9月 24日 (土) 00:36:41 JST


Kouhei Sutou	2011-09-23 15:36:41 +0000 (Fri, 23 Sep 2011)

  New Revision: f7c336475fe83b8861cb3513b3b0cb62153f9d92

  Log:
    [storage] support delete for multiple column primary key.
    
    refs #455

  Added files:
    test/sql/groonga_storage/r/multiple_column_primary_key_delete.result
    test/sql/groonga_storage/t/multiple_column_primary_key_delete.test
  Modified files:
    ha_mroonga.cc

  Modified: ha_mroonga.cc (+4 -0)
===================================================================
--- ha_mroonga.cc    2011-09-23 15:33:53 +0000 (e8dbe80)
+++ ha_mroonga.cc    2011-09-23 15:36:41 +0000 (826a9f1)
@@ -3721,6 +3721,10 @@ int ha_mroonga::storage_delete_row_index(const uchar *buf)
   uint i;
   uint n_keys = table->s->keys;
   for (i = 0; i < n_keys; i++) {
+    if (i == table->s->primary_key) {
+      continue;
+    }
+
     KEY key_info = table->key_info[i];
 
     if (key_info.key_parts == 1) {

  Added: test/sql/groonga_storage/r/multiple_column_primary_key_delete.result (+29 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/groonga_storage/r/multiple_column_primary_key_delete.result    2011-09-23 15:36:41 +0000 (a867532)
@@ -0,0 +1,29 @@
+drop table if exists listing;
+set names utf8;
+create table scores (
+name char(30) not null,
+score int not null,
+primary key (name, score)
+) default charset utf8;
+show create table scores;
+Table	Create Table
+scores	CREATE TABLE `scores` (
+  `name` char(30) NOT NULL,
+  `score` int(11) NOT NULL,
+  PRIMARY KEY (`name`,`score`)
+) ENGINE=groonga DEFAULT CHARSET=utf8
+insert into scores (name, score) values("Taro Yamada", 29);
+insert into scores (name, score) values("Taro Yamada", -12);
+insert into scores (name, score) values("Jiro Yamada", 27);
+insert into scores (name, score) values("Taro Yamada", 10);
+select * from scores;
+name	score
+Jiro Yamada	27
+Taro Yamada	-12
+Taro Yamada	10
+Taro Yamada	29
+delete from scores where name = "Taro Yamada" and score = 10;
+select * from scores where name = "Taro Yamada" and (score >= -12 and score < 29);
+name	score
+Taro Yamada	-12
+drop table scores;

  Added: test/sql/groonga_storage/t/multiple_column_primary_key_delete.test (+39 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/groonga_storage/t/multiple_column_primary_key_delete.test    2011-09-23 15:36:41 +0000 (2009884)
@@ -0,0 +1,39 @@
+# 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 listing;
+--enable_warnings
+
+set names utf8;
+create table scores (
+  name char(30) not null,
+  score int not null,
+  primary key (name, score)
+) default charset utf8;
+show create table scores;
+insert into scores (name, score) values("Taro Yamada", 29);
+insert into scores (name, score) values("Taro Yamada", -12);
+insert into scores (name, score) values("Jiro Yamada", 27);
+insert into scores (name, score) values("Taro Yamada", 10);
+select * from scores;
+delete from scores where name = "Taro Yamada" and score = 10;
+select * from scores where name = "Taro Yamada" and (score >= -12 and score < 29);
+drop table scores;
+
+--source suite/groonga_include/groonga_deinit.inc




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