aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2013-08-21 09:40:31 +0200
committerHans Bolinder <[email protected]>2013-08-21 09:40:31 +0200
commit5960967a506c2eeadb3cbf66a1e21fff5000f08b (patch)
tree223c3c47bb3ca35de2ad0f95ddb8298546cf09c0
parentc5ebeab7e56b48f47760f46247070821b9425c70 (diff)
parent4550ba795540b85d31b33cc2eda87c0e6952f222 (diff)
downloadotp-5960967a506c2eeadb3cbf66a1e21fff5000f08b.tar.gz
otp-5960967a506c2eeadb3cbf66a1e21fff5000f08b.tar.bz2
otp-5960967a506c2eeadb3cbf66a1e21fff5000f08b.zip
Merge branch 'hb/stdlib/dets_bugfix/OTP-11245' into maint
* hb/stdlib/dets_bugfix/OTP-11245: Fix a Dets bug concerning traversal of tables
-rw-r--r--lib/stdlib/src/dets.erl4
-rw-r--r--lib/stdlib/test/dets_SUITE.erl26
2 files changed, 26 insertions, 4 deletions
diff --git a/lib/stdlib/src/dets.erl b/lib/stdlib/src/dets.erl
index 50812cc532..68b157c13c 100644
--- a/lib/stdlib/src/dets.erl
+++ b/lib/stdlib/src/dets.erl
@@ -951,10 +951,10 @@ do_trav(Proc, Acc, Fun) ->
Error
end.
-do_trav(#dets_cont{bin = eof}, _Proc, Acc, _Fun) ->
- Acc;
do_trav(State, Proc, Acc, Fun) ->
case req(Proc, {match_init, State, safe}) of
+ '$end_of_table'->
+ Acc;
{cont, {Bins, NewState}} ->
do_trav_bins(NewState, Proc, Acc, Fun, lists:reverse(Bins));
Error ->
diff --git a/lib/stdlib/test/dets_SUITE.erl b/lib/stdlib/test/dets_SUITE.erl
index 8ff7c3ccc9..059d553b00 100644
--- a/lib/stdlib/test/dets_SUITE.erl
+++ b/lib/stdlib/test/dets_SUITE.erl
@@ -52,7 +52,7 @@
simultaneous_open/1, insert_new/1, repair_continuation/1,
otp_5487/1, otp_6206/1, otp_6359/1, otp_4738/1, otp_7146/1,
otp_8070/1, otp_8856/1, otp_8898/1, otp_8899/1, otp_8903/1,
- otp_8923/1, otp_9282/1]).
+ otp_8923/1, otp_9282/1, otp_11245/1]).
-export([dets_dirty_loop/0]).
@@ -109,7 +109,7 @@ all() ->
many_clients, otp_4906, otp_5402, simultaneous_open,
insert_new, repair_continuation, otp_5487, otp_6206,
otp_6359, otp_4738, otp_7146, otp_8070, otp_8856, otp_8898,
- otp_8899, otp_8903, otp_8923, otp_9282
+ otp_8899, otp_8903, otp_8923, otp_9282, otp_11245
].
groups() ->
@@ -3898,6 +3898,28 @@ some_calls(Tab, Config) ->
file:delete(File).
+otp_11245(doc) ->
+ ["OTP-11245. Tables remained fixed after traversal"];
+otp_11245(suite) ->
+ [];
+otp_11245(Config) when is_list(Config) ->
+ Tab = otp_11245,
+ File = filename(Tab, Config),
+ {ok, Tab} = dets:open_file(Tab, [{file,File}]),
+ N = 1024,
+ ins(Tab, N),
+ N = length(dets:match(Tab, '_')),
+ false = dets:info(Tab, safe_fixed),
+ dets:traverse(Tab, fun(_) -> continue end),
+ false = dets:info(Tab, safe_fixed),
+ N = dets:foldl(fun(_, N2) -> N2+1 end, 0, Tab),
+ false = dets:info(Tab, safe_fixed),
+ N = dets:foldr(fun(_, N2) -> N2+1 end, 0, Tab),
+ false = dets:info(Tab, safe_fixed),
+ ok = dets:close(Tab),
+ file:delete(File),
+ ok.
+
%%
%% Parts common to several test cases
%%