func (t enumType) Compare(a interface{}, b interface{}) (int, error) {
	if hasNulls, res := compareNulls(a, b); hasNulls {
		return res, nil
	}
	ai, err := t.ConvertToIndex(a)
	if err != nil {
		return 0, err
	}
	bi, err := t.ConvertToIndex(b)
	if err != nil {
		return 0, err
	}
	if ai < bi {
		return -1, nil
	} else if ai > bi {
		return 1, nil
	}
	return 0, nil
}
Compare implements Type interface.
package sql
import (
	"fmt"
	"strconv"
	"strings"
	"github.com/dolthub/vitess/go/sqltypes"
	"github.com/dolthub/vitess/go/vt/proto/query"
	"gopkg.in/src-d/go-errors.v1"
)
const (
	EnumTypeMinElements = 1
	EnumTypeMaxElements = 65535
)
var (
	ErrConvertingToEnum  = errors.NewKind("value %v is not valid for this Enum")
	ErrUnmarshallingEnum = errors.NewKind("value %v is not a marshalled value for this Enum")
)
type EnumType interface {
	Type
	At(index int) (string, bool)
	CharacterSet() CharacterSet
	Collation() Collation
	ConvertToIndex(v interface{}) (int, error)
	IndexOf(v string) int
	Marshal(v interface{}) (int64, error)
	NumberOfElements() uint16
	Unmarshal(v int64) (string, error)
	Values() []string
}
type enumType struct {
	collation  Collation
	valToIndex map[string]int
	indexToVal []string
}
func CreateEnumType(values []string, collation Collation) (EnumType, error) {
	if len(values) < EnumTypeMinElements {
		return nil, fmt.Errorf("number of values may not be zero")
	}
	if len(values) > EnumTypeMaxElements {
		return nil, fmt.Errorf("number of values is too large")
	}
	valToIndex := make(map[string]int)
	for i, value := range values {
		if !collation.Equals(Collation_binary) {
			value = strings.TrimRight(value, " ")
		}
		values[i] = value
		if _, ok := valToIndex[value]; ok {
			return nil, fmt.Errorf("duplicate entry: %v", value)
		}
		valToIndex[value] = i + 1
	}
	return enumType{
		collation:  collation,
		valToIndex: valToIndex,
		indexToVal: values,
	}, nil
}
func MustCreateEnumType(values []string, collation Collation) EnumType {
	et, err := CreateEnumType(values, collation)
	if err != nil {
		panic(err)
	}
	return et
}