mnesia:dirty_update_counter/3 - patch needed...

Peter Lund <>
Tue Aug 26 22:30:19 CEST 2003


Hi,

The command  mnesia:dirty_update_counter(Tab, Key, Incr) does not work as
well as I had expected to do.

When doing: mnesia:dirty_update_counter(counter, default, 3) and the  entry
{counter, default, 0} does not exist in mnesia, that row is created, BUT it
is left at {counter, default, 0} and it does not become {counter, default,
3} which I expected it to become.

I have made a patch and tested the patch. It works. When incrementing a
counter with 3 and the "counter" does not exist, it gets as initial value
the increment, 3 in this case.

I tried to attach the corrected file but it seems like the erlang list has
some size limitation. Anyhow:

I have updated the source file:
C:\PROGRAM\erl5.2.3.3\lib\mnesia-4.1.3\src\mnesia_tm.erl

The tiny change is on line number 1685:
%%%                Zero = {RecName, K, 0},
                Zero = {RecName, K, Incr},

Best regards,
Peter Lund






More information about the erlang-questions mailing list