code: func (s *session) StmtCommit() error {
  	defer s.txn.cleanup()
  	st := &s.txn
  	var count int
  	err := kv.WalkMemBuffer(st.buf, func(k kv.Key, v []byte) error {
  		failpoint.Inject("mockStmtCommitError", func(val failpoint.Value) {
  			if val.(bool) {
  				count++
  			}
  		})
  
  		if count > 3 {
  			return errors.New("mock stmt commit error")
  		}
  
  		if len(v) == 0 {
  			return st.Transaction.Delete(k)
  		}
  		return st.Transaction.Set(k, v)
  	})
  	if err != nil {
  		st.doNotCommit = err
  		return err
  	}
  
  	// Need to flush binlog.
  	for tableID, delta := range st.mutations {
  		mutation := getBinlogMutation(s, tableID)
  		mergeToMutation(mutation, delta)
  	}
  
  	if len(st.dirtyTableOP) > 0 {
  		dirtyDB := executor.GetDirtyDB(s)
  		for _, op := range st.dirtyTableOP {
  			mergeToDirtyDB(dirtyDB, op)
  		}
  	}
  	return nil
  }
docs: // StmtCommit implements the sessionctx.Context interface.