anchor.diff:      DBEntry2 = create_db_entry(db_entry:get_key(DBEntry1), Value2, WriteLock2, ReadLock2, Version2),
       DB = ?TEST_DB:new(),
       DB2 = ?TEST_DB:set_entry(DB, DBEntry1),
  -    DB3 = ?TEST_DB:update_entry(DB2, DBEntry2),
  -    IsNullEntry = db_entry:is_null(DBEntry2),
  -    check_entry(DB3, db_entry:get_key(DBEntry2), DBEntry2,
  -                {ok, db_entry:get_value(DBEntry2), db_entry:get_version(DBEntry2)},
  -                not IsNullEntry, "check_entry_update_entry_1"),
  -    case not db_entry:is_empty(DBEntry2) andalso
  -             not (db_entry:get_writelock(DBEntry2) andalso db_entry:get_readlock(DBEntry2) > 0) andalso
  -             db_entry:get_version(DBEntry2) >= 0 of
  -        true -> check_db(DB3, {true, []}, 1, [DBEntry2], "check_db_update_entry_0");
  -        _ when IsNullEntry ->
  -                check_db(DB3, {true, []}, 0, [], "check_db_update_entry_1");
  -        _    -> check_db(DB3, {false, [DBEntry2]}, 1, [DBEntry2], "check_db_update_entry_2")
  +    case db_entry:is_null(DBEntry1) of
  +        true -> % update not possible
  +            DB3 = DB2,
  +            ok; 
  +        false ->
  +            DB3 = ?TEST_DB:update_entry(DB2, DBEntry2),
  +            IsNullEntry = db_entry:is_null(DBEntry2),
  +            check_entry(DB3, db_entry:get_key(DBEntry2), DBEntry2,
  +                        {ok, db_entry:get_value(DBEntry2), db_entry:get_version(DBEntry2)},
  +                        not IsNullEntry, "check_entry_update_entry_1"),
  +            case not db_entry:is_empty(DBEntry2) andalso
  +                     not (db_entry:get_writelock(DBEntry2) andalso db_entry:get_readlock(DBEntry2) > 0) andalso
  +                     db_entry:get_version(DBEntry2) >= 0 of
  +                true -> check_db(DB3, {true, []}, 1, [DBEntry2], "check_db_update_entry_0");
  +                _ when IsNullEntry ->
  +                    check_db(DB3, {true, []}, 0, [], "check_db_update_entry_1");
  +                _    -> check_db(DB3, {false, [DBEntry2]}, 1, [DBEntry2], "check_db_update_entry_2")
  +            end
       end,
       ?TEST_DB:close(DB3),
       true.
  
positive.code:     ?equals_w_note(?TEST_DB:get_changes(DB9), {[], []}, "stop_record_changes_11"),
  
      ?TEST_DB:close(DB9),
      true.
  
  get_random_interval_from_changes(DB) ->
  
negative.code:         _    -> ok
      end.
  
  %% @doc Checks that an entry is present exactly once in the list of changed
  %%      entries returned by ?TEST_DB:get_changes/1.
  -spec check_entry_in_changes(
          DB::?TEST_DB:db(), ChangesInterval::intervals:interval(), Entry::db_entry:entry(),
          {OldExists::boolean(), OldEntry::db_entry:entry()}, Note::string()) -> ok.
  check_entry_in_changes(DB, ChangesInterval, NewEntry, {OldExists, OldEntry}, Note) ->
      {ChangedEntries, DeletedKeys} = ?TEST_DB:get_changes(DB),
      case db_entry:is_null(NewEntry) of
          true ->
              check_key_in_deleted_internal(DeletedKeys, ChangesInterval, db_entry:get_key(NewEntry), OldExists, Note);
          _ ->
              check_entry_in_changed_entries_internal(ChangedEntries, ChangesInterval, NewEntry, OldEntry, Note)
      end.
  