[Groonga-commit] groonga/groonga at a7685d7 [master] select: ignore space only --query

Back to archive index

Kouhei Sutou null+****@clear*****
Mon May 25 21:21:08 JST 2015


Kouhei Sutou	2015-05-25 21:21:08 +0900 (Mon, 25 May 2015)

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

  Message:
    select: ignore space only --query
    
    Suggested by TomyGX. Thanks!!!

  Added files:
    test/command/suite/select/query/space_only.expected
    test/command/suite/select/query/space_only.test
  Modified files:
    lib/proc.c

  Modified: lib/proc.c (+13 -0)
===================================================================
--- lib/proc.c    2015-05-25 18:29:39 +0900 (5ab4fcc)
+++ lib/proc.c    2015-05-25 21:21:08 +0900 (4d27b6b)
@@ -901,6 +901,19 @@ grn_select(grn_ctx *ctx, const char *table, unsigned int table_len,
   long long int threshold, original_threshold = 0;
   grn_cache *cache_obj = grn_cache_current_get(ctx);
 
+  {
+    const char *query_end = query + query_len;
+    int space_len;
+    while (query < query_end) {
+      space_len = grn_isspace(query, ctx->encoding);
+      if (space_len == 0) {
+        break;
+      }
+      query += space_len;
+      query_len -= space_len;
+    }
+  }
+
   cache_key_size = table_len + 1 + match_columns_len + 1 + query_len + 1 +
     filter_len + 1 + scorer_len + 1 + sortby_len + 1 + output_columns_len + 1 +
     match_escalation_threshold_len + 1 +

  Added: test/command/suite/select/query/space_only.expected (+46 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/query/space_only.expected    2015-05-25 21:21:08 +0900 (28c8261)
@@ -0,0 +1,46 @@
+table_create Memos TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+load --table Memos
+[
+{"_key": "Groonga is fast"},
+{"_key": "Mroonga is also fast"},
+{"_key": "Ruby is an object oriented script language"}
+]
+[[0,0.0,0.0],3]
+select Memos   --match_columns _key   --query '   '
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        3
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ]
+      ],
+      [
+        1,
+        "Groonga is fast"
+      ],
+      [
+        2,
+        "Mroonga is also fast"
+      ],
+      [
+        3,
+        "Ruby is an object oriented script language"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/query/space_only.test (+12 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/query/space_only.test    2015-05-25 21:21:08 +0900 (477f6c3)
@@ -0,0 +1,12 @@
+table_create Memos TABLE_HASH_KEY ShortText
+
+load --table Memos
+[
+{"_key": "Groonga is fast"},
+{"_key": "Mroonga is also fast"},
+{"_key": "Ruby is an object oriented script language"}
+]
+
+select Memos \
+  --match_columns _key \
+  --query '   '
-------------- next part --------------
HTML����������������������������...
下载 



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