mnesia:clear_table

Serge Aleynikov <>
Tue Aug 16 03:10:08 CEST 2005


Indeed when I do:

F = fun() ->
         mnesia:clear_table(Tab)
     end,
mnesia:transaction(F).

It works.  That means that nested transactions are supported, however 
this code returns an error:

p>erl -sname t
Erlang (BEAM) emulator version 5.4.8 [source] [hipe] [threads:0]
Eshell V5.4.8  (abort with ^G)
()1> mnesia:create_schema([node()]).
ok
()2> mnesia:start().
ok
()3> mnesia:create_table(test, [{ram_copies, [node()]}]).
{atomic,ok}
()4> mnesia:create_table(test1, [{ram_copies, [node()]}]). 

{atomic,ok}
()5> F = fun() -> mnesia:clear_table(test), 
mnesia:clear_table(test1) end.
#Fun<erl_eval.20.102880425>
()6> mnesia:transaction(F). 

{atomic,{aborted,nested_transaction}}

Am I doing something unconventional, or there is a limit on the depth of 
nested transactions?

Serge

Claes Wikstrom wrote:
> Serge Aleynikov wrote:
> 
>> Hi,
>>
>> I am wondering why the mnesia:clear_table/1 function is encapsulated 
>> in a transaction of its own.  It prevents this function to be included 
>> in another transaction.
>>
> 
> Transactions can be nested arbitrarily deep. Nesting doesn't
> come for free, but it works.
> 
> 
> /klacke
> 

-- 
Serge Aleynikov
R&D Telecom, IDT Corp.
Tel: (973) 438-3436
Fax: (973) 438-1464




More information about the erlang-questions mailing list