code: func (s *session) PrepareTxnCtx(ctx context.Context) {
  	if s.txn.validOrPending() {
  		return
  	}
  
  	txnFuture := s.getTxnFuture(ctx)
  	s.txn.changeInvalidToPending(txnFuture)
  	is := domain.GetDomain(s).InfoSchema()
  	s.sessionVars.TxnCtx = &variable.TransactionContext{
  		InfoSchema:    is,
  		SchemaVersion: is.SchemaMetaVersion(),
  		CreateTime:    time.Now(),
  	}
  }
docs: // PrepareTxnCtx starts a goroutine to begin a transaction if needed, and creates a new transaction context.
  // It is called before we execute a sql query.