Mnesia bug?
Rudolph van Graan
rvg@REDACTED
Mon Feb 2 16:58:10 CET 2004
It seems as though mnesia (R9C) does not allow updates to user
properties of a table during a transaction... Any ideas?
-module(mnesia_bug).
-export([run/0]).
run() ->
mnesia:delete_table(abc), %Drop Table
{atomic,ok} =
mnesia:create_table(abc,[{attributes,[a,b,c]}]), %Create a simple
table
mnesia:write_table_property(abc,{some_value,1}), %Write a value to
the table properties
{some_value,1} = mnesia:read_table_property(abc,some_value), %Check
that it is correct
io:format("Value of 1written and verified\n",[]),
F = fun() -> %Now modify the value in the fun
io:format("Changing value to 2\n",[]),
mnesia:write_table_property(abc,{some_value,2}),
{some_value,New_value_1} =
mnesia:read_table_property(abc,some_value),%Verify it is ok
case New_value_1 of
2 ->
io:format("Value has changed to 2 - this is ok\n",[]);
Other ->
io:format("Value is ~p - this is NOT ok\n",[Other])
end
end,
{atomic,ok} = mnesia:transaction(F), %Run the fun
io:format("Now read it back again...\n",[]),
{some_value,Last_Value} =
mnesia:read_table_property(abc,some_value), %And read it back again
io:format("Value is ~p\n",[Last_Value]) .
Rudolph van Graan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1313 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20040202/7e2c730d/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2112 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20040202/7e2c730d/attachment-0001.bin>
More information about the erlang-questions
mailing list