func (t systemEnumType) SQL(v interface{}) (sqltypes.Value, error) {
	if v == nil {
		return sqltypes.NULL, nil
	}
	v, err := t.Convert(v)
	if err != nil {
		return sqltypes.Value{}, err
	}
	return sqltypes.MakeTrusted(t.Type(), []byte(v.(string))), nil
}
SQL implements Type interface.
package sql
import (
	"strings"
	"github.com/dolthub/vitess/go/sqltypes"
	"github.com/dolthub/vitess/go/vt/proto/query"
)
type systemEnumType struct {
	varName    string
	valToIndex map[string]int
	indexToVal []string
}
var _ SystemVariableType = systemEnumType{}
func NewSystemEnumType(varName string, values ...string) SystemVariableType {
	if len(values) > 65535 {  
		panic(varName + " somehow has more than 65535 values")
	}
	valToIndex := make(map[string]int)
	for i, value := range values {
		valToIndex[strings.ToLower(value)] = i
	}
	return systemEnumType{varName, valToIndex, values}
}
func (t systemEnumType) Compare(a interface{}, b interface{}) (int, error) {
	as, err := t.Convert(a)
	if err != nil {
		return 0, err
	}
	bs, err := t.Convert(b)
	if err != nil {
		return 0, err
	}
	ai := as.(string)
	bi := bs.(string)
	if ai == bi {
		return 0, nil
	}
	if ai < bi {
		return -1, nil
	}
	return 1, nil
}
func (t systemEnumType) Convert(v interface{}) (interface{}, error) {
	switch value := v.(type) {
	case int:
		if value >= 0 && value < len(t.indexToVal) {
			return t.indexToVal[value], nil
		}
	case uint:
		return t.Convert(int(value))
	case int8:
		return t.Convert(int(value))
	case uint8:
		return t.Convert(int(value))
	case int16:
		return t.Convert(int(value))
	case uint16:
		return t.Convert(int(value))
	case int32:
		return t.Convert(int(value))
	case uint32:
		return t.Convert(int(value))
	case int64:
		return t.Convert(int(value))
	case uint64:
		return t.Convert(int(value))
	case float32:
		return t.Convert(float64(value))
	case float64:
		if value == float64(int(value)) {
			return t.Convert(int(value))
		}
	case string:
		if idx, ok := t.valToIndex[strings.ToLower(value)]; ok {
			return t.indexToVal[idx], nil
		}
	}
	return nil, ErrInvalidSystemVariableValue.New(t.varName, v)
}
func (t systemEnumType) MustConvert(v interface{}) interface{} {
	value, err := t.Convert(v)
	if err != nil {
		panic(err)
	}
	return value
}
func (t systemEnumType) Promote() Type {
	return t
}