[erlang-questions] Mnesia: Error on insert object with same key in Set

Dan Gudmundsson dangud@REDACTED
Mon Oct 17 08:40:51 CEST 2011


This should be fixed now and thus safe to use now.

/Dan


On Sun, Oct 16, 2011 at 11:29 PM, Tristan Sloughter
<tristan.sloughter@REDACTED> wrote:
> I wanted to make sure there was still no way to tell Mnesia to return an
> error if it is given a record to write that has the same key as an object
> already stored in the table.
> Reading through the docs it looks like there is no way through configuration
> but you must simply read and then write if its not there, like I found when
> this was asked in 2004 on this mailing list:
> insert(K,V) ->
>   fun() ->
>   case mnesia:wread(K) of
>     [Exist] -> {abort, Exist};
>     _ -> mnesia:write(V)
>   end
>   end.
> Which doesn't seem safe, as Ulf points on in that
> thread: http://erlang.org/pipermail/erlang-questions/2004-May/012307.html
> As well as slow.
> So I was hoping maybe in 2011 there is a better way to do this? :)
> Thanks,
> Tristan
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>



More information about the erlang-questions mailing list