[Groonga-commit] groonga/groonga at 98c01d6 [master] Don't normalize both target and pattern for GRN_OP_REGEXP

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Mar 10 19:05:50 JST 2015


Kouhei Sutou	2015-03-10 19:05:50 +0900 (Tue, 10 Mar 2015)

  New Revision: 98c01d6a368c986b2e33ecb8135f73feebf5d149
  https://github.com/groonga/groonga/commit/98c01d6a368c986b2e33ecb8135f73feebf5d149

  Message:
    Don't normalize both target and pattern for GRN_OP_REGEXP

  Modified files:
    lib/operator.c
    test/unit/core/test-operator.c

  Modified: lib/operator.c (+11 -1)
===================================================================
--- lib/operator.c    2015-03-10 18:52:53 +0900 (6e631aa)
+++ lib/operator.c    2015-03-10 19:05:50 +0900 (22636fd)
@@ -757,6 +757,12 @@ exec_text_operator_raw_text_raw_text(grn_ctx *ctx,
     return GRN_FALSE;
   }
 
+  if (op == GRN_OP_REGEXP) {
+    return exec_text_operator(ctx, op,
+                              target, target_len,
+                              query, query_len);
+  }
+
   normalizer = grn_ctx_get(ctx, GRN_NORMALIZER_AUTO_NAME, -1);
   norm_target = grn_string_open(ctx, target, target_len, normalizer, 0);
   norm_query  = grn_string_open(ctx, query,  query_len,  normalizer, 0);
@@ -797,10 +803,14 @@ exec_text_operator_record_text(grn_ctx *ctx,
     return GRN_FALSE;
   }
 
+  if (GRN_TEXT_LEN(query) == 0) {
+    return GRN_FALSE;
+  }
+
   record_key_len = grn_table_get_key(ctx, table, GRN_RECORD_VALUE(record),
                                      record_key, GRN_TABLE_MAX_KEY_SIZE);
   grn_table_get_info(ctx, table, NULL, NULL, NULL, &normalizer, NULL);
-  if (normalizer) {
+  if (normalizer && (op != GRN_OP_REGEXP)) {
     grn_obj *norm_query;
     const char *norm_query_raw;
     unsigned int norm_query_raw_length_in_bytes;

  Modified: test/unit/core/test-operator.c (+1 -1)
===================================================================
--- test/unit/core/test-operator.c    2015-03-10 18:52:53 +0900 (016885b)
+++ test/unit/core/test-operator.c    2015-03-10 19:05:50 +0900 (1cfa86b)
@@ -610,7 +610,7 @@ test_exec_regexp_true(gconstpointer data)
   rhs_type = gcut_data_get_string(data, "rhs_type");
 
   set_text(&lhs, "Hello");
-  set_text(&rhs, "e.l");
+  set_text(&rhs, "\\AHe");
   cut_assert_true(grn_operator_exec_regexp(context, &lhs, &rhs));
 }
 
-------------- next part --------------
HTML����������������������������...
Download 



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