[Groonga-commit] groonga/groonga at 8712afa [master] Fix codes_curr check position

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Jun 23 20:02:23 JST 2018


Kouhei Sutou	2018-06-23 20:02:23 +0900 (Sat, 23 Jun 2018)

  New Revision: 8712afa404864e2d2a4c00fa4d8d4d5d90187d75
  https://github.com/groonga/groonga/commit/8712afa404864e2d2a4c00fa4d8d4d5d90187d75

  Message:
    Fix codes_curr check position
    
    We should not touch expr->codes[si->end] when si->start >=
    expr->codes_curr.

  Modified files:
    lib/expr.c
    test/command/suite/select/function/sub_filter/and_or.expected

  Modified: lib/expr.c (+16 -12)
===================================================================
--- lib/expr.c    2018-06-22 19:02:37 +0900 (3c0051272)
+++ lib/expr.c    2018-06-23 20:02:23 +0900 (671b88dd4)
@@ -4694,13 +4694,23 @@ grn_table_select_inspect_condition(grn_ctx *ctx,
     return "";
   }
 
-  n_codes = si->end - si->start + 1;
-  last_operator = expr->codes[si->end].op;
-
   GRN_BULK_REWIND(buffer);
 
   GRN_TEXT_PUTS(ctx, buffer, ": ");
 
+  if (si->start >= expr->codes_curr) {
+    if (si->op != GRN_OP_NOP) {
+      GRN_TEXT_PUTS(ctx, buffer, grn_operator_to_string(si->op));
+      GRN_TEXT_PUTS(ctx, buffer, ": ");
+    }
+    GRN_TEXT_PUTS(ctx, buffer, grn_operator_to_string(si->logical_op));
+    GRN_TEXT_PUTC(ctx, buffer, '\0');
+    return GRN_TEXT_VALUE(buffer);
+  }
+
+  n_codes = si->end - si->start + 1;
+  last_operator = expr->codes[si->end].op;
+
   switch (last_operator) {
   case GRN_OP_CALL :
     for (i = si->start; i <= si->end; i++) {
@@ -4762,16 +4772,10 @@ grn_table_select_inspect_condition(grn_ctx *ctx,
       if (i > si->start) {
         GRN_TEXT_PUTC(ctx, buffer, ' ');
       }
-      if (i < expr->codes_curr) {
-        if (code->value) {
-          grn_table_select_inspect_condition_argument(ctx, buffer, code->value);
-        } else {
-          GRN_TEXT_PUTS(ctx, buffer, grn_operator_to_string(code->op));
-        }
+      if (code->value) {
+        grn_table_select_inspect_condition_argument(ctx, buffer, code->value);
       } else {
-        GRN_TEXT_PUTS(ctx, buffer, grn_operator_to_string(si->op));
-        GRN_TEXT_PUTS(ctx, buffer, ": ");
-        GRN_TEXT_PUTS(ctx, buffer, grn_operator_to_string(si->logical_op));
+        GRN_TEXT_PUTS(ctx, buffer, grn_operator_to_string(code->op));
       }
     }
     break;

  Modified: test/command/suite/select/function/sub_filter/and_or.expected (+1 -1)
===================================================================
--- test/command/suite/select/function/sub_filter/and_or.expected    2018-06-22 19:02:37 +0900 (8e78b5424)
+++ test/command/suite/select/function/sub_filter/and_or.expected    2018-06-23 20:02:23 +0900 (615c46419)
@@ -84,7 +84,7 @@ select Packages   --filter 'sub_filter(files,                        "revision >
 #:000000000000000 filter(0): #<accessor _key(Files)> "ha" prefix
 #:000000000000000 filter(1): #<accessor _key(Files)> "include/" prefix
 #:000000000000000 filter(1): Files.revision greater_equal 10
-#:000000000000000 filter(1): nop: and
+#:000000000000000 filter(1): and
 #:000000000000000 filter(1): sub_filter(Packages.files, "revision >= 10 &&                         (_key @^ \"ha\" || _key @^ \"include/\")")
 #:000000000000000 select(1)
 #:000000000000000 output(1)
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180623/a5b64a75/attachment-0001.htm 



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