[Groonga-commit] groonga/groonga at fbf58b7 [master] Add check exist of "WITH SECTION" flag when a full-text search for vector column.

Back to archive index

Yasuhiro Horimoto null+****@clear*****
Tue Jun 19 17:14:18 JST 2018


Yasuhiro Horimoto	2018-06-19 17:14:18 +0900 (Tue, 19 Jun 2018)

  New Revision: fbf58b702efcd65b275a007cb15733c7d2a8bac1
  https://github.com/groonga/groonga/commit/fbf58b702efcd65b275a007cb15733c7d2a8bac1

  Merged 8a52f23: Merge pull request #850 from komainu8/add_check_exist_with_section_flag

  Message:
    Add check exist of "WITH SECTION" flag when a full-text search for vector column.
    
    Because we can't a full-text search for vector column
    if we don't set "WITH_SECTION" flag.

  Added files:
    test/command/suite/column_create/index/without_section.expected
    test/command/suite/column_create/index/without_section.test
  Modified files:
    lib/db.c

  Modified: lib/db.c (+30 -0)
===================================================================
--- lib/db.c    2018-06-18 17:54:10 +0900 (1d648263a)
+++ lib/db.c    2018-06-19 17:14:18 +0900 (a91ebfc09)
@@ -8821,6 +8821,36 @@ grn_obj_set_info_source_validate(grn_ctx *ctx, grn_obj *obj, grn_obj *value)
 
   source_ids = (grn_id *)GRN_BULK_HEAD(value);
   n_source_ids = GRN_BULK_VSIZE(value) / sizeof(grn_id);
+  if (n_source_ids == 1) {
+    grn_obj *source;
+
+    source = grn_ctx_at(ctx, source_ids[0]);
+    switch (source->header.type) {
+    case GRN_COLUMN_VAR_SIZE :
+      switch (source->header.flags & GRN_OBJ_COLUMN_TYPE_MASK) {
+      case GRN_OBJ_COLUMN_VECTOR :
+        if ((obj->header.flags & GRN_OBJ_COLUMN_INDEX)
+            && (obj->header.flags & GRN_OBJ_WITH_POSITION)) {
+          if (!(obj->header.flags & GRN_OBJ_WITH_SECTION)) {
+            char index_name[GRN_TABLE_MAX_KEY_SIZE];
+            int index_name_size;
+            index_name_size = grn_obj_name(ctx, obj,
+                                           index_name, GRN_TABLE_MAX_KEY_SIZE);
+            ERR(GRN_INVALID_ARGUMENT,
+                "grn_obj_set_info(): GRN_INFO_SOURCE: "
+                "vector column index must be created with WITH_SECTION flag: <%.*s>",
+                index_name_size, index_name);
+            goto exit;
+          }
+        }
+      default:
+        break;
+      }
+    default:
+      break;
+    }
+  }
+
   if (n_source_ids > 1 && !(obj->header.flags & GRN_OBJ_WITH_SECTION)) {
     char index_name[GRN_TABLE_MAX_KEY_SIZE];
     int index_name_size;

  Added: test/command/suite/column_create/index/without_section.expected (+25 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/column_create/index/without_section.expected    2018-06-19 17:14:18 +0900 (86b683227)
@@ -0,0 +1,25 @@
+table_create Memos TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Memos content COLUMN_VECTOR ShortText
+[[0,0.0,0.0],true]
+load --table Memos
+[
+{"content": ["Groonga", "Mroonga", "PGroonga"]},
+{"content": ["Hello", "Good-bye"]}
+]
+[[0,0.0,0.0],2]
+table_create Terms TABLE_PAT_KEY ShortText   --default_tokenizer TokenBigram   --normalizer NormalizerAuto
+[[0,0.0,0.0],true]
+column_create Terms memos_content COLUMN_INDEX|WITH_POSITION Memos content
+[
+  [
+    [
+      -22,
+      0.0,
+      0.0
+    ],
+    "grn_obj_set_info(): GRN_INFO_SOURCE: vector column index must be created with WITH_SECTION flag: <Terms.memos_content>"
+  ],
+  false
+]
+#|e| grn_obj_set_info(): GRN_INFO_SOURCE: vector column index must be created with WITH_SECTION flag: <Terms.memos_content>

  Added: test/command/suite/column_create/index/without_section.test (+10 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/column_create/index/without_section.test    2018-06-19 17:14:18 +0900 (6b3bb35a3)
@@ -0,0 +1,10 @@
+table_create Memos TABLE_NO_KEY
+column_create Memos content COLUMN_VECTOR ShortText
+load --table Memos
+[
+{"content": ["Groonga", "Mroonga", "PGroonga"]},
+{"content": ["Hello", "Good-bye"]}
+]
+
+table_create Terms TABLE_PAT_KEY ShortText   --default_tokenizer TokenBigram   --normalizer NormalizerAuto
+column_create Terms memos_content COLUMN_INDEX|WITH_POSITION Memos content
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180619/cd385f0a/attachment-0001.htm 



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