Skip to content

Commit f466802

Browse files
committed
Passing context through
1 parent e8014e4 commit f466802

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

sql/analyzer/validate_create_table.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

sql/information_schema/columns_table.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func getRowFromColumn(ctx *sql.Context, curOrdPos int, col *sql.Column, dbName,
209209
}
210210
}
211211

212-
charName, collName, charMaxLen, charOctetLen := getCharAndCollNamesAndCharMaxAndOctetLens(col.Type)
212+
charName, collName, charMaxLen, charOctetLen := getCharAndCollNamesAndCharMaxAndOctetLens(ctx, col.Type)
213213

214214
numericPrecision, numericScale := getColumnPrecisionAndScale(col.Type)
215215
if types.IsDatetimeType(col.Type) || types.IsTimestampType(col.Type) {
@@ -539,7 +539,7 @@ func getColumnPrecisionAndScale(colType sql.Type) (interface{}, interface{}) {
539539
}
540540
}
541541

542-
func getCharAndCollNamesAndCharMaxAndOctetLens(colType sql.Type) (interface{}, interface{}, interface{}, interface{}) {
542+
func getCharAndCollNamesAndCharMaxAndOctetLens(ctx *sql.Context, colType sql.Type) (interface{}, interface{}, interface{}, interface{}) {
543543
var (
544544
charName interface{}
545545
collName interface{}
@@ -551,8 +551,8 @@ func getCharAndCollNamesAndCharMaxAndOctetLens(colType sql.Type) (interface{}, i
551551
collName = colColl.Name()
552552
charName = colColl.CharacterSet().String()
553553
if types.IsEnum(colType) || types.IsSet(colType) {
554-
charOctetLen = int64(colType.MaxTextResponseByteLength())
555-
charMaxLen = int64(colType.MaxTextResponseByteLength()) / colColl.CharacterSet().MaxLength()
554+
charOctetLen = int64(colType.MaxTextResponseByteLength(ctx))
555+
charMaxLen = int64(colType.MaxTextResponseByteLength(ctx)) / colColl.CharacterSet().MaxLength()
556556
}
557557
}
558558
if st, ok := colType.(sql.StringType); ok {

sql/information_schema/routines_table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ func parametersRowIter(ctx *Context, c Catalog, p map[string][]*plan.Procedure)
285285
parameterMode = "OUT"
286286
}
287287

288-
charName, collName, charMaxLen, charOctetLen := getCharAndCollNamesAndCharMaxAndOctetLens(param.Type)
288+
charName, collName, charMaxLen, charOctetLen := getCharAndCollNamesAndCharMaxAndOctetLens(ctx, param.Type)
289289
numericPrecision, numericScale := getColumnPrecisionAndScale(param.Type)
290290
// float types get nil for numericScale, but it gets 0 for this table
291291
if _, ok := param.Type.(NumberType); ok {

sql/types/set.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func CreateSetType(values []string, collation sql.CollationID) (sql.SetType, err
6666
var maxByteLength uint32
6767
maxCharLength := collation.Collation().CharacterSet.MaxLength()
6868
for i, value := range values {
69-
// ...SET member values should not themselves contain commas.
69+
// SET member values should not themselves contain commas.
7070
if strings.Contains(value, ",") {
7171
return nil, fmt.Errorf("values cannot contain a comma")
7272
}

0 commit comments

Comments
 (0)