func (r *Replace) IsNullable() bool {
	return r.str.IsNullable() || r.fromStr.IsNullable() || r.toStr.IsNullable()
}
IsNullable implements the Expression interface.
package function
import (
	"fmt"
	"strings"
	"github.com/src-d/go-mysql-server/sql"
	"github.com/src-d/go-mysql-server/sql/expression"
	"gopkg.in/src-d/go-errors.v1"
)
type Reverse struct {
	expression.UnaryExpression
}
func NewReverse(e sql.Expression) sql.Expression {
	return &Reverse{expression.UnaryExpression{Child: e}}
}
func (r *Reverse) Eval(
	ctx *sql.Context,
	row sql.Row,
) (interface{}, error) {
	v, err := r.Child.Eval(ctx, row)
	if v == nil || err != nil {
		return nil, err
	}
	v, err = sql.Text.Convert(v)
	if err != nil {
		return nil, err
	}
	return reverseString(v.(string)), nil
}
func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < j; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}
func (r *Reverse) String() string {
	return fmt.Sprintf("reverse(%s)", r.Child)
}
func (r *Reverse) WithChildren(children ...sql.Expression) (sql.Expression, error) {
	if len(children) != 1 {
		return nil, sql.ErrInvalidChildrenNumber.New(r, len(children), 1)
	}
	return NewReverse(children[0]), nil
}
func (r *Reverse) Type() sql.Type {
	return r.Child.Type()
}
var ErrNegativeRepeatCount = errors.NewKind("negative Repeat count: %v")
type Repeat struct {
	expression.BinaryExpression
}
func NewRepeat(str sql.Expression, count sql.Expression) sql.Expression {
	return &Repeat{expression.BinaryExpression{Left: str, Right: count}}
}
func (r *Repeat) String() string {
	return fmt.Sprintf("repeat(%s, %s)", r.Left, r.Right)
}
func (r *Repeat) Type() sql.Type {
	return sql.Text
}
func (r *Repeat) WithChildren(children ...sql.Expression) (sql.Expression, error) {
	if len(children) != 2 {
		return nil, sql.ErrInvalidChildrenNumber.New(r, len(children), 2)
	}
	return NewRepeat(children[0], children[1]), nil
}
func (r *Repeat) Eval(
	ctx *sql.Context,
	row sql.Row,
) (interface{}, error) {
	str, err := r.Left.Eval(ctx, row)
	if str == nil || err != nil {
		return nil, err
	}
	str, err = sql.Text.Convert(str)
	if err != nil {
		return nil, err
	}
	count, err := r.Right.Eval(ctx, row)
	if count == nil || err != nil {
		return nil, err
	}
	count, err = sql.Int32.Convert(count)
	if err != nil {
		return nil, err
	}
	if count.(int32) < 0 {
		return nil, ErrNegativeRepeatCount.New(count)
	}
	return strings.Repeat(str.(string), int(count.(int32))), nil
}
type Replace struct {
	str     sql.Expression
	fromStr sql.Expression
	toStr   sql.Expression
}
func NewReplace(str sql.Expression, fromStr sql.Expression, toStr sql.Expression) sql.Expression {
	return &Replace{str, fromStr, toStr}
}
func (r *Replace) Children() []sql.Expression {
	return []sql.Expression{r.str, r.fromStr, r.toStr}
}
func (r *Replace) Resolved() bool {
	return r.str.Resolved() && r.fromStr.Resolved() && r.toStr.Resolved()
}