Mnesia fundamentals & hipe segmentation fault

kaslist kaslist@REDACTED
Mon Apr 3 19:06:55 CEST 2006


tty@REDACTED wrote:
> mnesia:write looks at the record you are writting and find that its of type 'employee'. With this the record is then written into the 'employee' table even though you stated 'employee2' as part of the write. To place anything into table 'employee2' it must be a record of type 'employee2'.
>
> To get around this when creating 'employee2' add the '{record_name, Name}' to the option list.
>
> e.g.
>
>     mnesia:create_table(employee2,  [{attributes, record_info(fields, 
>                                      employee)}, {record_name, employee}]).
>
> Regards
>
> t
>
> -------- Original Message --------
> From: kaslist <kaslist@REDACTED>
> Apparently from: owner-erlang-questions@REDACTED
> To: erlang-questions@REDACTED
> Cc: kaslist@REDACTED
> Subject: Mnesia fundamentals
> Date: Mon, 03 Apr 2006 16:45:51 +0200
>
>   
>> Hi,
>>
>> I think this is a just a quick question for someone who knows.... 
>>
>> I've been trying to get to grips with using Mnesia and, with a simple: 
>> one table one record setup, I've managed to work through most of the 
>> functions very happily.  I thought I was really getting somewhere until 
>> a couple of days ago when... I tried to fill two tables defined with the 
>> same record type.
>>
>> Specifically, the tutorial that I based my studies on used:
>>
>> -record(employee, {emp_no, name, salary, sex, phone, room_no}).
>> mnesia:create_table(employee,  [{attributes, record_info(fields, 
>> employee)}]),
>> Emp  = #employee{emp_no= 843838, name = klacke, salary = 3, sex = male, 
>> phone = 98111, room_no ={221, 051}},
>>
>> ...and to insert the data within a transaction:
>>
>> mnesia:write(employee, Emp, write)
>>
>> All well and good.  However, when I restart the program with the 
>> addition a second table:
>>
>> mnesia:create_table(employee2,  [{attributes, record_info(fields, 
>> employee)}]),
>>
>> and attempted to insert the data within a transaction thus:
>>
>>     mnesia:write(employee2, Emp, write)
>>
>> ...everything compiles happily, runs happily... but employee2 table is 
>> not filled and yet no errors/exceptions are found. 
>>
>> I have gone over and over the tutorials and the dozen or so Mnesia 
>> references/blogs on the net looking for examples of this issue but to no 
>> avail. Must there be a relationship between the record and table 
>> names??? Can anyone help me out of this newbie ditch I've got myself into?
>>
>> Thanks,
>>
>> Kyle.
>>     
>
>   
Yes that solves it... both tables populate correctly now. 
Thanks very much 't'.

Kyle.


P.S. Re the 'hipe segmentation fault' thread.... If it's any use to 
anyone... these are the results for big.erl on my Win laptop:

Eshell V5.4.13  (abort with ^G)
1> big:bang(1).
1.00000e-6
2> big:bang(10).
1.00000e-6
3> big:bang(100).
4.00000e-2
4> big:bang(1000).
48.1600

Also, the rapid increase in processing work/time follows approx the same 
gradient on my Linux box, when I tried that. 





More information about the erlang-questions mailing list