Create table in a transaction

Chandrashekhar Mullaparthi Chandrashekhar.Mullaparthi@REDACTED
Fri Nov 3 11:05:30 CET 2000


I tried running normal table ops(mnesia:write/1) within the schema
transaction. But the transaction aborts with {aborted, {no_exists,
TableName}} - which I think is understandable. I haven't read thru the code
- but I think schema changes are probably not committed until the schema
transaction is completed - which is why mnesia:write complains that it cant
find the table. Though I don't understand why schema transactions are
different from normal transactions. Maybe I'll go thru the code.....once I
get ccviewer installed and running!

Chandru

-----Original Message-----
From: Ulf Wiger [mailto:etxuwig@REDACTED]
Sent: 3 November 2000 08:53
To: Dan Gudmundsson
Cc: Chandrashekhar Mullaparthi; 'Erlang mailing list'
Subject: Re: Create table in a transaction


On Thu, 2 Nov 2000, Dan Gudmundsson wrote:

>
>Sorry, but you can't do schema_transactions inside a normal transaction.
>
>schema_transaction's include 
>create_table
>move_table_copy
>add_table_copy
>change_table_copy
>del_table
>transform_table
>..
>
>I got some requests on this but it is a lot of work do it rigth
>with current implementation..
>
>/Dan

But wouldn't it be possible to perform normal table updates from
within a schema transaction?

I haven't followed the complete thread, but it does seem as if
schema_transaction calls mnesia:transaction/1, and that mnesia_tm.erl
doesn't really care if schema transactions are combined with other
operations.

My mnesia_schema patch in the rdbms contrib exports
mnesia_schema:schema_transaction/1, and has a few hacks to support
multiple calls to write_table_property/2 within one schema
transaction. You could try calling normal table ops within
schema_transaction and see what happens.

Note, though, that schema_transaction can't be called from within a
transaction. If you want to try this, you'd also have to call
create_table a bit differently. Here's an example from some code I've
written:

initialise_class(Class) ->
    {Attrs, TableProps, UserProps} = Class:describe(),
    F = fun() ->
                create_table(
                   Class, table_properties(Attrs, TableProps)),
                rdbms:do_add_properties(UserProps, Class)
        end,
    mnesia_schema:schema_transaction(F).


create_table(Name, Properties) ->
    Cs = mnesia_schema:list2cs([{name, Name}|Properties]),
    mnesia_schema:do_create_table(Cs).




/Uffe


>Chandrashekhar Mullaparthi writes:
> > 
> > I can't create a table within a transaction. Why is that?? A comment in
> > mnesia_schema.erl says that a "very special transaction is used when we
want
> > to manipulate the schema". Basically what I want to do is:
> > 
> > * Do some checks
> > * Update table_1
> > * create table_2
> > * Make entries in table_2
> > 
> > in one single transaction. I'm failing at step 3.
> > 
> > tia,
> > Chandru
> > 
>

-- 
Ulf Wiger                                    tfn: +46  8 719 81 95
Senior System Architect                      mob: +46 70 519 81 95
Strategic Product & System Management    ATM Multiservice Networks
Data Backbone & Optical Services Division      Ericsson Telecom AB



NOTICE AND DISCLAIMER:
This email (including attachments) is confidential.  If you have received
this email in error please notify the sender immediately and delete this
email from your system without copying or disseminating it or placing any
reliance upon its contents.  We cannot accept liability for any breaches of
confidence arising through use of email.  Any opinions expressed in this
email (including attachments) are those of the author and do not necessarily
reflect our opinions.  We will not accept responsibility for any commitments
made by our employees outside the scope of our business.  We do not warrant
the accuracy or completeness of such information.




More information about the erlang-questions mailing list