code: func (s *session) setVersion(r *sessionRecord, v *version) {
  	s.vmu.Lock()
  	defer s.vmu.Unlock()
  	// Hold by session. It is important to call this first before releasing
  	// current version, otherwise the still used files might get released.
  	v.incref()
  	if s.stVersion != nil {
  		if r != nil {
  			var (
  				added   = make([]int64, 0, len(r.addedTables))
  				deleted = make([]int64, 0, len(r.deletedTables))
  			)
  			for _, t := range r.addedTables {
  				added = append(added, t.num)
  			}
  			for _, t := range r.deletedTables {
  				deleted = append(deleted, t.num)
  			}
  			select {
  			case s.deltaCh <- &vDelta{vid: s.stVersion.id, added: added, deleted: deleted}:
  			case <-v.s.closeC:
  				s.log("reference loop already exist")
  			}
  		}
  		// Release current version.
  		s.stVersion.releaseNB()
  	}
  	s.stVersion = v
  }
docs: // Set current version to v.