aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia/src
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2011-09-21 12:01:38 +0200
committerDan Gudmundsson <[email protected]>2011-09-21 12:01:38 +0200
commit2629a629a2f5b16067d9ca6f99be9711c52bf9ca (patch)
treefb42051c10580839316697db0a6912b8d7fbc2a3 /lib/mnesia/src
parent41f5777aea48b2eec358c342b7fd8610bf13601c (diff)
parent533aeba2211bc29bf2a207737d74ffa52a46bdec (diff)
downloadotp-2629a629a2f5b16067d9ca6f99be9711c52bf9ca.tar.gz
otp-2629a629a2f5b16067d9ca6f99be9711c52bf9ca.tar.bz2
otp-2629a629a2f5b16067d9ca6f99be9711c52bf9ca.zip
Merge branch 'dgud/mnesia/cleartable-ded-api/OTP-9558' into dev
* dgud/mnesia/cleartable-ded-api/OTP-9558: [mnesia] Use dedicated api for clearing tables
Diffstat (limited to 'lib/mnesia/src')
-rw-r--r--lib/mnesia/src/mnesia_dumper.erl2
-rw-r--r--lib/mnesia/src/mnesia_lib.erl6
-rw-r--r--lib/mnesia/src/mnesia_log.erl5
3 files changed, 10 insertions, 3 deletions
diff --git a/lib/mnesia/src/mnesia_dumper.erl b/lib/mnesia/src/mnesia_dumper.erl
index daa9e6aff2..f8d7664156 100644
--- a/lib/mnesia/src/mnesia_dumper.erl
+++ b/lib/mnesia/src/mnesia_dumper.erl
@@ -364,7 +364,7 @@ dets_insert(Op,Tab,Key,Val) ->
ok = dets:delete_object(Tab, Val);
clear_table ->
dets_cleared(Tab),
- ok = dets:match_delete(Tab, '_')
+ ok = dets:delete_all_objects(Tab)
end.
dets_updated(Tab,Key) ->
diff --git a/lib/mnesia/src/mnesia_lib.erl b/lib/mnesia/src/mnesia_lib.erl
index 7e926a6258..e8b8c58c70 100644
--- a/lib/mnesia/src/mnesia_lib.erl
+++ b/lib/mnesia/src/mnesia_lib.erl
@@ -1141,12 +1141,18 @@ db_erase(ram_copies, Tab, Key) -> ?ets_delete(Tab, Key), ok;
db_erase(disc_copies, Tab, Key) -> ?ets_delete(Tab, Key), ok;
db_erase(disc_only_copies, Tab, Key) -> dets:delete(Tab, Key).
+db_match_erase(Tab, '_') ->
+ db_delete_all(val({Tab, storage_type}),Tab);
db_match_erase(Tab, Pat) ->
db_match_erase(val({Tab, storage_type}), Tab, Pat).
db_match_erase(ram_copies, Tab, Pat) -> ?ets_match_delete(Tab, Pat), ok;
db_match_erase(disc_copies, Tab, Pat) -> ?ets_match_delete(Tab, Pat), ok;
db_match_erase(disc_only_copies, Tab, Pat) -> dets:match_delete(Tab, Pat).
+db_delete_all(ram_copies, Tab) -> ets:delete_all_objects(Tab);
+db_delete_all(disc_copies, Tab) -> ets:delete_all_objects(Tab);
+db_delete_all(disc_only_copies, Tab) -> dets:delete_all_objects(Tab).
+
db_first(Tab) ->
db_first(val({Tab, storage_type}), Tab).
db_first(ram_copies, Tab) -> ?ets_first(Tab);
diff --git a/lib/mnesia/src/mnesia_log.erl b/lib/mnesia/src/mnesia_log.erl
index 9e804cc4c2..94153473cb 100644
--- a/lib/mnesia/src/mnesia_log.erl
+++ b/lib/mnesia/src/mnesia_log.erl
@@ -1021,7 +1021,8 @@ add_recs([LogH|Rest], N)
LogH#log_header.log_version >= "1.0" ->
add_recs(Rest, N);
add_recs([{{Tab, _Key}, _Val, clear_table} | Rest], N) ->
- true = ets:match_delete(Tab, '_'),
- add_recs(Rest, N+ets:info(Tab, size));
+ Size = ets:info(Tab, size),
+ true = ets:delete_all_objects(Tab),
+ add_recs(Rest, N+Size);
add_recs([], N) ->
N.