Moved string type

This commit is contained in:
Zach Musgrave
2023-01-23 17:16:00 -08:00
parent a888059189
commit d29fbe8da6
12 changed files with 27 additions and 29 deletions

View File

@@ -775,7 +775,7 @@ func NameAndTypeTransform(row sql.Row, rowOperationSchema sql.PrimaryKeySchema,
// For non string types we want empty strings to be converted to nils. String types should be allowed to take on
// an empty string value
switch col.Type.(type) {
case types2.StringType:
case sql.StringType:
default:
row[i] = emptyStringToNil(row[i])
}

View File

@@ -20,8 +20,6 @@ import (
"fmt"
"strings"
types2 "github.com/dolthub/go-mysql-server/sql/types"
"github.com/dolthub/dolt/go/libraries/doltcore/conflict"
"github.com/dolthub/dolt/go/libraries/doltcore/diff"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
@@ -32,6 +30,7 @@ import (
"github.com/dolthub/dolt/go/store/hash"
"github.com/dolthub/dolt/go/store/prolly/tree"
"github.com/dolthub/dolt/go/store/types"
"github.com/dolthub/go-mysql-server/sql"
)
type MergeOpts struct {
@@ -408,8 +407,8 @@ func validateTupleFields(existingSch schema.Schema, targetSch schema.Schema) (bo
// If the collation was changed, bail.
// Different collations will affect the ordering of any secondary indexes using this column.
existingStr, ok1 := existingSch.GetNonPKCols().GetByIndex(i).TypeInfo.ToSqlType().(types2.StringType)
targetStr, ok2 := targetSch.GetNonPKCols().GetByIndex(i).TypeInfo.ToSqlType().(types2.StringType)
existingStr, ok1 := existingSch.GetNonPKCols().GetByIndex(i).TypeInfo.ToSqlType().(sql.StringType)
targetStr, ok2 := targetSch.GetNonPKCols().GetByIndex(i).TypeInfo.ToSqlType().(sql.StringType)
if ok1 && ok2 && !existingStr.Collation().Equals(targetStr.Collation()) {
return false, nil

View File

@@ -502,7 +502,7 @@ func migrateSchema(ctx context.Context, tableName string, existing schema.Schema
// String types are sorted using a binary collation in __LD_1__
// force-set collation to utf8mb4_0900_bin to match the order
for i, c := range cols {
st, ok := c.TypeInfo.ToSqlType().(types2.StringType)
st, ok := c.TypeInfo.ToSqlType().(sql.StringType)
if !ok {
continue
}

View File

@@ -21,7 +21,6 @@ import (
"strings"
"github.com/dolthub/go-mysql-server/sql"
types2 "github.com/dolthub/go-mysql-server/sql/types"
"github.com/dolthub/vitess/go/vt/proto/query"
"github.com/dolthub/dolt/go/store/types"
@@ -439,7 +438,7 @@ func (si *schemaImpl) GetKeyDescriptor() val.TupleDesc {
tt = append(tt, t)
if queryType == query.Type_CHAR || queryType == query.Type_VARCHAR || queryType == query.Type_TEXT {
useCollations = true
collations = append(collations, sqlType.(types2.StringType).Collation())
collations = append(collations, sqlType.(sql.StringType).Collation())
} else {
collations = append(collations, sql.Collation_Unspecified)
}
@@ -476,7 +475,7 @@ func (si *schemaImpl) GetValueDescriptor() val.TupleDesc {
})
if queryType == query.Type_CHAR || queryType == query.Type_VARCHAR {
useCollations = true
collations = append(collations, sqlType.(types2.StringType).Collation())
collations = append(collations, sqlType.(sql.StringType).Collation())
} else {
collations = append(collations, sql.Collation_Unspecified)
}

View File

@@ -39,7 +39,7 @@ const (
// repositories that were made before the introduction of blobStringType will still use varStringType for existing
// columns.
type blobStringType struct {
sqlStringType types2.StringType
sqlStringType sql.StringType
}
var _ TypeInfo = (*blobStringType)(nil)
@@ -192,7 +192,7 @@ func (ti *blobStringType) NomsKind() types.NomsKind {
// Promote implements TypeInfo interface.
func (ti *blobStringType) Promote() TypeInfo {
return &blobStringType{ti.sqlStringType.Promote().(types2.StringType)}
return &blobStringType{ti.sqlStringType.Promote().(sql.StringType)}
}
// String implements TypeInfo interface.

View File

@@ -37,7 +37,7 @@ const (
// inlineBlobType handles BINARY and VARBINARY. BLOB types are handled by varBinaryType.
type inlineBlobType struct {
sqlBinaryType types2.StringType
sqlBinaryType sql.StringType
}
var _ TypeInfo = (*inlineBlobType)(nil)
@@ -58,7 +58,7 @@ func CreateInlineBlobTypeFromParams(params map[string]string) (TypeInfo, error)
return nil, fmt.Errorf(`create inlineblob type info is missing param "%v"`, inlineBlobTypeParam_Length)
}
if sqlStr, ok := params[inlineBlobTypeParam_SQL]; ok {
var sqlType types2.StringType
var sqlType sql.StringType
switch sqlStr {
case inlineBlobTypeParam_SQL_Binary:
sqlType, err = types2.CreateBinary(sqltypes.Binary, length)
@@ -187,7 +187,7 @@ func (ti *inlineBlobType) NomsKind() types.NomsKind {
// Promote implements TypeInfo interface.
func (ti *inlineBlobType) Promote() TypeInfo {
return &inlineBlobType{ti.sqlBinaryType.Promote().(types2.StringType)}
return &inlineBlobType{ti.sqlBinaryType.Promote().(sql.StringType)}
}
// String implements TypeInfo interface.

View File

@@ -200,37 +200,37 @@ func FromSqlType(sqlType sql.Type) (TypeInfo, error) {
}
return &decimalType{decimalSQLType}, nil
case sqltypes.Text:
stringType, ok := sqlType.(types2.StringType)
stringType, ok := sqlType.(sql.StringType)
if !ok {
return nil, fmt.Errorf(`expected "StringType" from SQL basetype "Text"`)
}
return &blobStringType{stringType}, nil
case sqltypes.Blob:
stringType, ok := sqlType.(types2.StringType)
stringType, ok := sqlType.(sql.StringType)
if !ok {
return nil, fmt.Errorf(`expected "StringType" from SQL basetype "Blob"`)
}
return &varBinaryType{stringType}, nil
case sqltypes.VarChar:
stringType, ok := sqlType.(types2.StringType)
stringType, ok := sqlType.(sql.StringType)
if !ok {
return nil, fmt.Errorf(`expected "StringType" from SQL basetype "VarChar"`)
}
return &varStringType{stringType}, nil
case sqltypes.VarBinary:
stringType, ok := sqlType.(types2.StringType)
stringType, ok := sqlType.(sql.StringType)
if !ok {
return nil, fmt.Errorf(`expected "StringType" from SQL basetype "VarBinary"`)
}
return &inlineBlobType{stringType}, nil
case sqltypes.Char:
stringType, ok := sqlType.(types2.StringType)
stringType, ok := sqlType.(sql.StringType)
if !ok {
return nil, fmt.Errorf(`expected "StringType" from SQL basetype "Char"`)
}
return &varStringType{stringType}, nil
case sqltypes.Binary:
stringType, ok := sqlType.(types2.StringType)
stringType, ok := sqlType.(sql.StringType)
if !ok {
return nil, fmt.Errorf(`expected "StringType" from SQL basetype "Binary"`)
}

View File

@@ -27,7 +27,7 @@ import (
)
type uuidType struct {
sqlCharType types2.StringType
sqlCharType sql.StringType
}
var _ TypeInfo = (*uuidType)(nil)

View File

@@ -41,7 +41,7 @@ const (
//
// This type handles the BLOB types. BINARY and VARBINARY are handled by inlineBlobType.
type varBinaryType struct {
sqlBinaryType types2.StringType
sqlBinaryType sql.StringType
}
var _ TypeInfo = (*varBinaryType)(nil)
@@ -174,7 +174,7 @@ func (ti *varBinaryType) NomsKind() types.NomsKind {
// Promote implements TypeInfo interface.
func (ti *varBinaryType) Promote() TypeInfo {
return &varBinaryType{ti.sqlBinaryType.Promote().(types2.StringType)}
return &varBinaryType{ti.sqlBinaryType.Promote().(sql.StringType)}
}
// String implements TypeInfo interface.

View File

@@ -43,7 +43,7 @@ const (
// legacy repositories will run into issues if they attempt to insert very large strings. Any and all new repositories
// must use blobStringType for all TEXT types to ensure proper behavior.
type varStringType struct {
sqlStringType types2.StringType
sqlStringType sql.StringType
}
var _ TypeInfo = (*varStringType)(nil)
@@ -74,7 +74,7 @@ func CreateVarStringTypeFromParams(params map[string]string) (TypeInfo, error) {
return nil, fmt.Errorf(`create varstring type info is missing param "%v"`, varStringTypeParam_Length)
}
if sqlStr, ok := params[varStringTypeParam_SQL]; ok {
var sqlType types2.StringType
var sqlType sql.StringType
switch sqlStr {
case varStringTypeParam_SQL_Char:
sqlType, err = types2.CreateString(sqltypes.Char, length, collation)
@@ -226,7 +226,7 @@ func (ti *varStringType) NomsKind() types.NomsKind {
// Promote implements TypeInfo interface.
func (ti *varStringType) Promote() TypeInfo {
return &varStringType{ti.sqlStringType.Promote().(types2.StringType)}
return &varStringType{ti.sqlStringType.Promote().(sql.StringType)}
}
// String implements TypeInfo interface.

View File

@@ -39,10 +39,10 @@ func NewMergeBase(left, right sql.Expression) sql.Expression {
// Eval implements the sql.Expression interface.
func (d MergeBase) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
if _, ok := d.Left.Type().(types.StringType); !ok {
if _, ok := d.Left.Type().(sql.StringType); !ok {
return nil, sql.ErrInvalidType.New(d.Left.Type())
}
if _, ok := d.Right.Type().(types.StringType); !ok {
if _, ok := d.Right.Type().(sql.StringType); !ok {
return nil, sql.ErrInvalidType.New(d.Right.Type())
}

View File

@@ -408,7 +408,7 @@ func (t *DoltTable) DataLength(ctx *sql.Context) (uint64, error) {
switch n := col.Type.(type) {
case sql.NumberType:
numBytesPerRow += 8
case types2.StringType:
case sql.StringType:
numBytesPerRow += uint64(n.MaxByteLength())
case types2.BitType:
numBytesPerRow += 1