anchor.diff:      #lvl{}    -> false
     end.
   
  -delete_tab(S,Tab) ->
  -  case get_lvl(S,Tab) of
  +delete_tab(S,Lvl) ->
  +  case Lvl of
       undefined -> false;
       Lvl       -> get_rid_off(Lvl,S#state.keep_db),true
     end.
  
positive.code:          dir}).
  
  -record(lvl,
          {table,
           file,
           handle}).
  
  init(Env) ->
    BaseDir = proplists:get_value(table_dir,Env),
  
negative.code: key_match([E|Wkey],[E|Ekey])   -> key_match(Wkey,Ekey);
  key_match(_,_)                 -> false.
  
  next_prev(Lvl,OP,Key) ->
    case nextprev(Lvl,OP,Key) of
      end_of_table -> throw({409,end_of_table});
      {NewKey,V}   -> {[{NewKey,unpack_val(V)}]}
    end.
  
  nextprev(Lvl,OP,Key) ->
    Iter = lvl_iter(Lvl,key_vals),
    try
      check_np(OP,lvl_mv_iter(Iter,Key),Iter,Key)
    after
      lvl_close_iter(Iter)
    end.
  
  check_np(prev,invalid_iterator,Iter,Key) ->
    %% lvl_mv_iter/2 moved the iterator to the first record after TK: in
    %% case of TK being the last record, it will return an
    %% invalid_iterator and we have to fix the situation here
    check_np(prev,lvl_mv_iter(Iter,last),Key);
  check_np(prev,{KeyNext,_},Iter,Key) when KeyNext >= Key ->
    %% lvl_mv_iter/2 moved the iterator to the first record not before
    %% TK: we are interested in the previous record, so an additional
    %% iterator step is necessary
    check_np(prev,lvl_mv_iter(Iter,prev),Key);
  check_np(next,{Key,_},Iter,Key) ->
    %% the requested key was in the table: an additional iterator step
    %% is necessary
    check_np(next,lvl_mv_iter(Iter,next),Key);
  check_np(next,KV,_Iter,Key) ->
    check_np(next,KV,Key).
  
  check_np(_,invalid_iterator,_) ->
    end_of_table;
  check_np(OP,{K2,V},K1) when OP =:= next andalso K1 < K2;
                              OP =:= prev andalso K2 < K1 ->
    {K2,V}.
  
  
  deleter(Lvl,Key) ->
    case lvl_get(Lvl,Key) of
      not_found ->
        null;
      Val ->
        lvl_delete(Lvl,Key),
        Val
    end.
  
  via(Lvl1,Lvl2,Key2) ->
    %% Key2 in Tab2 holds the last visited key of Tab1. This operation
    %% gets the next key and value from Tab1, updating the pointer under
    %% Key2.
  