func (t *FromBase64) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
	str, err := t.Child.Eval(ctx, row)
	if err != nil {
		return nil, err
	}
	if str == nil {
		return nil, nil
	}
	str, err = sql.LongText.Convert(str)
	if err != nil {
		return nil, sql.ErrInvalidType.New(reflect.TypeOf(str))
	}
	decoded, err := base64.StdEncoding.DecodeString(str.(string))
	if err != nil {
		return nil, err
	}
	return string(decoded), nil
}
Eval implements the Expression interface.
package function
import (
	"encoding/base64"
	"fmt"
	"reflect"
	"strings"
	"github.com/dolthub/go-mysql-server/sql"
	"github.com/dolthub/go-mysql-server/sql/expression"
)
type ToBase64 struct {
	expression.UnaryExpression
}
var _ sql.FunctionExpression = (*ToBase64)(nil)
func NewToBase64(e sql.Expression) sql.Expression {
	return &ToBase64{expression.UnaryExpression{Child: e}}
}
func (t *ToBase64) FunctionName() string {
	return "to_base64"
}
func (t *ToBase64) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
	str, err := t.Child.Eval(ctx, row)
	if err != nil {
		return nil, err
	}
	if str == nil {
		return nil, nil
	}
	str, err = sql.LongText.Convert(str)
	if err != nil {
		return nil, sql.ErrInvalidType.New(reflect.TypeOf(str))
	}
	encoded := base64.StdEncoding.EncodeToString([]byte(str.(string)))
	lenEncoded := len(encoded)
	if lenEncoded <= 76 {
		return encoded, nil
	}
	var out strings.Builder
	start := 0
	end := 76
	for {
		out.WriteString(encoded[start:end] + "\n")
		start += 76
		end += 76
		if end >= lenEncoded {
			out.WriteString(encoded[start:lenEncoded])
			break
		}
	}
	return out.String(), nil
}
func (t *ToBase64) String() string {
	return fmt.Sprintf("TO_BASE64(%s)", t.Child)
}
func (t *ToBase64) IsNullable() bool {
	return t.Child.IsNullable()
}
func (t *ToBase64) WithChildren(children ...sql.Expression) (sql.Expression, error) {
	if len(children) != 1 {
		return nil, sql.ErrInvalidChildrenNumber.New(t, len(children), 1)
	}
	return NewToBase64(children[0]), nil
}
func (t *ToBase64) Type() sql.Type {
	return sql.LongText
}
type FromBase64 struct {
	expression.UnaryExpression
}
var _ sql.FunctionExpression = (*FromBase64)(nil)
func NewFromBase64(e sql.Expression) sql.Expression {
	return &FromBase64{expression.UnaryExpression{Child: e}}
}
func (t *FromBase64) FunctionName() string {
	return "from_base64"
}