[Groonga-commit] groonga/groonga [master] Fix a bug that deleting record can be found

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Nov 16 19:06:56 JST 2012


Kouhei Sutou	2012-11-16 19:06:56 +0900 (Fri, 16 Nov 2012)

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

  Log:
    Fix a bug that deleting record can be found
    
    If a record has fixed size column (e.g. Int32) and it is indexed, the
    bug is occurred. If a record is deleted, the deleted record can be
    found index search with 0 value. 0 value for Int32 is 0.
    
    This fixes mroonga's bug found at
    c2b8afce57c89286f8118ebcc5e6260c902c2488.

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

  Modified: lib/db.c (+0 -3)
===================================================================
--- lib/db.c    2012-11-15 18:05:33 +0900 (c9c0bf0)
+++ lib/db.c    2012-11-16 19:06:56 +0900 (4a31490)
@@ -1528,10 +1528,7 @@ grn_obj_clear_value(grn_ctx *ctx, grn_obj *obj, grn_id id)
     GRN_OBJ_INIT(&buf, GRN_BULK, 0, range);
     switch (obj->header.type) {
     case GRN_COLUMN_VAR_SIZE :
-      rc = grn_obj_set_value(ctx, obj, id, &buf, GRN_OBJ_SET);
-      break;
     case GRN_COLUMN_FIX_SIZE :
-      grn_bulk_truncate(ctx, &buf, ((grn_ra *)obj)->header->element_size);
       rc = grn_obj_set_value(ctx, obj, id, &buf, GRN_OBJ_SET);
       break;
     }

  Added: test/command/suite/delete/index/fix_size_column.expected (+134 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/delete/index/fix_size_column.expected    2012-11-16 19:06:56 +0900 (653b46a)
@@ -0,0 +1,134 @@
+table_create Users TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Users age COLUMN_SCALAR UInt8
+[[0,0.0,0.0],true]
+table_create Ages TABLE_PAT_KEY UInt8
+[[0,0.0,0.0],true]
+column_create Ages users_age COLUMN_INDEX Users age
+[[0,0.0,0.0],true]
+load --table Users
+[
+{"_key": "Alice", "age": 20},
+{"_key": "Bob",   "age": 18}
+]
+[[0,0.0,0.0],2]
+select Ages
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        2
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "UInt8"
+        ],
+        [
+          "users_age",
+          "Users"
+        ]
+      ],
+      [
+        2,
+        18,
+        1
+      ],
+      [
+        1,
+        20,
+        1
+      ]
+    ]
+  ]
+]
+select Users --filter 'age == 20'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "age",
+          "UInt8"
+        ]
+      ],
+      [
+        1,
+        "Alice",
+        20
+      ]
+    ]
+  ]
+]
+select Users --filter 'age == 0'
+[[0,0.0,0.0],[[[0],[["_id","UInt32"],["_key","ShortText"],["age","UInt8"]]]]]
+delete Users --filter 'age == 20'
+[[0,0.0,0.0],true]
+select Ages
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        2
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "UInt8"
+        ],
+        [
+          "users_age",
+          "Users"
+        ]
+      ],
+      [
+        2,
+        18,
+        1
+      ],
+      [
+        1,
+        20,
+        0
+      ]
+    ]
+  ]
+]
+select Users --filter 'age == 20'
+[[0,0.0,0.0],[[[0],[["_id","UInt32"],["_key","ShortText"],["age","UInt8"]]]]]
+select Users --filter 'age == 0'
+[[0,0.0,0.0],[[[0],[["_id","UInt32"],["_key","ShortText"],["age","UInt8"]]]]]

  Added: test/command/suite/delete/index/fix_size_column.test (+21 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/delete/index/fix_size_column.test    2012-11-16 19:06:56 +0900 (9312f4b)
@@ -0,0 +1,21 @@
+table_create Users TABLE_HASH_KEY ShortText
+column_create Users age COLUMN_SCALAR UInt8
+
+table_create Ages TABLE_PAT_KEY UInt8
+column_create Ages users_age COLUMN_INDEX Users age
+
+load --table Users
+[
+{"_key": "Alice", "age": 20},
+{"_key": "Bob",   "age": 18}
+]
+
+select Ages
+select Users --filter 'age == 20'
+select Users --filter 'age == 0'
+
+delete Users --filter 'age == 20'
+
+select Ages
+select Users --filter 'age == 20'
+select Users --filter 'age == 0'
-------------- next part --------------
HTML����������������������������...
Download 



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