diff options
author | Bartlomiej Puzon <[email protected]> | 2012-06-18 16:16:00 -0700 |
---|---|---|
committer | Bartlomiej Puzon <[email protected]> | 2012-06-18 16:16:00 -0700 |
commit | 0fcdb6fdd38291072dd130cf4362ea5e8f3d1717 (patch) | |
tree | 08512bcff4587baae92885928d10d4654d85c66a /lib/mnesia/src/mnesia_index.erl | |
parent | 8490cb6328da880119dbc1eb92d3b439a2c5f34a (diff) | |
download | otp-0fcdb6fdd38291072dd130cf4362ea5e8f3d1717.tar.gz otp-0fcdb6fdd38291072dd130cf4362ea5e8f3d1717.tar.bz2 otp-0fcdb6fdd38291072dd130cf4362ea5e8f3d1717.zip |
Prevent index from being corrupted if a nonexistent item is deleted
We have to ensure that we actually delete the last object with a
given (key, index) pair before removing the index.
Diffstat (limited to 'lib/mnesia/src/mnesia_index.erl')
-rw-r--r-- | lib/mnesia/src/mnesia_index.erl | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/mnesia/src/mnesia_index.erl b/lib/mnesia/src/mnesia_index.erl index 61210d7e55..37989a1958 100644 --- a/lib/mnesia/src/mnesia_index.erl +++ b/lib/mnesia/src/mnesia_index.erl @@ -120,9 +120,9 @@ del_object_bag(Tab, Key, Obj, Pos, Ixt, undefined) -> IxKey = element(Pos, Obj), Old = [X || X <- mnesia_lib:db_get(Tab, Key), element(Pos, X) =:= IxKey], del_object_bag(Tab, Key, Obj, Pos, Ixt, Old); -%% If Tab type is bag we need remove index identifier if Tab -%% contains less than 2 elements. -del_object_bag(_Tab, Key, Obj, Pos, Ixt, Old) when length(Old) < 2 -> +%% If Tab type is bag we need remove index identifier if the object being +%% deleted was the last one +del_object_bag(_Tab, Key, Obj, Pos, Ixt, Old) when Old =:= [Obj] -> del_ixes(Ixt, [Obj], Pos, Key); del_object_bag(_Tab, _Key, _Obj, _Pos, _Ixt, _Old) -> ok. |