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
}
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"
}