[Groonga-commit] groonga/groonga at 0215831 [master] Add empty string check to similar search

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Apr 30 16:03:02 JST 2013


Kouhei Sutou	2013-04-30 16:03:02 +0900 (Tue, 30 Apr 2013)

  New Revision: 02158314a952ac12aaab65181b89c313b4381653
  https://github.com/groonga/groonga/commit/02158314a952ac12aaab65181b89c313b4381653

  Message:
    Add empty string check to similar search
    
    It causes SEGV.
    
    [groonga-dev,01346]
    
    Reported by Nakai Kanako. Thanks!!!

  Added files:
    test/command/suite/select/filter/similar/empty_string.expected
    test/command/suite/select/filter/similar/empty_string.test
  Modified files:
    lib/ii.c

  Modified: lib/ii.c (+1 -1)
===================================================================
--- lib/ii.c    2013-04-30 15:59:18 +0900 (62ed7d5)
+++ lib/ii.c    2013-04-30 16:03:02 +0900 (6ba9bf2)
@@ -5716,7 +5716,7 @@ grn_ii_similar_search(grn_ctx *ctx, grn_ii *ii,
   grn_token *token;
   unsigned int token_flags = GRN_TOKEN_ENABLE_TOKENIZED_DELIMITER;
   grn_obj *lexicon = ii->lexicon;
-  if (!lexicon || !ii || !string || !s || !optarg) { return GRN_INVALID_ARGUMENT; }
+  if (!lexicon || !ii || !string || !string_len || !s || !optarg) { return GRN_INVALID_ARGUMENT; }
   if (!(h = grn_hash_create(ctx, NULL, sizeof(grn_id), sizeof(int), 0))) {
     return GRN_NO_MEMORY_AVAILABLE;
   }

  Added: test/command/suite/select/filter/similar/empty_string.expected (+44 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/similar/empty_string.expected    2013-04-30 16:03:02 +0900 (edf8b93)
@@ -0,0 +1,44 @@
+table_create Documents TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Documents content COLUMN_SCALAR Text
+[[0,0.0,0.0],true]
+table_create Terms TABLE_PAT_KEY|KEY_NORMALIZE ShortText --default_tokenizer TokenBigram
+[[0,0.0,0.0],true]
+column_create Terms document_index COLUMN_INDEX|WITH_POSITION Documents content
+[[0,0.0,0.0],true]
+load --table Documents
+[
+["_key", "content"],
+["Groonga overview", "Groonga is a fast and accurate full text search engine based on inverted index. One of the characteristics of groonga is that a newly registered document instantly appears in search results. Also, groonga allows updates without read locks. These characteristics result in superior performance on real-time applications."]
+]
+[[0,0.0,0.0],1]
+select Documents --filter 'content *S ""' --output_columns '_key, _score, content'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        0
+      ],
+      [
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "_score",
+          "Int32"
+        ],
+        [
+          "content",
+          "Text"
+        ]
+      ]
+    ]
+  ]
+]
+#|e| grn_ii_select on grn_ii_sel(1) failed !

  Added: test/command/suite/select/filter/similar/empty_string.test (+13 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/similar/empty_string.test    2013-04-30 16:03:02 +0900 (677f20a)
@@ -0,0 +1,13 @@
+table_create Documents TABLE_HASH_KEY ShortText
+column_create Documents content COLUMN_SCALAR Text
+
+table_create Terms TABLE_PAT_KEY|KEY_NORMALIZE ShortText --default_tokenizer TokenBigram
+column_create Terms document_index COLUMN_INDEX|WITH_POSITION Documents content
+
+load --table Documents
+[
+["_key", "content"],
+["Groonga overview", "Groonga is a fast and accurate full text search engine based on inverted index. One of the characteristics of groonga is that a newly registered document instantly appears in search results. Also, groonga allows updates without read locks. These characteristics result in superior performance on real-time applications."]
+]
+
+select Documents --filter 'content *S ""' --output_columns '_key, _score, content'
-------------- next part --------------
HTML����������������������������...
Download 



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