Skip to content

Commit

Permalink
Merge branch 'dgud/mnesia/match_object_bug/OTP-12304' into maint
Browse files Browse the repository at this point in the history
* dgud/mnesia/match_object_bug/OTP-12304:
  mnesia: Fix match_object bug
  • Loading branch information
dgud committed Nov 26, 2014
2 parents 748de45 + dff52d0 commit 3fe044d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/mnesia/src/mnesia.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1140,10 +1140,12 @@ match_object(_Tid, _Ts, Tab, Pat, _LockKind) ->

add_written_match(S, Pat, Tab, Objs) ->
Ops = find_ops(S, Tab, Pat),
add_match(Ops, Objs, val({Tab, setorbag})).
FixedRes = add_match(Ops, Objs, val({Tab, setorbag})),
MS = ets:match_spec_compile([{Pat, [], ['$_']}]),
ets:match_spec_run(FixedRes, MS).

find_ops(S, Tab, Pat) ->
GetWritten = [{{{Tab, '_'}, Pat, write}, [], ['$_']},
GetWritten = [{{{Tab, '_'}, '_', write}, [], ['$_']},
{{{Tab, '_'}, '_', delete}, [], ['$_']},
{{{Tab, '_'}, Pat, delete_object}, [], ['$_']}],
ets:select(S, GetWritten).
Expand Down
2 changes: 1 addition & 1 deletion lib/mnesia/src/mnesia_subscr.erl
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ call(Msg) ->
Res = gen_server:call(Pid, Msg, infinity),
%% We get an exit signal if server dies
receive
{'EXIT', _Pid, _Reason} ->
{'EXIT', Pid, _Reason} ->
{error, {node_not_running, node()}}
after 0 ->
Res
Expand Down
4 changes: 3 additions & 1 deletion lib/mnesia/test/mnesia_isolation_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,8 @@ write_shadows(Config) when is_list(Config) ->

?match([RecA2], mnesia:read({Tab, a})),
?match([RecA2], mnesia:wread({Tab, a})),
?match([RecA2], mnesia:match_object(PatA2)), %% delete shadow old but not new write - is the new value visable
?match([], mnesia:match_object(PatA1)), %% delete shadow old but not new write
?match([RecA2], mnesia:match_object(PatA2)), %% is the new value visable

?match([a], mnesia:all_keys(Tab)),
?match([RecA2], mnesia:index_match_object(PatA2, ValPos)),
Expand Down Expand Up @@ -1643,6 +1644,7 @@ delete_shadows(Config) when is_list(Config) ->

?match([RecA2], mnesia:read({Tab, a})),
?match([RecA2], mnesia:wread({Tab, a})),
?match([], mnesia:match_object(PatA1)),
?match([RecA2], mnesia:match_object(PatA2)),
?match([a], mnesia:all_keys(Tab)),
?match([RecA2], mnesia:index_match_object(PatA2, ValPos)),
Expand Down

0 comments on commit 3fe044d

Please sign in to comment.