[Groonga-mysql-commit] mroonga/mroonga at 61142a2 [master] storage: add empty primary key check

Zurück zum Archiv-Index

Kouhei Sutou null+****@clear*****
Tue Nov 25 22:52:20 JST 2014


Kouhei Sutou	2014-11-25 22:52:20 +0900 (Tue, 25 Nov 2014)

  New Revision: 61142a2fc3bb66895265610a41fcd273959664bd
  https://github.com/mroonga/mroonga/commit/61142a2fc3bb66895265610a41fcd273959664bd

  Message:
    storage: add empty primary key check
    
    Groonga doesn't accept empty value for key. So Mroonga reports error for
    empty primary key case.
    
    [groonga-dev,02963]
    
    Reported by kashihara. Thanks!!!

  Added files:
    mysql-test/mroonga/storage/replace/r/without_key.result
    mysql-test/mroonga/storage/replace/t/without_key.test
  Modified files:
    ha_mroonga.cpp

  Modified: ha_mroonga.cpp (+5 -0)
===================================================================
--- ha_mroonga.cpp    2014-11-24 18:17:39 +0900 (a18c3b5)
+++ ha_mroonga.cpp    2014-11-25 22:52:20 +0900 (2d28fdf)
@@ -5290,6 +5290,11 @@ int ha_mroonga::storage_write_row(uchar *buf)
     }
   }
 
+  if (pkey_size == 0) {
+    my_message(ER_ERROR_ON_WRITE, "primary key is empty", MYF(0));
+    DBUG_RETURN(ER_ERROR_ON_WRITE);
+  }
+
   int added;
   record_id = grn_table_add(ctx, grn_table, pkey, pkey_size, &added);
   if (ctx->rc) {

  Added: mysql-test/mroonga/storage/replace/r/without_key.result (+10 -0) 100644
===================================================================
--- /dev/null
+++ mysql-test/mroonga/storage/replace/r/without_key.result    2014-11-25 22:52:20 +0900 (2c6c1cb)
@@ -0,0 +1,10 @@
+DROP TABLE IF EXISTS diaries;
+SET NAMES utf8;
+CREATE TABLE diaries (
+id varchar(32) NOT NULL PRIMARY KEY,
+content text,
+FULLTEXT INDEX (content)
+) DEFAULT CHARSET=utf8;
+REPLACE INTO diaries(content) VALUES("Hello");
+ERROR HY000: primary key is empty
+DROP TABLE diaries;

  Added: mysql-test/mroonga/storage/replace/t/without_key.test (+35 -0) 100644
===================================================================
--- /dev/null
+++ mysql-test/mroonga/storage/replace/t/without_key.test    2014-11-25 22:52:20 +0900 (8dc12f7)
@@ -0,0 +1,35 @@
+# Copyright(C) 2014 Kouhei Sutou <kou �� clear-code.com>
+#
+# 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/mroonga/have_mroonga.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS diaries;
+--enable_warnings
+
+SET NAMES utf8;
+CREATE TABLE diaries (
+  id varchar(32) NOT NULL PRIMARY KEY,
+  content text,
+  FULLTEXT INDEX (content)
+) DEFAULT CHARSET=utf8;
+
+-- error ER_ERROR_ON_WRITE
+REPLACE INTO diaries(content) VALUES("Hello");
+
+DROP TABLE diaries;
+
+--source ../../../include/mroonga/have_mroonga_deinit.inc
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-mysql-commit mailing list
Zurück zum Archiv-Index