[Groonga-commit] groonga/groonga at bdf2033 [master] Fix a crash bug when deleting a record

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Sep 2 14:36:21 JST 2014


Kouhei Sutou	2014-09-02 14:36:21 +0900 (Tue, 02 Sep 2014)

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

  Message:
    Fix a crash bug when deleting a record
    
    If the table of the record has _key and _key is indexed from two or more
    index columns, deleting causes a crash.

  Added files:
    test/command/suite/delete/index/key/multiple.expected
    test/command/suite/delete/index/key/multiple.test
  Modified files:
    lib/db.c

  Modified: lib/db.c (+4 -4)
===================================================================
--- lib/db.c    2014-09-02 14:26:46 +0900 (28ec256)
+++ lib/db.c    2014-09-02 14:36:21 +0900 (15bedd4)
@@ -1472,11 +1472,11 @@ call_delete_hook(grn_ctx *ctx, grn_obj *table, grn_id rid, const void *key, unsi
       GRN_TEXT_SET_REF(&oldvalue_, key, key_size);
       GRN_UINT32_SET(ctx, &id_, rid);
       GRN_UINT32_SET(ctx, &flags_, GRN_OBJ_SET);
-      grn_ctx_push(ctx, &id_);
-      grn_ctx_push(ctx, &oldvalue_);
-      grn_ctx_push(ctx, &value_);
-      grn_ctx_push(ctx, &flags_);
       while (hooks) {
+        grn_ctx_push(ctx, &id_);
+        grn_ctx_push(ctx, &oldvalue_);
+        grn_ctx_push(ctx, &value_);
+        grn_ctx_push(ctx, &flags_);
         pctx.caller = NULL;
         pctx.currh = hooks;
         if (hooks->proc) {

  Added: test/command/suite/delete/index/key/multiple.expected (+264 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/delete/index/key/multiple.expected    2014-09-02 14:36:21 +0900 (6162a08)
@@ -0,0 +1,264 @@
+table_create Memos TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+table_create BigramTokens TABLE_PAT_KEY ShortText   --default_tokenizer TokenBigram   --normalizer NormalizerAuto
+[[0,0.0,0.0],true]
+column_create BigramTokens memo_key COLUMN_INDEX|WITH_POSITION Memos _key
+[[0,0.0,0.0],true]
+table_create TrigramTokens TABLE_PAT_KEY ShortText   --default_tokenizer TokenTrigram   --normalizer NormalizerAuto
+[[0,0.0,0.0],true]
+column_create TrigramTokens memo_key COLUMN_INDEX|WITH_POSITION Memos _key
+[[0,0.0,0.0],true]
+load --table Memos
+[
+{"_key": "Today is sunny day."}
+]
+[[0,0.0,0.0],1]
+select Memos --filter '_key @ "sunny"'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ]
+      ],
+      [
+        1,
+        "Today is sunny day."
+      ]
+    ]
+  ]
+]
+select BigramTokens
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        5
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "memo_key",
+          "Memos"
+        ]
+      ],
+      [
+        5,
+        ".",
+        1
+      ],
+      [
+        4,
+        "day",
+        1
+      ],
+      [
+        2,
+        "is",
+        1
+      ],
+      [
+        3,
+        "sunny",
+        1
+      ],
+      [
+        1,
+        "today",
+        1
+      ]
+    ]
+  ]
+]
+select TrigramTokens
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        5
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "memo_key",
+          "Memos"
+        ]
+      ],
+      [
+        5,
+        ".",
+        1
+      ],
+      [
+        4,
+        "day",
+        1
+      ],
+      [
+        2,
+        "is",
+        1
+      ],
+      [
+        3,
+        "sunny",
+        1
+      ],
+      [
+        1,
+        "today",
+        1
+      ]
+    ]
+  ]
+]
+delete Memos --filter '_key @ "sunny"'
+[[0,0.0,0.0],true]
+select Memos
+[[0,0.0,0.0],[[[0],[["_id","UInt32"],["_key","ShortText"]]]]]
+select BigramTokens
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        5
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "memo_key",
+          "Memos"
+        ]
+      ],
+      [
+        5,
+        ".",
+        0
+      ],
+      [
+        4,
+        "day",
+        0
+      ],
+      [
+        2,
+        "is",
+        0
+      ],
+      [
+        3,
+        "sunny",
+        0
+      ],
+      [
+        1,
+        "today",
+        0
+      ]
+    ]
+  ]
+]
+select TrigramTokens
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        5
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "memo_key",
+          "Memos"
+        ]
+      ],
+      [
+        5,
+        ".",
+        0
+      ],
+      [
+        4,
+        "day",
+        0
+      ],
+      [
+        2,
+        "is",
+        0
+      ],
+      [
+        3,
+        "sunny",
+        0
+      ],
+      [
+        1,
+        "today",
+        0
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/delete/index/key/multiple.test (+26 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/delete/index/key/multiple.test    2014-09-02 14:36:21 +0900 (272ed53)
@@ -0,0 +1,26 @@
+table_create Memos TABLE_HASH_KEY ShortText
+
+table_create BigramTokens TABLE_PAT_KEY ShortText \
+  --default_tokenizer TokenBigram \
+  --normalizer NormalizerAuto
+column_create BigramTokens memo_key COLUMN_INDEX|WITH_POSITION Memos _key
+
+table_create TrigramTokens TABLE_PAT_KEY ShortText \
+  --default_tokenizer TokenTrigram \
+  --normalizer NormalizerAuto
+column_create TrigramTokens memo_key COLUMN_INDEX|WITH_POSITION Memos _key
+
+load --table Memos
+[
+{"_key": "Today is sunny day."}
+]
+
+select Memos --filter '_key @ "sunny"'
+select BigramTokens
+select TrigramTokens
+
+delete Memos --filter '_key @ "sunny"'
+select Memos
+
+select BigramTokens
+select TrigramTokens
-------------- next part --------------
HTML����������������������������...
Download 



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