[erlang-bugs] Strange behavior of dets:match_object/1.

Zichen Cao <>
Thu Jun 16 19:44:33 CEST 2011


Hi,

I was testing the functions in dets, and I found the behavior of dets:match_object/1 is strange. I am not sure if it's a bug.

f() ->
             file:delete(test),
        {ok, Tab} = dets:open_file(test, [{type, bag}]),
        dets:safe_fixtable(Tab, true),
        dets:insert(Tab, [{a},{b},{c,0},{d,0}]),
        {M1, C} = dets:match_object(Tab, {'_'}, 3),
        dets:insert(Tab, {b,0}),
        _ = dets:match_object(Tab, '_', 1),
        {M2, _} = dets:match_object(C),
        dets:close(Tab),
        {M1, M2}.

This function returns {[{b}],[{a},{b}]}. It shows that dets:match_object/1 returned a tuple which had already been returned by dets:match_object/3. This is minimal test case, and only happen with using dets:safe_fixtable/2. The call _ = dets:match_object(Tab, '_', 1) is also necessary to provoke the problem.

Zichen Cao


More information about the erlang-bugs mailing list