[Groonga-commit] groonga/groonga at 73f19eb [master] table_create: stop ignoring nonexistent normalizer

Back to archive index

Kouhei Sutou null+****@clear*****
Mon May 2 16:29:36 JST 2016


Kouhei Sutou	2016-05-02 16:29:36 +0900 (Mon, 02 May 2016)

  New Revision: 73f19ebe949ba296b070e6aa3f5a0228af13c1eb
  https://github.com/groonga/groonga/commit/73f19ebe949ba296b070e6aa3f5a0228af13c1eb

  Message:
    table_create: stop ignoring nonexistent normalizer
    
    It's backward incompatibility change. But it'll be useful to find a typo
    in --normalizer. The current behavior, ignoring nonexistent normalizer
    silently, causes a delay in finding problems.

  Modified files:
    lib/proc/proc_table.c
    test/command/suite/table_create/normalizer/nonexistent.expected
    test/command/suite/table_create/normalizer/nonexistent.test

  Modified: lib/proc/proc_table.c (+18 -5)
===================================================================
--- lib/proc/proc_table.c    2016-05-02 16:22:49 +0900 (ddaa9be)
+++ lib/proc/proc_table.c    2016-05-02 16:29:36 +0900 (84381b4)
@@ -298,11 +298,24 @@ command_table_create(grn_ctx *ctx,
     }
 
     if (GRN_TEXT_LEN(normalizer_name) > 0) {
-        grn_obj_set_info(ctx, table,
-                         GRN_INFO_NORMALIZER,
-                         grn_ctx_get(ctx,
-                                     GRN_TEXT_VALUE(normalizer_name),
-                                     GRN_TEXT_LEN(normalizer_name)));
+      grn_obj *normalizer;
+
+      normalizer =
+        grn_ctx_get(ctx,
+                    GRN_TEXT_VALUE(normalizer_name),
+                    GRN_TEXT_LEN(normalizer_name));
+      if (!normalizer) {
+        GRN_PLUGIN_ERROR(ctx,
+                         GRN_INVALID_ARGUMENT,
+                         "[table][create][%.*s] unknown normalizer: <%.*s>",
+                         (int)GRN_TEXT_LEN(name),
+                         GRN_TEXT_VALUE(name),
+                         (int)GRN_TEXT_LEN(normalizer_name),
+                         GRN_TEXT_VALUE(normalizer_name));
+        grn_obj_remove(ctx, table);
+        goto exit;
+      }
+      grn_obj_set_info(ctx, table, GRN_INFO_NORMALIZER, normalizer);
     }
 
     grn_proc_table_set_token_filters(ctx, table, token_filters_name);

  Modified: test/command/suite/table_create/normalizer/nonexistent.expected (+8 -51)
===================================================================
--- test/command/suite/table_create/normalizer/nonexistent.expected    2016-05-02 16:22:49 +0900 (15f25c4)
+++ test/command/suite/table_create/normalizer/nonexistent.expected    2016-05-02 16:29:36 +0900 (a00cfb5)
@@ -1,57 +1,14 @@
 table_create Terms TABLE_PAT_KEY ShortText   --normalizer NormalizerNonexistent
-[[0,0.0,0.0],true]
-table_create Movies TABLE_NO_KEY
-[[0,0.0,0.0],true]
-column_create Movies name COLUMN_SCALAR ShortText
-[[0,0.0,0.0],true]
-column_create Terms movies_name COLUMN_INDEX Movies name
-[[0,0.0,0.0],true]
-load --table Movies
 [
-{"name": "Seven Samurai"},
-{"name": "The Last Samurai"}
-]
-[[0,0.0,0.0],2]
-select Terms --output_columns _key --limit -1
-[
-  [
-    0,
-    0.0,
-    0.0
-  ],
   [
     [
-      [
-        2
-      ],
-      [
-        [
-          "_key",
-          "ShortText"
-        ]
-      ],
-      [
-        "Seven Samurai"
-      ],
-      [
-        "The Last Samurai"
-      ]
-    ]
-  ]
+      -22,
+      0.0,
+      0.0
+    ],
+    "[table][create][Terms] unknown normalizer: <NormalizerNonexistent>"
+  ],
+  false
 ]
-select Movies --match_columns name --query seven
-[[0,0.0,0.0],[[[0],[["_id","UInt32"],["name","ShortText"]]]]]
+#|e| [table][create][Terms] unknown normalizer: <NormalizerNonexistent>
 dump
-table_create Terms TABLE_PAT_KEY ShortText
-
-table_create Movies TABLE_NO_KEY
-column_create Movies name COLUMN_SCALAR ShortText
-
-load --table Movies
-[
-["_id","name"],
-[1,"Seven Samurai"],
-[2,"The Last Samurai"]
-]
-
-column_create Terms movies_name COLUMN_INDEX Movies name

  Modified: test/command/suite/table_create/normalizer/nonexistent.test (+0 -15)
===================================================================
--- test/command/suite/table_create/normalizer/nonexistent.test    2016-05-02 16:22:49 +0900 (4cb12a4)
+++ test/command/suite/table_create/normalizer/nonexistent.test    2016-05-02 16:29:36 +0900 (9b12f14)
@@ -1,19 +1,4 @@
 table_create Terms TABLE_PAT_KEY ShortText \
   --normalizer NormalizerNonexistent
 
-table_create Movies TABLE_NO_KEY
-column_create Movies name COLUMN_SCALAR ShortText
-
-column_create Terms movies_name COLUMN_INDEX Movies name
-
-load --table Movies
-[
-{"name": "Seven Samurai"},
-{"name": "The Last Samurai"}
-]
-
-select Terms --output_columns _key --limit -1
-
-select Movies --match_columns name --query seven
-
 dump
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index