code: func (b *builtinCastStringAsIntSig) handleOverflow(origRes int64, origStr string, origErr error, isNegative bool) (res int64, err error) {
  	res, err = origRes, origErr
  	if err == nil {
  		return
  	}
  
  	sc := b.ctx.GetSessionVars().StmtCtx
  	if sc.InSelectStmt && types.ErrOverflow.Equal(origErr) {
  		if isNegative {
  			res = math.MinInt64
  		} else {
  			uval := uint64(math.MaxUint64)
  			res = int64(uval)
  		}
  		warnErr := types.ErrTruncatedWrongVal.GenWithStackByArgs("INTEGER", origStr)
  		err = sc.HandleOverflow(origErr, warnErr)
  	}
  	return
  }
docs: // handleOverflow handles the overflow caused by cast string as int,
  // see https://dev.mysql.com/doc/refman/5.7/en/out-of-range-and-overflow.html.
  // When an out-of-range value is assigned to an integer column, MySQL stores the value representing the corresponding endpoint of the column data type range. If it is in select statement, it will return the
  // endpoint value with a warning.