Mnesia Bug with select and disc_only_copies tables

Dan Gudmundsson dgud@REDACTED
Tue Oct 4 16:13:54 CEST 2005


Rudolph van Graan writes:
 > Hey there,
 > 
 > Think I found a bug in mnesia select.
 > 
 > If you use
 > 
 >      select(Tab, MatchSpec, NObjects, Lock)
 > 
 > on a disc_only table, it never returns any rows (I.e. using NObjects  
 > to limit the number of rows). The same query works if you use  
 > disc_copies instead.
 > 
 > Regards,
 > 
 > Rudolph van Graan

hi

See the manual:

 For efficiency
          the NObjects is a recommendation only  and  the  result
          may  contain  anything from an empty list to all avail-
          able results.

(it is written because of dets :-)

It works here: 

1> mnesia:start().
2> mnesia:create_table(a, []).                
{atomic,ok}
6> mnesia:change_table_copy_type(schema, node(), disc_copies).        
{atomic,ok}
7> [mnesia:dirty_write({a, N,N}) || N <- lists:seq(1,1000)].
8> mnesia:change_table_copy_type(a, node(), disc_only_copies).
{atomic,ok}
14> P = ets:fun2ms(fun({a,_,A}) when A > 990 -> A end). 
16> F = fun('$end_of_table', _, Acc) -> Acc; 
           ({Recs,Cont}, Fun,Acc) -> 
	       R = mnesia:select(Cnt), 
               Fun(R, Fun, Recs ++Acc) 
        end.
17> mnesia:transaction(fun() -> 
			     Cont = mnesia:select(a, P, 10, read),      
			     F(Cont, F, []) 
		       end).
{atomic,[996,997,1000,998,994,992,993,995,999,991]}

/Dan




More information about the erlang-questions mailing list