@@ -217,7 +217,12 @@ func (t *DoltgresType) Compare(ctx context.Context, v1 interface{}, v2 interface
217217
218218 if t .TypType == TypeType_Enum {
219219 // TODO: temporary solution to getting the enum type (which has label info) into the 'enum_cmp' function
220- qf := globalFunctionRegistry .GetFunction (ctx .(* sql.Context ), t .CompareFunc )
220+ // ctx is not guaranteed to be a *sql.Context when called from index comparator goroutines.
221+ sqlCtx , ok := ctx .(* sql.Context )
222+ if ! ok {
223+ sqlCtx = sql .NewEmptyContext ()
224+ }
225+ qf := globalFunctionRegistry .GetFunction (sqlCtx , t .CompareFunc )
221226 resTypes := qf .ResolvedTypes ()
222227 newFunc := qf .WithResolvedTypes ([]* DoltgresType {t , t , resTypes [len (resTypes )- 1 ]})
223228 i , err := newFunc .(QuickFunction ).CallVariadic (nil , v1 , v2 )
@@ -226,7 +231,12 @@ func (t *DoltgresType) Compare(ctx context.Context, v1 interface{}, v2 interface
226231 }
227232 return int (i .(int32 )), nil
228233 } else if t == Oidvector {
229- i , err := globalFunctionRegistry .GetFunction (ctx .(* sql.Context ), t .CompareFunc ).CallVariadic (nil , v1 , v2 )
234+ // ctx is not guaranteed to be a *sql.Context when called from index comparator goroutines.
235+ sqlCtx , ok := ctx .(* sql.Context )
236+ if ! ok {
237+ sqlCtx = sql .NewEmptyContext ()
238+ }
239+ i , err := globalFunctionRegistry .GetFunction (sqlCtx , t .CompareFunc ).CallVariadic (nil , v1 , v2 )
230240 if err != nil {
231241 return 0 , err
232242 }
0 commit comments