mnesia:clear_table

Serge Aleynikov serge@REDACTED
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)
(t@REDACTED)1> mnesia:create_schema([node()]).
ok
(t@REDACTED)2> mnesia:start().
ok
(t@REDACTED)3> mnesia:create_table(test, [{ram_copies, [node()]}]).
{atomic,ok}
(t@REDACTED)4> mnesia:create_table(test1, [{ram_copies, [node()]}]). 

{atomic,ok}
(t@REDACTED)5> F = fun() -> mnesia:clear_table(test), 
mnesia:clear_table(test1) end.
#Fun<erl_eval.20.102880425>
(t@REDACTED)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
serge@REDACTED



More information about the erlang-questions mailing list