code: func builtinLog(args []types.Datum, ctx context.Context) (d types.Datum, err error) {
  	sc := ctx.GetSessionVars().StmtCtx
  
  	switch len(args) {
  	case 1:
  		x, err := args[0].ToFloat64(sc)
  		if err != nil {
  			return d, errors.Trace(err)
  		}
  
  		if x <= 0 {
  			return d, nil
  		}
  
  		d.SetFloat64(math.Log(x))
  		return d, nil
  	case 2:
  		b, err := args[0].ToFloat64(sc)
  		if err != nil {
  			return d, errors.Trace(err)
  		}
  
  		x, err := args[1].ToFloat64(sc)
  		if err != nil {
  			return d, errors.Trace(err)
  		}
  
  		if b <= 1 || x <= 0 {
  			return d, nil
  		}
  
  		d.SetFloat64(math.Log(x) / math.Log(b))
  		return d, nil
  	}
  	return
  }
docs: // See http://dev.mysql.com/doc/refman/5.7/en/mathematical-functions.html#function_log