[Groonga-commit] groonga/groonga [master] make key_type for TABLE_NO_KEY error. #341

Back to archive index

null+****@clear***** null+****@clear*****
2010年 6月 25日 (金) 12:50:11 JST


Kouhei Sutou	2010-06-25 03:50:11 +0000 (Fri, 25 Jun 2010)

  New Revision: fb84120ed08f0ae33958d9ab564bfc1812563c77

  Log:
    make key_type for TABLE_NO_KEY error. #341

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

  Modified: lib/db.c (+9 -3)
===================================================================
--- lib/db.c    2010-06-25 02:55:36 +0000 (0dd200f)
+++ lib/db.c    2010-06-25 03:50:11 +0000 (621c267)
@@ -497,6 +497,15 @@ grn_table_create(grn_ctx *ctx, const char *name, unsigned name_size,
     GRN_API_RETURN(NULL);
   }
   if (key_type) {
+    if ((flags & GRN_OBJ_TABLE_TYPE_MASK) == GRN_OBJ_TABLE_NO_KEY) {
+      if (name_size > 0) {
+        ERR(GRN_INVALID_ARGUMENT,
+            "key_type assigned for no key table: <%.*s>", name_size, name);
+      } else {
+        ERR(GRN_INVALID_ARGUMENT, "key_type assigned for no key table");
+      }
+      GRN_API_RETURN(NULL);
+    }
     domain = DB_OBJ(key_type)->id;
     switch (key_type->header.type) {
     case GRN_TYPE :
@@ -595,9 +604,6 @@ grn_table_create(grn_ctx *ctx, const char *name, unsigned name_size,
     }
     break;
   case GRN_OBJ_TABLE_NO_KEY :
-    if (key_type) {
-      GRN_LOG(ctx, GRN_LOG_WARNING, "key_type assigned for no key table");
-    }
     if (value_type && value_type->header.type == GRN_TABLE_VIEW) {
       res = grn_view_transcript(ctx, path, key_type, value_type, flags);
     } else {

  Modified: test/unit/http/test-http-schema.rb (+2 -2)
===================================================================
--- test/unit/http/test-http-schema.rb    2010-06-25 02:55:36 +0000 (f77df98)
+++ test/unit/http/test-http-schema.rb    2010-06-25 03:50:11 +0000 (9dd7902)
@@ -520,8 +520,8 @@ class HTTPSchemaTest < Test::Unit::TestCase
                                   :name => "users",
                                   :flags => Table::NO_KEY,
                                   :key_type => "ShortText"))
-      assert_error_response(Result::UNKNOWN_ERROR,
-                            "key isn't supported",
+      assert_error_response(Result::INVALID_ARGUMENT,
+                            "key_type assigned for no key table: <users>",
                             response,
                             :content_type => "application/json")
 




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