[Groonga-commit] groonga/groonga at 0a4561f [master] query-log show-condition: (maybe) fix a crash bug

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Jun 22 18:48:57 JST 2018


Kouhei Sutou	2018-06-22 18:48:57 +0900 (Fri, 22 Jun 2018)

  New Revision: 0a4561f676588535a831f4cb6d9afca3de5d4aaa
  https://github.com/groonga/groonga/commit/0a4561f676588535a831f4cb6d9afca3de5d4aaa

  Message:
    query-log show-condition: (maybe) fix a crash bug
    
    We need to check scan_info that doesn't have corresponding expr_code.

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

  Modified: lib/expr.c (+9 -3)
===================================================================
--- lib/expr.c    2018-06-22 17:43:23 +0900 (658293304)
+++ lib/expr.c    2018-06-22 18:48:57 +0900 (3c0051272)
@@ -4762,10 +4762,16 @@ grn_table_select_inspect_condition(grn_ctx *ctx,
       if (i > si->start) {
         GRN_TEXT_PUTC(ctx, buffer, ' ');
       }
-      if (code->value) {
-        grn_table_select_inspect_condition_argument(ctx, buffer, code->value);
+      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));
+        }
       } else {
-        GRN_TEXT_PUTS(ctx, buffer, grn_operator_to_string(code->op));
+        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));
       }
     }
     break;

  Added: test/command/suite/select/function/sub_filter/and_or.expected (+91 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/sub_filter/and_or.expected    2018-06-22 18:48:57 +0900 (8e78b5424)
@@ -0,0 +1,91 @@
+table_create Files TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Files revision COLUMN_SCALAR UInt32
+[[0,0.0,0.0],true]
+table_create Packages TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Packages files COLUMN_VECTOR Files
+[[0,0.0,0.0],true]
+column_create Files packages_files_index COLUMN_INDEX Packages files
+[[0,0.0,0.0],true]
+table_create Revisions TABLE_PAT_KEY UInt32
+[[0,0.0,0.0],true]
+column_create Revisions files_revision_index COLUMN_INDEX Files revision
+[[0,0.0,0.0],true]
+table_create Names TABLE_PAT_KEY ShortText   --default_tokenizer TokenBigramSplitSymbolAlpha
+[[0,0.0,0.0],true]
+column_create Names packages_key_index COLUMN_INDEX|WITH_POSITION Packages _key
+[[0,0.0,0.0],true]
+load --table Files
+[
+{"_key": "include/groonga.h", "revision": 100},
+{"_key": "src/groonga.c",     "revision": 29},
+{"_key": "lib/groonga.rb",    "revision": 12},
+{"_key": "README.textile",    "revision": 24},
+{"_key": "ha_mroonga.cc",     "revision": 40},
+{"_key": "ha_mroonga.hpp",    "revision": 6}
+]
+[[0,0.0,0.0],6]
+load --table Packages
+[
+{"_key": "groonga", "files": ["include/groonga.h", "src/groonga.c"]},
+{"_key": "rroonga", "files": ["lib/groonga.rb", "README.textile"]},
+{"_key": "mroonga", "files": ["ha_mroonga.cc", "ha_mroonga.hpp"]}
+]
+[[0,0.0,0.0],3]
+select Packages   --filter 'sub_filter(files,                        "revision >= 10 &&                         (_key @^ \\\"ha\\\" || _key @^ \\\"include/\\\")") &&             (_key == "groonga" || _key == "rroonga")'   --output_columns '_key, _score, files, files.revision'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "_score",
+          "Int32"
+        ],
+        [
+          "files",
+          "Files"
+        ],
+        [
+          "files.revision",
+          "UInt32"
+        ]
+      ],
+      [
+        "groonga",
+        3,
+        [
+          "include/groonga.h",
+          "src/groonga.c"
+        ],
+        [
+          100,
+          29
+        ]
+      ]
+    ]
+  ]
+]
+#>select --filter "sub_filter(files,                        \"revision >= 10 &&                         (_key @^ \\\"ha\\\" || _key @^ \\\"include/\\\")\") &&             (_key == \"groonga\" || _key == \"rroonga\")" --output_columns "_key, _score, files, files.revision" --table "Packages"
+#:000000000000000 filter(1): #<accessor _key(Packages)> equal "groonga"
+#:000000000000000 filter(2): #<accessor _key(Packages)> equal "rroonga"
+#: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): sub_filter(Packages.files, "revision >= 10 &&                         (_key @^ \"ha\" || _key @^ \"include/\")")
+#:000000000000000 select(1)
+#:000000000000000 output(1)
+#<000000000000000 rc=0

  Added: test/command/suite/select/function/sub_filter/and_or.test (+41 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/sub_filter/and_or.test    2018-06-22 18:48:57 +0900 (7f58a5360)
@@ -0,0 +1,41 @@
+table_create Files TABLE_PAT_KEY ShortText
+column_create Files revision COLUMN_SCALAR UInt32
+
+table_create Packages TABLE_PAT_KEY ShortText
+column_create Packages files COLUMN_VECTOR Files
+
+column_create Files packages_files_index COLUMN_INDEX Packages files
+
+table_create Revisions TABLE_PAT_KEY UInt32
+column_create Revisions files_revision_index COLUMN_INDEX Files revision
+
+table_create Names TABLE_PAT_KEY ShortText \
+  --default_tokenizer TokenBigramSplitSymbolAlpha
+column_create Names packages_key_index COLUMN_INDEX|WITH_POSITION Packages _key
+
+load --table Files
+[
+{"_key": "include/groonga.h", "revision": 100},
+{"_key": "src/groonga.c",     "revision": 29},
+{"_key": "lib/groonga.rb",    "revision": 12},
+{"_key": "README.textile",    "revision": 24},
+{"_key": "ha_mroonga.cc",     "revision": 40},
+{"_key": "ha_mroonga.hpp",    "revision": 6}
+]
+
+load --table Packages
+[
+{"_key": "groonga", "files": ["include/groonga.h", "src/groonga.c"]},
+{"_key": "rroonga", "files": ["lib/groonga.rb", "README.textile"]},
+{"_key": "mroonga", "files": ["ha_mroonga.cc", "ha_mroonga.hpp"]}
+]
+
+#$GRN_QUERY_LOG_SHOW_CONDITION=yes
+#@collect-query-log true
+select Packages \
+  --filter 'sub_filter(files, \
+                       "revision >= 10 && \
+                        (_key @^ \\\"ha\\\" || _key @^ \\\"include/\\\")") && \
+            (_key == "groonga" || _key == "rroonga")' \
+  --output_columns '_key, _score, files, files.revision'
+#@collect-query-log false
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180622/7dd3571e/attachment-0001.htm 



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