mnesia:create_table in transaction?

Shawn Pearce spearce@REDACTED
Sat Feb 7 20:59:46 CET 2004


Wow, so mnesia can do table creation in a transaction.  This works
nicely for non-fragmented tables.  If a table has a fragment, the
call doesn't seem to be exported; though you could build the fragments
by duplicating the work yourself.

Fortunately I'm not using fragments, so this works just fine.  I wonder
why its not more documented?


Ulf Wiger <ulf.wiger@REDACTED> wrote:
> On Fri, 6 Feb 2004 23:08:38 -0500, Shawn Pearce <spearce@REDACTED> 
> wrote:
> 
> >Is the following not allowed?
> >
> >mnesia:transaction(fun() ->
> >	mnesia:create_table(....)
> >end).
> >
> >as mnesia:create_table/2 is returning {aborted, nested_transaction}.
> >
> >I just thought I'd create all of my tables in a single transaction,
> >in case one fails to create.  Apparently its not supported.
> >Understandable, as very few databases allow table creation within
> >transactions.  I just thought it was possible in Mnesia.
> 
> In mnesia_schema.erl, you will find some (undocumented) functions:
> 
> mnesia_schema:schema_transaction(
>    fun() ->
>       do_create_table(mnesia_schema:list2cs([{name,Name}|Opts])),
>       ...
>    end).
> 
> 
> /Uffe
> -- 
> Ulf Wiger
> 

-- 
Shawn.

  So from the depths of its enchantment, Terra was able to calculate a course
  of action.  Here at last was an opportunity to consort with Dirbanu on a
  friendly basis -- great Durbanu which, since it had force fields which Earth
  could not duplicate, must of necessity have many other things Earth could
  use; mighty Durbanu before whom we would kneel in supplication (with purely-
  for-defense bombs hidden in our pockets) with lowered heads (making invisible
  the knife in our teeth) and ask for crumbs from their table (in order to
  extrapolate the location of their kitchens).
  		-- Theodore Sturgeon, "The World Well Lost"


This communication is confidential and intended solely for the addressee(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you believe this message has been sent to you in error, please notify the sender by replying to this transmission and delete the message without disclosing it. Thank you.

E-mail including attachments is susceptible to data corruption, interruption, unauthorized amendment, tampering and viruses, and we only send and receive e-mails on the basis that we are not liable for any such corruption, interception, amendment, tampering or viruses or any consequences thereof.




More information about the erlang-questions mailing list