[Groonga-mysql-commit] mroonga/mroonga [master] add auto_increment feature #670

アーカイブの一覧に戻る

null+****@clear***** null+****@clear*****
2011年 4月 2日 (土) 18:22:24 JST


Kentoku SHIBA	2011-04-02 09:22:24 +0000 (Sat, 02 Apr 2011)

  New Revision: 814ab951a2c3bb46b1b11eb8b8661c2934fa2c37

  Log:
    add auto_increment feature #670

  Added files:
    test/sql/r/auto_increment.result
    test/sql/t/auto_increment.test
  Modified files:
    doc/ja/source/news.rst
    ha_mroonga.cc

  Modified: doc/ja/source/news.rst (+5 -0)
===================================================================
--- doc/ja/source/news.rst    2011-04-02 07:03:31 +0000 (563b8b9)
+++ doc/ja/source/news.rst    2011-04-02 09:22:24 +0000 (b173d58)
@@ -8,6 +8,11 @@
 0.6 リリース - 
 -------------------------
 
+改良
+++++
+
+* auto_increment機能の追加。#670
+
 修正
 ++++
 

  Modified: ha_mroonga.cc (+8 -1)
===================================================================
--- ha_mroonga.cc    2011-04-02 07:03:31 +0000 (54c819a)
+++ ha_mroonga.cc    2011-04-02 09:22:24 +0000 (a47cd02)
@@ -872,7 +872,6 @@ ulonglong ha_mroonga_table_flags =
     HA_STATS_RECORDS_IS_EXACT |
     HA_NO_PREFIX_CHAR_KEYS |
     HA_CAN_FULLTEXT |
-    HA_NO_AUTO_INCREMENT |
     HA_CAN_INSERT_DELAYED |
     HA_BINLOG_FLAGS |
     HA_CAN_BIT_FIELD |
@@ -1432,6 +1431,14 @@ int ha_mroonga::write_row(uchar *buf)
   THD *thd = ha_thd();
   int i, col_size;
   int n_columns = table->s->fields;
+  int error;
+
+  if (table->next_number_field && buf == table->record[0])
+  {
+    if ((error = update_auto_increment()))
+      DBUG_RETURN(error);
+  }
+
 #ifndef DBUG_OFF
   my_bitmap_map *tmp_map = dbug_tmp_use_all_columns(table, table->read_set);
 #endif

  Added: test/sql/r/auto_increment.result (+53 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/r/auto_increment.result    2011-04-02 09:22:24 +0000 (6a5729a)
@@ -0,0 +1,53 @@
+drop table if exists t1;
+create table t1 (c1 int auto_increment, primary key(c1));
+insert into t1 values(null);
+select c1 from t1 order by c1 desc limit 1;
+c1
+1
+insert into t1 values(null);
+select c1 from t1 order by c1 desc limit 1;
+c1
+2
+insert into t1 values(10);
+select c1 from t1 order by c1 desc limit 1;
+c1
+10
+insert into t1 values(null);
+select c1 from t1 order by c1 desc limit 1;
+c1
+11
+insert into t1 values(6);
+select c1 from t1 order by c1 desc limit 1;
+c1
+11
+insert into t1 values(null);
+select c1 from t1 order by c1 desc limit 1;
+c1
+12
+drop table t1;
+create table t1 (c1 int, c2 int auto_increment, primary key(c1), key idx1(c2));
+insert into t1 values(1, null);
+select * from t1 order by c2 desc limit 1;
+c1	c2
+1	1
+insert into t1 values(2, null);
+select * from t1 order by c2 desc limit 1;
+c1	c2
+2	2
+insert into t1 values(3, 10);
+select * from t1 order by c2 desc limit 1;
+c1	c2
+3	10
+insert into t1 values(4, null);
+select * from t1 order by c2 desc limit 1;
+c1	c2
+4	11
+insert into t1 values(5, 6);
+select * from t1 order by c2 desc limit 1;
+c1	c2
+4	11
+insert into t1 values(6, null);
+select * from t1 order by c2 desc limit 1;
+c1	c2
+6	12
+drop table t1;

  Added: test/sql/t/auto_increment.test (+53 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/t/auto_increment.test    2011-04-02 09:22:24 +0000 (7f51381)
@@ -0,0 +1,53 @@
+# Copyright(C) 2011 Kentoku SHIBA
+#
+# 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.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (c1 int auto_increment, primary key(c1));
+insert into t1 values(null);
+select c1 from t1 order by c1 desc limit 1;
+insert into t1 values(null);
+select c1 from t1 order by c1 desc limit 1;
+insert into t1 values(10);
+select c1 from t1 order by c1 desc limit 1;
+insert into t1 values(null);
+select c1 from t1 order by c1 desc limit 1;
+insert into t1 values(6);
+select c1 from t1 order by c1 desc limit 1;
+insert into t1 values(null);
+select c1 from t1 order by c1 desc limit 1;
+drop table t1;
+
+create table t1 (c1 int, c2 int auto_increment, primary key(c1), key idx1(c2));
+insert into t1 values(1, null);
+select * from t1 order by c2 desc limit 1;
+insert into t1 values(2, null);
+select * from t1 order by c2 desc limit 1;
+insert into t1 values(3, 10);
+select * from t1 order by c2 desc limit 1;
+insert into t1 values(4, null);
+select * from t1 order by c2 desc limit 1;
+insert into t1 values(5, 6);
+select * from t1 order by c2 desc limit 1;
+insert into t1 values(6, null);
+select * from t1 order by c2 desc limit 1;
+drop table t1;
+
+--source suite/groonga/include/groonga_deinit.inc




Groonga-mysql-commit メーリングリストの案内
アーカイブの一覧に戻る