[Groonga-commit] groonga/groonga [master] [shcema][table-create] validate WITH_SIS flag.

Back to archive index

null+****@clear***** null+****@clear*****
2011年 12月 19日 (月) 13:01:29 JST


Kouhei Sutou	2011-12-19 04:01:29 +0000 (Mon, 19 Dec 2011)

  New Revision: 37e70ecf589f8152abf69fade85ebfe48d145513

  Log:
    [shcema][table-create] validate WITH_SIS flag.
    
    refs #915
    refs #1210

  Modified files:
    lib/db.c
    test/unit/http/test-http-schema.rb

  Modified: lib/db.c (+15 -2)
===================================================================
--- lib/db.c    2011-12-19 03:53:37 +0000 (038c057)
+++ lib/db.c    2011-12-19 04:01:29 +0000 (0794aad)
@@ -614,20 +614,33 @@ grn_table_create_validate(grn_ctx *ctx, const char *name, unsigned name_size,
 {
   switch (flags & GRN_OBJ_TABLE_TYPE_MASK) {
   case GRN_OBJ_TABLE_HASH_KEY :
+    if (flags & GRN_OBJ_KEY_WITH_SIS) {
+      ERR(GRN_INVALID_ARGUMENT,
+          "key with SIS isn't available for hash table: <%.*s>",
+          name_size, name);
+    }
     break;
   case GRN_OBJ_TABLE_PAT_KEY :
     break;
   case GRN_OBJ_TABLE_DAT_KEY :
     break;
   case GRN_OBJ_TABLE_NO_KEY :
-    if (flags & GRN_OBJ_KEY_NORMALIZE) {
+    if (flags & GRN_OBJ_KEY_WITH_SIS) {
+      ERR(GRN_INVALID_ARGUMENT,
+          "key with SIS isn't available for no key table: <%.*s>",
+          name_size, name);
+    } else if (flags & GRN_OBJ_KEY_NORMALIZE) {
       ERR(GRN_INVALID_ARGUMENT,
           "key normalization isn't available for no key table: <%.*s>",
           name_size, name);
     }
     break;
   case GRN_OBJ_TABLE_VIEW :
-    if (flags & GRN_OBJ_KEY_NORMALIZE) {
+    if (flags & GRN_OBJ_KEY_WITH_SIS) {
+      ERR(GRN_INVALID_ARGUMENT,
+          "key with SIS isn't available for view table: <%.*s>",
+          name_size, name);
+    } else if (flags & GRN_OBJ_KEY_NORMALIZE) {
       ERR(GRN_INVALID_ARGUMENT,
           "key normalization isn't available for view table: <%.*s>",
           name_size, name);

  Modified: test/unit/http/test-http-schema.rb (+9 -6)
===================================================================
--- test/unit/http/test-http-schema.rb    2011-12-19 03:53:37 +0000 (1efe999)
+++ test/unit/http/test-http-schema.rb    2011-12-19 04:01:29 +0000 (e18fcbe)
@@ -336,8 +336,9 @@ class HTTPSchemaTest < Test::Unit::TestCase
                                   :name => "users",
                                   :flags => Key::SIS,
                                   :key_type => "ShortText"))
-      assert_error_response(Result::UNKNOWN_ERROR,
-                            "SIS is invalid flag for hash",
+      assert_error_response(Result::INVALID_ARGUMENT,
+                            "key with SIS isn't available " +
+                              "for hash table: <users>",
                             response,
                             :content_type => "application/json")
 
@@ -557,8 +558,9 @@ class HTTPSchemaTest < Test::Unit::TestCase
       response = get(command_path(:table_create,
                                   :name => "users",
                                   :flags => Table::NO_KEY | Key::SIS))
-      assert_error_response(Result::UNKNOWN_ERROR,
-                            "SIS key isn't available",
+      assert_error_response(Result::INVALID_ARGUMENT,
+                            "key with SIS isn't available " +
+                              "for no key table: <users>",
                             response,
                             :content_type => "application/json")
 
@@ -648,8 +650,9 @@ class HTTPSchemaTest < Test::Unit::TestCase
       response = get(command_path(:table_create,
                                   :name => "users",
                                   :flags => Table::VIEW | Key::SIS))
-      assert_error_response(Result::UNKNOWN_ERROR,
-                            "SIS key isn't available",
+      assert_error_response(Result::INVALID_ARGUMENT,
+                            "key with SIS isn't available " +
+                              "for view table: <users>",
                             response,
                             :content_type => "application/json")
 




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