code: func builtinRpad(args []types.Datum, ctx context.Context) (d types.Datum, err error) {
  	// RPAD(str,len,padstr)
  	// args[0] string, args[1] int, args[2] string
  	str, err := args[0].ToString()
  	if err != nil {
  		return d, errors.Trace(err)
  	}
  	length, err := args[1].ToInt64(ctx.GetSessionVars().StmtCtx)
  	if err != nil {
  		return d, errors.Trace(err)
  	}
  	l := int(length)
  
  	padStr, err := args[2].ToString()
  	if err != nil {
  		return d, errors.Trace(err)
  	}
  
  	if l < 0 || (len(str) < l && padStr == "") {
  		d.SetNull()
  		return d, nil
  	}
  
  	tailLen := l - len(str)
  	if tailLen > 0 {
  		repeatCount := tailLen/len(padStr) + 1
  		str = str + strings.Repeat(padStr, repeatCount)
  	}
  	d.SetString(str[:l])
  
  	return d, nil
  }
docs: // See https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_rpad