@@ -397,7 +397,7 @@ func validateAlterIndex(ctx *sql.Context, initialSch, sch sql.Schema, ai *plan.A
397397 if ! ok {
398398 return nil , sql .ErrKeyColumnDoesNotExist .New (badColName )
399399 }
400- err := validateIndexType (ai .Columns , sch )
400+ err := validateIndexType (ctx , ai .Columns , sch )
401401 if err != nil {
402402 return nil , err
403403 }
@@ -455,7 +455,7 @@ func validateAlterIndex(ctx *sql.Context, initialSch, sch sql.Schema, ai *plan.A
455455}
456456
457457// validatePrefixLength handles all errors related to creating indexes with prefix lengths
458- func validatePrefixLength (schCol * sql.Column , idxCol sql.IndexColumn ) error {
458+ func validatePrefixLength (ctx * sql. Context , schCol * sql.Column , idxCol sql.IndexColumn ) error {
459459 // Throw prefix length error for non-string types with prefixes
460460 if idxCol .Length > 0 && ! types .IsText (schCol .Type ) {
461461 return sql .ErrInvalidIndexPrefix .New (schCol .Name )
@@ -473,7 +473,7 @@ func validatePrefixLength(schCol *sql.Column, idxCol sql.IndexColumn) error {
473473 }
474474
475475 // The specified prefix length is longer than the column
476- maxByteLength := int64 (schCol .Type .MaxTextResponseByteLength ())
476+ maxByteLength := int64 (schCol .Type .MaxTextResponseByteLength (ctx ))
477477 if prefixByteLength > maxByteLength {
478478 return sql .ErrInvalidIndexPrefix .New (schCol .Name )
479479 }
@@ -487,10 +487,10 @@ func validatePrefixLength(schCol *sql.Column, idxCol sql.IndexColumn) error {
487487}
488488
489489// validateIndexType prevents creating invalid indexes
490- func validateIndexType (cols []sql.IndexColumn , sch sql.Schema ) error {
490+ func validateIndexType (ctx * sql. Context , cols []sql.IndexColumn , sch sql.Schema ) error {
491491 for _ , idxCol := range cols {
492492 schCol := sch [sch .IndexOfColName (idxCol .Name )]
493- err := validatePrefixLength (schCol , idxCol )
493+ err := validatePrefixLength (ctx , schCol , idxCol )
494494 if err != nil {
495495 return err
496496 }
0 commit comments