[erlang-questions] mnesia:dirty_update_counter

Bob Ippolito bob@REDACTED
Mon Mar 5 16:17:18 CET 2007


It definitely seems like a bug, but I think that's intended behavior
for backwards compatibility. Here's what we do, which seems to work:

    case mnesia:dirty_update_counter(Db, Key, Inc) of
	X when X == Inc ->
	    F = fun () ->
			[R] = mnesia:read(Db, Key, write),
			mnesia:write(R)
		end,
	    mnesia:transaction(F);
	_ ->
	    ok
    end.

On 3/5/07, Sébastien Saint-Sevin <seb-cl-mailist@REDACTED> wrote:
> Hi list,
>
> It seems I've found a bug regarding mnesia:dirty_update_counter(Tab, Key, Incr).
> When I use the function for the first time with an Incr of 1 (Key not existing), the table is populated with a value of 0 for the key Key (1 expected) and returns 1 for NewVal (as expected).
> The doc says : "If Key don't exits, a new record is created with the value Incr if it is larger than 0, otherwise it is set to 0."
>
> Is this confirmed or did I missed something ?
>
> Cheers,
> Sébastien.
>
> PS : erl-5.5.3 under windows XP
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>




More information about the erlang-questions mailing list