[Groonga-commit] groonga/groonga [master] Fix a bug that snippet_html(XXX), XXX fails with "stack error"

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Sun Mar 3 23:17:04 JST 2013


Kouhei Sutou	2013-03-03 23:17:04 +0900 (Sun, 03 Mar 2013)

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

  Log:
    Fix a bug that snippet_html(XXX),XXX fails with "stack error"
    
    [Groonga-talk] (no subject)
    http://sourceforge.net/mailarchive/message.php?msg_id=30545009
    
    Reported by Hendro Wibowo. Thanks!!!

  Added files:
    test/command/suite/select/function/snippet_html/first.expected
    test/command/suite/select/function/snippet_html/first.test
    test/command/suite/select/function/snippet_html/second.expected
    test/command/suite/select/function/snippet_html/second.test
    test/command/suite/select/function/snippet_html/third.expected
    test/command/suite/select/function/snippet_html/third.test
  Modified files:
    lib/output.c

  Modified: lib/output.c (+10 -5)
===================================================================
--- lib/output.c    2013-03-02 15:34:49 +0900 (2615716)
+++ lib/output.c    2013-03-03 23:17:04 +0900 (d5c4a29)
@@ -1162,20 +1162,25 @@ grn_output_table_records_by_expression(grn_ctx *ctx, grn_obj *outbuf,
     for (code = expr->codes; code < code_end; code++) {
       if (code->op == GRN_OP_COMMA) {
         int code_start_offset = previous_comma_offset + 1;
-        int code_end_offset = code - expr->codes - code_start_offset;
+        int code_end_offset;
         int original_codes_curr = expr->codes_curr;
 
         have_comma = GRN_TRUE;
         if (is_first_comma) {
-          expr->codes_curr = count_used_n_codes(ctx,
-                                                expr->codes,
-                                                expr->codes + expr->codes_curr);
+          int second_code_offset;
+          int second_code_n_used_code;
+          second_code_offset = code - expr->codes - 1;
+          second_code_n_used_code =
+            count_used_n_codes(ctx,
+                               expr->codes,
+                               expr->codes + second_code_offset);
+          expr->codes_curr = second_code_offset - second_code_n_used_code + 1;
           grn_output_table_record_by_expression(ctx, outbuf, output_type,
                                                 format->expression);
           code_start_offset = expr->codes_curr;
-          code_end_offset -= expr->codes_curr;
           is_first_comma = GRN_FALSE;
         }
+        code_end_offset = code - expr->codes - code_start_offset;
         expr->codes += code_start_offset;
         expr->codes_curr = code_end_offset;
         grn_output_table_record_by_expression(ctx, outbuf, output_type,

  Added: test/command/suite/select/function/snippet_html/first.expected (+53 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_html/first.expected    2013-03-03 23:17:04 +0900 (dca65d5)
@@ -0,0 +1,53 @@
+table_create Entries TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Entries title COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+column_create Entries content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+table_create Tokens TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+[[0,0.0,0.0],true]
+column_create Tokens entries_title COLUMN_INDEX|WITH_POSITION Entries title
+[[0,0.0,0.0],true]
+column_create Tokens entries_content COLUMN_INDEX|WITH_POSITION Entries content
+[[0,0.0,0.0],true]
+load --table Entries
+[
+{"title": "groonga and MySQL", "content": "groonga + MySQL = mroonga."}
+]
+[[0,0.0,0.0],1]
+select Entries   --output_columns 'snippet_html(title), title, content'   --command_version 2   --match_columns 'title'   --query groonga
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "snippet_html",
+          "null"
+        ],
+        [
+          "title",
+          "ShortText"
+        ],
+        [
+          "content",
+          "ShortText"
+        ]
+      ],
+      [
+        [
+          "<span class=\"keyword\">groonga</span> and MySQL"
+        ],
+        "groonga and MySQL",
+        "groonga + MySQL = mroonga."
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/function/snippet_html/first.test (+18 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_html/first.test    2013-03-03 23:17:04 +0900 (680aa28)
@@ -0,0 +1,18 @@
+table_create Entries TABLE_NO_KEY
+column_create Entries title COLUMN_SCALAR ShortText
+column_create Entries content COLUMN_SCALAR ShortText
+
+table_create Tokens TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+column_create Tokens entries_title COLUMN_INDEX|WITH_POSITION Entries title
+column_create Tokens entries_content COLUMN_INDEX|WITH_POSITION Entries content
+
+load --table Entries
+[
+{"title": "groonga and MySQL", "content": "groonga + MySQL = mroonga."}
+]
+
+select Entries \
+  --output_columns 'snippet_html(title), title, content' \
+  --command_version 2 \
+  --match_columns 'title' \
+  --query groonga

  Added: test/command/suite/select/function/snippet_html/second.expected (+53 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_html/second.expected    2013-03-03 23:17:04 +0900 (d70dd95)
@@ -0,0 +1,53 @@
+table_create Entries TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Entries title COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+column_create Entries content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+table_create Tokens TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+[[0,0.0,0.0],true]
+column_create Tokens entries_title COLUMN_INDEX|WITH_POSITION Entries title
+[[0,0.0,0.0],true]
+column_create Tokens entries_content COLUMN_INDEX|WITH_POSITION Entries content
+[[0,0.0,0.0],true]
+load --table Entries
+[
+{"title": "groonga and MySQL", "content": "groonga + MySQL = mroonga."}
+]
+[[0,0.0,0.0],1]
+select Entries   --output_columns 'title, snippet_html(title), content'   --command_version 2   --match_columns 'title'   --query groonga
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "title",
+          "ShortText"
+        ],
+        [
+          "snippet_html",
+          "null"
+        ],
+        [
+          "content",
+          "ShortText"
+        ]
+      ],
+      [
+        "groonga and MySQL",
+        [
+          "<span class=\"keyword\">groonga</span> and MySQL"
+        ],
+        "groonga + MySQL = mroonga."
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/function/snippet_html/second.test (+18 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_html/second.test    2013-03-03 23:17:04 +0900 (f0b8c15)
@@ -0,0 +1,18 @@
+table_create Entries TABLE_NO_KEY
+column_create Entries title COLUMN_SCALAR ShortText
+column_create Entries content COLUMN_SCALAR ShortText
+
+table_create Tokens TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+column_create Tokens entries_title COLUMN_INDEX|WITH_POSITION Entries title
+column_create Tokens entries_content COLUMN_INDEX|WITH_POSITION Entries content
+
+load --table Entries
+[
+{"title": "groonga and MySQL", "content": "groonga + MySQL = mroonga."}
+]
+
+select Entries \
+  --output_columns 'title, snippet_html(title), content' \
+  --command_version 2 \
+  --match_columns 'title' \
+  --query groonga

  Added: test/command/suite/select/function/snippet_html/third.expected (+53 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_html/third.expected    2013-03-03 23:17:04 +0900 (16f2f1a)
@@ -0,0 +1,53 @@
+table_create Entries TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Entries title COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+column_create Entries content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+table_create Tokens TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+[[0,0.0,0.0],true]
+column_create Tokens entries_title COLUMN_INDEX|WITH_POSITION Entries title
+[[0,0.0,0.0],true]
+column_create Tokens entries_content COLUMN_INDEX|WITH_POSITION Entries content
+[[0,0.0,0.0],true]
+load --table Entries
+[
+{"title": "groonga and MySQL", "content": "groonga + MySQL = mroonga."}
+]
+[[0,0.0,0.0],1]
+select Entries   --output_columns 'title, content, snippet_html(title)'   --command_version 2   --match_columns 'title'   --query groonga
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "title",
+          "ShortText"
+        ],
+        [
+          "content",
+          "ShortText"
+        ],
+        [
+          "snippet_html",
+          "null"
+        ]
+      ],
+      [
+        "groonga and MySQL",
+        "groonga + MySQL = mroonga.",
+        [
+          "<span class=\"keyword\">groonga</span> and MySQL"
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/function/snippet_html/third.test (+18 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_html/third.test    2013-03-03 23:17:04 +0900 (3b3287f)
@@ -0,0 +1,18 @@
+table_create Entries TABLE_NO_KEY
+column_create Entries title COLUMN_SCALAR ShortText
+column_create Entries content COLUMN_SCALAR ShortText
+
+table_create Tokens TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+column_create Tokens entries_title COLUMN_INDEX|WITH_POSITION Entries title
+column_create Tokens entries_content COLUMN_INDEX|WITH_POSITION Entries content
+
+load --table Entries
+[
+{"title": "groonga and MySQL", "content": "groonga + MySQL = mroonga."}
+]
+
+select Entries \
+  --output_columns 'title, content, snippet_html(title)' \
+  --command_version 2 \
+  --match_columns 'title' \
+  --query groonga
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る