code: func createSessionWithDomain(store kv.Storage, dom *domain.Domain) (*session, error) {
  	s := &session{
  		store:       store,
  		parser:      parser.New(),
  		sessionVars: variable.NewSessionVars(),
  	}
  	if plannercore.PreparedPlanCacheEnabled() {
  		s.preparedPlanCache = kvcache.NewSimpleLRUCache(plannercore.PreparedPlanCacheCapacity,
  			plannercore.PreparedPlanCacheMemoryGuardRatio, plannercore.PreparedPlanCacheMaxMemory.Load())
  	}
  	s.mu.values = make(map[fmt.Stringer]interface{})
  	domain.BindDomain(s, dom)
  	// session implements variable.GlobalVarAccessor. Bind it to ctx.
  	s.sessionVars.GlobalVarsAccessor = s
  	s.txn.init()
  	return s, nil
  }
docs: // createSessionWithDomain creates a new Session and binds it with a Domain.
  // We need this because when we start DDL in Domain, the DDL need a session
  // to change some system tables. But at that time, we have been already in
  // a lock context, which cause we can't call createSesion directly.