diff --git a/go/cmd/dolt/commands/diffsplitter_test.go b/go/cmd/dolt/commands/diffsplitter_test.go index b54d8677af..8d6ffaa899 100755 --- a/go/cmd/dolt/commands/diffsplitter_test.go +++ b/go/cmd/dolt/commands/diffsplitter_test.go @@ -18,6 +18,7 @@ import ( "testing" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -231,9 +232,9 @@ func emptyRowDiff(columns int) rowDiff { } func strCol(name string) *sql.Column { - return &sql.Column{Name: name, Type: sql.Text} + return &sql.Column{Name: name, Type: types.Text} } func intCol(name string) *sql.Column { - return &sql.Column{Name: name, Type: sql.Int64} + return &sql.Column{Name: name, Type: types.Int64} } diff --git a/go/cmd/dolt/commands/engine/sql_print.go b/go/cmd/dolt/commands/engine/sql_print.go index 1d07b431cc..a81a70b0bd 100644 --- a/go/cmd/dolt/commands/engine/sql_print.go +++ b/go/cmd/dolt/commands/engine/sql_print.go @@ -21,6 +21,7 @@ import ( "time" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/row" @@ -201,7 +202,7 @@ func printOKResult(ctx *sql.Context, iter sql.RowIter, start time.Time) error { return err } - if okResult, ok := row[0].(sql.OkResult); ok { + if okResult, ok := row[0].(types.OkResult); ok { rowNoun := "row" if okResult.RowsAffected != 1 { rowNoun = "rows" @@ -219,7 +220,7 @@ func printOKResult(ctx *sql.Context, iter sql.RowIter, start time.Time) error { } func isOkResult(sch sql.Schema) bool { - return sch.Equals(sql.OkResultSchema) + return sch.Equals(types.OkResultSchema) } type verticalRowWriter struct { diff --git a/go/cmd/dolt/commands/engine/sqlengine.go b/go/cmd/dolt/commands/engine/sqlengine.go index a1a60640e1..5a9e556599 100644 --- a/go/cmd/dolt/commands/engine/sqlengine.go +++ b/go/cmd/dolt/commands/engine/sqlengine.go @@ -25,6 +25,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/analyzer" "github.com/dolthub/go-mysql-server/sql/mysql_db" + "github.com/dolthub/go-mysql-server/sql/sysvars" "github.com/dolthub/vitess/go/vt/sqlparser" "github.com/dolthub/dolt/go/cmd/dolt/cli" @@ -90,7 +91,7 @@ func NewSqlEngine( return nil, err } - config.ClusterController.ManageSystemVariables(sql.SystemVariables) + config.ClusterController.ManageSystemVariables(variables.SystemVariables) err = config.ClusterController.ApplyStandbyReplicationConfig(ctx, bThreads, mrEnv, dbs...) if err != nil { diff --git a/go/cmd/dolt/commands/engine/utils.go b/go/cmd/dolt/commands/engine/utils.go index d46f313400..316655eadb 100644 --- a/go/cmd/dolt/commands/engine/utils.go +++ b/go/cmd/dolt/commands/engine/utils.go @@ -19,6 +19,7 @@ import ( "fmt" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/sysvars" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" @@ -49,7 +50,7 @@ func CollectDBs(ctx context.Context, mrEnv *env.MultiRepoEnv, useBulkEditor bool return false, err } - if _, remote, ok := sql.SystemVariables.GetGlobal(dsess.ReadReplicaRemote); ok && remote != "" { + if _, remote, ok := variables.SystemVariables.GetGlobal(dsess.ReadReplicaRemote); ok && remote != "" { remoteName, ok := remote.(string) if !ok { return true, sql.ErrInvalidSystemVariableValue.New(remote) @@ -141,7 +142,7 @@ func newReplicaDatabase(ctx context.Context, name string, remoteName string, dEn } func getPushOnWriteHook(ctx context.Context, dEnv *env.DoltEnv) (*doltdb.PushOnWriteHook, error) { - _, val, ok := sql.SystemVariables.GetGlobal(dsess.ReplicateToRemote) + _, val, ok := variables.SystemVariables.GetGlobal(dsess.ReplicateToRemote) if !ok { return nil, sql.ErrUnknownSystemVariable.New(dsess.ReplicateToRemote) } else if val == "" { diff --git a/go/cmd/dolt/commands/schcmds/tags.go b/go/cmd/dolt/commands/schcmds/tags.go index 3af06b966f..9be57680a7 100644 --- a/go/cmd/dolt/commands/schcmds/tags.go +++ b/go/cmd/dolt/commands/schcmds/tags.go @@ -18,6 +18,7 @@ import ( "context" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/cmd/dolt/commands" @@ -91,9 +92,9 @@ func (cmd TagsCmd) Exec(ctx context.Context, commandStr string, args []string, d } var headerSchema = sql.Schema{ - {Name: "table", Type: sql.Text, Default: nil}, - {Name: "column", Type: sql.Text, Default: nil}, - {Name: "tag", Type: sql.Uint64, Default: nil}, + {Name: "table", Type: types.Text, Default: nil}, + {Name: "column", Type: types.Text, Default: nil}, + {Name: "tag", Type: types.Uint64, Default: nil}, } rows := make([]sql.Row, 0) diff --git a/go/cmd/dolt/commands/sql.go b/go/cmd/dolt/commands/sql.go index ab233ef8f2..7d81bf8d07 100644 --- a/go/cmd/dolt/commands/sql.go +++ b/go/cmd/dolt/commands/sql.go @@ -30,6 +30,7 @@ import ( "github.com/dolthub/go-mysql-server/sql/parse" "github.com/dolthub/go-mysql-server/sql/plan" "github.com/dolthub/go-mysql-server/sql/transform" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/ishell" "github.com/dolthub/vitess/go/vt/sqlparser" "github.com/dolthub/vitess/go/vt/vterrors" @@ -1560,7 +1561,7 @@ func mergeResultIntoStats(ctx *sql.Context, statement sqlparser.Statement, rowIt } else if err != nil { return err } else { - okResult := row[0].(sql.OkResult) + okResult := row[0].(types.OkResult) s.unflushedEdits += int(okResult.RowsAffected) s.unprintedEdits += int(okResult.RowsAffected) switch statement.(type) { diff --git a/go/cmd/dolt/commands/sql_test.go b/go/cmd/dolt/commands/sql_test.go index e81c9827f2..f0982c4ce1 100644 --- a/go/cmd/dolt/commands/sql_test.go +++ b/go/cmd/dolt/commands/sql_test.go @@ -19,7 +19,7 @@ import ( "fmt" "testing" - "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/sysvars" "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -564,8 +564,8 @@ func TestCommitHooksNoErrors(t *testing.T) { require.NoError(t, err) sqle.AddDoltSystemVariables() - sql.SystemVariables.SetGlobal(dsess.SkipReplicationErrors, true) - sql.SystemVariables.SetGlobal(dsess.ReplicateToRemote, "unknown") + variables.SystemVariables.SetGlobal(dsess.SkipReplicationErrors, true) + variables.SystemVariables.SetGlobal(dsess.ReplicateToRemote, "unknown") hooks, err := engine.GetCommitHooks(context.Background(), dEnv) assert.NoError(t, err) if len(hooks) < 1 { diff --git a/go/cmd/dolt/commands/sqlserver/server.go b/go/cmd/dolt/commands/sqlserver/server.go index 4c343d0e8b..6900864504 100644 --- a/go/cmd/dolt/commands/sqlserver/server.go +++ b/go/cmd/dolt/commands/sqlserver/server.go @@ -496,3 +496,4 @@ func checkForUnixSocket(config ServerConfig) (string, bool, error) { return "", false, nil } + \ No newline at end of file diff --git a/go/cmd/dolt/commands/sqlserver/sqlclient.go b/go/cmd/dolt/commands/sqlserver/sqlclient.go index 2e2dce1ec4..12e64b087d 100644 --- a/go/cmd/dolt/commands/sqlserver/sqlclient.go +++ b/go/cmd/dolt/commands/sqlserver/sqlclient.go @@ -26,6 +26,7 @@ import ( "github.com/abiosoft/readline" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/ishell" "github.com/fatih/color" mysqlDriver "github.com/go-sql-driver/mysql" @@ -390,7 +391,7 @@ func NewMysqlRowWrapper(rows *mysql.Rows) (*MysqlRowWrapper, error) { for i, colName := range colNames { schema[i] = &sql.Column{ Name: colName, - Type: sql.LongText, + Type: types.LongText, Nullable: true, } iRow[i] = &vRow[i] diff --git a/go/cmd/dolt/commands/sqlserver/sqlserver.go b/go/cmd/dolt/commands/sqlserver/sqlserver.go index 0a337ad7c6..7848ffb17a 100644 --- a/go/cmd/dolt/commands/sqlserver/sqlserver.go +++ b/go/cmd/dolt/commands/sqlserver/sqlserver.go @@ -22,7 +22,7 @@ import ( "strconv" "strings" - "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/sysvars" "github.com/fatih/color" "github.com/dolthub/dolt/go/cmd/dolt/cli" @@ -387,11 +387,11 @@ func getCommandLineServerConfig(dEnv *env.DoltEnv, apr *argparser.ArgParseResult serverConfig.withTimeout(timeout * 1000) - err = sql.SystemVariables.SetGlobal("net_read_timeout", timeout*1000) + err = variables.SystemVariables.SetGlobal("net_read_timeout", timeout*1000) if err != nil { return nil, fmt.Errorf("failed to set net_read_timeout. Error: %s", err.Error()) } - err = sql.SystemVariables.SetGlobal("net_write_timeout", timeout*1000) + err = variables.SystemVariables.SetGlobal("net_write_timeout", timeout*1000) if err != nil { return nil, fmt.Errorf("failed to set net_write_timeout. Error: %s", err.Error()) } @@ -431,7 +431,7 @@ func getCommandLineServerConfig(dEnv *env.DoltEnv, apr *argparser.ArgParseResult if maxConnections, ok := apr.GetInt(maxConnectionsFlag); ok { serverConfig.withMaxConnections(uint64(maxConnections)) - err := sql.SystemVariables.SetGlobal("max_connections", uint64(maxConnections)) + err := variables.SystemVariables.SetGlobal("max_connections", uint64(maxConnections)) if err != nil { return nil, fmt.Errorf("failed to set max_connections. Error: %s", err.Error()) } @@ -461,19 +461,19 @@ func getYAMLServerConfig(fs filesys.Filesys, path string) (ServerConfig, error) } if cfg.ListenerConfig.MaxConnections != nil { - err = sql.SystemVariables.SetGlobal("max_connections", *cfg.ListenerConfig.MaxConnections) + err = variables.SystemVariables.SetGlobal("max_connections", *cfg.ListenerConfig.MaxConnections) if err != nil { return nil, fmt.Errorf("Failed to set max_connections from yaml file '%s'. Error: %s", path, err.Error()) } } if cfg.ListenerConfig.ReadTimeoutMillis != nil { - err = sql.SystemVariables.SetGlobal("net_read_timeout", *cfg.ListenerConfig.ReadTimeoutMillis) + err = variables.SystemVariables.SetGlobal("net_read_timeout", *cfg.ListenerConfig.ReadTimeoutMillis) if err != nil { return nil, fmt.Errorf("Failed to set net_read_timeout from yaml file '%s'. Error: %s", path, err.Error()) } } if cfg.ListenerConfig.WriteTimeoutMillis != nil { - err = sql.SystemVariables.SetGlobal("net_write_timeout", *cfg.ListenerConfig.WriteTimeoutMillis) + err = variables.SystemVariables.SetGlobal("net_write_timeout", *cfg.ListenerConfig.WriteTimeoutMillis) if err != nil { return nil, fmt.Errorf("Failed to set net_write_timeout from yaml file '%s'. Error: %s", path, err.Error()) } diff --git a/go/cmd/dolt/commands/tblcmds/import.go b/go/cmd/dolt/commands/tblcmds/import.go index 769136429f..f976af09ae 100644 --- a/go/cmd/dolt/commands/tblcmds/import.go +++ b/go/cmd/dolt/commands/tblcmds/import.go @@ -25,6 +25,7 @@ import ( "sync/atomic" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/fatih/color" "golang.org/x/sync/errgroup" @@ -737,7 +738,7 @@ func NameAndTypeTransform(row sql.Row, rowOperationSchema sql.PrimaryKeySchema, // Bit types need additional verification due to the differing values they can take on. "4", "0x04", b'100' should // be interpreted in the correct manner. - if _, ok := col.Type.(sql.BitType); ok { + if _, ok := col.Type.(types2.BitType); ok { colAsString, ok := row[i].(string) if !ok { return nil, fmt.Errorf("error: column value should be of type string") @@ -774,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 sql.StringType: + case types2.StringType: default: row[i] = emptyStringToNil(row[i]) } diff --git a/go/go.mod b/go/go.mod index cbdc19280e..c43fd5d79f 100644 --- a/go/go.mod +++ b/go/go.mod @@ -139,4 +139,6 @@ replace ( github.com/oliveagle/jsonpath => github.com/dolthub/jsonpath v0.0.0-20210609232853-d49537a30474 ) +replace github.com/dolthub/go-mysql-server => ../../go-mysql-server + go 1.19 diff --git a/go/libraries/doltcore/doltdb/table.go b/go/libraries/doltcore/doltdb/table.go index 27edd51aee..bb30110811 100644 --- a/go/libraries/doltcore/doltdb/table.go +++ b/go/libraries/doltcore/doltdb/table.go @@ -23,6 +23,7 @@ import ( "unicode" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/conflict" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb/durable" @@ -354,7 +355,7 @@ func (t *Table) GetConstraintViolationsSchema(ctx context.Context) (schema.Schem } typeType, err := typeinfo.FromSqlType( - sql.MustCreateEnumType([]string{"foreign key", "unique index", "check constraint"}, sql.Collation_Default)) + types2.MustCreateEnumType([]string{"foreign key", "unique index", "check constraint"}, sql.Collation_Default)) if err != nil { return nil, err } diff --git a/go/libraries/doltcore/merge/merge_rows.go b/go/libraries/doltcore/merge/merge_rows.go index 3155ff3227..6183ba9fbb 100644 --- a/go/libraries/doltcore/merge/merge_rows.go +++ b/go/libraries/doltcore/merge/merge_rows.go @@ -20,7 +20,7 @@ import ( "fmt" "strings" - "github.com/dolthub/go-mysql-server/sql" + 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" @@ -408,8 +408,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().(sql.StringType) - targetStr, ok2 := targetSch.GetNonPKCols().GetByIndex(i).TypeInfo.ToSqlType().(sql.StringType) + existingStr, ok1 := existingSch.GetNonPKCols().GetByIndex(i).TypeInfo.ToSqlType().(types2.StringType) + targetStr, ok2 := targetSch.GetNonPKCols().GetByIndex(i).TypeInfo.ToSqlType().(types2.StringType) if ok1 && ok2 && !existingStr.Collation().Equals(targetStr.Collation()) { return false, nil diff --git a/go/libraries/doltcore/merge/violations_fk.go b/go/libraries/doltcore/merge/violations_fk.go index 74692c7de1..d380d6669f 100644 --- a/go/libraries/doltcore/merge/violations_fk.go +++ b/go/libraries/doltcore/merge/violations_fk.go @@ -21,7 +21,7 @@ import ( "io" "time" - "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/diff" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" @@ -625,7 +625,7 @@ func jsonDataToNomsValue(ctx context.Context, vrw types.ValueReadWriter, data [] if err := json.Unmarshal(data, &doc); err != nil { return types.JSON{}, err } - sqlDoc := sql.JSONDocument{Val: doc} + sqlDoc := types2.JSONDocument{Val: doc} nomsJson, err := json2.NomsJSONFromJSONValue(ctx, vrw, sqlDoc) if err != nil { return types.JSON{}, err diff --git a/go/libraries/doltcore/merge/violations_fk_prolly.go b/go/libraries/doltcore/merge/violations_fk_prolly.go index e213c13ce0..4f026660e2 100644 --- a/go/libraries/doltcore/merge/violations_fk_prolly.go +++ b/go/libraries/doltcore/merge/violations_fk_prolly.go @@ -22,6 +22,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb/durable" @@ -332,12 +333,12 @@ type FkCVMeta struct { Table string `json:"Table"` } -func (m FkCVMeta) Unmarshall(ctx *sql.Context) (val sql.JSONDocument, err error) { - return sql.JSONDocument{Val: m}, nil +func (m FkCVMeta) Unmarshall(ctx *sql.Context) (val types.JSONDocument, err error) { + return types.JSONDocument{Val: m}, nil } -func (m FkCVMeta) Compare(ctx *sql.Context, v sql.JSONValue) (cmp int, err error) { - ours := sql.JSONDocument{Val: m} +func (m FkCVMeta) Compare(ctx *sql.Context, v types.JSONValue) (cmp int, err error) { + ours := types.JSONDocument{Val: m} return ours.Compare(ctx, v) } @@ -345,7 +346,7 @@ func (m FkCVMeta) ToString(ctx *sql.Context) (string, error) { return m.PrettyPrint(), nil } -var _ sql.JSONValue = FkCVMeta{} +var _ types.JSONValue = FkCVMeta{} // PrettyPrint is a custom pretty print function to match the old format's // output which includes additional whitespace between keys, values, and array elements. diff --git a/go/libraries/doltcore/merge/violations_unique_prolly.go b/go/libraries/doltcore/merge/violations_unique_prolly.go index de946e5e15..e3bcd3fef9 100644 --- a/go/libraries/doltcore/merge/violations_unique_prolly.go +++ b/go/libraries/doltcore/merge/violations_unique_prolly.go @@ -22,6 +22,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/schema" @@ -120,12 +121,12 @@ type UniqCVMeta struct { Name string `json:"Name"` } -func (m UniqCVMeta) Unmarshall(ctx *sql.Context) (val sql.JSONDocument, err error) { - return sql.JSONDocument{Val: m}, nil +func (m UniqCVMeta) Unmarshall(ctx *sql.Context) (val types.JSONDocument, err error) { + return types.JSONDocument{Val: m}, nil } -func (m UniqCVMeta) Compare(ctx *sql.Context, v sql.JSONValue) (cmp int, err error) { - ours := sql.JSONDocument{Val: m} +func (m UniqCVMeta) Compare(ctx *sql.Context, v types.JSONValue) (cmp int, err error) { + ours := types.JSONDocument{Val: m} return ours.Compare(ctx, v) } diff --git a/go/libraries/doltcore/migrate/transform.go b/go/libraries/doltcore/migrate/transform.go index 9f537accc2..c3ebefaa5d 100644 --- a/go/libraries/doltcore/migrate/transform.go +++ b/go/libraries/doltcore/migrate/transform.go @@ -19,6 +19,7 @@ import ( "fmt" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/vt/proto/query" "golang.org/x/sync/errgroup" @@ -501,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().(sql.StringType) + st, ok := c.TypeInfo.ToSqlType().(types2.StringType) if !ok { continue } @@ -510,9 +511,9 @@ func migrateSchema(ctx context.Context, tableName string, existing schema.Schema var err error switch st.Type() { case query.Type_CHAR, query.Type_VARCHAR, query.Type_TEXT: - st, err = sql.CreateString(st.Type(), st.Length(), sql.Collation_utf8mb4_0900_bin) + st, err = types2.CreateString(st.Type(), st.Length(), sql.Collation_utf8mb4_0900_bin) case query.Type_BINARY, query.Type_VARBINARY, query.Type_BLOB: - st, err = sql.CreateString(st.Type(), st.Length(), sql.Collation_binary) + st, err = types2.CreateString(st.Type(), st.Length(), sql.Collation_binary) } if err != nil { return nil, err diff --git a/go/libraries/doltcore/migrate/validation.go b/go/libraries/doltcore/migrate/validation.go index 713ad15c98..962f87bb5f 100644 --- a/go/libraries/doltcore/migrate/validation.go +++ b/go/libraries/doltcore/migrate/validation.go @@ -24,6 +24,7 @@ import ( "unicode" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/vt/proto/query" "golang.org/x/sync/errgroup" @@ -184,13 +185,13 @@ func equalRows(old, new sql.Row, sch sql.Schema) (bool, error) { // for precision changes between formats if _, ok := old[i].(time.Time); ok { var o, n interface{} - if o, err = sql.Int64.Convert(old[i]); err != nil { + if o, err = types2.Int64.Convert(old[i]); err != nil { return false, err } - if n, err = sql.Int64.Convert(new[i]); err != nil { + if n, err = types2.Int64.Convert(new[i]); err != nil { return false, err } - if cmp, err = sql.Int64.Compare(o, n); err != nil { + if cmp, err = types2.Int64.Compare(o, n); err != nil { return false, err } } else { diff --git a/go/libraries/doltcore/schema/encoding/schema_marshaling_test.go b/go/libraries/doltcore/schema/encoding/schema_marshaling_test.go index 6d6ea420b7..575b462cfe 100644 --- a/go/libraries/doltcore/schema/encoding/schema_marshaling_test.go +++ b/go/libraries/doltcore/schema/encoding/schema_marshaling_test.go @@ -23,6 +23,7 @@ import ( "testing" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -93,41 +94,41 @@ func getSqlTypes() []sql.Type { //TODO: determine the storage format for TINYBLOB //TODO: determine the storage format for VARBINARY return []sql.Type{ - sql.Int64, //BIGINT - sql.Uint64, //BIGINT UNSIGNED + types2.Int64, //BIGINT + types2.Uint64, //BIGINT UNSIGNED //sql.MustCreateBinary(sqltypes.Binary, 10), //BINARY(10) - sql.MustCreateBitType(10), //BIT(10) + types2.MustCreateBitType(10), //BIT(10) //sql.Blob, //BLOB - sql.Boolean, //BOOLEAN - sql.MustCreateStringWithDefaults(sqltypes.Char, 10), //CHAR(10) - sql.Date, //DATE - sql.Datetime, //DATETIME - sql.MustCreateColumnDecimalType(9, 5), //DECIMAL(9, 5) - sql.Float64, //DOUBLE - sql.MustCreateEnumType([]string{"a", "b", "c"}, sql.Collation_Default), //ENUM('a','b','c') - sql.Float32, //FLOAT - sql.Int32, //INT - sql.Uint32, //INT UNSIGNED + types2.Boolean, //BOOLEAN + types2.MustCreateStringWithDefaults(sqltypes.Char, 10), //CHAR(10) + types2.Date, //DATE + types2.Datetime, //DATETIME + types2.MustCreateColumnDecimalType(9, 5), //DECIMAL(9, 5) + types2.Float64, //DOUBLE + types2.MustCreateEnumType([]string{"a", "b", "c"}, sql.Collation_Default), //ENUM('a','b','c') + types2.Float32, //FLOAT + types2.Int32, //INT + types2.Uint32, //INT UNSIGNED //sql.LongBlob, //LONGBLOB - sql.LongText, //LONGTEXT + types2.LongText, //LONGTEXT //sql.MediumBlob, //MEDIUMBLOB - sql.Int24, //MEDIUMINT - sql.Uint24, //MEDIUMINT UNSIGNED - sql.MediumText, //MEDIUMTEXT - sql.MustCreateSetType([]string{"a", "b", "c"}, sql.Collation_Default), //SET('a','b','c') - sql.Int16, //SMALLINT - sql.Uint16, //SMALLINT UNSIGNED - sql.Text, //TEXT - sql.Time, //TIME - sql.Timestamp, //TIMESTAMP + types2.Int24, //MEDIUMINT + types2.Uint24, //MEDIUMINT UNSIGNED + types2.MediumText, //MEDIUMTEXT + types2.MustCreateSetType([]string{"a", "b", "c"}, sql.Collation_Default), //SET('a','b','c') + types2.Int16, //SMALLINT + types2.Uint16, //SMALLINT UNSIGNED + types2.Text, //TEXT + types2.Time, //TIME + types2.Timestamp, //TIMESTAMP //sql.TinyBlob, //TINYBLOB - sql.Int8, //TINYINT - sql.Uint8, //TINYINT UNSIGNED - sql.TinyText, //TINYTEXT + types2.Int8, //TINYINT + types2.Uint8, //TINYINT UNSIGNED + types2.TinyText, //TINYTEXT //sql.MustCreateBinary(sqltypes.VarBinary, 10), //VARBINARY(10) - sql.MustCreateStringWithDefaults(sqltypes.VarChar, 10), //VARCHAR(10) - sql.MustCreateString(sqltypes.VarChar, 10, sql.Collation_utf8mb3_bin), //VARCHAR(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin - sql.Year, //YEAR + types2.MustCreateStringWithDefaults(sqltypes.VarChar, 10), //VARCHAR(10) + types2.MustCreateString(sqltypes.VarChar, 10, sql.Collation_utf8mb3_bin), //VARCHAR(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin + types2.Year, //YEAR } } diff --git a/go/libraries/doltcore/schema/schema_impl.go b/go/libraries/doltcore/schema/schema_impl.go index 5f8ddc7c8f..fb2f8dbc6a 100644 --- a/go/libraries/doltcore/schema/schema_impl.go +++ b/go/libraries/doltcore/schema/schema_impl.go @@ -21,6 +21,7 @@ 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" @@ -438,7 +439,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.(sql.StringType).Collation()) + collations = append(collations, sqlType.(types2.StringType).Collation()) } else { collations = append(collations, sql.Collation_Unspecified) } @@ -475,7 +476,7 @@ func (si *schemaImpl) GetValueDescriptor() val.TupleDesc { }) if queryType == query.Type_CHAR || queryType == query.Type_VARCHAR { useCollations = true - collations = append(collations, sqlType.(sql.StringType).Collation()) + collations = append(collations, sqlType.(types2.StringType).Collation()) } else { collations = append(collations, sql.Collation_Unspecified) } diff --git a/go/libraries/doltcore/schema/typeinfo/bit.go b/go/libraries/doltcore/schema/typeinfo/bit.go index e9f882a24f..81b67729ea 100644 --- a/go/libraries/doltcore/schema/typeinfo/bit.go +++ b/go/libraries/doltcore/schema/typeinfo/bit.go @@ -24,6 +24,7 @@ import ( "unicode/utf8" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/dolthub/dolt/go/store/types" @@ -36,12 +37,12 @@ const ( // This is a dolt implementation of the MySQL type Bit, thus most of the functionality // within is directly reliant on the go-mysql-server implementation. type bitType struct { - sqlBitType sql.BitType + sqlBitType types2.BitType } var _ TypeInfo = (*bitType)(nil) -var PseudoBoolType TypeInfo = &bitType{sql.MustCreateBitType(1)} +var PseudoBoolType TypeInfo = &bitType{types2.MustCreateBitType(1)} func CreateBitTypeFromParams(params map[string]string) (TypeInfo, error) { if bitStr, ok := params[bitTypeParam_Bits]; ok { @@ -49,7 +50,7 @@ func CreateBitTypeFromParams(params map[string]string) (TypeInfo, error) { if err != nil { return nil, err } - sqlBitType, err := sql.CreateBitType(uint8(bitUint)) + sqlBitType, err := types2.CreateBitType(uint8(bitUint)) if err != nil { return nil, err } @@ -162,7 +163,7 @@ func (ti *bitType) NomsKind() types.NomsKind { // Promote implements TypeInfo interface. func (ti *bitType) Promote() TypeInfo { - return &bitType{ti.sqlBitType.Promote().(sql.BitType)} + return &bitType{ti.sqlBitType.Promote().(types2.BitType)} } // String implements TypeInfo interface. @@ -198,7 +199,7 @@ func bitTypeConverter(ctx context.Context, src *bitType, destTi TypeInfo) (tc Ty return nil, fmt.Errorf("unexpected type converting bit to %s: %T", strings.ToLower(dest.String()), v) } if val == 0 { - return types.Timestamp(sql.Datetime.Zero().(time.Time)), nil + return types.Timestamp(types2.Datetime.Zero().(time.Time)), nil } return nil, fmt.Errorf("invalid %s value: %d", strings.ToLower(dest.String()), uint64(val)) }, true, nil diff --git a/go/libraries/doltcore/schema/typeinfo/blobstring.go b/go/libraries/doltcore/schema/typeinfo/blobstring.go index c866a331e7..ec95eee1e7 100644 --- a/go/libraries/doltcore/schema/typeinfo/blobstring.go +++ b/go/libraries/doltcore/schema/typeinfo/blobstring.go @@ -23,6 +23,7 @@ import ( "unsafe" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/dolthub/dolt/go/store/types" @@ -38,16 +39,16 @@ const ( // repositories that were made before the introduction of blobStringType will still use varStringType for existing // columns. type blobStringType struct { - sqlStringType sql.StringType + sqlStringType types2.StringType } var _ TypeInfo = (*blobStringType)(nil) var ( - TinyTextType TypeInfo = &blobStringType{sqlStringType: sql.TinyText} - TextType TypeInfo = &blobStringType{sqlStringType: sql.Text} - MediumTextType TypeInfo = &blobStringType{sqlStringType: sql.MediumText} - LongTextType TypeInfo = &blobStringType{sqlStringType: sql.LongText} + TinyTextType TypeInfo = &blobStringType{sqlStringType: types2.TinyText} + TextType TypeInfo = &blobStringType{sqlStringType: types2.Text} + MediumTextType TypeInfo = &blobStringType{sqlStringType: types2.MediumText} + LongTextType TypeInfo = &blobStringType{sqlStringType: types2.LongText} ) func CreateBlobStringTypeFromParams(params map[string]string) (TypeInfo, error) { @@ -71,7 +72,7 @@ func CreateBlobStringTypeFromParams(params map[string]string) (TypeInfo, error) } else { return nil, fmt.Errorf(`create blobstring type info is missing param "%v"`, blobStringTypeParam_Length) } - sqlType, err := sql.CreateString(sqltypes.Text, length, collation) + sqlType, err := types2.CreateString(sqltypes.Text, length, collation) if err != nil { return nil, err } @@ -82,7 +83,7 @@ func CreateBlobStringTypeFromParams(params map[string]string) (TypeInfo, error) func (ti *blobStringType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { if val, ok := v.(types.Blob); ok { b, err := fromBlob(val) - if sql.IsBinaryType(ti.sqlStringType) { + if types2.IsBinaryType(ti.sqlStringType) { return b, err } return string(b), err @@ -103,7 +104,7 @@ func (ti *blobStringType) ReadFrom(_ *types.NomsBinFormat, reader types.CodecRea return nil, err } b, err := fromBlob(val) - if sql.IsBinaryType(ti.sqlStringType) { + if types2.IsBinaryType(ti.sqlStringType) { return b, err } return string(b), err @@ -191,7 +192,7 @@ func (ti *blobStringType) NomsKind() types.NomsKind { // Promote implements TypeInfo interface. func (ti *blobStringType) Promote() TypeInfo { - return &blobStringType{ti.sqlStringType.Promote().(sql.StringType)} + return &blobStringType{ti.sqlStringType.Promote().(types2.StringType)} } // String implements TypeInfo interface. diff --git a/go/libraries/doltcore/schema/typeinfo/blobstring_test.go b/go/libraries/doltcore/schema/typeinfo/blobstring_test.go index 6c0f299301..725a69f900 100644 --- a/go/libraries/doltcore/schema/typeinfo/blobstring_test.go +++ b/go/libraries/doltcore/schema/typeinfo/blobstring_test.go @@ -21,6 +21,7 @@ import ( "time" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -47,7 +48,7 @@ func TestBlobStringConvertNomsValueToValue(t *testing.T) { false, }, { - &blobStringType{sql.CreateLongText(sql.Collation_Default)}, + &blobStringType{types2.CreateLongText(sql.Collation_Default)}, mustBlobString(t, " This is a sentence. "), " This is a sentence. ", false, @@ -87,7 +88,7 @@ func TestBlobStringConvertValueToNomsValue(t *testing.T) { false, }, { - &blobStringType{sql.CreateLongText(sql.Collation_Default)}, + &blobStringType{types2.CreateLongText(sql.Collation_Default)}, float32(3724.75), mustBlobString(t, "3724.75"), false, @@ -134,7 +135,7 @@ func TestBlobStringFormatValue(t *testing.T) { false, }, { - &blobStringType{sql.CreateLongText(sql.Collation_Default)}, + &blobStringType{types2.CreateLongText(sql.Collation_Default)}, mustBlobString(t, " This is a sentence. "), " This is a sentence. ", false, @@ -174,7 +175,7 @@ func TestBlobStringParseValue(t *testing.T) { false, }, { - &blobStringType{sql.CreateLongText(sql.Collation_Default)}, + &blobStringType{types2.CreateLongText(sql.Collation_Default)}, " This is a sentence. ", mustBlobString(t, " This is a sentence. "), false, diff --git a/go/libraries/doltcore/schema/typeinfo/bool.go b/go/libraries/doltcore/schema/typeinfo/bool.go index 0f2bf8f33a..6434a68ea0 100644 --- a/go/libraries/doltcore/schema/typeinfo/bool.go +++ b/go/libraries/doltcore/schema/typeinfo/bool.go @@ -21,17 +21,18 @@ import ( "strconv" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/types" ) type boolType struct { - sqlBitType sql.BitType + sqlBitType types2.BitType } var _ TypeInfo = (*boolType)(nil) -var BoolType TypeInfo = &boolType{sql.MustCreateBitType(1)} +var BoolType TypeInfo = &boolType{types2.MustCreateBitType(1)} // ConvertNomsValueToValue implements TypeInfo interface. func (ti *boolType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { @@ -173,7 +174,7 @@ func (ti *boolType) String() string { // ToSqlType implements TypeInfo interface. func (ti *boolType) ToSqlType() sql.Type { - return sql.Boolean + return types2.Boolean } // boolTypeConverter is an internal function for GetTypeConverter that handles the specific type as the source TypeInfo. diff --git a/go/libraries/doltcore/schema/typeinfo/common_test.go b/go/libraries/doltcore/schema/typeinfo/common_test.go index fa05e1de06..cc2bc82f40 100644 --- a/go/libraries/doltcore/schema/typeinfo/common_test.go +++ b/go/libraries/doltcore/schema/typeinfo/common_test.go @@ -23,6 +23,7 @@ import ( "testing" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/stretchr/testify/require" @@ -50,8 +51,8 @@ func generateBitType(t *testing.T, bits uint8) *bitType { func generateDecimalTypes(t *testing.T, numOfTypes uint16) []TypeInfo { var res []TypeInfo - scaleMult := float64(sql.DecimalTypeMaxScale) / sql.DecimalTypeMaxPrecision - loop(t, 1, sql.DecimalTypeMaxPrecision, numOfTypes, func(i int64) { + scaleMult := float64(types2.DecimalTypeMaxScale) / types2.DecimalTypeMaxPrecision + loop(t, 1, types2.DecimalTypeMaxPrecision, numOfTypes, func(i int64) { if i%9 <= 5 { res = append(res, generateDecimalType(t, i, int64(float64(i)*scaleMult))) } else { @@ -81,7 +82,7 @@ func generateEnumTypes(t *testing.T, numOfTypes int64) []TypeInfo { } func generateEnumType(t *testing.T, numOfElements int) *enumType { - require.True(t, numOfElements >= 1 && numOfElements <= sql.EnumTypeMaxElements) + require.True(t, numOfElements >= 1 && numOfElements <= types2.EnumTypeMaxElements) vals := make([]string, numOfElements) str := make([]byte, 4) alphabet := "abcdefghijklmnopqrstuvwxyz" @@ -94,7 +95,7 @@ func generateEnumType(t *testing.T, numOfElements int) *enumType { str[3] = alphabet[i%len(alphabet)] vals[i] = string(str) } - return &enumType{sql.MustCreateEnumType(vals, sql.Collation_Default)} + return &enumType{types2.MustCreateEnumType(vals, sql.Collation_Default)} } func generateSetTypes(t *testing.T, numOfTypes int64) []TypeInfo { @@ -106,14 +107,14 @@ func generateSetTypes(t *testing.T, numOfTypes int64) []TypeInfo { } func generateSetType(t *testing.T, numOfElements int) *setType { - require.True(t, numOfElements >= 1 && numOfElements <= sql.SetTypeMaxElements) + require.True(t, numOfElements >= 1 && numOfElements <= types2.SetTypeMaxElements) vals := make([]string, numOfElements) alphabet := "abcdefghijklmnopqrstuvwxyz" lenAlphabet := len(alphabet) for i := 0; i < numOfElements; i++ { vals[i] = string([]byte{alphabet[(i/lenAlphabet)%lenAlphabet], alphabet[i%lenAlphabet]}) } - return &setType{sql.MustCreateSetType(vals, sql.Collation_Default)} + return &setType{types2.MustCreateSetType(vals, sql.Collation_Default)} } func generateInlineBlobTypes(t *testing.T, numOfTypes uint16) []TypeInfo { @@ -131,12 +132,12 @@ func generateInlineBlobTypes(t *testing.T, numOfTypes uint16) []TypeInfo { func generateInlineBlobType(t *testing.T, length int64, pad bool) *inlineBlobType { require.True(t, length > 0) if pad { - t, err := sql.CreateBinary(sqltypes.Binary, length) + t, err := types2.CreateBinary(sqltypes.Binary, length) if err == nil { return &inlineBlobType{t} } } - return &inlineBlobType{sql.MustCreateBinary(sqltypes.VarBinary, length)} + return &inlineBlobType{types2.MustCreateBinary(sqltypes.VarBinary, length)} } func generateVarStringTypes(t *testing.T, numOfTypes uint16) []TypeInfo { @@ -154,17 +155,17 @@ func generateVarStringTypes(t *testing.T, numOfTypes uint16) []TypeInfo { func generateVarStringType(t *testing.T, length int64, rts bool) *varStringType { require.True(t, length > 0) if rts { - t, err := sql.CreateStringWithDefaults(sqltypes.Char, length) + t, err := types2.CreateStringWithDefaults(sqltypes.Char, length) if err == nil { return &varStringType{t} } } - return &varStringType{sql.MustCreateStringWithDefaults(sqltypes.VarChar, length)} + return &varStringType{types2.MustCreateStringWithDefaults(sqltypes.VarChar, length)} } func generateBlobStringType(t *testing.T, length int64) *blobStringType { require.True(t, length > 0) - return &blobStringType{sql.MustCreateStringWithDefaults(sqltypes.Text, length)} + return &blobStringType{types2.MustCreateStringWithDefaults(sqltypes.Text, length)} } func mustBlobString(t *testing.T, str string) types.Blob { diff --git a/go/libraries/doltcore/schema/typeinfo/datetime.go b/go/libraries/doltcore/schema/typeinfo/datetime.go index fc4ae2c106..63800965f5 100644 --- a/go/libraries/doltcore/schema/typeinfo/datetime.go +++ b/go/libraries/doltcore/schema/typeinfo/datetime.go @@ -20,6 +20,7 @@ import ( "time" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/dolthub/dolt/go/store/types" @@ -38,9 +39,9 @@ type datetimeType struct { var _ TypeInfo = (*datetimeType)(nil) var ( - DateType = &datetimeType{sql.Date} - DatetimeType = &datetimeType{sql.Datetime} - TimestampType = &datetimeType{sql.Timestamp} + DateType = &datetimeType{types2.Date} + DatetimeType = &datetimeType{types2.Datetime} + TimestampType = &datetimeType{types2.Timestamp} ) func CreateDatetimeTypeFromParams(params map[string]string) (TypeInfo, error) { diff --git a/go/libraries/doltcore/schema/typeinfo/decimal.go b/go/libraries/doltcore/schema/typeinfo/decimal.go index e194b9c70c..43eb2bb8cf 100644 --- a/go/libraries/doltcore/schema/typeinfo/decimal.go +++ b/go/libraries/doltcore/schema/typeinfo/decimal.go @@ -20,6 +20,7 @@ import ( "strconv" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/shopspring/decimal" "github.com/dolthub/dolt/go/store/types" @@ -59,7 +60,7 @@ func CreateDecimalTypeFromParams(params map[string]string) (TypeInfo, error) { } else { return nil, fmt.Errorf(`create decimal type info is missing param "%v"`, decimalTypeParam_Scale) } - sqlDecimalType, err := sql.CreateColumnDecimalType(precision, scale) + sqlDecimalType, err := types2.CreateColumnDecimalType(precision, scale) if err != nil { return nil, err } @@ -232,7 +233,7 @@ func decimalTypeConverter(ctx context.Context, src *decimalType, destTi TypeInfo if !ok { return nil, fmt.Errorf("unexpected type converting decimal to enum: %T", v) } - uintVal, err := sql.Uint64.Convert(decimal.Decimal(val)) + uintVal, err := types2.Uint64.Convert(decimal.Decimal(val)) if err != nil { return nil, err } @@ -328,7 +329,7 @@ func decimalTypeConverter(ctx context.Context, src *decimalType, destTi TypeInfo if !ok { return nil, fmt.Errorf("unexpected type converting decimal to year: %T", v) } - intVal, err := sql.Int64.Convert(decimal.Decimal(val)) + intVal, err := types2.Int64.Convert(decimal.Decimal(val)) if err != nil { return nil, err } diff --git a/go/libraries/doltcore/schema/typeinfo/decimal_test.go b/go/libraries/doltcore/schema/typeinfo/decimal_test.go index 0104aeeb44..a66fb60f89 100644 --- a/go/libraries/doltcore/schema/typeinfo/decimal_test.go +++ b/go/libraries/doltcore/schema/typeinfo/decimal_test.go @@ -22,6 +22,7 @@ import ( "time" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/shopspring/decimal" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -343,7 +344,7 @@ func TestDecimalMarshal(t *testing.T) { for _, test := range tests { t.Run(fmt.Sprintf("%v %v %v", test.precision, test.scale, test.val), func(t *testing.T) { - typ := &decimalType{sql.MustCreateDecimalType(test.precision, test.scale)} + typ := &decimalType{types2.MustCreateDecimalType(test.precision, test.scale)} vrw := types.NewMemoryValueStore() val, err := typ.ConvertValueToNomsValue(context.Background(), vrw, test.val) if test.expectedErr { diff --git a/go/libraries/doltcore/schema/typeinfo/enum.go b/go/libraries/doltcore/schema/typeinfo/enum.go index e7ceb8d04a..8c3889938f 100644 --- a/go/libraries/doltcore/schema/typeinfo/enum.go +++ b/go/libraries/doltcore/schema/typeinfo/enum.go @@ -21,6 +21,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/types" ) @@ -59,7 +60,7 @@ func CreateEnumTypeFromParams(params map[string]string) (TypeInfo, error) { } else { return nil, fmt.Errorf(`create enum type info is missing param "%v"`, enumTypeParam_Values) } - sqlEnumType, err := sql.CreateEnumType(values, collation) + sqlEnumType, err := types2.CreateEnumType(values, collation) if err != nil { return nil, err } diff --git a/go/libraries/doltcore/schema/typeinfo/float.go b/go/libraries/doltcore/schema/typeinfo/float.go index 30c21062f1..092ca8e033 100644 --- a/go/libraries/doltcore/schema/typeinfo/float.go +++ b/go/libraries/doltcore/schema/typeinfo/float.go @@ -22,6 +22,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/dolthub/dolt/go/store/types" @@ -41,8 +42,8 @@ type floatType struct { var _ TypeInfo = (*floatType)(nil) var ( - Float32Type = &floatType{sql.Float32} - Float64Type = &floatType{sql.Float64} + Float32Type = &floatType{types2.Float32} + Float64Type = &floatType{types2.Float64} ) func CreateFloatTypeFromParams(params map[string]string) (TypeInfo, error) { @@ -63,9 +64,9 @@ func CreateFloatTypeFromParams(params map[string]string) (TypeInfo, error) { func (ti *floatType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { if val, ok := v.(types.Float); ok { switch ti.sqlFloatType { - case sql.Float32: + case types2.Float32: return float32(val), nil - case sql.Float64: + case types2.Float64: return float64(val), nil } } @@ -82,9 +83,9 @@ func (ti *floatType) ReadFrom(nbf *types.NomsBinFormat, reader types.CodecReader case types.FloatKind: f := reader.ReadFloat(nbf) switch ti.sqlFloatType { - case sql.Float32: + case types2.Float32: return float32(f), nil - case sql.Float64: + case types2.Float64: return f, nil } case types.NullKind: @@ -219,7 +220,7 @@ func floatTypeConverter(ctx context.Context, src *floatType, destTi TypeInfo) (t return nil, fmt.Errorf("unexpected type converting float to enum: %T", v) } fltVal := floatTypeRoundToZero(float64(val)) - intVal, err := sql.Int64.Convert(fltVal) + intVal, err := types2.Int64.Convert(fltVal) if err != nil { return nil, err } diff --git a/go/libraries/doltcore/schema/typeinfo/geometry.go b/go/libraries/doltcore/schema/typeinfo/geometry.go index f7c9029eb8..2199a82e34 100644 --- a/go/libraries/doltcore/schema/typeinfo/geometry.go +++ b/go/libraries/doltcore/schema/typeinfo/geometry.go @@ -20,6 +20,7 @@ import ( "strconv" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/types" ) @@ -27,12 +28,12 @@ import ( // This is a dolt implementation of the MySQL type Geometry, thus most of the functionality // within is directly reliant on the go-mysql-server implementation. type geometryType struct { - sqlGeometryType sql.GeometryType // References the corresponding GeometryType in GMS + sqlGeometryType types2.GeometryType // References the corresponding GeometryType in GMS } var _ TypeInfo = (*geometryType)(nil) -var GeometryType = &geometryType{sql.GeometryType{}} +var GeometryType = &geometryType{types2.GeometryType{}} // ConvertNomsValueToValue implements TypeInfo interface. func (ti *geometryType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { @@ -318,5 +319,5 @@ func CreateGeometryTypeFromParams(params map[string]string) (TypeInfo, error) { } } - return &geometryType{sqlGeometryType: sql.GeometryType{SRID: uint32(sridVal), DefinedSRID: def}}, nil + return &geometryType{sqlGeometryType: types2.GeometryType{SRID: uint32(sridVal), DefinedSRID: def}}, nil } diff --git a/go/libraries/doltcore/schema/typeinfo/geometry_collection.go b/go/libraries/doltcore/schema/typeinfo/geometry_collection.go index 3c25c99309..80cb1c807a 100644 --- a/go/libraries/doltcore/schema/typeinfo/geometry_collection.go +++ b/go/libraries/doltcore/schema/typeinfo/geometry_collection.go @@ -20,6 +20,7 @@ import ( "strconv" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/types" ) @@ -27,12 +28,12 @@ import ( // This is a dolt implementation of the MySQL type Point, thus most of the functionality // within is directly reliant on the go-mysql-server implementation. type geomcollType struct { - sqlGeomCollType sql.GeomCollType + sqlGeomCollType types2.GeomCollType } var _ TypeInfo = (*geomcollType)(nil) -var GeomCollType = &geomcollType{sql.GeomCollType{}} +var GeomCollType = &geomcollType{types2.GeomCollType{}} // ConvertNomsValueToValue implements TypeInfo interface. func (ti *geomcollType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { @@ -78,7 +79,7 @@ func (ti *geomcollType) ConvertValueToNomsValue(ctx context.Context, vrw types.V return nil, err } - return types.ConvertSQLGeomCollToTypesGeomColl(geomColl.(sql.GeomColl)), nil + return types.ConvertSQLGeomCollToTypesGeomColl(geomColl.(types2.GeomColl)), nil } // Equals implements TypeInfo interface. @@ -135,7 +136,7 @@ func (ti *geomcollType) NomsKind() types.NomsKind { // Promote implements TypeInfo interface. func (ti *geomcollType) Promote() TypeInfo { - return &geomcollType{ti.sqlGeomCollType.Promote().(sql.GeomCollType)} + return &geomcollType{ti.sqlGeomCollType.Promote().(types2.GeomCollType)} } // String implements TypeInfo interface. @@ -227,5 +228,5 @@ func CreateGeomCollTypeFromParams(params map[string]string) (TypeInfo, error) { } } - return &geomcollType{sqlGeomCollType: sql.GeomCollType{SRID: uint32(sridVal), DefinedSRID: def}}, nil + return &geomcollType{sqlGeomCollType: types2.GeomCollType{SRID: uint32(sridVal), DefinedSRID: def}}, nil } diff --git a/go/libraries/doltcore/schema/typeinfo/inlineblob.go b/go/libraries/doltcore/schema/typeinfo/inlineblob.go index 449dafd541..0b5a1443c2 100644 --- a/go/libraries/doltcore/schema/typeinfo/inlineblob.go +++ b/go/libraries/doltcore/schema/typeinfo/inlineblob.go @@ -22,6 +22,7 @@ import ( "unsafe" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/dolthub/dolt/go/store/types" @@ -36,13 +37,13 @@ const ( // inlineBlobType handles BINARY and VARBINARY. BLOB types are handled by varBinaryType. type inlineBlobType struct { - sqlBinaryType sql.StringType + sqlBinaryType types2.StringType } var _ TypeInfo = (*inlineBlobType)(nil) var ( - VarbinaryDefaultType = &inlineBlobType{sql.MustCreateBinary(sqltypes.VarBinary, 16383)} + VarbinaryDefaultType = &inlineBlobType{types2.MustCreateBinary(sqltypes.VarBinary, 16383)} ) func CreateInlineBlobTypeFromParams(params map[string]string) (TypeInfo, error) { @@ -57,12 +58,12 @@ 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 sql.StringType + var sqlType types2.StringType switch sqlStr { case inlineBlobTypeParam_SQL_Binary: - sqlType, err = sql.CreateBinary(sqltypes.Binary, length) + sqlType, err = types2.CreateBinary(sqltypes.Binary, length) case inlineBlobTypeParam_SQL_VarBinary: - sqlType, err = sql.CreateBinary(sqltypes.VarBinary, length) + sqlType, err = types2.CreateBinary(sqltypes.VarBinary, length) default: return nil, fmt.Errorf(`create inlineblob type info has "%v" param with value "%v"`, inlineBlobTypeParam_SQL, sqlStr) } @@ -186,7 +187,7 @@ func (ti *inlineBlobType) NomsKind() types.NomsKind { // Promote implements TypeInfo interface. func (ti *inlineBlobType) Promote() TypeInfo { - return &inlineBlobType{ti.sqlBinaryType.Promote().(sql.StringType)} + return &inlineBlobType{ti.sqlBinaryType.Promote().(types2.StringType)} } // String implements TypeInfo interface. diff --git a/go/libraries/doltcore/schema/typeinfo/inlineblob_test.go b/go/libraries/doltcore/schema/typeinfo/inlineblob_test.go index 946d18f3a7..c8313545b4 100644 --- a/go/libraries/doltcore/schema/typeinfo/inlineblob_test.go +++ b/go/libraries/doltcore/schema/typeinfo/inlineblob_test.go @@ -21,7 +21,7 @@ import ( "testing" "time" - "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -29,7 +29,7 @@ import ( "github.com/dolthub/dolt/go/store/types" ) -var DefaultInlineBlobType = &inlineBlobType{sql.MustCreateBinary(sqltypes.VarBinary, math.MaxUint16)} +var DefaultInlineBlobType = &inlineBlobType{types2.MustCreateBinary(sqltypes.VarBinary, math.MaxUint16)} func TestInlineBlobConvertNomsValueToValue(t *testing.T) { tests := []struct { diff --git a/go/libraries/doltcore/schema/typeinfo/int.go b/go/libraries/doltcore/schema/typeinfo/int.go index 548a07121d..c389699aca 100644 --- a/go/libraries/doltcore/schema/typeinfo/int.go +++ b/go/libraries/doltcore/schema/typeinfo/int.go @@ -20,6 +20,7 @@ import ( "strconv" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/dolthub/dolt/go/store/types" @@ -40,11 +41,11 @@ type intType struct { var _ TypeInfo = (*intType)(nil) var ( - Int8Type = &intType{sql.Int8} - Int16Type = &intType{sql.Int16} - Int24Type = &intType{sql.Int24} - Int32Type = &intType{sql.Int32} - Int64Type = &intType{sql.Int64} + Int8Type = &intType{types2.Int8} + Int16Type = &intType{types2.Int16} + Int24Type = &intType{types2.Int24} + Int32Type = &intType{types2.Int32} + Int64Type = &intType{types2.Int64} ) func CreateIntTypeFromParams(params map[string]string) (TypeInfo, error) { @@ -71,15 +72,15 @@ func CreateIntTypeFromParams(params map[string]string) (TypeInfo, error) { func (ti *intType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { if val, ok := v.(types.Int); ok { switch ti.sqlIntType { - case sql.Int8: + case types2.Int8: return int8(val), nil - case sql.Int16: + case types2.Int16: return int16(val), nil - case sql.Int24: + case types2.Int24: return int32(val), nil - case sql.Int32: + case types2.Int32: return int32(val), nil - case sql.Int64: + case types2.Int64: return int64(val), nil } } @@ -96,15 +97,15 @@ func (ti *intType) ReadFrom(_ *types.NomsBinFormat, reader types.CodecReader) (i case types.IntKind: val := reader.ReadInt() switch ti.sqlIntType { - case sql.Int8: + case types2.Int8: return int8(val), nil - case sql.Int16: + case types2.Int16: return int16(val), nil - case sql.Int24: + case types2.Int24: return int32(val), nil - case sql.Int32: + case types2.Int32: return int32(val), nil - case sql.Int64: + case types2.Int64: return int64(val), nil } case types.NullKind: diff --git a/go/libraries/doltcore/schema/typeinfo/json.go b/go/libraries/doltcore/schema/typeinfo/json.go index 9e127afc58..3339915cbc 100644 --- a/go/libraries/doltcore/schema/typeinfo/json.go +++ b/go/libraries/doltcore/schema/typeinfo/json.go @@ -19,6 +19,7 @@ import ( "fmt" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/json" "github.com/dolthub/dolt/go/store/types" @@ -29,7 +30,7 @@ type jsonType struct { } var _ TypeInfo = (*jsonType)(nil) -var JSONType = &jsonType{sql.JSON} +var JSONType = &jsonType{types2.JSON} // ConvertNomsValueToValue implements TypeInfo interface. func (ti *jsonType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { @@ -71,7 +72,7 @@ func (ti *jsonType) ConvertValueToNomsValue(ctx context.Context, vrw types.Value return nil, err } - jsVal, ok := jsDoc.(sql.JSONValue) + jsVal, ok := jsDoc.(types2.JSONValue) if !ok { return nil, fmt.Errorf(`"%v" cannot convert value "%v" of type "%T" as it is invalid`, ti.String(), v, v) } diff --git a/go/libraries/doltcore/schema/typeinfo/linestring.go b/go/libraries/doltcore/schema/typeinfo/linestring.go index 6e8c3c3ac1..e50e9aa59f 100644 --- a/go/libraries/doltcore/schema/typeinfo/linestring.go +++ b/go/libraries/doltcore/schema/typeinfo/linestring.go @@ -20,6 +20,7 @@ import ( "strconv" "github.com/dolthub/dolt/go/store/types" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/go-mysql-server/sql" ) @@ -27,12 +28,12 @@ import ( // This is a dolt implementation of the MySQL type Point, thus most of the functionality // within is directly reliant on the go-mysql-server implementation. type linestringType struct { - sqlLineStringType sql.LineStringType + sqlLineStringType types2.LineStringType } var _ TypeInfo = (*linestringType)(nil) -var LineStringType = &linestringType{sql.LineStringType{}} +var LineStringType = &linestringType{types2.LineStringType{}} // ConvertNomsValueToValue implements TypeInfo interface. func (ti *linestringType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { @@ -78,7 +79,7 @@ func (ti *linestringType) ConvertValueToNomsValue(ctx context.Context, vrw types return nil, err } - return types.ConvertSQLLineStringToTypesLineString(line.(sql.LineString)), nil + return types.ConvertSQLLineStringToTypesLineString(line.(types2.LineString)), nil } // Equals implements TypeInfo interface. @@ -135,7 +136,7 @@ func (ti *linestringType) NomsKind() types.NomsKind { // Promote implements TypeInfo interface. func (ti *linestringType) Promote() TypeInfo { - return &linestringType{ti.sqlLineStringType.Promote().(sql.LineStringType)} + return &linestringType{ti.sqlLineStringType.Promote().(types2.LineStringType)} } // String implements TypeInfo interface. @@ -226,5 +227,5 @@ func CreateLineStringTypeFromParams(params map[string]string) (TypeInfo, error) return nil, err } } - return &linestringType{sqlLineStringType: sql.LineStringType{SRID: uint32(sridVal), DefinedSRID: def}}, nil + return &linestringType{sqlLineStringType: types2.LineStringType{SRID: uint32(sridVal), DefinedSRID: def}}, nil } diff --git a/go/libraries/doltcore/schema/typeinfo/multilinestring.go b/go/libraries/doltcore/schema/typeinfo/multilinestring.go index ddd40e7a54..882a1a9499 100644 --- a/go/libraries/doltcore/schema/typeinfo/multilinestring.go +++ b/go/libraries/doltcore/schema/typeinfo/multilinestring.go @@ -20,6 +20,7 @@ import ( "strconv" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/types" ) @@ -27,12 +28,12 @@ import ( // This is a dolt implementation of the MySQL type Point, thus most of the functionality // within is directly reliant on the go-mysql-server implementation. type multilinestringType struct { - sqlMultiLineStringType sql.MultiLineStringType + sqlMultiLineStringType types2.MultiLineStringType } var _ TypeInfo = (*multilinestringType)(nil) -var MultiLineStringType = &multilinestringType{sql.MultiLineStringType{}} +var MultiLineStringType = &multilinestringType{types2.MultiLineStringType{}} // ConvertNomsValueToValue implements TypeInfo interface. func (ti *multilinestringType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { @@ -78,7 +79,7 @@ func (ti *multilinestringType) ConvertValueToNomsValue(ctx context.Context, vrw return nil, err } - return types.ConvertSQLMultiLineStringToTypesMultiLineString(mline.(sql.MultiLineString)), nil + return types.ConvertSQLMultiLineStringToTypesMultiLineString(mline.(types2.MultiLineString)), nil } // Equals implements TypeInfo interface. @@ -135,7 +136,7 @@ func (ti *multilinestringType) NomsKind() types.NomsKind { // Promote implements TypeInfo interface. func (ti *multilinestringType) Promote() TypeInfo { - return &multilinestringType{ti.sqlMultiLineStringType.Promote().(sql.MultiLineStringType)} + return &multilinestringType{ti.sqlMultiLineStringType.Promote().(types2.MultiLineStringType)} } // String implements TypeInfo interface. @@ -227,5 +228,5 @@ func CreateMultiLineStringTypeFromParams(params map[string]string) (TypeInfo, er } } - return &multilinestringType{sqlMultiLineStringType: sql.MultiLineStringType{SRID: uint32(sridVal), DefinedSRID: def}}, nil + return &multilinestringType{sqlMultiLineStringType: types2.MultiLineStringType{SRID: uint32(sridVal), DefinedSRID: def}}, nil } diff --git a/go/libraries/doltcore/schema/typeinfo/multipoint.go b/go/libraries/doltcore/schema/typeinfo/multipoint.go index 58b1fe245e..9c4d03e6e3 100644 --- a/go/libraries/doltcore/schema/typeinfo/multipoint.go +++ b/go/libraries/doltcore/schema/typeinfo/multipoint.go @@ -20,6 +20,7 @@ import ( "strconv" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/types" ) @@ -27,12 +28,12 @@ import ( // This is a dolt implementation of the MySQL type Point, thus most of the functionality // within is directly reliant on the go-mysql-server implementation. type multipointType struct { - sqlMultiPointType sql.MultiPointType + sqlMultiPointType types2.MultiPointType } var _ TypeInfo = (*multipointType)(nil) -var MultiPointType = &multipointType{sql.MultiPointType{}} +var MultiPointType = &multipointType{types2.MultiPointType{}} // ConvertNomsValueToValue implements TypeInfo interface. func (ti *multipointType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { @@ -78,7 +79,7 @@ func (ti *multipointType) ConvertValueToNomsValue(ctx context.Context, vrw types return nil, err } - return types.ConvertSQLMultiPointToTypesMultiPoint(multipoint.(sql.MultiPoint)), nil + return types.ConvertSQLMultiPointToTypesMultiPoint(multipoint.(types2.MultiPoint)), nil } // Equals implements TypeInfo interface. @@ -135,7 +136,7 @@ func (ti *multipointType) NomsKind() types.NomsKind { // Promote implements TypeInfo interface. func (ti *multipointType) Promote() TypeInfo { - return &multipointType{ti.sqlMultiPointType.Promote().(sql.MultiPointType)} + return &multipointType{ti.sqlMultiPointType.Promote().(types2.MultiPointType)} } // String implements TypeInfo interface. @@ -226,5 +227,5 @@ func CreateMultiPointTypeFromParams(params map[string]string) (TypeInfo, error) return nil, err } } - return &multipointType{sqlMultiPointType: sql.MultiPointType{SRID: uint32(sridVal), DefinedSRID: def}}, nil + return &multipointType{sqlMultiPointType: types2.MultiPointType{SRID: uint32(sridVal), DefinedSRID: def}}, nil } diff --git a/go/libraries/doltcore/schema/typeinfo/multipolygon.go b/go/libraries/doltcore/schema/typeinfo/multipolygon.go index 476765ee7c..bf3a912cfd 100644 --- a/go/libraries/doltcore/schema/typeinfo/multipolygon.go +++ b/go/libraries/doltcore/schema/typeinfo/multipolygon.go @@ -20,6 +20,7 @@ import ( "strconv" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/types" ) @@ -27,12 +28,12 @@ import ( // This is a dolt implementation of the MySQL type Point, thus most of the functionality // within is directly reliant on the go-mysql-server implementation. type multipolygonType struct { - sqlMultiPolygonType sql.MultiPolygonType + sqlMultiPolygonType types2.MultiPolygonType } var _ TypeInfo = (*multipolygonType)(nil) -var MultiPolygonType = &multipolygonType{sql.MultiPolygonType{}} +var MultiPolygonType = &multipolygonType{types2.MultiPolygonType{}} // ConvertNomsValueToValue implements TypeInfo interface. func (ti *multipolygonType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { @@ -78,7 +79,7 @@ func (ti *multipolygonType) ConvertValueToNomsValue(ctx context.Context, vrw typ return nil, err } - return types.ConvertSQLMultiPolygonToTypesMultiPolygon(mpoly.(sql.MultiPolygon)), nil + return types.ConvertSQLMultiPolygonToTypesMultiPolygon(mpoly.(types2.MultiPolygon)), nil } // Equals implements TypeInfo interface. @@ -135,7 +136,7 @@ func (ti *multipolygonType) NomsKind() types.NomsKind { // Promote implements TypeInfo interface. func (ti *multipolygonType) Promote() TypeInfo { - return &multipolygonType{ti.sqlMultiPolygonType.Promote().(sql.MultiPolygonType)} + return &multipolygonType{ti.sqlMultiPolygonType.Promote().(types2.MultiPolygonType)} } // String implements TypeInfo interface. @@ -227,5 +228,5 @@ func CreateMultiPolygonTypeFromParams(params map[string]string) (TypeInfo, error } } - return &multipolygonType{sqlMultiPolygonType: sql.MultiPolygonType{SRID: uint32(sridVal), DefinedSRID: def}}, nil + return &multipolygonType{sqlMultiPolygonType: types2.MultiPolygonType{SRID: uint32(sridVal), DefinedSRID: def}}, nil } diff --git a/go/libraries/doltcore/schema/typeinfo/point.go b/go/libraries/doltcore/schema/typeinfo/point.go index c421c7141f..f5b71def84 100644 --- a/go/libraries/doltcore/schema/typeinfo/point.go +++ b/go/libraries/doltcore/schema/typeinfo/point.go @@ -20,6 +20,7 @@ import ( "strconv" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/types" ) @@ -27,12 +28,12 @@ import ( // This is a dolt implementation of the MySQL type Point, thus most of the functionality // within is directly reliant on the go-mysql-server implementation. type pointType struct { - sqlPointType sql.PointType + sqlPointType types2.PointType } var _ TypeInfo = (*pointType)(nil) -var PointType = &pointType{sql.PointType{}} +var PointType = &pointType{types2.PointType{}} // ConvertNomsValueToValue implements TypeInfo interface. func (ti *pointType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { @@ -78,7 +79,7 @@ func (ti *pointType) ConvertValueToNomsValue(ctx context.Context, vrw types.Valu return nil, err } - return types.ConvertSQLPointToTypesPoint(point.(sql.Point)), nil + return types.ConvertSQLPointToTypesPoint(point.(types2.Point)), nil } // Equals implements TypeInfo interface. @@ -135,7 +136,7 @@ func (ti *pointType) NomsKind() types.NomsKind { // Promote implements TypeInfo interface. func (ti *pointType) Promote() TypeInfo { - return &pointType{ti.sqlPointType.Promote().(sql.PointType)} + return &pointType{ti.sqlPointType.promote().(types2.PointType)} } // String implements TypeInfo interface. @@ -227,5 +228,5 @@ func CreatePointTypeFromParams(params map[string]string) (TypeInfo, error) { } } - return &pointType{sqlPointType: sql.PointType{SRID: uint32(sridVal), DefinedSRID: def}}, nil + return &pointType{sqlPointType: types2.PointType{SRID: uint32(sridVal), DefinedSRID: def}}, nil } diff --git a/go/libraries/doltcore/schema/typeinfo/polygon.go b/go/libraries/doltcore/schema/typeinfo/polygon.go index af089b81b3..861a81ec61 100644 --- a/go/libraries/doltcore/schema/typeinfo/polygon.go +++ b/go/libraries/doltcore/schema/typeinfo/polygon.go @@ -20,6 +20,7 @@ import ( "strconv" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/types" ) @@ -27,12 +28,12 @@ import ( // This is a dolt implementation of the MySQL type Point, thus most of the functionality // within is directly reliant on the go-mysql-server implementation. type polygonType struct { - sqlPolygonType sql.PolygonType + sqlPolygonType types2.PolygonType } var _ TypeInfo = (*polygonType)(nil) -var PolygonType = &polygonType{sql.PolygonType{}} +var PolygonType = &polygonType{types2.PolygonType{}} // ConvertNomsValueToValue implements TypeInfo interface. func (ti *polygonType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { @@ -78,7 +79,7 @@ func (ti *polygonType) ConvertValueToNomsValue(ctx context.Context, vrw types.Va return nil, err } - return types.ConvertSQLPolygonToTypesPolygon(poly.(sql.Polygon)), nil + return types.ConvertSQLPolygonToTypesPolygon(poly.(types2.Polygon)), nil } // Equals implements TypeInfo interface. @@ -135,7 +136,7 @@ func (ti *polygonType) NomsKind() types.NomsKind { // Promote implements TypeInfo interface. func (ti *polygonType) Promote() TypeInfo { - return &polygonType{ti.sqlPolygonType.Promote().(sql.PolygonType)} + return &polygonType{ti.sqlPolygonType.Promote().(types2.PolygonType)} } // String implements TypeInfo interface. @@ -227,5 +228,5 @@ func CreatePolygonTypeFromParams(params map[string]string) (TypeInfo, error) { } } - return &polygonType{sqlPolygonType: sql.PolygonType{SRID: uint32(sridVal), DefinedSRID: def}}, nil + return &polygonType{sqlPolygonType: types2.PolygonType{SRID: uint32(sridVal), DefinedSRID: def}}, nil } diff --git a/go/libraries/doltcore/schema/typeinfo/set.go b/go/libraries/doltcore/schema/typeinfo/set.go index b0a5aa96f3..09169e8601 100644 --- a/go/libraries/doltcore/schema/typeinfo/set.go +++ b/go/libraries/doltcore/schema/typeinfo/set.go @@ -21,6 +21,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/types" ) @@ -59,7 +60,7 @@ func CreateSetTypeFromParams(params map[string]string) (TypeInfo, error) { } else { return nil, fmt.Errorf(`create set type info is missing param "%v"`, setTypeParam_Values) } - sqlSetType, err := sql.CreateSetType(values, collation) + sqlSetType, err := types2.CreateSetType(values, collation) if err != nil { return nil, err } diff --git a/go/libraries/doltcore/schema/typeinfo/time.go b/go/libraries/doltcore/schema/typeinfo/time.go index 08958e194b..ee1dac32a7 100644 --- a/go/libraries/doltcore/schema/typeinfo/time.go +++ b/go/libraries/doltcore/schema/typeinfo/time.go @@ -19,6 +19,7 @@ import ( "fmt" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/types" ) @@ -26,17 +27,17 @@ import ( // This is a dolt implementation of the MySQL type Time, thus most of the functionality // within is directly reliant on the go-mysql-server implementation. type timeType struct { - sqlTimeType sql.TimeType + sqlTimeType types2.TimeType } var _ TypeInfo = (*timeType)(nil) -var TimeType = &timeType{sql.Time} +var TimeType = &timeType{types2.Time} // ConvertNomsValueToValue implements TypeInfo interface. func (ti *timeType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { if val, ok := v.(types.Int); ok { - return ti.sqlTimeType.Convert(sql.Timespan(val)) + return ti.sqlTimeType.Convert(types2.Timespan(val)) } if _, ok := v.(types.Null); ok || v == nil { return nil, nil @@ -50,7 +51,7 @@ func (ti *timeType) ReadFrom(_ *types.NomsBinFormat, reader types.CodecReader) ( switch k { case types.IntKind: val := reader.ReadInt() - return ti.sqlTimeType.Convert(sql.Timespan(val)) + return ti.sqlTimeType.Convert(types2.Timespan(val)) case types.NullKind: return nil, nil } @@ -67,7 +68,7 @@ func (ti *timeType) ConvertValueToNomsValue(ctx context.Context, vrw types.Value if err != nil { return nil, err } - return types.Int(val.(sql.Timespan)), nil + return types.Int(val.(types2.Timespan)), nil } // Equals implements TypeInfo interface. @@ -88,7 +89,7 @@ func (ti *timeType) FormatValue(v types.Value) (*string, error) { if err != nil { return nil, err } - val := convVal.(sql.Timespan).String() + val := convVal.(types2.Timespan).String() return &val, nil } @@ -120,7 +121,7 @@ func (ti *timeType) NomsKind() types.NomsKind { // Promote implements TypeInfo interface. func (ti *timeType) Promote() TypeInfo { - return &timeType{ti.sqlTimeType.Promote().(sql.TimeType)} + return &timeType{ti.sqlTimeType.Promote().(types2.TimeType)} } // String implements TypeInfo interface. diff --git a/go/libraries/doltcore/schema/typeinfo/time_test.go b/go/libraries/doltcore/schema/typeinfo/time_test.go index 2cf3934ce7..7417b36951 100644 --- a/go/libraries/doltcore/schema/typeinfo/time_test.go +++ b/go/libraries/doltcore/schema/typeinfo/time_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -30,7 +30,7 @@ import ( func TestTimeConvertNomsValueToValue(t *testing.T) { tests := []struct { input types.Int - output sql.Timespan + output types2.Timespan expectedErr bool }{ { diff --git a/go/libraries/doltcore/schema/typeinfo/typeinfo.go b/go/libraries/doltcore/schema/typeinfo/typeinfo.go index 3453eb0764..42dc2d46a3 100644 --- a/go/libraries/doltcore/schema/typeinfo/typeinfo.go +++ b/go/libraries/doltcore/schema/typeinfo/typeinfo.go @@ -20,6 +20,7 @@ import ( "math" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/dolthub/dolt/go/store/types" @@ -173,22 +174,22 @@ func FromSqlType(sqlType sql.Type) (TypeInfo, error) { return YearType, nil case sqltypes.Geometry: switch sqlType.String() { - case sql.PointType{}.String(): - return &pointType{sqlType.(sql.PointType)}, nil - case sql.LineStringType{}.String(): - return &linestringType{sqlType.(sql.LineStringType)}, nil - case sql.PolygonType{}.String(): - return &polygonType{sqlType.(sql.PolygonType)}, nil - case sql.MultiPointType{}.String(): + case types2.PointType{}.String(): + return &pointType{sqlType.(types2.PointType)}, nil + case types2.LineStringType{}.String(): + return &linestringType{sqlType.(types2.LineStringType)}, nil + case types2.PolygonType{}.String(): + return &polygonType{sqlType.(types2.PolygonType)}, nil + case types2.MultiPointType{}.String(): return &multipointType{}, nil - case sql.MultiLineStringType{}.String(): + case types2.MultiLineStringType{}.String(): return &multilinestringType{}, nil - case sql.MultiPolygonType{}.String(): + case types2.MultiPolygonType{}.String(): return &multipolygonType{}, nil - case sql.GeomCollType{}.String(): + case types2.GeomCollType{}.String(): return &geomcollType{}, nil - case sql.GeometryType{}.String(): - return &geometryType{sqlGeometryType: sqlType.(sql.GeometryType)}, nil + case types2.GeometryType{}.String(): + return &geometryType{sqlGeometryType: sqlType.(types2.GeometryType)}, nil default: return nil, fmt.Errorf(`expected "PointTypeIdentifier" from SQL basetype "Geometry"`) } @@ -199,43 +200,43 @@ func FromSqlType(sqlType sql.Type) (TypeInfo, error) { } return &decimalType{decimalSQLType}, nil case sqltypes.Text: - stringType, ok := sqlType.(sql.StringType) + stringType, ok := sqlType.(types2.StringType) if !ok { return nil, fmt.Errorf(`expected "StringType" from SQL basetype "Text"`) } return &blobStringType{stringType}, nil case sqltypes.Blob: - stringType, ok := sqlType.(sql.StringType) + stringType, ok := sqlType.(types2.StringType) if !ok { return nil, fmt.Errorf(`expected "StringType" from SQL basetype "Blob"`) } return &varBinaryType{stringType}, nil case sqltypes.VarChar: - stringType, ok := sqlType.(sql.StringType) + stringType, ok := sqlType.(types2.StringType) if !ok { return nil, fmt.Errorf(`expected "StringType" from SQL basetype "VarChar"`) } return &varStringType{stringType}, nil case sqltypes.VarBinary: - stringType, ok := sqlType.(sql.StringType) + stringType, ok := sqlType.(types2.StringType) if !ok { return nil, fmt.Errorf(`expected "StringType" from SQL basetype "VarBinary"`) } return &inlineBlobType{stringType}, nil case sqltypes.Char: - stringType, ok := sqlType.(sql.StringType) + stringType, ok := sqlType.(types2.StringType) if !ok { return nil, fmt.Errorf(`expected "StringType" from SQL basetype "Char"`) } return &varStringType{stringType}, nil case sqltypes.Binary: - stringType, ok := sqlType.(sql.StringType) + stringType, ok := sqlType.(types2.StringType) if !ok { return nil, fmt.Errorf(`expected "StringType" from SQL basetype "Binary"`) } return &inlineBlobType{stringType}, nil case sqltypes.Bit: - bitSQLType, ok := sqlType.(sql.BitType) + bitSQLType, ok := sqlType.(types2.BitType) if !ok { return nil, fmt.Errorf(`expected "BitTypeIdentifier" from SQL basetype "Bit"`) } @@ -327,13 +328,13 @@ func FromTypeParams(id Identifier, params map[string]string) (TypeInfo, error) { func FromKind(kind types.NomsKind) TypeInfo { switch kind { case types.BlobKind: - return &varBinaryType{sql.LongBlob} + return &varBinaryType{types2.LongBlob} case types.BoolKind: return BoolType case types.FloatKind: return Float64Type case types.InlineBlobKind: - return &inlineBlobType{sql.MustCreateBinary(sqltypes.VarBinary, math.MaxUint16)} + return &inlineBlobType{types2.MustCreateBinary(sqltypes.VarBinary, math.MaxUint16)} case types.IntKind: return Int64Type case types.JSONKind: @@ -359,7 +360,7 @@ func FromKind(kind types.NomsKind) TypeInfo { case types.UUIDKind: return UuidType case types.DecimalKind: - return &decimalType{sql.MustCreateDecimalType(65, 30)} + return &decimalType{types2.MustCreateDecimalType(65, 30)} default: panic(fmt.Errorf(`no default type info for NomsKind "%v"`, kind.String())) } diff --git a/go/libraries/doltcore/schema/typeinfo/typeinfo_test.go b/go/libraries/doltcore/schema/typeinfo/typeinfo_test.go index c0d0eaa612..f72a7b13da 100644 --- a/go/libraries/doltcore/schema/typeinfo/typeinfo_test.go +++ b/go/libraries/doltcore/schema/typeinfo/typeinfo_test.go @@ -21,6 +21,7 @@ import ( "time" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/shopspring/decimal" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -345,8 +346,8 @@ func testTypeInfoConversionsExist(t *testing.T, tiArrays [][]TypeInfo) { func generateTypeInfoArrays(t *testing.T) ([][]TypeInfo, [][]types.Value) { return [][]TypeInfo{ generateBitTypes(t, 16), - {&blobStringType{sql.TinyText}, &blobStringType{sql.Text}, - &blobStringType{sql.MediumText}, &blobStringType{sql.LongText}}, + {&blobStringType{types2.TinyText}, &blobStringType{types2.Text}, + &blobStringType{types2.MediumText}, &blobStringType{types2.LongText}}, {BoolType}, {DateType, DatetimeType, TimestampType}, generateDecimalTypes(t, 16), @@ -367,11 +368,11 @@ func generateTypeInfoArrays(t *testing.T) ([][]TypeInfo, [][]types.Value) { {TimeType}, {Uint8Type, Uint16Type, Uint24Type, Uint32Type, Uint64Type}, {UuidType}, - {&varBinaryType{sql.TinyBlob}, &varBinaryType{sql.Blob}, - &varBinaryType{sql.MediumBlob}, &varBinaryType{sql.LongBlob}}, + {&varBinaryType{types2.TinyBlob}, &varBinaryType{types2.Blob}, + &varBinaryType{types2.MediumBlob}, &varBinaryType{types2.LongBlob}}, append(generateVarStringTypes(t, 12), - &varStringType{sql.CreateTinyText(sql.Collation_Default)}, &varStringType{sql.CreateText(sql.Collation_Default)}, - &varStringType{sql.CreateMediumText(sql.Collation_Default)}, &varStringType{sql.CreateLongText(sql.Collation_Default)}), + &varStringType{types2.CreateTinyText(sql.Collation_Default)}, &varStringType{types2.CreateText(sql.Collation_Default)}, + &varStringType{types2.CreateMediumText(sql.Collation_Default)}, &varStringType{types2.CreateLongText(sql.Collation_Default)}), {YearType}, }, [][]types.Value{ diff --git a/go/libraries/doltcore/schema/typeinfo/uint.go b/go/libraries/doltcore/schema/typeinfo/uint.go index 24306bc8ea..7ddb60ab77 100644 --- a/go/libraries/doltcore/schema/typeinfo/uint.go +++ b/go/libraries/doltcore/schema/typeinfo/uint.go @@ -20,6 +20,7 @@ import ( "strconv" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/dolthub/dolt/go/store/types" @@ -40,11 +41,11 @@ type uintType struct { var _ TypeInfo = (*uintType)(nil) var ( - Uint8Type = &uintType{sql.Uint8} - Uint16Type = &uintType{sql.Uint16} - Uint24Type = &uintType{sql.Uint24} - Uint32Type = &uintType{sql.Uint32} - Uint64Type = &uintType{sql.Uint64} + Uint8Type = &uintType{types2.Uint8} + Uint16Type = &uintType{types2.Uint16} + Uint24Type = &uintType{types2.Uint24} + Uint32Type = &uintType{types2.Uint32} + Uint64Type = &uintType{types2.Uint64} ) func CreateUintTypeFromParams(params map[string]string) (TypeInfo, error) { @@ -71,15 +72,15 @@ func CreateUintTypeFromParams(params map[string]string) (TypeInfo, error) { func (ti *uintType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { if val, ok := v.(types.Uint); ok { switch ti.sqlUintType { - case sql.Uint8: + case types2.Uint8: return uint8(val), nil - case sql.Uint16: + case types2.Uint16: return uint16(val), nil - case sql.Uint24: + case types2.Uint24: return uint32(val), nil - case sql.Uint32: + case types2.Uint32: return uint32(val), nil - case sql.Uint64: + case types2.Uint64: return uint64(val), nil } } @@ -96,15 +97,15 @@ func (ti *uintType) ReadFrom(_ *types.NomsBinFormat, reader types.CodecReader) ( case types.UintKind: val := reader.ReadUint() switch ti.sqlUintType { - case sql.Uint8: + case types2.Uint8: return uint8(val), nil - case sql.Uint16: + case types2.Uint16: return uint16(val), nil - case sql.Uint24: + case types2.Uint24: return uint32(val), nil - case sql.Uint32: + case types2.Uint32: return uint32(val), nil - case sql.Uint64: + case types2.Uint64: return val, nil } case types.NullKind: diff --git a/go/libraries/doltcore/schema/typeinfo/uuid.go b/go/libraries/doltcore/schema/typeinfo/uuid.go index 7e83d92c0f..cdf2234727 100644 --- a/go/libraries/doltcore/schema/typeinfo/uuid.go +++ b/go/libraries/doltcore/schema/typeinfo/uuid.go @@ -19,6 +19,7 @@ import ( "fmt" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/google/uuid" @@ -26,12 +27,12 @@ import ( ) type uuidType struct { - sqlCharType sql.StringType + sqlCharType types2.StringType } var _ TypeInfo = (*uuidType)(nil) -var UuidType = &uuidType{sql.MustCreateString(sqltypes.Char, 36, sql.Collation_ascii_bin)} +var UuidType = &uuidType{types2.MustCreateString(sqltypes.Char, 36, sql.Collation_ascii_bin)} // ConvertNomsValueToValue implements TypeInfo interface. func (ti *uuidType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { diff --git a/go/libraries/doltcore/schema/typeinfo/varbinary.go b/go/libraries/doltcore/schema/typeinfo/varbinary.go index ea64981e9d..7b19bd8645 100644 --- a/go/libraries/doltcore/schema/typeinfo/varbinary.go +++ b/go/libraries/doltcore/schema/typeinfo/varbinary.go @@ -24,6 +24,7 @@ import ( "unsafe" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/dolthub/dolt/go/store/types" @@ -40,16 +41,16 @@ const ( // // This type handles the BLOB types. BINARY and VARBINARY are handled by inlineBlobType. type varBinaryType struct { - sqlBinaryType sql.StringType + sqlBinaryType types2.StringType } var _ TypeInfo = (*varBinaryType)(nil) var ( - TinyBlobType TypeInfo = &varBinaryType{sqlBinaryType: sql.TinyBlob} - BlobType TypeInfo = &varBinaryType{sqlBinaryType: sql.Blob} - MediumBlobType TypeInfo = &varBinaryType{sqlBinaryType: sql.MediumBlob} - LongBlobType TypeInfo = &varBinaryType{sqlBinaryType: sql.LongBlob} + TinyBlobType TypeInfo = &varBinaryType{sqlBinaryType: types2.TinyBlob} + BlobType TypeInfo = &varBinaryType{sqlBinaryType: types2.Blob} + MediumBlobType TypeInfo = &varBinaryType{sqlBinaryType: types2.MediumBlob} + LongBlobType TypeInfo = &varBinaryType{sqlBinaryType: types2.LongBlob} ) func CreateVarBinaryTypeFromParams(params map[string]string) (TypeInfo, error) { @@ -63,7 +64,7 @@ func CreateVarBinaryTypeFromParams(params map[string]string) (TypeInfo, error) { } else { return nil, fmt.Errorf(`create varbinary type info is missing param "%v"`, varBinaryTypeParam_Length) } - sqlType, err := sql.CreateBinary(sqltypes.Blob, length) + sqlType, err := types2.CreateBinary(sqltypes.Blob, length) if err != nil { return nil, err } @@ -173,7 +174,7 @@ func (ti *varBinaryType) NomsKind() types.NomsKind { // Promote implements TypeInfo interface. func (ti *varBinaryType) Promote() TypeInfo { - return &varBinaryType{ti.sqlBinaryType.Promote().(sql.StringType)} + return &varBinaryType{ti.sqlBinaryType.Promote().(types2.StringType)} } // String implements TypeInfo interface. diff --git a/go/libraries/doltcore/schema/typeinfo/varstring.go b/go/libraries/doltcore/schema/typeinfo/varstring.go index 7f3dcc5597..49a612bd7e 100644 --- a/go/libraries/doltcore/schema/typeinfo/varstring.go +++ b/go/libraries/doltcore/schema/typeinfo/varstring.go @@ -22,6 +22,7 @@ import ( "unicode" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/dolthub/dolt/go/store/types" @@ -42,13 +43,13 @@ 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 sql.StringType + sqlStringType types2.StringType } var _ TypeInfo = (*varStringType)(nil) var ( - StringDefaultType = &varStringType{sql.MustCreateStringWithDefaults(sqltypes.VarChar, 16383)} + StringDefaultType = &varStringType{types2.MustCreateStringWithDefaults(sqltypes.VarChar, 16383)} ) func CreateVarStringTypeFromParams(params map[string]string) (TypeInfo, error) { @@ -73,14 +74,14 @@ 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 sql.StringType + var sqlType types2.StringType switch sqlStr { case varStringTypeParam_SQL_Char: - sqlType, err = sql.CreateString(sqltypes.Char, length, collation) + sqlType, err = types2.CreateString(sqltypes.Char, length, collation) case varStringTypeParam_SQL_VarChar: - sqlType, err = sql.CreateString(sqltypes.VarChar, length, collation) + sqlType, err = types2.CreateString(sqltypes.VarChar, length, collation) case varStringTypeParam_SQL_Text: - sqlType, err = sql.CreateString(sqltypes.Text, length, collation) + sqlType, err = types2.CreateString(sqltypes.Text, length, collation) default: return nil, fmt.Errorf(`create varstring type info has "%v" param with value "%v"`, varStringTypeParam_SQL, sqlStr) } @@ -225,7 +226,7 @@ func (ti *varStringType) NomsKind() types.NomsKind { // Promote implements TypeInfo interface. func (ti *varStringType) Promote() TypeInfo { - return &varStringType{ti.sqlStringType.Promote().(sql.StringType)} + return &varStringType{ti.sqlStringType.Promote().(types2.StringType)} } // String implements TypeInfo interface. diff --git a/go/libraries/doltcore/schema/typeinfo/varstring_test.go b/go/libraries/doltcore/schema/typeinfo/varstring_test.go index bb6ea58e1a..ef905c8e40 100644 --- a/go/libraries/doltcore/schema/typeinfo/varstring_test.go +++ b/go/libraries/doltcore/schema/typeinfo/varstring_test.go @@ -21,6 +21,7 @@ import ( "time" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -53,7 +54,7 @@ func TestVarStringConvertNomsValueToValue(t *testing.T) { false, }, { - &varStringType{sql.CreateLongText(sql.Collation_Default)}, + &varStringType{types2.CreateLongText(sql.Collation_Default)}, " This is a sentence. ", " This is a sentence. ", false, @@ -99,7 +100,7 @@ func TestVarStringConvertValueToNomsValue(t *testing.T) { false, }, { - &varStringType{sql.CreateLongText(sql.Collation_Default)}, + &varStringType{types2.CreateLongText(sql.Collation_Default)}, float32(3724.75), "3724.75", false, @@ -164,7 +165,7 @@ func TestVarStringFormatValue(t *testing.T) { false, }, { - &varStringType{sql.CreateLongText(sql.Collation_Default)}, + &varStringType{types2.CreateLongText(sql.Collation_Default)}, " This is a sentence. ", " This is a sentence. ", false, @@ -210,7 +211,7 @@ func TestVarStringParseValue(t *testing.T) { false, }, { - &varStringType{sql.CreateLongText(sql.Collation_Default)}, + &varStringType{types2.CreateLongText(sql.Collation_Default)}, " This is a sentence. ", " This is a sentence. ", false, diff --git a/go/libraries/doltcore/schema/typeinfo/year.go b/go/libraries/doltcore/schema/typeinfo/year.go index 212e626f6d..4cd860c6e2 100644 --- a/go/libraries/doltcore/schema/typeinfo/year.go +++ b/go/libraries/doltcore/schema/typeinfo/year.go @@ -20,6 +20,7 @@ import ( "strconv" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/types" ) @@ -32,7 +33,7 @@ type yearType struct { var _ TypeInfo = (*yearType)(nil) -var YearType = &yearType{sql.Year} +var YearType = &yearType{types2.Year} // ConvertNomsValueToValue implements TypeInfo interface. func (ti *yearType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { diff --git a/go/libraries/doltcore/sqle/alterschema_test.go b/go/libraries/doltcore/sqle/alterschema_test.go index d6e3b37112..744d3965a8 100644 --- a/go/libraries/doltcore/sqle/alterschema_test.go +++ b/go/libraries/doltcore/sqle/alterschema_test.go @@ -22,6 +22,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/parse" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -644,7 +645,7 @@ func TestModifyColumn(t *testing.T) { schema.NewColumn("is_married", dtestutils.IsMarriedTag, types.IntKind, false, schema.NotNullConstraint{}), schema.NewColumn("title", dtestutils.TitleTag, types.StringKind, false), ) - ti, err := typeinfo.FromSqlType(sql.MustCreateStringWithDefaults(sqltypes.VarChar, 599)) + ti, err := typeinfo.FromSqlType(types2.MustCreateStringWithDefaults(sqltypes.VarChar, 599)) require.NoError(t, err) newNameColSameTag, err := schema.NewColumnWithTypeInfo("name", dtestutils.NameTag, ti, false, "", false, "", schema.NotNullConstraint{}) require.NoError(t, err) diff --git a/go/libraries/doltcore/sqle/cluster/assume_role.go b/go/libraries/doltcore/sqle/cluster/assume_role.go index 8845ae8bed..aa2ca581a0 100644 --- a/go/libraries/doltcore/sqle/cluster/assume_role.go +++ b/go/libraries/doltcore/sqle/cluster/assume_role.go @@ -18,6 +18,7 @@ import ( "errors" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" ) @@ -30,7 +31,7 @@ func newAssumeRoleProcedure(controller *Controller) sql.ExternalStoredProcedureD Schema: sql.Schema{ &sql.Column{ Name: "status", - Type: sql.Int64, + Type: types.Int64, Nullable: false, }, }, diff --git a/go/libraries/doltcore/sqle/cluster/controller.go b/go/libraries/doltcore/sqle/cluster/controller.go index df08a4dc26..3b31cf0b15 100644 --- a/go/libraries/doltcore/sqle/cluster/controller.go +++ b/go/libraries/doltcore/sqle/cluster/controller.go @@ -30,6 +30,7 @@ import ( "time" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/sirupsen/logrus" "google.golang.org/grpc" "google.golang.org/grpc/credentials" @@ -285,14 +286,14 @@ func (c *Controller) refreshSystemVars() { Name: DoltClusterRoleVariable, Dynamic: false, Scope: sql.SystemVariableScope_Persist, - Type: sql.NewSystemStringType(DoltClusterRoleVariable), + Type: types2.NewSystemStringType(DoltClusterRoleVariable), Default: role, }, { Name: DoltClusterRoleEpochVariable, Dynamic: false, Scope: sql.SystemVariableScope_Persist, - Type: sql.NewSystemIntType(DoltClusterRoleEpochVariable, 0, 9223372036854775807, false), + Type: types2.NewSystemIntType(DoltClusterRoleEpochVariable, 0, 9223372036854775807, false), Default: epoch, }, } diff --git a/go/libraries/doltcore/sqle/clusterdb/cluster_status_table.go b/go/libraries/doltcore/sqle/clusterdb/cluster_status_table.go index cca51c6163..1bb62a1379 100644 --- a/go/libraries/doltcore/sqle/clusterdb/cluster_status_table.go +++ b/go/libraries/doltcore/sqle/clusterdb/cluster_status_table.go @@ -18,6 +18,7 @@ import ( "time" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" ) type ReplicaStatus struct { @@ -111,12 +112,12 @@ func replicaStatusToRow(rs ReplicaStatus) sql.Row { func (t ClusterStatusTable) Schema() sql.Schema { return sql.Schema{ - {Name: "database", Type: sql.Text, Source: StatusTableName, PrimaryKey: true, Nullable: false}, - {Name: "standby_remote", Type: sql.Text, Source: StatusTableName, PrimaryKey: true, Nullable: false}, - {Name: "role", Type: sql.Text, Source: StatusTableName, PrimaryKey: false, Nullable: false}, - {Name: "epoch", Type: sql.Int64, Source: StatusTableName, PrimaryKey: false, Nullable: false}, - {Name: "replication_lag_millis", Type: sql.Int64, Source: StatusTableName, PrimaryKey: false, Nullable: true}, - {Name: "last_update", Type: sql.Datetime, Source: StatusTableName, PrimaryKey: false, Nullable: true}, - {Name: "current_error", Type: sql.Text, Source: StatusTableName, PrimaryKey: false, Nullable: true}, + {Name: "database", Type: types.Text, Source: StatusTableName, PrimaryKey: true, Nullable: false}, + {Name: "standby_remote", Type: types.Text, Source: StatusTableName, PrimaryKey: true, Nullable: false}, + {Name: "role", Type: types.Text, Source: StatusTableName, PrimaryKey: false, Nullable: false}, + {Name: "epoch", Type: types.Int64, Source: StatusTableName, PrimaryKey: false, Nullable: false}, + {Name: "replication_lag_millis", Type: types.Int64, Source: StatusTableName, PrimaryKey: false, Nullable: true}, + {Name: "last_update", Type: types.Datetime, Source: StatusTableName, PrimaryKey: false, Nullable: true}, + {Name: "current_error", Type: types.Text, Source: StatusTableName, PrimaryKey: false, Nullable: true}, } } diff --git a/go/libraries/doltcore/sqle/database.go b/go/libraries/doltcore/sqle/database.go index ca5e25568f..efa556fc2c 100644 --- a/go/libraries/doltcore/sqle/database.go +++ b/go/libraries/doltcore/sqle/database.go @@ -24,6 +24,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/mysql_db" + "github.com/dolthub/go-mysql-server/sql/types" "gopkg.in/src-d/go-errors.v1" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" @@ -940,7 +941,7 @@ func (db Database) createIndexedSqlTable(ctx *sql.Context, tableName string, sch // Prevent any tables that use BINARY, CHAR, VARBINARY, VARCHAR prefixes in Primary Key for _, idxCol := range idxDef.Columns { col := sch.Schema[sch.Schema.IndexOfColName(idxCol.Name)] - if col.PrimaryKey && sql.IsText(col.Type) && idxCol.Length > 0 { + if col.PrimaryKey && types.IsText(col.Type) && idxCol.Length > 0 { return sql.ErrUnsupportedIndexPrefix.New(col.Name) } } diff --git a/go/libraries/doltcore/sqle/database_provider.go b/go/libraries/doltcore/sqle/database_provider.go index 5d247a6985..8e5ea31d0c 100644 --- a/go/libraries/doltcore/sqle/database_provider.go +++ b/go/libraries/doltcore/sqle/database_provider.go @@ -22,6 +22,7 @@ import ( "sync" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/sysvars" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/dbfactory" @@ -226,7 +227,7 @@ func wrapForStandby(db sql.Database, standby bool) sql.Database { // TODO: distinct error for not found v. others func (p DoltDatabaseProvider) attemptCloneReplica(ctx *sql.Context, dbName string) error { // TODO: these need some reworking, they don't make total sense together - _, readReplicaRemoteName, _ := sql.SystemVariables.GetGlobal(dsess.ReadReplicaRemote) + _, readReplicaRemoteName, _ := variables.SystemVariables.GetGlobal(dsess.ReadReplicaRemote) if readReplicaRemoteName == "" { // not a read replica DB return nil @@ -235,7 +236,7 @@ func (p DoltDatabaseProvider) attemptCloneReplica(ctx *sql.Context, dbName strin remoteName := readReplicaRemoteName.(string) // TODO: error handling when not set - _, remoteUrlTemplate, _ := sql.SystemVariables.GetGlobal(dsess.ReplicationRemoteURLTemplate) + _, remoteUrlTemplate, _ := variables.SystemVariables.GetGlobal(dsess.ReplicationRemoteURLTemplate) if remoteUrlTemplate == "" { return nil } @@ -419,7 +420,7 @@ type InitDatabaseHook func(ctx *sql.Context, pro DoltDatabaseProvider, name stri // configureReplication sets up replication for a newly created database as necessary // TODO: consider the replication heads / all heads setting func ConfigureReplicationDatabaseHook(ctx *sql.Context, p DoltDatabaseProvider, name string, newEnv *env.DoltEnv) error { - _, replicationRemoteName, _ := sql.SystemVariables.GetGlobal(dsess.ReplicateToRemote) + _, replicationRemoteName, _ := variables.SystemVariables.GetGlobal(dsess.ReplicateToRemote) if replicationRemoteName == "" { return nil } @@ -429,7 +430,7 @@ func ConfigureReplicationDatabaseHook(ctx *sql.Context, p DoltDatabaseProvider, return nil } - _, remoteUrlTemplate, _ := sql.SystemVariables.GetGlobal(dsess.ReplicationRemoteURLTemplate) + _, remoteUrlTemplate, _ := variables.SystemVariables.GetGlobal(dsess.ReplicationRemoteURLTemplate) if remoteUrlTemplate == "" { return nil } @@ -776,12 +777,12 @@ func (p DoltDatabaseProvider) databaseForClone(ctx *sql.Context, revDB string) ( // TODO: figure out the right contract: which variables must be set? What happens if they aren't all set? func readReplicationActive(ctx *sql.Context) bool { - _, readReplicaRemoteName, _ := sql.SystemVariables.GetGlobal(dsess.ReadReplicaRemote) + _, readReplicaRemoteName, _ := variables.SystemVariables.GetGlobal(dsess.ReadReplicaRemote) if readReplicaRemoteName == "" { return false } - _, remoteUrlTemplate, _ := sql.SystemVariables.GetGlobal(dsess.ReplicationRemoteURLTemplate) + _, remoteUrlTemplate, _ := variables.SystemVariables.GetGlobal(dsess.ReplicationRemoteURLTemplate) if remoteUrlTemplate == "" { return false } diff --git a/go/libraries/doltcore/sqle/dfunctions/active_branch.go b/go/libraries/doltcore/sqle/dfunctions/active_branch.go index 51645ac79e..ddb987482d 100644 --- a/go/libraries/doltcore/sqle/dfunctions/active_branch.go +++ b/go/libraries/doltcore/sqle/dfunctions/active_branch.go @@ -18,6 +18,7 @@ import ( "fmt" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/ref" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" @@ -79,7 +80,7 @@ func (*ActiveBranchFunc) Resolved() bool { } func (ab *ActiveBranchFunc) Type() sql.Type { - return sql.Text + return types.Text } // Children implements the Expression interface. diff --git a/go/libraries/doltcore/sqle/dfunctions/commit.go b/go/libraries/doltcore/sqle/dfunctions/commit.go index b8e2838212..70dd70b1f0 100644 --- a/go/libraries/doltcore/sqle/dfunctions/commit.go +++ b/go/libraries/doltcore/sqle/dfunctions/commit.go @@ -19,6 +19,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" ) const CommitFuncName = "commit" @@ -78,5 +79,5 @@ func (cf *CommitFunc) WithChildren(children ...sql.Expression) (sql.Expression, } func (cf *CommitFunc) Type() sql.Type { - return sql.Text + return types.Text } diff --git a/go/libraries/doltcore/sqle/dfunctions/dolt_add.go b/go/libraries/doltcore/sqle/dfunctions/dolt_add.go index d3d3d14e51..b04fceeed7 100644 --- a/go/libraries/doltcore/sqle/dfunctions/dolt_add.go +++ b/go/libraries/doltcore/sqle/dfunctions/dolt_add.go @@ -19,6 +19,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" @@ -111,7 +112,7 @@ func (d DoltAddFunc) String() string { } func (d DoltAddFunc) Type() sql.Type { - return sql.Int8 + return types.Int8 } func (d DoltAddFunc) IsNullable() bool { diff --git a/go/libraries/doltcore/sqle/dfunctions/dolt_backup.go b/go/libraries/doltcore/sqle/dfunctions/dolt_backup.go index e20f8fbb1a..478fb4158b 100644 --- a/go/libraries/doltcore/sqle/dfunctions/dolt_backup.go +++ b/go/libraries/doltcore/sqle/dfunctions/dolt_backup.go @@ -20,6 +20,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" @@ -59,7 +60,7 @@ func (d DoltBackupFunc) String() string { } func (d DoltBackupFunc) Type() sql.Type { - return sql.Int8 + return types.Int8 } func (d DoltBackupFunc) WithChildren(children ...sql.Expression) (sql.Expression, error) { diff --git a/go/libraries/doltcore/sqle/dfunctions/dolt_branch.go b/go/libraries/doltcore/sqle/dfunctions/dolt_branch.go index 52660f7734..fc5fca7327 100644 --- a/go/libraries/doltcore/sqle/dfunctions/dolt_branch.go +++ b/go/libraries/doltcore/sqle/dfunctions/dolt_branch.go @@ -21,6 +21,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" @@ -60,7 +61,7 @@ func (d DoltBranchFunc) String() string { } func (d DoltBranchFunc) Type() sql.Type { - return sql.Int8 + return types.Int8 } func (d DoltBranchFunc) WithChildren(children ...sql.Expression) (sql.Expression, error) { diff --git a/go/libraries/doltcore/sqle/dfunctions/dolt_checkout.go b/go/libraries/doltcore/sqle/dfunctions/dolt_checkout.go index 0bf3b58d8d..be085c4fef 100644 --- a/go/libraries/doltcore/sqle/dfunctions/dolt_checkout.go +++ b/go/libraries/doltcore/sqle/dfunctions/dolt_checkout.go @@ -21,6 +21,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/cmd/dolt/errhand" @@ -290,7 +291,7 @@ func (d DoltCheckoutFunc) String() string { } func (d DoltCheckoutFunc) Type() sql.Type { - return sql.Int8 + return types.Int8 } func (d DoltCheckoutFunc) WithChildren(children ...sql.Expression) (sql.Expression, error) { diff --git a/go/libraries/doltcore/sqle/dfunctions/dolt_clean.go b/go/libraries/doltcore/sqle/dfunctions/dolt_clean.go index d96bf31d1d..0ababaf656 100644 --- a/go/libraries/doltcore/sqle/dfunctions/dolt_clean.go +++ b/go/libraries/doltcore/sqle/dfunctions/dolt_clean.go @@ -19,6 +19,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" @@ -96,7 +97,7 @@ func (d DoltCleanFunc) String() string { } func (d DoltCleanFunc) Type() sql.Type { - return sql.Int8 + return types.Int8 } func (d DoltCleanFunc) IsNullable() bool { diff --git a/go/libraries/doltcore/sqle/dfunctions/dolt_commit.go b/go/libraries/doltcore/sqle/dfunctions/dolt_commit.go index bf23f23d9e..7431f2e6c5 100644 --- a/go/libraries/doltcore/sqle/dfunctions/dolt_commit.go +++ b/go/libraries/doltcore/sqle/dfunctions/dolt_commit.go @@ -19,6 +19,7 @@ import ( "fmt" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/vt/proto/query" "github.com/dolthub/dolt/go/cmd/dolt/cli" @@ -29,7 +30,7 @@ import ( const DoltCommitFuncName = "dolt_commit" -var hashType = sql.MustCreateString(query.Type_TEXT, 32, sql.Collation_ascii_bin) +var hashType = types.MustCreateString(query.Type_TEXT, 32, sql.Collation_ascii_bin) // DoltCommitFunc runs a `dolt commit` in the SQL context, committing staged changes to head. // Deprecated: please use the version in the dprocedures package @@ -161,7 +162,7 @@ func getDoltArgs(ctx *sql.Context, row sql.Row, children []sql.Expression) ([]st return nil, err } - text, err := sql.Text.Convert(childVal) + text, err := types.Text.Convert(childVal) if err != nil { return nil, err @@ -183,7 +184,7 @@ func (d DoltCommitFunc) String() string { } func (d DoltCommitFunc) Type() sql.Type { - return sql.Text + return types.Text } func (d DoltCommitFunc) IsNullable() bool { diff --git a/go/libraries/doltcore/sqle/dfunctions/dolt_fetch.go b/go/libraries/doltcore/sqle/dfunctions/dolt_fetch.go index fd78469bc7..a1fcfbc822 100644 --- a/go/libraries/doltcore/sqle/dfunctions/dolt_fetch.go +++ b/go/libraries/doltcore/sqle/dfunctions/dolt_fetch.go @@ -20,6 +20,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" @@ -58,7 +59,7 @@ func (d DoltFetchFunc) String() string { } func (d DoltFetchFunc) Type() sql.Type { - return sql.Boolean + return types.Boolean } func (d DoltFetchFunc) WithChildren(children ...sql.Expression) (sql.Expression, error) { diff --git a/go/libraries/doltcore/sqle/dfunctions/dolt_merge.go b/go/libraries/doltcore/sqle/dfunctions/dolt_merge.go index e52fef4475..6da561b18b 100644 --- a/go/libraries/doltcore/sqle/dfunctions/dolt_merge.go +++ b/go/libraries/doltcore/sqle/dfunctions/dolt_merge.go @@ -21,6 +21,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" @@ -479,7 +480,7 @@ func (d DoltMergeFunc) String() string { } func (d DoltMergeFunc) Type() sql.Type { - return sql.Boolean + return types.Boolean } func (d DoltMergeFunc) WithChildren(children ...sql.Expression) (sql.Expression, error) { diff --git a/go/libraries/doltcore/sqle/dfunctions/dolt_merge_base.go b/go/libraries/doltcore/sqle/dfunctions/dolt_merge_base.go index 33800b37de..eef80410aa 100644 --- a/go/libraries/doltcore/sqle/dfunctions/dolt_merge_base.go +++ b/go/libraries/doltcore/sqle/dfunctions/dolt_merge_base.go @@ -19,6 +19,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/merge" @@ -38,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().(sql.StringType); !ok { + if _, ok := d.Left.Type().(types.StringType); !ok { return nil, sql.ErrInvalidType.New(d.Left.Type()) } - if _, ok := d.Right.Type().(sql.StringType); !ok { + if _, ok := d.Right.Type().(types.StringType); !ok { return nil, sql.ErrInvalidType.New(d.Right.Type()) } @@ -112,7 +113,7 @@ func (d MergeBase) String() string { // Type implements the sql.Expression interface. func (d MergeBase) Type() sql.Type { - return sql.Text + return types.Text } // WithChildren implements the sql.Expression interface. diff --git a/go/libraries/doltcore/sqle/dfunctions/dolt_pull.go b/go/libraries/doltcore/sqle/dfunctions/dolt_pull.go index 9a28195149..94a55b8db7 100644 --- a/go/libraries/doltcore/sqle/dfunctions/dolt_pull.go +++ b/go/libraries/doltcore/sqle/dfunctions/dolt_pull.go @@ -23,6 +23,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" @@ -58,7 +59,7 @@ func (d DoltPullFunc) String() string { } func (d DoltPullFunc) Type() sql.Type { - return sql.Boolean + return types.Boolean } func (d DoltPullFunc) WithChildren(children ...sql.Expression) (sql.Expression, error) { diff --git a/go/libraries/doltcore/sqle/dfunctions/dolt_push.go b/go/libraries/doltcore/sqle/dfunctions/dolt_push.go index 2a4ef333b6..d71c74fb82 100644 --- a/go/libraries/doltcore/sqle/dfunctions/dolt_push.go +++ b/go/libraries/doltcore/sqle/dfunctions/dolt_push.go @@ -21,6 +21,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" @@ -55,7 +56,7 @@ func (d DoltPushFunc) String() string { } func (d DoltPushFunc) Type() sql.Type { - return sql.Boolean + return types.Boolean } func (d DoltPushFunc) WithChildren(children ...sql.Expression) (sql.Expression, error) { diff --git a/go/libraries/doltcore/sqle/dfunctions/dolt_reset.go b/go/libraries/doltcore/sqle/dfunctions/dolt_reset.go index 5e340adcf6..0d397e9008 100644 --- a/go/libraries/doltcore/sqle/dfunctions/dolt_reset.go +++ b/go/libraries/doltcore/sqle/dfunctions/dolt_reset.go @@ -19,6 +19,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" @@ -155,7 +156,7 @@ func (d DoltResetFunc) String() string { } func (d DoltResetFunc) Type() sql.Type { - return sql.Int8 + return types.Int8 } func (d DoltResetFunc) IsNullable() bool { diff --git a/go/libraries/doltcore/sqle/dfunctions/hashof.go b/go/libraries/doltcore/sqle/dfunctions/hashof.go index 83f8d11352..bd938185ee 100644 --- a/go/libraries/doltcore/sqle/dfunctions/hashof.go +++ b/go/libraries/doltcore/sqle/dfunctions/hashof.go @@ -21,6 +21,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" @@ -131,5 +132,5 @@ func (t *HashOf) WithChildren(children ...sql.Expression) (sql.Expression, error // Type implements the Expression interface. func (t *HashOf) Type() sql.Type { - return sql.Text + return types.Text } diff --git a/go/libraries/doltcore/sqle/dfunctions/merge.go b/go/libraries/doltcore/sqle/dfunctions/merge.go index b86241a8ba..8a3ff78390 100644 --- a/go/libraries/doltcore/sqle/dfunctions/merge.go +++ b/go/libraries/doltcore/sqle/dfunctions/merge.go @@ -19,6 +19,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" goerrors "gopkg.in/src-d/go-errors.v1" ) @@ -82,5 +83,5 @@ func (mf *MergeFunc) WithChildren(children ...sql.Expression) (sql.Expression, e // Type implements the Expression interface. func (mf *MergeFunc) Type() sql.Type { - return sql.Text + return types.Text } diff --git a/go/libraries/doltcore/sqle/dfunctions/revert.go b/go/libraries/doltcore/sqle/dfunctions/revert.go index 5831414d31..964c9173f1 100644 --- a/go/libraries/doltcore/sqle/dfunctions/revert.go +++ b/go/libraries/doltcore/sqle/dfunctions/revert.go @@ -19,6 +19,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" @@ -175,7 +176,7 @@ func (r *RevertFunc) Resolved() bool { } func (r *RevertFunc) Type() sql.Type { - return sql.Int8 + return types.Int8 } // Children implements the Expression interface. diff --git a/go/libraries/doltcore/sqle/dfunctions/storage_format.go b/go/libraries/doltcore/sqle/dfunctions/storage_format.go index 71704b93c5..5fca2278ff 100644 --- a/go/libraries/doltcore/sqle/dfunctions/storage_format.go +++ b/go/libraries/doltcore/sqle/dfunctions/storage_format.go @@ -19,6 +19,7 @@ import ( "fmt" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" "github.com/dolthub/dolt/go/store/types" @@ -80,7 +81,7 @@ func (*StorageFormat) String() string { // Type implements the Expression interface. func (*StorageFormat) Type() sql.Type { - return sql.Text + return types2.Text } // WithChildren implements the Expression interface. diff --git a/go/libraries/doltcore/sqle/dfunctions/verify_constraints.go b/go/libraries/doltcore/sqle/dfunctions/verify_constraints.go index f849dd2ba2..4200c1fcdf 100644 --- a/go/libraries/doltcore/sqle/dfunctions/verify_constraints.go +++ b/go/libraries/doltcore/sqle/dfunctions/verify_constraints.go @@ -19,6 +19,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" @@ -152,7 +153,7 @@ func (vc *ConstraintsVerifyFunc) Resolved() bool { } func (vc *ConstraintsVerifyFunc) Type() sql.Type { - return sql.Int8 + return types.Int8 } // Children implements the Expression interface. diff --git a/go/libraries/doltcore/sqle/dfunctions/version.go b/go/libraries/doltcore/sqle/dfunctions/version.go index 666424c420..ca9d618dee 100644 --- a/go/libraries/doltcore/sqle/dfunctions/version.go +++ b/go/libraries/doltcore/sqle/dfunctions/version.go @@ -14,7 +14,10 @@ package dfunctions -import "github.com/dolthub/go-mysql-server/sql" +import ( + "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" +) const VersionFuncName = "dolt_version" @@ -54,7 +57,7 @@ func (*Version) String() string { // Type implements the Expression interface. func (*Version) Type() sql.Type { - return sql.Text + return types.Text } // WithChildren implements the Expression interface. diff --git a/go/libraries/doltcore/sqle/dolt_diff_summary_table_function.go b/go/libraries/doltcore/sqle/dolt_diff_summary_table_function.go index 1a85e63c63..6468ac477f 100644 --- a/go/libraries/doltcore/sqle/dolt_diff_summary_table_function.go +++ b/go/libraries/doltcore/sqle/dolt_diff_summary_table_function.go @@ -22,6 +22,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "golang.org/x/sync/errgroup" "github.com/dolthub/dolt/go/libraries/doltcore/diff" @@ -43,18 +44,18 @@ type DiffSummaryTableFunction struct { } var diffSummaryTableSchema = sql.Schema{ - &sql.Column{Name: "table_name", Type: sql.LongText, Nullable: false}, - &sql.Column{Name: "rows_unmodified", Type: sql.Int64, Nullable: true}, - &sql.Column{Name: "rows_added", Type: sql.Int64, Nullable: true}, - &sql.Column{Name: "rows_deleted", Type: sql.Int64, Nullable: true}, - &sql.Column{Name: "rows_modified", Type: sql.Int64, Nullable: true}, - &sql.Column{Name: "cells_added", Type: sql.Int64, Nullable: true}, - &sql.Column{Name: "cells_deleted", Type: sql.Int64, Nullable: true}, - &sql.Column{Name: "cells_modified", Type: sql.Int64, Nullable: true}, - &sql.Column{Name: "old_row_count", Type: sql.Int64, Nullable: true}, - &sql.Column{Name: "new_row_count", Type: sql.Int64, Nullable: true}, - &sql.Column{Name: "old_cell_count", Type: sql.Int64, Nullable: true}, - &sql.Column{Name: "new_cell_count", Type: sql.Int64, Nullable: true}, + &sql.Column{Name: "table_name", Type: types.LongText, Nullable: false}, + &sql.Column{Name: "rows_unmodified", Type: types.Int64, Nullable: true}, + &sql.Column{Name: "rows_added", Type: types.Int64, Nullable: true}, + &sql.Column{Name: "rows_deleted", Type: types.Int64, Nullable: true}, + &sql.Column{Name: "rows_modified", Type: types.Int64, Nullable: true}, + &sql.Column{Name: "cells_added", Type: types.Int64, Nullable: true}, + &sql.Column{Name: "cells_deleted", Type: types.Int64, Nullable: true}, + &sql.Column{Name: "cells_modified", Type: types.Int64, Nullable: true}, + &sql.Column{Name: "old_row_count", Type: types.Int64, Nullable: true}, + &sql.Column{Name: "new_row_count", Type: types.Int64, Nullable: true}, + &sql.Column{Name: "old_cell_count", Type: types.Int64, Nullable: true}, + &sql.Column{Name: "new_cell_count", Type: types.Int64, Nullable: true}, } // NewInstance creates a new instance of TableFunction interface @@ -138,7 +139,7 @@ func (ds *DiffSummaryTableFunction) WithChildren(children ...sql.Node) (sql.Node // CheckPrivileges implements the interface sql.Node. func (ds *DiffSummaryTableFunction) CheckPrivileges(ctx *sql.Context, opChecker sql.PrivilegedOperationChecker) bool { if ds.tableNameExpr != nil { - if !sql.IsText(ds.tableNameExpr.Type()) { + if !types.IsText(ds.tableNameExpr.Type()) { return false } @@ -220,20 +221,20 @@ func (ds *DiffSummaryTableFunction) WithExpressions(expression ...sql.Expression // validate the expressions if ds.dotCommitExpr != nil { - if !sql.IsText(ds.dotCommitExpr.Type()) { + if !types.IsText(ds.dotCommitExpr.Type()) { return nil, sql.ErrInvalidArgumentDetails.New(ds.Name(), ds.dotCommitExpr.String()) } } else { - if !sql.IsText(ds.fromCommitExpr.Type()) { + if !types.IsText(ds.fromCommitExpr.Type()) { return nil, sql.ErrInvalidArgumentDetails.New(ds.Name(), ds.fromCommitExpr.String()) } - if !sql.IsText(ds.toCommitExpr.Type()) { + if !types.IsText(ds.toCommitExpr.Type()) { return nil, sql.ErrInvalidArgumentDetails.New(ds.Name(), ds.toCommitExpr.String()) } } if ds.tableNameExpr != nil { - if !sql.IsText(ds.tableNameExpr.Type()) { + if !types.IsText(ds.tableNameExpr.Type()) { return nil, sql.ErrInvalidArgumentDetails.New(ds.Name(), ds.tableNameExpr.String()) } } diff --git a/go/libraries/doltcore/sqle/dolt_diff_table_function.go b/go/libraries/doltcore/sqle/dolt_diff_table_function.go index 15a8c07ca6..43fbe97d6a 100644 --- a/go/libraries/doltcore/sqle/dolt_diff_table_function.go +++ b/go/libraries/doltcore/sqle/dolt_diff_table_function.go @@ -29,6 +29,7 @@ import ( "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlutil" "github.com/dolthub/dolt/go/store/types" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/go-mysql-server/sql" "gopkg.in/src-d/go-errors.v1" @@ -346,7 +347,7 @@ func (dtf *DiffTableFunction) evaluateArguments() (interface{}, interface{}, int return nil, nil, nil, "", nil } - if !sql.IsText(dtf.tableNameExpr.Type()) { + if !types2.IsText(dtf.tableNameExpr.Type()) { return nil, nil, nil, "", sql.ErrInvalidArgumentDetails.New(dtf.Name(), dtf.tableNameExpr.String()) } @@ -361,7 +362,7 @@ func (dtf *DiffTableFunction) evaluateArguments() (interface{}, interface{}, int } if dtf.dotCommitExpr != nil { - if !sql.IsText(dtf.dotCommitExpr.Type()) { + if !types2.IsText(dtf.dotCommitExpr.Type()) { return nil, nil, nil, "", sql.ErrInvalidArgumentDetails.New(dtf.Name(), dtf.dotCommitExpr.String()) } @@ -373,10 +374,10 @@ func (dtf *DiffTableFunction) evaluateArguments() (interface{}, interface{}, int return nil, nil, dotCommitVal, tableName, nil } - if !sql.IsText(dtf.fromCommitExpr.Type()) { + if !types2.IsText(dtf.fromCommitExpr.Type()) { return nil, nil, nil, "", sql.ErrInvalidArgumentDetails.New(dtf.Name(), dtf.fromCommitExpr.String()) } - if !sql.IsText(dtf.toCommitExpr.Type()) { + if !types2.IsText(dtf.toCommitExpr.Type()) { return nil, nil, nil, "", sql.ErrInvalidArgumentDetails.New(dtf.Name(), dtf.toCommitExpr.String()) } diff --git a/go/libraries/doltcore/sqle/dolt_log_table_function.go b/go/libraries/doltcore/sqle/dolt_log_table_function.go index 39fec2ff12..51c1e1e94c 100644 --- a/go/libraries/doltcore/sqle/dolt_log_table_function.go +++ b/go/libraries/doltcore/sqle/dolt_log_table_function.go @@ -19,6 +19,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "gopkg.in/src-d/go-errors.v1" "github.com/dolthub/dolt/go/cmd/dolt/cli" @@ -46,11 +47,11 @@ type LogTableFunction struct { } var logTableSchema = sql.Schema{ - &sql.Column{Name: "commit_hash", Type: sql.Text}, - &sql.Column{Name: "committer", Type: sql.Text}, - &sql.Column{Name: "email", Type: sql.Text}, - &sql.Column{Name: "date", Type: sql.Datetime}, - &sql.Column{Name: "message", Type: sql.Text}, + &sql.Column{Name: "commit_hash", Type: types.Text}, + &sql.Column{Name: "committer", Type: types.Text}, + &sql.Column{Name: "email", Type: types.Text}, + &sql.Column{Name: "date", Type: types.Datetime}, + &sql.Column{Name: "message", Type: types.Text}, } // NewInstance creates a new instance of TableFunction interface @@ -135,10 +136,10 @@ func (ltf *LogTableFunction) Schema() sql.Schema { logSchema := logTableSchema if ltf.showParents { - logSchema = append(logSchema, &sql.Column{Name: "parents", Type: sql.Text}) + logSchema = append(logSchema, &sql.Column{Name: "parents", Type: types.Text}) } if shouldDecorateWithRefs(ltf.decoration) { - logSchema = append(logSchema, &sql.Column{Name: "refs", Type: sql.Text}) + logSchema = append(logSchema, &sql.Column{Name: "refs", Type: types.Text}) } return logSchema @@ -195,11 +196,11 @@ func getDoltArgs(ctx *sql.Context, expressions []sql.Expression, name string) ([ return nil, err } - if !sql.IsText(expr.Type()) { + if !types.IsText(expr.Type()) { return args, sql.ErrInvalidArgumentDetails.New(name, expr.String()) } - text, err := sql.Text.Convert(childVal) + text, err := types.Text.Convert(childVal) if err != nil { return nil, err } @@ -301,7 +302,7 @@ func (ltf *LogTableFunction) validateRevisionExpressions() error { if ltf.revisionExpr != nil { revisionStr = mustExpressionToString(ltf.ctx, ltf.revisionExpr) - if !sql.IsText(ltf.revisionExpr.Type()) { + if !types.IsText(ltf.revisionExpr.Type()) { return sql.ErrInvalidArgumentDetails.New(ltf.Name(), ltf.revisionExpr.String()) } if ltf.secondRevisionExpr == nil && strings.HasPrefix(revisionStr, "^") { @@ -314,7 +315,7 @@ func (ltf *LogTableFunction) validateRevisionExpressions() error { if ltf.secondRevisionExpr != nil { secondRevisionStr = mustExpressionToString(ltf.ctx, ltf.secondRevisionExpr) - if !sql.IsText(ltf.secondRevisionExpr.Type()) { + if !types.IsText(ltf.secondRevisionExpr.Type()) { return sql.ErrInvalidArgumentDetails.New(ltf.Name(), ltf.secondRevisionExpr.String()) } if strings.Contains(secondRevisionStr, "..") { diff --git a/go/libraries/doltcore/sqle/dprocedures/init.go b/go/libraries/doltcore/sqle/dprocedures/init.go index c8fa98b4df..f09dc6e511 100644 --- a/go/libraries/doltcore/sqle/dprocedures/init.go +++ b/go/libraries/doltcore/sqle/dprocedures/init.go @@ -14,7 +14,10 @@ package dprocedures -import "github.com/dolthub/go-mysql-server/sql" +import ( + "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" +) var DoltProcedures = []sql.ExternalStoredProcedureDetails{ {Name: "dolt_add", Schema: int64Schema("status"), Function: doltAdd}, @@ -61,7 +64,7 @@ func stringSchema(columnNames ...string) sql.Schema { for i, colName := range columnNames { sch[i] = &sql.Column{ Name: colName, - Type: sql.LongText, + Type: types.LongText, Nullable: false, } } @@ -74,7 +77,7 @@ func int64Schema(columnNames ...string) sql.Schema { for i, colName := range columnNames { sch[i] = &sql.Column{ Name: colName, - Type: sql.Int64, + Type: types.Int64, Nullable: false, } } diff --git a/go/libraries/doltcore/sqle/dsess/session.go b/go/libraries/doltcore/sqle/dsess/session.go index eeefe68cba..200a76d883 100644 --- a/go/libraries/doltcore/sqle/dsess/session.go +++ b/go/libraries/doltcore/sqle/dsess/session.go @@ -24,6 +24,8 @@ import ( "time" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/sysvars" + types2 "github.com/dolthub/go-mysql-server/sql/types" goerrors "gopkg.in/src-d/go-errors.v1" "github.com/dolthub/dolt/go/cmd/dolt/cli" @@ -145,7 +147,7 @@ func (d *DoltSession) lookupDbState(ctx *sql.Context, dbName string) (*DatabaseS var init InitialDbState var err error - _, val, ok := sql.SystemVariables.GetGlobal(DefaultBranchKey(dbName)) + _, val, ok := variables.SystemVariables.GetGlobal(DefaultBranchKey(dbName)) initialBranch := "" if ok { initialBranch = val.(string) @@ -323,7 +325,7 @@ func (d *DoltSession) StartTransaction(ctx *sql.Context, tCharacteristic sql.Tra return DisabledTransaction{}, nil } - if _, v, ok := sql.SystemVariables.GetGlobal(ReadReplicaRemote); ok && v != "" { + if _, v, ok := variables.SystemVariables.GetGlobal(ReadReplicaRemote); ok && v != "" { err = sessionState.dbData.Ddb.Rebase(ctx) if err != nil && !IgnoreReplicationErrors() { return nil, err @@ -1037,7 +1039,7 @@ func (d *DoltSession) setHeadRefSessionVar(ctx *sql.Context, db, value string) e } func (d *DoltSession) setForeignKeyChecksSessionVar(ctx *sql.Context, key string, value interface{}) error { - convertedVal, err := sql.Int64.Convert(value) + convertedVal, err := types2.Int64.Convert(value) if err != nil { return err } @@ -1373,7 +1375,7 @@ func (d *DoltSession) GetController() *branch_control.Controller { // validatePersistedSysVar checks whether a system variable exists and is dynamic func validatePersistableSysVar(name string) (sql.SystemVariable, interface{}, error) { - sysVar, val, ok := sql.SystemVariables.GetGlobal(name) + sysVar, val, ok := variables.SystemVariables.GetGlobal(name) if !ok { return sql.SystemVariable{}, nil, sql.ErrUnknownSystemVariable.New(name) } @@ -1480,7 +1482,7 @@ func SystemVariablesInConfig(conf config.ReadableConfig) ([]sql.SystemVariable, return true } // getPersistedVal already checked for errors - sysVar, _, _ = sql.SystemVariables.GetGlobal(k) + sysVar, _, _ = variables.SystemVariables.GetGlobal(k) sysVar.Default = def allVars[i] = sysVar i++ @@ -1515,6 +1517,6 @@ func InitPersistedSystemVars(dEnv *env.DoltEnv) error { for _, k := range missingKeys { cli.Printf("warning: persisted system variable %s was not loaded since its definition does not exist.\n", k) } - sql.SystemVariables.AddSystemVariables(persistedGlobalVars) + variables.SystemVariables.AddSystemVariables(persistedGlobalVars) return nil } diff --git a/go/libraries/doltcore/sqle/dsess/variables.go b/go/libraries/doltcore/sqle/dsess/variables.go index 94066e4e26..a0d3213a53 100644 --- a/go/libraries/doltcore/sqle/dsess/variables.go +++ b/go/libraries/doltcore/sqle/dsess/variables.go @@ -19,6 +19,8 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/sysvars" + "github.com/dolthub/go-mysql-server/sql/types" ) // Per-DB system variables @@ -54,14 +56,14 @@ const URLTemplateDatabasePlaceholder = "{database}" // DefineSystemVariablesForDB defines per database dolt-session variables in the engine as necessary func DefineSystemVariablesForDB(name string) { - if _, _, ok := sql.SystemVariables.GetGlobal(name + HeadKeySuffix); !ok { - sql.SystemVariables.AddSystemVariables([]sql.SystemVariable{ + if _, _, ok := variables.SystemVariables.GetGlobal(name + HeadKeySuffix); !ok { + variables.SystemVariables.AddSystemVariables([]sql.SystemVariable{ { Name: HeadRefKey(name), Scope: sql.SystemVariableScope_Session, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemStringType(HeadRefKey(name)), + Type: types.NewSystemStringType(HeadRefKey(name)), Default: "", }, // The following variable are Dynamic, but read-only. Their values @@ -71,7 +73,7 @@ func DefineSystemVariablesForDB(name string) { Scope: sql.SystemVariableScope_Session, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemStringType(HeadKey(name)), + Type: types.NewSystemStringType(HeadKey(name)), Default: "", }, { @@ -79,7 +81,7 @@ func DefineSystemVariablesForDB(name string) { Scope: sql.SystemVariableScope_Session, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemStringType(WorkingKey(name)), + Type: types.NewSystemStringType(WorkingKey(name)), Default: "", }, { @@ -87,7 +89,7 @@ func DefineSystemVariablesForDB(name string) { Scope: sql.SystemVariableScope_Session, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemStringType(StagedKey(name)), + Type: types.NewSystemStringType(StagedKey(name)), Default: "", }, { @@ -95,7 +97,7 @@ func DefineSystemVariablesForDB(name string) { Scope: sql.SystemVariableScope_Global, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemStringType(DefaultBranchKey(name)), + Type: types.NewSystemStringType(DefaultBranchKey(name)), Default: "", }, }) @@ -171,7 +173,7 @@ func GetBooleanSystemVar(ctx *sql.Context, varName string) (bool, error) { // IgnoreReplicationErrors returns true if the dolt_skip_replication_errors system variable is set to true, which means // that errors that occur during replication should be logged and ignored. func IgnoreReplicationErrors() bool { - _, skip, ok := sql.SystemVariables.GetGlobal(SkipReplicationErrors) + _, skip, ok := variables.SystemVariables.GetGlobal(SkipReplicationErrors) if !ok { panic("dolt system variables not loaded") } diff --git a/go/libraries/doltcore/sqle/dtables/binlog_table.go b/go/libraries/doltcore/sqle/dtables/binlog_table.go index 73241f19e3..5dbd8d1c03 100644 --- a/go/libraries/doltcore/sqle/dtables/binlog_table.go +++ b/go/libraries/doltcore/sqle/dtables/binlog_table.go @@ -16,6 +16,7 @@ package dtables import ( "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" @@ -32,37 +33,37 @@ const ( var accessBinlogSchema = sql.Schema{ &sql.Column{ Name: "index", - Type: sql.Int64, + Type: types.Int64, Source: AccessBinlogTableName, PrimaryKey: true, }, &sql.Column{ Name: "operation", - Type: sql.MustCreateEnumType([]string{"insert", "delete"}, sql.Collation_utf8mb4_0900_bin), + Type: types.MustCreateEnumType([]string{"insert", "delete"}, sql.Collation_utf8mb4_0900_bin), Source: AccessBinlogTableName, PrimaryKey: false, }, &sql.Column{ Name: "branch", - Type: sql.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), + Type: types.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), Source: AccessBinlogTableName, PrimaryKey: false, }, &sql.Column{ Name: "user", - Type: sql.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_bin), + Type: types.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_bin), Source: AccessBinlogTableName, PrimaryKey: false, }, &sql.Column{ Name: "host", - Type: sql.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), + Type: types.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), Source: AccessBinlogTableName, PrimaryKey: false, }, &sql.Column{ Name: "permissions", - Type: sql.MustCreateSetType(PermissionsStrings, sql.Collation_utf8mb4_0900_ai_ci), + Type: types.MustCreateSetType(PermissionsStrings, sql.Collation_utf8mb4_0900_ai_ci), Source: AccessBinlogTableName, PrimaryKey: false, }, @@ -72,31 +73,31 @@ var accessBinlogSchema = sql.Schema{ var namespaceBinlogSchema = sql.Schema{ &sql.Column{ Name: "index", - Type: sql.Int64, + Type: types.Int64, Source: NamespaceBinlogTableName, PrimaryKey: true, }, &sql.Column{ Name: "operation", - Type: sql.MustCreateEnumType([]string{"insert", "delete"}, sql.Collation_utf8mb4_0900_bin), + Type: types.MustCreateEnumType([]string{"insert", "delete"}, sql.Collation_utf8mb4_0900_bin), Source: NamespaceBinlogTableName, PrimaryKey: false, }, &sql.Column{ Name: "branch", - Type: sql.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), + Type: types.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), Source: NamespaceBinlogTableName, PrimaryKey: false, }, &sql.Column{ Name: "user", - Type: sql.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_bin), + Type: types.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_bin), Source: NamespaceBinlogTableName, PrimaryKey: false, }, &sql.Column{ Name: "host", - Type: sql.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), + Type: types.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), Source: NamespaceBinlogTableName, PrimaryKey: false, }, diff --git a/go/libraries/doltcore/sqle/dtables/branch_control_table.go b/go/libraries/doltcore/sqle/dtables/branch_control_table.go index 9fe1e1cdb0..40c3de736c 100644 --- a/go/libraries/doltcore/sqle/dtables/branch_control_table.go +++ b/go/libraries/doltcore/sqle/dtables/branch_control_table.go @@ -21,6 +21,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" @@ -39,31 +40,31 @@ var PermissionsStrings = []string{"admin", "write"} var accessSchema = sql.Schema{ &sql.Column{ Name: "database", - Type: sql.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), + Type: types.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), Source: AccessTableName, PrimaryKey: true, }, &sql.Column{ Name: "branch", - Type: sql.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), + Type: types.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), Source: AccessTableName, PrimaryKey: true, }, &sql.Column{ Name: "user", - Type: sql.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_bin), + Type: types.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_bin), Source: AccessTableName, PrimaryKey: true, }, &sql.Column{ Name: "host", - Type: sql.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), + Type: types.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), Source: AccessTableName, PrimaryKey: true, }, &sql.Column{ Name: "permissions", - Type: sql.MustCreateSetType(PermissionsStrings, sql.Collation_utf8mb4_0900_ai_ci), + Type: types.MustCreateSetType(PermissionsStrings, sql.Collation_utf8mb4_0900_ai_ci), Source: AccessTableName, PrimaryKey: false, }, diff --git a/go/libraries/doltcore/sqle/dtables/branch_namespace_control.go b/go/libraries/doltcore/sqle/dtables/branch_namespace_control.go index d78a92c83b..fd68796c66 100644 --- a/go/libraries/doltcore/sqle/dtables/branch_namespace_control.go +++ b/go/libraries/doltcore/sqle/dtables/branch_namespace_control.go @@ -21,6 +21,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" @@ -35,25 +36,25 @@ const ( var namespaceSchema = sql.Schema{ &sql.Column{ Name: "database", - Type: sql.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), + Type: types.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), Source: NamespaceTableName, PrimaryKey: true, }, &sql.Column{ Name: "branch", - Type: sql.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), + Type: types.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), Source: NamespaceTableName, PrimaryKey: true, }, &sql.Column{ Name: "user", - Type: sql.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_bin), + Type: types.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_bin), Source: NamespaceTableName, PrimaryKey: true, }, &sql.Column{ Name: "host", - Type: sql.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), + Type: types.MustCreateString(sqltypes.VarChar, 16383, sql.Collation_utf8mb4_0900_ai_ci), Source: NamespaceTableName, PrimaryKey: true, }, diff --git a/go/libraries/doltcore/sqle/dtables/branches_table.go b/go/libraries/doltcore/sqle/dtables/branches_table.go index e93d27c70c..e847620d55 100644 --- a/go/libraries/doltcore/sqle/dtables/branches_table.go +++ b/go/libraries/doltcore/sqle/dtables/branches_table.go @@ -19,6 +19,7 @@ import ( "io" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/index" @@ -55,12 +56,12 @@ func (bt *BranchesTable) String() string { // Schema is a sql.Table interface function that gets the sql.Schema of the branches system table func (bt *BranchesTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "name", Type: sql.Text, Source: doltdb.BranchesTableName, PrimaryKey: true, Nullable: false}, - {Name: "hash", Type: sql.Text, Source: doltdb.BranchesTableName, PrimaryKey: false, Nullable: false}, - {Name: "latest_committer", Type: sql.Text, Source: doltdb.BranchesTableName, PrimaryKey: false, Nullable: true}, - {Name: "latest_committer_email", Type: sql.Text, Source: doltdb.BranchesTableName, PrimaryKey: false, Nullable: true}, - {Name: "latest_commit_date", Type: sql.Datetime, Source: doltdb.BranchesTableName, PrimaryKey: false, Nullable: true}, - {Name: "latest_commit_message", Type: sql.Text, Source: doltdb.BranchesTableName, PrimaryKey: false, Nullable: true}, + {Name: "name", Type: types.Text, Source: doltdb.BranchesTableName, PrimaryKey: true, Nullable: false}, + {Name: "hash", Type: types.Text, Source: doltdb.BranchesTableName, PrimaryKey: false, Nullable: false}, + {Name: "latest_committer", Type: types.Text, Source: doltdb.BranchesTableName, PrimaryKey: false, Nullable: true}, + {Name: "latest_committer_email", Type: types.Text, Source: doltdb.BranchesTableName, PrimaryKey: false, Nullable: true}, + {Name: "latest_commit_date", Type: types.Datetime, Source: doltdb.BranchesTableName, PrimaryKey: false, Nullable: true}, + {Name: "latest_commit_message", Type: types.Text, Source: doltdb.BranchesTableName, PrimaryKey: false, Nullable: true}, } } diff --git a/go/libraries/doltcore/sqle/dtables/commit_ancestors_table.go b/go/libraries/doltcore/sqle/dtables/commit_ancestors_table.go index cbde12e055..b9393ca0ac 100644 --- a/go/libraries/doltcore/sqle/dtables/commit_ancestors_table.go +++ b/go/libraries/doltcore/sqle/dtables/commit_ancestors_table.go @@ -16,6 +16,7 @@ package dtables import ( "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/index" @@ -47,9 +48,9 @@ func (dt *CommitAncestorsTable) String() string { // Schema is a sql.Table interface function that gets the sql.Schema of the commit_ancestors system table. func (dt *CommitAncestorsTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "commit_hash", Type: sql.Text, Source: doltdb.CommitAncestorsTableName, PrimaryKey: true}, - {Name: "parent_hash", Type: sql.Text, Source: doltdb.CommitAncestorsTableName, PrimaryKey: true}, - {Name: "parent_index", Type: sql.Int32, Source: doltdb.CommitAncestorsTableName, PrimaryKey: true}, + {Name: "commit_hash", Type: types.Text, Source: doltdb.CommitAncestorsTableName, PrimaryKey: true}, + {Name: "parent_hash", Type: types.Text, Source: doltdb.CommitAncestorsTableName, PrimaryKey: true}, + {Name: "parent_index", Type: types.Int32, Source: doltdb.CommitAncestorsTableName, PrimaryKey: true}, } } diff --git a/go/libraries/doltcore/sqle/dtables/commits_table.go b/go/libraries/doltcore/sqle/dtables/commits_table.go index c85884a536..6f43936091 100644 --- a/go/libraries/doltcore/sqle/dtables/commits_table.go +++ b/go/libraries/doltcore/sqle/dtables/commits_table.go @@ -16,6 +16,7 @@ package dtables import ( "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/index" @@ -48,11 +49,11 @@ func (dt *CommitsTable) String() string { // Schema is a sql.Table interface function that gets the sql.Schema of the commits system table. func (dt *CommitsTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "commit_hash", Type: sql.Text, Source: doltdb.CommitsTableName, PrimaryKey: true}, - {Name: "committer", Type: sql.Text, Source: doltdb.CommitsTableName, PrimaryKey: false}, - {Name: "email", Type: sql.Text, Source: doltdb.CommitsTableName, PrimaryKey: false}, - {Name: "date", Type: sql.Datetime, Source: doltdb.CommitsTableName, PrimaryKey: false}, - {Name: "message", Type: sql.Text, Source: doltdb.CommitsTableName, PrimaryKey: false}, + {Name: "commit_hash", Type: types.Text, Source: doltdb.CommitsTableName, PrimaryKey: true}, + {Name: "committer", Type: types.Text, Source: doltdb.CommitsTableName, PrimaryKey: false}, + {Name: "email", Type: types.Text, Source: doltdb.CommitsTableName, PrimaryKey: false}, + {Name: "date", Type: types.Datetime, Source: doltdb.CommitsTableName, PrimaryKey: false}, + {Name: "message", Type: types.Text, Source: doltdb.CommitsTableName, PrimaryKey: false}, } } diff --git a/go/libraries/doltcore/sqle/dtables/log_table.go b/go/libraries/doltcore/sqle/dtables/log_table.go index d4aab1c506..8eefd9cebe 100644 --- a/go/libraries/doltcore/sqle/dtables/log_table.go +++ b/go/libraries/doltcore/sqle/dtables/log_table.go @@ -16,6 +16,7 @@ package dtables import ( "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/env/actions/commitwalk" "github.com/dolthub/dolt/go/store/hash" @@ -52,11 +53,11 @@ func (dt *LogTable) String() string { // Schema is a sql.Table interface function that gets the sql.Schema of the log system table. func (dt *LogTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "commit_hash", Type: sql.Text, Source: doltdb.LogTableName, PrimaryKey: true}, - {Name: "committer", Type: sql.Text, Source: doltdb.LogTableName, PrimaryKey: false}, - {Name: "email", Type: sql.Text, Source: doltdb.LogTableName, PrimaryKey: false}, - {Name: "date", Type: sql.Datetime, Source: doltdb.LogTableName, PrimaryKey: false}, - {Name: "message", Type: sql.Text, Source: doltdb.LogTableName, PrimaryKey: false}, + {Name: "commit_hash", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: true}, + {Name: "committer", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: false}, + {Name: "email", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: false}, + {Name: "date", Type: types.Datetime, Source: doltdb.LogTableName, PrimaryKey: false}, + {Name: "message", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: false}, } } diff --git a/go/libraries/doltcore/sqle/dtables/merge_status_table.go b/go/libraries/doltcore/sqle/dtables/merge_status_table.go index ac89470a32..2047bebf6a 100644 --- a/go/libraries/doltcore/sqle/dtables/merge_status_table.go +++ b/go/libraries/doltcore/sqle/dtables/merge_status_table.go @@ -20,6 +20,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" @@ -43,11 +44,11 @@ func (s MergeStatusTable) String() string { func (s MergeStatusTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "is_merging", Type: sql.Boolean, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: false}, - {Name: "source", Type: sql.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true}, - {Name: "source_commit", Type: sql.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true}, - {Name: "target", Type: sql.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true}, - {Name: "unmerged_tables", Type: sql.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true}, + {Name: "is_merging", Type: types.Boolean, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: false}, + {Name: "source", Type: types.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true}, + {Name: "source_commit", Type: types.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true}, + {Name: "target", Type: types.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true}, + {Name: "unmerged_tables", Type: types.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true}, } } diff --git a/go/libraries/doltcore/sqle/dtables/remotes_table.go b/go/libraries/doltcore/sqle/dtables/remotes_table.go index 95b01d36df..e431ffec11 100644 --- a/go/libraries/doltcore/sqle/dtables/remotes_table.go +++ b/go/libraries/doltcore/sqle/dtables/remotes_table.go @@ -19,6 +19,7 @@ import ( "io" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/env" @@ -57,10 +58,10 @@ func (bt *RemotesTable) String() string { // Schema is a sql.Table interface function that gets the sql.Schema of the remotes system table func (bt *RemotesTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "name", Type: sql.Text, Source: doltdb.RemotesTableName, PrimaryKey: true, Nullable: false}, - {Name: "url", Type: sql.Text, Source: doltdb.RemotesTableName, PrimaryKey: false, Nullable: false}, - {Name: "fetch_specs", Type: sql.JSON, Source: doltdb.RemotesTableName, PrimaryKey: false, Nullable: true}, - {Name: "params", Type: sql.JSON, Source: doltdb.RemotesTableName, PrimaryKey: false, Nullable: true}, + {Name: "name", Type: types.Text, Source: doltdb.RemotesTableName, PrimaryKey: true, Nullable: false}, + {Name: "url", Type: types.Text, Source: doltdb.RemotesTableName, PrimaryKey: false, Nullable: false}, + {Name: "fetch_specs", Type: types.JSON, Source: doltdb.RemotesTableName, PrimaryKey: false, Nullable: true}, + {Name: "params", Type: types.JSON, Source: doltdb.RemotesTableName, PrimaryKey: false, Nullable: true}, } } @@ -126,11 +127,11 @@ func (itr *RemoteItr) Next(*sql.Context) (sql.Row, error) { remote := itr.remotes[itr.idx] - fs, err := sql.JSON.Convert(remote.FetchSpecs) + fs, err := types.JSON.Convert(remote.FetchSpecs) if err != nil { return nil, err } - params, err := sql.JSON.Convert(remote.Params) + params, err := types.JSON.Convert(remote.Params) if err != nil { return nil, err } diff --git a/go/libraries/doltcore/sqle/dtables/status_table.go b/go/libraries/doltcore/sqle/dtables/status_table.go index 88bc06c15a..ab13cb7481 100644 --- a/go/libraries/doltcore/sqle/dtables/status_table.go +++ b/go/libraries/doltcore/sqle/dtables/status_table.go @@ -19,6 +19,7 @@ import ( "io" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/diff" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" @@ -44,9 +45,9 @@ func (s StatusTable) String() string { func (s StatusTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "table_name", Type: sql.Text, Source: doltdb.StatusTableName, PrimaryKey: true, Nullable: false}, - {Name: "staged", Type: sql.Boolean, Source: doltdb.StatusTableName, PrimaryKey: false, Nullable: false}, - {Name: "status", Type: sql.Text, Source: doltdb.StatusTableName, PrimaryKey: false, Nullable: false}, + {Name: "table_name", Type: types.Text, Source: doltdb.StatusTableName, PrimaryKey: true, Nullable: false}, + {Name: "staged", Type: types.Boolean, Source: doltdb.StatusTableName, PrimaryKey: false, Nullable: false}, + {Name: "status", Type: types.Text, Source: doltdb.StatusTableName, PrimaryKey: false, Nullable: false}, } } diff --git a/go/libraries/doltcore/sqle/dtables/table_of_tables_in_conflict.go b/go/libraries/doltcore/sqle/dtables/table_of_tables_in_conflict.go index fc9496c1cf..aa52493bd4 100644 --- a/go/libraries/doltcore/sqle/dtables/table_of_tables_in_conflict.go +++ b/go/libraries/doltcore/sqle/dtables/table_of_tables_in_conflict.go @@ -18,6 +18,7 @@ import ( "io" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" @@ -51,8 +52,8 @@ func (dt *TableOfTablesInConflict) String() string { // Schema is a sql.Table interface function that gets the sql.Schema of the log system table. func (dt *TableOfTablesInConflict) Schema() sql.Schema { return []*sql.Column{ - {Name: "table", Type: sql.Text, Source: doltdb.TableOfTablesInConflictName, PrimaryKey: true}, - {Name: "num_conflicts", Type: sql.Uint64, Source: doltdb.TableOfTablesInConflictName, PrimaryKey: false}, + {Name: "table", Type: types.Text, Source: doltdb.TableOfTablesInConflictName, PrimaryKey: true}, + {Name: "num_conflicts", Type: types.Uint64, Source: doltdb.TableOfTablesInConflictName, PrimaryKey: false}, } } diff --git a/go/libraries/doltcore/sqle/dtables/table_of_tables_with_violations.go b/go/libraries/doltcore/sqle/dtables/table_of_tables_with_violations.go index e9e801762e..bb3ab3dce8 100644 --- a/go/libraries/doltcore/sqle/dtables/table_of_tables_with_violations.go +++ b/go/libraries/doltcore/sqle/dtables/table_of_tables_with_violations.go @@ -19,6 +19,7 @@ import ( "io" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" ) @@ -49,8 +50,8 @@ func (totwv *TableOfTablesWithViolations) String() string { // Schema implements the interface sql.Table. func (totwv *TableOfTablesWithViolations) Schema() sql.Schema { return []*sql.Column{ - {Name: "table", Type: sql.Text, Source: doltdb.TableOfTablesWithViolationsName, PrimaryKey: true}, - {Name: "num_violations", Type: sql.Uint64, Source: doltdb.TableOfTablesWithViolationsName, PrimaryKey: false}, + {Name: "table", Type: types.Text, Source: doltdb.TableOfTablesWithViolationsName, PrimaryKey: true}, + {Name: "num_violations", Type: types.Uint64, Source: doltdb.TableOfTablesWithViolationsName, PrimaryKey: false}, } } diff --git a/go/libraries/doltcore/sqle/dtables/tags_table.go b/go/libraries/doltcore/sqle/dtables/tags_table.go index 81610db102..51a08fb4cb 100644 --- a/go/libraries/doltcore/sqle/dtables/tags_table.go +++ b/go/libraries/doltcore/sqle/dtables/tags_table.go @@ -18,6 +18,7 @@ import ( "io" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/index" @@ -50,12 +51,12 @@ func (dt *TagsTable) String() string { // Schema is a sql.Table interface function that gets the sql.Schema of the tags system table. func (dt *TagsTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "tag_name", Type: sql.Text, Source: doltdb.TagsTableName, PrimaryKey: true}, - {Name: "tag_hash", Type: sql.Text, Source: doltdb.TagsTableName, PrimaryKey: true}, - {Name: "tagger", Type: sql.Text, Source: doltdb.TagsTableName, PrimaryKey: false}, - {Name: "email", Type: sql.Text, Source: doltdb.TagsTableName, PrimaryKey: false}, - {Name: "date", Type: sql.Datetime, Source: doltdb.TagsTableName, PrimaryKey: false}, - {Name: "message", Type: sql.Text, Source: doltdb.TagsTableName, PrimaryKey: false}, + {Name: "tag_name", Type: types.Text, Source: doltdb.TagsTableName, PrimaryKey: true}, + {Name: "tag_hash", Type: types.Text, Source: doltdb.TagsTableName, PrimaryKey: true}, + {Name: "tagger", Type: types.Text, Source: doltdb.TagsTableName, PrimaryKey: false}, + {Name: "email", Type: types.Text, Source: doltdb.TagsTableName, PrimaryKey: false}, + {Name: "date", Type: types.Datetime, Source: doltdb.TagsTableName, PrimaryKey: false}, + {Name: "message", Type: types.Text, Source: doltdb.TagsTableName, PrimaryKey: false}, } } diff --git a/go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go b/go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go index e7ed8675f2..7284b9f69a 100644 --- a/go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go +++ b/go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go @@ -26,6 +26,7 @@ import ( "github.com/dolthub/dolt/go/libraries/utils/set" "github.com/dolthub/dolt/go/store/datas" "github.com/dolthub/dolt/go/store/hash" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" @@ -106,14 +107,14 @@ func (dt *UnscopedDiffTable) String() string { // Schema is a sql.Table interface function that returns the sql.Schema for this system table. func (dt *UnscopedDiffTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "commit_hash", Type: sql.Text, Source: doltdb.DiffTableName, PrimaryKey: true}, - {Name: "table_name", Type: sql.Text, Source: doltdb.DiffTableName, PrimaryKey: true}, - {Name: "committer", Type: sql.Text, Source: doltdb.DiffTableName, PrimaryKey: false}, - {Name: "email", Type: sql.Text, Source: doltdb.DiffTableName, PrimaryKey: false}, - {Name: "date", Type: sql.Datetime, Source: doltdb.DiffTableName, PrimaryKey: false}, - {Name: "message", Type: sql.Text, Source: doltdb.DiffTableName, PrimaryKey: false}, - {Name: "data_change", Type: sql.Boolean, Source: doltdb.DiffTableName, PrimaryKey: false}, - {Name: "schema_change", Type: sql.Boolean, Source: doltdb.DiffTableName, PrimaryKey: false}, + {Name: "commit_hash", Type: types.Text, Source: doltdb.DiffTableName, PrimaryKey: true}, + {Name: "table_name", Type: types.Text, Source: doltdb.DiffTableName, PrimaryKey: true}, + {Name: "committer", Type: types.Text, Source: doltdb.DiffTableName, PrimaryKey: false}, + {Name: "email", Type: types.Text, Source: doltdb.DiffTableName, PrimaryKey: false}, + {Name: "date", Type: types.Datetime, Source: doltdb.DiffTableName, PrimaryKey: false}, + {Name: "message", Type: types.Text, Source: doltdb.DiffTableName, PrimaryKey: false}, + {Name: "data_change", Type: types.Boolean, Source: doltdb.DiffTableName, PrimaryKey: false}, + {Name: "schema_change", Type: types.Boolean, Source: doltdb.DiffTableName, PrimaryKey: false}, } } diff --git a/go/libraries/doltcore/sqle/enginetest/blob_queries.go b/go/libraries/doltcore/sqle/enginetest/blob_queries.go index 6c546c3809..7ef929a3ab 100644 --- a/go/libraries/doltcore/sqle/enginetest/blob_queries.go +++ b/go/libraries/doltcore/sqle/enginetest/blob_queries.go @@ -17,12 +17,13 @@ package enginetest import ( "github.com/dolthub/go-mysql-server/enginetest/queries" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" ) var BigBlobQueries = []queries.WriteQueryTest{ { WriteQuery: "INSERT INTO blobt VALUES(4, LOAD_FILE('testdata/test1.png'))", - ExpectedWriteResult: []sql.Row{{sql.NewOkResult(1)}}, + ExpectedWriteResult: []sql.Row{{types.NewOkResult(1)}}, SelectQuery: "select sha1(b) from blobt where i = 4", ExpectedSelect: []sql.Row{{"012bcb75a319f2913614a5170fc046fb6c49ee86"}}, }, diff --git a/go/libraries/doltcore/sqle/enginetest/branch_control_test.go b/go/libraries/doltcore/sqle/enginetest/branch_control_test.go index f190bd44f6..c1943e3ce5 100644 --- a/go/libraries/doltcore/sqle/enginetest/branch_control_test.go +++ b/go/libraries/doltcore/sqle/enginetest/branch_control_test.go @@ -21,6 +21,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/mysql_db" "github.com/dolthub/go-mysql-server/sql/plan" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gopkg.in/src-d/go-errors.v1" @@ -387,7 +388,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "INSERT INTO dolt_branch_namespace_control VALUES ('%', 'other%', 'root', 'localhost');", Expected: []sql.Row{ - {sql.NewOkResult(1)}, + {types.NewOkResult(1)}, }, }, { @@ -401,7 +402,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "INSERT INTO dolt_branch_namespace_control VALUES ('%', 'other%', 'testuser', 'localhost');", Expected: []sql.Row{ - {sql.NewOkResult(1)}, + {types.NewOkResult(1)}, }, }, { @@ -415,7 +416,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "INSERT INTO dolt_branch_namespace_control VALUES ('%', 'otherbranch%', 'root', 'localhost');", Expected: []sql.Row{ - {sql.NewOkResult(1)}, + {types.NewOkResult(1)}, }, }, { // Matches both "other%" and "otherbranch%", but "otherbranch%" wins by being the longer match @@ -435,7 +436,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "INSERT INTO dolt_branch_namespace_control VALUES ('%', 'otherbranch%', 'testuser', 'localhost');", Expected: []sql.Row{ - {sql.NewOkResult(1)}, + {types.NewOkResult(1)}, }, }, { @@ -483,7 +484,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "INSERT INTO dolt_branch_control VALUES ('%', 'prefix1%', 'b', 'localhost', 'write');", Expected: []sql.Row{ - {sql.NewOkResult(1)}, + {types.NewOkResult(1)}, }, }, { @@ -509,7 +510,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "UPDATE dolt_branch_control SET permissions = 'admin' WHERE branch = 'prefix1%';", Expected: []sql.Row{ - {sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}, + {types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}, }, }, { @@ -517,7 +518,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "DELETE FROM dolt_branch_control WHERE branch = 'prefix1%';", Expected: []sql.Row{ - {sql.NewOkResult(1)}, + {types.NewOkResult(1)}, }, }, { @@ -531,7 +532,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "INSERT INTO dolt_branch_namespace_control VALUES ('%', 'prefix___', 'a', 'localhost');", Expected: []sql.Row{ - {sql.NewOkResult(1)}, + {types.NewOkResult(1)}, }, }, { @@ -545,7 +546,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "UPDATE dolt_branch_namespace_control SET branch = 'prefix%';", Expected: []sql.Row{ - {sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}, + {types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}, }, }, { @@ -601,7 +602,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "INSERT INTO test VALUES (1);", Expected: []sql.Row{ - {sql.NewOkResult(1)}, + {types.NewOkResult(1)}, }, }, }, @@ -762,7 +763,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "CREATE TABLE test (pk BIGINT PRIMARY KEY);", Expected: []sql.Row{ - {sql.NewOkResult(0)}, + {types.NewOkResult(0)}, }, }, { @@ -770,7 +771,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "DROP TABLE test;", Expected: []sql.Row{ - {sql.NewOkResult(0)}, + {types.NewOkResult(0)}, }, }, { @@ -808,7 +809,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "CREATE TABLE test (pk BIGINT PRIMARY KEY);", Expected: []sql.Row{ - {sql.NewOkResult(0)}, + {types.NewOkResult(0)}, }, }, }, @@ -871,7 +872,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "INSERT INTO dolt_branch_control VALUES ('dba', 'dummy1', '%', '%', 'write');", Expected: []sql.Row{ - {sql.NewOkResult(1)}, + {types.NewOkResult(1)}, }, }, { @@ -903,7 +904,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "INSERT INTO dolt_branch_control VALUES ('dbb', 'dummy6', '%', '%', 'write');", Expected: []sql.Row{ - {sql.NewOkResult(1)}, + {types.NewOkResult(1)}, }, }, { @@ -911,7 +912,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "GRANT SUPER ON *.* TO a@localhost WITH GRANT OPTION;", Expected: []sql.Row{ - {sql.NewOkResult(0)}, + {types.NewOkResult(0)}, }, }, { @@ -919,7 +920,7 @@ var BranchControlTests = []BranchControlTest{ Host: "localhost", Query: "INSERT INTO dolt_branch_control VALUES ('db_', 'dummy7', '%', '%', 'write');", Expected: []sql.Row{ - {sql.NewOkResult(1)}, + {types.NewOkResult(1)}, }, }, { @@ -1015,7 +1016,7 @@ func TestBranchControlBlocks(t *testing.T) { }) enginetest.AssertErrWithCtx(t, engine, harness, userCtx, test.Query, test.ExpectedErr) addUserQuery := "INSERT INTO dolt_branch_control VALUES ('%', 'main', 'testuser', 'localhost', 'write'), ('%', 'other', 'testuser', 'localhost', 'write');" - addUserQueryResults := []sql.Row{{sql.NewOkResult(2)}} + addUserQueryResults := []sql.Row{{types.NewOkResult(2)}} enginetest.TestQueryWithContext(t, rootCtx, engine, harness, addUserQuery, addUserQueryResults, nil, nil) sch, iter, err := engine.Query(userCtx, test.Query) if err == nil { diff --git a/go/libraries/doltcore/sqle/enginetest/ddl_queries.go b/go/libraries/doltcore/sqle/enginetest/ddl_queries.go index 546d91567c..6bd3f1c3d9 100755 --- a/go/libraries/doltcore/sqle/enginetest/ddl_queries.go +++ b/go/libraries/doltcore/sqle/enginetest/ddl_queries.go @@ -17,6 +17,7 @@ package enginetest import ( "github.com/dolthub/go-mysql-server/enginetest/queries" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/schema" ) @@ -453,7 +454,7 @@ var ModifyColumnTypeScripts = []queries.ScriptTest{ Assertions: []queries.ScriptTestAssertion{ { Query: "alter table test modify column pk datetime", - ExpectedErr: sql.ErrConvertingToTime, + ExpectedErr: types.ErrConvertingToTime, }, }, }, diff --git a/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go b/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go index 65ede3073a..ebb0d8977e 100644 --- a/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go +++ b/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go @@ -28,6 +28,7 @@ import ( "github.com/dolthub/go-mysql-server/sql/expression" "github.com/dolthub/go-mysql-server/sql/mysql_db" "github.com/dolthub/go-mysql-server/sql/plan" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/mysql" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -204,7 +205,7 @@ func TestSingleScriptPrepared(t *testing.T) { tt := queries.QueryTest{ Query: "select * from test as of 'HEAD~2' where pk=?", Bindings: map[string]sql.Expression{ - "v1": expression.NewLiteral(0, sql.Int8), + "v1": expression.NewLiteral(0, types2.Int8), }, Expected: []sql.Row{{0, 0}}, } @@ -543,7 +544,7 @@ func TestDropDatabase(t *testing.T) { Assertions: []queries.ScriptTestAssertion{ { Query: "DROP DATABASE TeSt2DB", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types2.OkResult{RowsAffected: 1}}}, }, { Query: "USE test2db", @@ -555,7 +556,7 @@ func TestDropDatabase(t *testing.T) { }, { Query: "DROP DATABASE IF EXISTS test1DB", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types2.OkResult{RowsAffected: 1}}}, }, { Query: "USE Test1db", @@ -1048,7 +1049,7 @@ func TestSingleTransactionScript(t *testing.T) { }, { Query: "/* client a */ insert into test values (1, 1)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types2.NewOkResult(1)}}, }, { Query: "/* client b */ call dolt_checkout('-b', 'new-branch')", @@ -1060,7 +1061,7 @@ func TestSingleTransactionScript(t *testing.T) { }, { Query: "/* client b */ insert into test values (1, 2)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types2.NewOkResult(1)}}, }, { Query: "/* client b */ call dolt_commit('-am', 'commit on new-branch')", @@ -1084,7 +1085,7 @@ func TestSingleTransactionScript(t *testing.T) { }, { // TODO: it should be possible to do this without specifying a literal in the subselect, but it's not working Query: "/* client b */ update test t set val = (select their_val from dolt_conflicts_test where our_pk = 1) where pk = 1", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types2.OkResult{ RowsAffected: 1, Info: plan.UpdateInfo{ Matched: 1, @@ -1094,7 +1095,7 @@ func TestSingleTransactionScript(t *testing.T) { }, { Query: "/* client b */ delete from dolt_conflicts_test", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types2.NewOkResult(1)}}, }, { Query: "/* client b */ commit", diff --git a/go/libraries/doltcore/sqle/enginetest/dolt_queries.go b/go/libraries/doltcore/sqle/enginetest/dolt_queries.go index 877dd66138..76b0d1491c 100644 --- a/go/libraries/doltcore/sqle/enginetest/dolt_queries.go +++ b/go/libraries/doltcore/sqle/enginetest/dolt_queries.go @@ -22,6 +22,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" "github.com/dolthub/go-mysql-server/sql/plan" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/sqle" ) @@ -408,7 +409,7 @@ var DoltRevisionDbScripts = []queries.ScriptTest{ }, { Query: "create table working_set_table(pk int primary key);", - Expected: []sql.Row{{sql.NewOkResult(0)}}, + Expected: []sql.Row{{types.NewOkResult(0)}}, }, { // Create a table in the working set to verify the main db @@ -489,7 +490,7 @@ var DoltScripts = []queries.ScriptTest{ Assertions: []queries.ScriptTestAssertion{ { Query: "alter table t add index ```i```(c1);", - Expected: []sql.Row{{sql.OkResult{}}}, + Expected: []sql.Row{{types.OkResult{}}}, }, { Query: "show create table t;", @@ -628,28 +629,28 @@ var DoltScripts = []queries.ScriptTest{ Query: "select * from test as of 'HEAD~' where pk=?;", Expected: []sql.Row{{0, 0}}, Bindings: map[string]sql.Expression{ - "v1": expression.NewLiteral(0, sql.Int8), + "v1": expression.NewLiteral(0, types.Int8), }, }, { Query: "select * from test as of hashof('HEAD') where pk=?;", Expected: []sql.Row{{1, 1, nil}}, Bindings: map[string]sql.Expression{ - "v1": expression.NewLiteral(1, sql.Int8), + "v1": expression.NewLiteral(1, types.Int8), }, }, { Query: "select * from test as of @Commit1 where pk=?;", Expected: []sql.Row{{0, 0}}, Bindings: map[string]sql.Expression{ - "v1": expression.NewLiteral(0, sql.Int8), + "v1": expression.NewLiteral(0, types.Int8), }, }, { Query: "select * from test as of @Commit2 where pk=?;", Expected: []sql.Row{{0, 0, nil}}, Bindings: map[string]sql.Expression{ - "v1": expression.NewLiteral(0, sql.Int8), + "v1": expression.NewLiteral(0, types.Int8), }, }, }, @@ -720,7 +721,7 @@ var DoltScripts = []queries.ScriptTest{ { Query: "INSERT INTO `users_token` (`id`, `user_id`, `created`, `expires`, `key`, `write_enabled`, `description`) " + "VALUES ('acc2e157db2845a79221cc654b1dcecc', '1056443cc03446c592fa4c06bb06a1a6', '2022-08-30 18:27:21.948487', NULL, '0123456789abcdef0123456789abcdef01234567', 1, '');", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 0x1, InsertID: 0x0}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 0x1, InsertID: 0x0}}}, }, }, }, @@ -807,7 +808,7 @@ var DoltUserPrivTests = []queries.UserPrivilegeTest{ User: "root", Host: "localhost", Query: "GRANT SELECT ON mydb.test TO tester@localhost;", - Expected: []sql.Row{{sql.NewOkResult(0)}}, + Expected: []sql.Row{{types.NewOkResult(0)}}, }, { // After granting access to mydb.test, dolt_diff should work @@ -870,7 +871,7 @@ var DoltUserPrivTests = []queries.UserPrivilegeTest{ User: "root", Host: "localhost", Query: "REVOKE SELECT ON mydb.test from tester@localhost;", - Expected: []sql.Row{{sql.NewOkResult(0)}}, + Expected: []sql.Row{{types.NewOkResult(0)}}, }, { // After revoking access, dolt_diff should fail @@ -891,7 +892,7 @@ var DoltUserPrivTests = []queries.UserPrivilegeTest{ User: "root", Host: "localhost", Query: "GRANT SELECT ON mydb.* to tester@localhost;", - Expected: []sql.Row{{sql.NewOkResult(0)}}, + Expected: []sql.Row{{types.NewOkResult(0)}}, }, { // After granting access to the entire db, dolt_diff should work @@ -933,7 +934,7 @@ var DoltUserPrivTests = []queries.UserPrivilegeTest{ User: "root", Host: "localhost", Query: "REVOKE SELECT ON mydb.* from tester@localhost;", - Expected: []sql.Row{{sql.NewOkResult(0)}}, + Expected: []sql.Row{{types.NewOkResult(0)}}, }, { // After revoking access, dolt_diff should fail @@ -968,7 +969,7 @@ var DoltUserPrivTests = []queries.UserPrivilegeTest{ User: "root", Host: "localhost", Query: "GRANT SELECT ON *.* to tester@localhost;", - Expected: []sql.Row{{sql.NewOkResult(0)}}, + Expected: []sql.Row{{types.NewOkResult(0)}}, }, { // After granting global access to *.*, dolt_diff should work @@ -989,7 +990,7 @@ var DoltUserPrivTests = []queries.UserPrivilegeTest{ User: "root", Host: "localhost", Query: "REVOKE ALL ON *.* from tester@localhost;", - Expected: []sql.Row{{sql.NewOkResult(0)}}, + Expected: []sql.Row{{types.NewOkResult(0)}}, }, { // After revoking global access, dolt_diff should fail @@ -2361,7 +2362,7 @@ var LargeJsonObjectScriptTests = []queries.ScriptTest{ Assertions: []queries.ScriptTestAssertion{ { Query: `insert into t set j= concat('[', repeat('"word",', 10000000), '"word"]')`, - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, }, }, @@ -2373,7 +2374,7 @@ var LargeJsonObjectScriptTests = []queries.ScriptTest{ Assertions: []queries.ScriptTestAssertion{ { Query: `insert into t set j= concat('[', repeat('"word",', 50000000), '"word"]')`, - ExpectedErr: sql.ErrLengthTooLarge, + ExpectedErr: types.ErrLengthTooLarge, }, }, }, @@ -2463,7 +2464,7 @@ var DoltTagTestScripts = []queries.ScriptTest{ }, { Query: "INSERT INTO test VALUES (8), (9)", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2}}}, }, { Query: "CALL DOLT_COMMIT('-am','made changes in other')", @@ -2491,7 +2492,7 @@ var DoltRemoteTestScripts = []queries.ScriptTest{ }, { Query: "SELECT name, IF(CHAR_LENGTH(url) < 0, NULL, 'not null'), fetch_specs, params FROM DOLT_REMOTES", - Expected: []sql.Row{{"origin", "not null", sql.MustJSON(`["refs/heads/*:refs/remotes/origin/*"]`), sql.MustJSON(`{}`)}}, + Expected: []sql.Row{{"origin", "not null", types.MustJSON(`["refs/heads/*:refs/remotes/origin/*"]`), types.MustJSON(`{}`)}}, }, { Query: "CALL DOLT_REMOTE()", @@ -2517,8 +2518,8 @@ var DoltRemoteTestScripts = []queries.ScriptTest{ { Query: "SELECT name, IF(CHAR_LENGTH(url) < 0, NULL, 'not null'), fetch_specs, params FROM DOLT_REMOTES", Expected: []sql.Row{ - {"origin1", "not null", sql.MustJSON(`["refs/heads/*:refs/remotes/origin1/*"]`), sql.MustJSON(`{}`)}, - {"origin2", "not null", sql.MustJSON(`["refs/heads/*:refs/remotes/origin2/*"]`), sql.MustJSON(`{}`)}}, + {"origin1", "not null", types.MustJSON(`["refs/heads/*:refs/remotes/origin1/*"]`), types.MustJSON(`{}`)}, + {"origin2", "not null", types.MustJSON(`["refs/heads/*:refs/remotes/origin2/*"]`), types.MustJSON(`{}`)}}, }, { Query: "CALL DOLT_REMOTE('remove','origin2')", @@ -2526,7 +2527,7 @@ var DoltRemoteTestScripts = []queries.ScriptTest{ }, { Query: "SELECT name, IF(CHAR_LENGTH(url) < 0, NULL, 'not null'), fetch_specs, params FROM DOLT_REMOTES", - Expected: []sql.Row{{"origin1", "not null", sql.MustJSON(`["refs/heads/*:refs/remotes/origin1/*"]`), sql.MustJSON(`{}`)}}, + Expected: []sql.Row{{"origin1", "not null", types.MustJSON(`["refs/heads/*:refs/remotes/origin1/*"]`), types.MustJSON(`{}`)}}, }, // 'origin1' remote must exist in order this error to be returned; otherwise, no error from EOF { @@ -2579,7 +2580,7 @@ var DoltAutoIncrementTests = []queries.ScriptTest{ Assertions: []queries.ScriptTestAssertion{ { Query: "insert into t (b) values (1), (2)", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2, InsertID: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2, InsertID: 1}}}, }, { Query: "call dolt_commit('-am', 'two values on main')", @@ -2591,7 +2592,7 @@ var DoltAutoIncrementTests = []queries.ScriptTest{ }, { Query: "insert into t (b) values (3), (4)", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2, InsertID: 3}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2, InsertID: 3}}}, }, { Query: "select * from t order by a", @@ -2610,7 +2611,7 @@ var DoltAutoIncrementTests = []queries.ScriptTest{ }, { Query: "insert into t (b) values (5), (6)", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2, InsertID: 5}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2, InsertID: 5}}}, }, { Query: "select * from t order by a", @@ -2641,7 +2642,7 @@ var DoltAutoIncrementTests = []queries.ScriptTest{ Assertions: []queries.ScriptTestAssertion{ { Query: "drop table t", - Expected: []sql.Row{{sql.NewOkResult(0)}}, + Expected: []sql.Row{{types.NewOkResult(0)}}, }, { Query: "call dolt_checkout('main')", @@ -2650,7 +2651,7 @@ var DoltAutoIncrementTests = []queries.ScriptTest{ { // highest value in any branch is 6 Query: "insert into t (b) values (7), (8)", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2, InsertID: 7}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2, InsertID: 7}}}, }, { Query: "select * from t order by a", @@ -2663,7 +2664,7 @@ var DoltAutoIncrementTests = []queries.ScriptTest{ }, { Query: "drop table t", - Expected: []sql.Row{{sql.NewOkResult(0)}}, + Expected: []sql.Row{{types.NewOkResult(0)}}, }, { Query: "call dolt_checkout('branch2')", @@ -2672,7 +2673,7 @@ var DoltAutoIncrementTests = []queries.ScriptTest{ { // highest value in any branch is still 6 (dropped table above) Query: "insert into t (b) values (7), (8)", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2, InsertID: 7}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2, InsertID: 7}}}, }, { Query: "select * from t order by a", @@ -2685,7 +2686,7 @@ var DoltAutoIncrementTests = []queries.ScriptTest{ }, { Query: "drop table t", - Expected: []sql.Row{{sql.NewOkResult(0)}}, + Expected: []sql.Row{{types.NewOkResult(0)}}, }, { Query: "create table t (a int primary key auto_increment, b int)", @@ -2694,7 +2695,7 @@ var DoltAutoIncrementTests = []queries.ScriptTest{ { // no value on any branch Query: "insert into t (b) values (1), (2)", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2, InsertID: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2, InsertID: 1}}}, }, { Query: "select * from t order by a", @@ -2731,7 +2732,7 @@ var BrokenAutoIncrementTests = []queries.ScriptTest{ Assertions: []queries.ScriptTestAssertion{ { Query: "truncate table t", - Expected: []sql.Row{{sql.NewOkResult(2)}}, + Expected: []sql.Row{{types.NewOkResult(2)}}, }, { Query: "call dolt_checkout('main')", @@ -2740,7 +2741,7 @@ var BrokenAutoIncrementTests = []queries.ScriptTest{ { // highest value in any branch is 6 Query: "insert into t (b) values (7), (8)", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2, InsertID: 7}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2, InsertID: 7}}}, }, { Query: "select * from t order by a", @@ -2753,7 +2754,7 @@ var BrokenAutoIncrementTests = []queries.ScriptTest{ }, { Query: "truncate table t", - Expected: []sql.Row{{sql.NewOkResult(4)}}, + Expected: []sql.Row{{types.NewOkResult(4)}}, }, { Query: "call dolt_checkout('branch2')", @@ -2762,7 +2763,7 @@ var BrokenAutoIncrementTests = []queries.ScriptTest{ { // highest value in any branch is still 6 (truncated table above) Query: "insert into t (b) values (7), (8)", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2, InsertID: 7}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2, InsertID: 7}}}, }, { Query: "select * from t order by a", @@ -2775,12 +2776,12 @@ var BrokenAutoIncrementTests = []queries.ScriptTest{ }, { Query: "truncate table t", - Expected: []sql.Row{{sql.NewOkResult(4)}}, + Expected: []sql.Row{{types.NewOkResult(4)}}, }, { // no value on any branch Query: "insert into t (b) values (1), (2)", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2, InsertID: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2, InsertID: 1}}}, }, { Query: "select * from t order by a", @@ -2811,7 +2812,7 @@ var DoltCommitTests = []queries.ScriptTest{ // update a table { Query: "DELETE from t where pk = 1;", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "CALL DOLT_COMMIT('-ALL', '-m', 'update table terminator');", @@ -2843,7 +2844,7 @@ var DoltCommitTests = []queries.ScriptTest{ // delete a table { Query: "DROP TABLE t;", - Expected: []sql.Row{{sql.NewOkResult(0)}}, + Expected: []sql.Row{{types.NewOkResult(0)}}, }, { Query: "CALL DOLT_COMMIT('-Am', 'drop table t');", @@ -2860,7 +2861,7 @@ var DoltCommitTests = []queries.ScriptTest{ // create a table { Query: "CREATE table t2 (pk int primary key);", - Expected: []sql.Row{{sql.NewOkResult(0)}}, + Expected: []sql.Row{{types.NewOkResult(0)}}, }, { Query: "CALL DOLT_COMMIT('-Am', 'add table 21');", @@ -2989,7 +2990,7 @@ var DoltCommitTests = []queries.ScriptTest{ }, { Query: "INSERT INTO test (id) VALUES (4)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "SELECT COUNT(*) FROM dolt_status;", @@ -3027,7 +3028,7 @@ var DoltCommitTests = []queries.ScriptTest{ }, { Query: "INSERT INTO test (id) VALUES (5)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "SELECT COUNT(*) FROM dolt_status;", @@ -3097,7 +3098,7 @@ var DoltCommitTests = []queries.ScriptTest{ }, { Query: "DELETE FROM test WHERE id = 6", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "CALL DOLT_ADD('.');", @@ -3210,7 +3211,7 @@ var DoltIndexPrefixScripts = []queries.ScriptTest{ }, { Query: "insert into t values (0, 'a', 'a'), (1, 'ab','ab'), (2, 'abc', 'abc'), (3, 'abcde', 'abcde')", - Expected: []sql.Row{{sql.NewOkResult(4)}}, + Expected: []sql.Row{{types.NewOkResult(4)}}, }, { Query: "insert into t values (99, 'ABC', 'ABCDE')", @@ -3261,7 +3262,7 @@ var DoltIndexPrefixScripts = []queries.ScriptTest{ { Query: "update t set v1 = concat(v1, 'Z') where v1 >= 'A'", Expected: []sql.Row{ - {sql.OkResult{RowsAffected: 4, InsertID: 0, Info: plan.UpdateInfo{Matched: 4, Updated: 4}}}, + {types.OkResult{RowsAffected: 4, InsertID: 0, Info: plan.UpdateInfo{Matched: 4, Updated: 4}}}, }, }, { @@ -3276,7 +3277,7 @@ var DoltIndexPrefixScripts = []queries.ScriptTest{ { Query: "delete from t where v1 >= 'A'", Expected: []sql.Row{ - {sql.OkResult{RowsAffected: 4}}, + {types.OkResult{RowsAffected: 4}}, }, }, { @@ -3294,7 +3295,7 @@ var DoltIndexPrefixScripts = []queries.ScriptTest{ Assertions: []queries.ScriptTestAssertion{ { Query: "alter table t modify column j int", - Expected: []sql.Row{{sql.OkResult{}}}, + Expected: []sql.Row{{types.OkResult{}}}, }, { Query: "show create table t", @@ -3310,7 +3311,7 @@ var DoltIndexPrefixScripts = []queries.ScriptTest{ Assertions: []queries.ScriptTestAssertion{ { Query: "alter table t modify column j varchar(2)", - Expected: []sql.Row{{sql.OkResult{}}}, + Expected: []sql.Row{{types.OkResult{}}}, }, { Query: "show create table t", @@ -3326,7 +3327,7 @@ var DoltIndexPrefixScripts = []queries.ScriptTest{ Assertions: []queries.ScriptTestAssertion{ { Query: "alter table t modify column j varchar(200)", - Expected: []sql.Row{{sql.OkResult{}}}, + Expected: []sql.Row{{types.OkResult{}}}, }, { Query: "show create table t", @@ -3342,7 +3343,7 @@ var DoltIndexPrefixScripts = []queries.ScriptTest{ Assertions: []queries.ScriptTestAssertion{ { Query: "alter table t modify column j int", - Expected: []sql.Row{{sql.OkResult{}}}, + Expected: []sql.Row{{types.OkResult{}}}, }, { Query: "show create table t", diff --git a/go/libraries/doltcore/sqle/enginetest/dolt_queries_merge.go b/go/libraries/doltcore/sqle/enginetest/dolt_queries_merge.go index f1da7f4b8e..44eac184b1 100644 --- a/go/libraries/doltcore/sqle/enginetest/dolt_queries_merge.go +++ b/go/libraries/doltcore/sqle/enginetest/dolt_queries_merge.go @@ -20,6 +20,7 @@ import ( "github.com/dolthub/go-mysql-server/enginetest/queries" "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/plan" + "github.com/dolthub/go-mysql-server/sql/types" "gopkg.in/src-d/go-errors.v1" "github.com/dolthub/dolt/go/libraries/doltcore/merge" @@ -84,7 +85,7 @@ var MergeScripts = []queries.ScriptTest{ }, { Query: "INSERT INTO test VALUES (4)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, }, }, @@ -260,7 +261,7 @@ var MergeScripts = []queries.ScriptTest{ }, { Query: "DELETE FROM dolt_conflicts_test", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "commit", @@ -367,7 +368,7 @@ var MergeScripts = []queries.ScriptTest{ }, { Query: "INSERT INTO test VALUES (4)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, }, }, @@ -1029,7 +1030,7 @@ var MergeScripts = []queries.ScriptTest{ }, { Query: "INSERT INTO t VALUES (NULL,5),(6,6),(NULL,7);", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 3, InsertID: 5}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 3, InsertID: 5}}}, }, { Query: "SELECT * FROM t ORDER BY pk;", @@ -1066,7 +1067,7 @@ var MergeScripts = []queries.ScriptTest{ }, { Query: "INSERT INTO t VALUES (NULL,6),(7,7),(NULL,8);", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 3, InsertID: 6}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 3, InsertID: 6}}}, }, { Query: "SELECT * FROM t ORDER BY pk;", @@ -1101,7 +1102,7 @@ var MergeScripts = []queries.ScriptTest{ }, { Query: "INSERT INTO t VALUES (3,3),(NULL,6);", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2, InsertID: 3}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2, InsertID: 3}}}, }, { Query: "SELECT * FROM t ORDER BY pk;", @@ -1137,7 +1138,7 @@ var MergeScripts = []queries.ScriptTest{ }, { Query: "INSERT INTO t VALUES (3,3),(NULL,7);", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2, InsertID: 3}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2, InsertID: 3}}}, }, { Query: "SELECT * FROM t ORDER BY pk;", @@ -1219,7 +1220,7 @@ var Dolt1MergeScripts = []queries.ScriptTest{ }, { Query: "delete from t;", - Expected: []sql.Row{{sql.NewOkResult(2)}}, + Expected: []sql.Row{{types.NewOkResult(2)}}, }, { Query: "select * from t;", @@ -1247,7 +1248,7 @@ var Dolt1MergeScripts = []queries.ScriptTest{ }, { Query: "truncate t;", - Expected: []sql.Row{{sql.NewOkResult(2)}}, + Expected: []sql.Row{{types.NewOkResult(2)}}, }, { Query: "select * from t;", @@ -1272,7 +1273,7 @@ var Dolt1MergeScripts = []queries.ScriptTest{ }, { Query: "delete from t;", - Expected: []sql.Row{{sql.NewOkResult(4)}}, + Expected: []sql.Row{{types.NewOkResult(4)}}, }, { Query: "select * from t;", @@ -1294,7 +1295,7 @@ var Dolt1MergeScripts = []queries.ScriptTest{ }, { Query: "truncate t;", - Expected: []sql.Row{{sql.NewOkResult(4)}}, + Expected: []sql.Row{{types.NewOkResult(4)}}, }, { Query: "select * from t;", @@ -1556,7 +1557,7 @@ var Dolt1ConflictTableNameTableTests = []queries.ScriptTest{ // Make sure that we can update using it { Query: "update dolt_conflicts_t SET our_col1 = their_col1 where dolt_conflict_id = @hash1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "select base_pk, base_col1, our_pk, our_col1, their_pk, their_col1 from dolt_conflicts_t;", @@ -1568,7 +1569,7 @@ var Dolt1ConflictTableNameTableTests = []queries.ScriptTest{ // And delete { Query: "delete from dolt_conflicts_t where dolt_conflict_id = @hash1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "select base_pk, base_col1, our_pk, our_col1, their_pk, their_col1 from dolt_conflicts_t;", @@ -1617,7 +1618,7 @@ var Dolt1ConflictTableNameTableTests = []queries.ScriptTest{ }, { Query: "update dolt_conflicts_t set our_col1 = 1000 where our_pk = 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "select base_pk, base_col1, our_pk, our_col1, their_pk, their_col1 from dolt_conflicts_t;", @@ -1635,7 +1636,7 @@ var Dolt1ConflictTableNameTableTests = []queries.ScriptTest{ }, { Query: "update dolt_conflicts_t set our_col1 = their_col1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2, Info: plan.UpdateInfo{Matched: 2, Updated: 2}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2, Info: plan.UpdateInfo{Matched: 2, Updated: 2}}}}, }, { Query: "select base_pk, base_col1, our_pk, our_col1, their_pk, their_col1 from dolt_conflicts_t;", @@ -1680,7 +1681,7 @@ var Dolt1ConflictTableNameTableTests = []queries.ScriptTest{ }, { Query: "Update dolt_conflicts_t set our_col1 = 1000;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2, Info: plan.UpdateInfo{Matched: 2, Updated: 2}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2, Info: plan.UpdateInfo{Matched: 2, Updated: 2}}}}, }, { Query: "select base_pk1, base_pk2, base_col1, our_pk1, our_pk2, our_col1, their_pk1, their_pk2, their_col1 from dolt_conflicts_t;", @@ -1728,7 +1729,7 @@ var Dolt1ConflictTableNameTableTests = []queries.ScriptTest{ { Query: "update dolt_conflicts_t set our_name = 'orange' where our_name = 'apple'", Expected: []sql.Row{ - {sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Updated: 1, Matched: 1}}}, + {types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Updated: 1, Matched: 1}}}, }, }, { @@ -1795,7 +1796,7 @@ var Dolt1ConflictTableNameTableTests = []queries.ScriptTest{ }, { Query: "delete from t;", - Expected: []sql.Row{{sql.NewOkResult(3)}}, + Expected: []sql.Row{{types.NewOkResult(3)}}, }, { Query: "select base_pk, base_col1, our_pk, our_col1, their_pk, their_col1 from dolt_conflicts_t;", @@ -1818,7 +1819,7 @@ var Dolt1ConflictTableNameTableTests = []queries.ScriptTest{ // Take theirs { Query: "update dolt_conflicts_t set our_pk = their_pk, our_col1 = their_col1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 3, Info: plan.UpdateInfo{Matched: 4, Updated: 3}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 3, Info: plan.UpdateInfo{Matched: 4, Updated: 3}}}}, }, { Query: "select * from t;", @@ -1853,7 +1854,7 @@ var Dolt1ConflictTableNameTableTests = []queries.ScriptTest{ }, { Query: "update dolt_conflicts_t set base_col1 = 9999, their_col1 = 9999;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2, Info: plan.UpdateInfo{Matched: 2, Updated: 2}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2, Info: plan.UpdateInfo{Matched: 2, Updated: 2}}}}, }, { Query: "select base_pk, base_col1, our_pk, our_col1, their_pk, their_col1 from dolt_conflicts_t;", @@ -1955,7 +1956,7 @@ var MergeArtifactsScripts = []queries.ScriptTest{ }, { Query: "UPDATE t SET col1 = 300;", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: 2, Info: plan.UpdateInfo{ Matched: 2, @@ -2117,7 +2118,7 @@ var MergeArtifactsScripts = []queries.ScriptTest{ }, { Query: "UPDATE child set fk = 4;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 2, InsertID: 0, Info: plan.UpdateInfo{Matched: 2, Updated: 2}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 2, InsertID: 0, Info: plan.UpdateInfo{Matched: 2, Updated: 2}}}}, }, { Query: "CALL DOLT_COMMIT('-afm', 'update children to new value');", @@ -2353,7 +2354,7 @@ var OldFormatMergeConflictsAndCVsScripts = []queries.ScriptTest{ }, { Query: "DELETE FROM parent where pk = 1;", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "CALL DOLT_COMMIT('-am', 'delete parent 1');", @@ -2365,7 +2366,7 @@ var OldFormatMergeConflictsAndCVsScripts = []queries.ScriptTest{ }, { Query: "INSERT INTO CHILD VALUES (1, 1);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "CALL DOLT_COMMIT('-am', 'insert child of parent 1');", @@ -2401,7 +2402,7 @@ var OldFormatMergeConflictsAndCVsScripts = []queries.ScriptTest{ }, { Query: "DELETE FROM parent where pk = 2;", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "CALL DOLT_COMMIT('-afm', 'remove parent 2');", @@ -2413,7 +2414,7 @@ var OldFormatMergeConflictsAndCVsScripts = []queries.ScriptTest{ }, { Query: "INSERT INTO OTHER VALUES (1);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "CALL DOLT_COMMIT('-am', 'non-fk insert');", @@ -2449,7 +2450,7 @@ var OldFormatMergeConflictsAndCVsScripts = []queries.ScriptTest{ }, { Query: "INSERT INTO CHILD VALUES (2, 2);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "CALL DOLT_COMMIT('-afm', 'add child of parent 2');", diff --git a/go/libraries/doltcore/sqle/enginetest/dolt_transaction_commit_test.go b/go/libraries/doltcore/sqle/enginetest/dolt_transaction_commit_test.go index fb37326ba3..cec21ecd95 100644 --- a/go/libraries/doltcore/sqle/enginetest/dolt_transaction_commit_test.go +++ b/go/libraries/doltcore/sqle/enginetest/dolt_transaction_commit_test.go @@ -22,6 +22,7 @@ import ( "github.com/dolthub/go-mysql-server/enginetest/queries" "github.com/dolthub/go-mysql-server/enginetest/scriptgen/setup" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/stretchr/testify/require" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" @@ -77,11 +78,11 @@ func TestDoltTransactionCommitOneClient(t *testing.T) { }, { Query: "/* client a */ INSERT INTO x VALUES (2,2);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ INSERT INTO x VALUES (3,3);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ SELECT * FROM x ORDER BY y;", @@ -217,11 +218,11 @@ func TestDoltTransactionCommitTwoClients(t *testing.T) { }, { Query: "/* client a */ INSERT INTO x VALUES (2,2);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ INSERT INTO x VALUES (3,3);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ SELECT * FROM x ORDER BY y;", @@ -327,11 +328,11 @@ func TestDoltTransactionCommitAutocommit(t *testing.T) { }, { Query: "/* client a */ INSERT INTO x VALUES (2,2);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ INSERT INTO x VALUES (3,3);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ SELECT * FROM x ORDER BY y;", @@ -415,11 +416,11 @@ func TestDoltTransactionCommitLateFkResolution(t *testing.T) { }, { Query: "/* client a */ INSERT INTO child VALUES (1, 1);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ INSERT INTO child VALUES (2, 2);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ COMMIT;", diff --git a/go/libraries/doltcore/sqle/enginetest/dolt_transaction_queries.go b/go/libraries/doltcore/sqle/enginetest/dolt_transaction_queries.go index 7226f22e6e..e4435fe407 100755 --- a/go/libraries/doltcore/sqle/enginetest/dolt_transaction_queries.go +++ b/go/libraries/doltcore/sqle/enginetest/dolt_transaction_queries.go @@ -18,6 +18,7 @@ import ( "github.com/dolthub/go-mysql-server/enginetest/queries" "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/plan" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" ) @@ -45,7 +46,7 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ create table t(pk int primary key);", - Expected: []sql.Row{{sql.OkResult{}}}, + Expected: []sql.Row{{types.OkResult{}}}, }, { Query: "/* client b */ select count(*) from t;", @@ -62,7 +63,7 @@ var DoltTransactionTests = []queries.TransactionTest{ Assertions: []queries.ScriptTestAssertion{ { Query: "/* client a */ insert into t values (2, 2)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ insert into t values (2, 2)", @@ -87,11 +88,11 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ insert into t values (2, 2)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ insert into t values (2, 2)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ commit", @@ -128,11 +129,11 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ insert into t values (2, 2)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ insert into t values (2, 3)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ commit", @@ -169,7 +170,7 @@ var DoltTransactionTests = []queries.TransactionTest{ Assertions: []queries.ScriptTestAssertion{ { Query: "/* client a */ update t set y = 2", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: uint64(1), Info: plan.UpdateInfo{ Matched: 2, @@ -179,7 +180,7 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client b */ update t set y = 2", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: uint64(0), Info: plan.UpdateInfo{ Matched: 2, @@ -214,7 +215,7 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ update t set y = 2", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: uint64(1), Info: plan.UpdateInfo{ Matched: 2, @@ -224,7 +225,7 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client b */ update t set y = 2", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: uint64(1), Info: plan.UpdateInfo{ Matched: 2, @@ -267,7 +268,7 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ update t set y = 3", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: uint64(2), Info: plan.UpdateInfo{ Matched: 2, @@ -277,7 +278,7 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client b */ update t set y = 4", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: uint64(2), Info: plan.UpdateInfo{ Matched: 2, @@ -328,7 +329,7 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ update t set y = 3 where x = 1", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: uint64(1), Info: plan.UpdateInfo{ Matched: 1, @@ -338,7 +339,7 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client b */ update t set y = 4 where x = 2", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: uint64(1), Info: plan.UpdateInfo{ Matched: 1, @@ -381,7 +382,7 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ update t set y = 2", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: uint64(1), Info: plan.UpdateInfo{ Matched: 2, @@ -391,7 +392,7 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client b */ update t set z = 3", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: uint64(2), Info: plan.UpdateInfo{ Matched: 2, @@ -426,11 +427,11 @@ var DoltTransactionTests = []queries.TransactionTest{ Assertions: []queries.ScriptTestAssertion{ { Query: "/* client a */ delete from t where y = 2", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ delete from t where y = 2", - Expected: []sql.Row{{sql.NewOkResult(0)}}, + Expected: []sql.Row{{types.NewOkResult(0)}}, }, { Query: "/* client a */ select * from t order by x", @@ -459,11 +460,11 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ delete from t where y = 2", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ delete from t where y = 2", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ commit", @@ -500,11 +501,11 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ delete from t where y = 2", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ delete from t where y = 3", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ commit", @@ -541,7 +542,7 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ update t set y = 3 where y = 2", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: uint64(1), Info: plan.UpdateInfo{ Matched: 1, @@ -551,7 +552,7 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client b */ delete from t where y = 2", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ commit", @@ -592,15 +593,15 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ delete from t where y = 1", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ delete from t", - Expected: []sql.Row{{sql.NewOkResult(2)}}, + Expected: []sql.Row{{types.NewOkResult(2)}}, }, { Query: "/* client b */ insert into t values (1,1)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ commit", @@ -641,7 +642,7 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ update t set y = 3 where y = 2", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: uint64(1), Info: plan.UpdateInfo{ Matched: 1, @@ -651,11 +652,11 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client b */ delete from t where y = 1", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client c */ update t set z = 4 where y = 2", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: uint64(1), Info: plan.UpdateInfo{ Matched: 1, @@ -714,7 +715,7 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ update test set y = 3 where y = 2", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: uint64(1), Info: plan.UpdateInfo{ Matched: 1, @@ -724,7 +725,7 @@ var DoltTransactionTests = []queries.TransactionTest{ }, { Query: "/* client b */ update test set y = 5 where y = 2", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: uint64(1), Info: plan.UpdateInfo{ Matched: 1, @@ -784,11 +785,11 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { Query: "/* client a */ insert into test values (1, 1)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ insert into test values (1, 2)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ commit", @@ -835,11 +836,11 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { Query: "/* client a */ insert into test values (1, 1)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ insert into test values (1, 2)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ commit", @@ -886,11 +887,11 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { Query: "/* client a */ insert into test values (1, 1)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ insert into test values (1, 2)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ commit", @@ -937,7 +938,7 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { Query: "/* client a */ insert into test values (1, 1)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ call dolt_checkout('-b', 'new-branch')", @@ -949,7 +950,7 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { Query: "/* client b */ insert into test values (1, 2)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ call dolt_commit('-am', 'commit on new-branch')", @@ -975,7 +976,7 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { // TODO: it should be possible to do this without specifying a literal in the subselect, but it's not working Query: "/* client b */ update test t set val = (select their_val from dolt_conflicts_test where our_pk = 1) where pk = 1", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: 1, Info: plan.UpdateInfo{ Matched: 1, @@ -985,7 +986,7 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { Query: "/* client b */ delete from dolt_conflicts_test", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ commit", @@ -1028,7 +1029,7 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { Query: "/* client a */ insert into test values (1, 1)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ call dolt_checkout('-b', 'new-branch')", @@ -1040,7 +1041,7 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { Query: "/* client b */ insert into test values (1, 2)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ call dolt_commit('-am', 'commit on new-branch')", @@ -1064,7 +1065,7 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { // TODO: it should be possible to do this without specifying a literal in the subselect, but it's not working Query: "/* client b */ update test t set val = (select their_val from dolt_conflicts_test where our_pk = 1) where pk = 1", - Expected: []sql.Row{{sql.OkResult{ + Expected: []sql.Row{{types.OkResult{ RowsAffected: 1, Info: plan.UpdateInfo{ Matched: 1, @@ -1074,7 +1075,7 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { Query: "/* client b */ delete from dolt_conflicts_test", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ commit", @@ -1117,7 +1118,7 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { Query: "/* client a */ insert into test values (1, 1)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ call dolt_checkout('-b', 'new-branch')", @@ -1129,7 +1130,7 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { Query: "/* client b */ insert into test values (1, 2)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ call dolt_commit('-am', 'commit on new-branch')", @@ -1149,7 +1150,7 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { Query: "/* client b */ insert into test values (2, 2)", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ commit", @@ -1201,11 +1202,11 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ // They are needed to trigger a three-way transaction merge { Query: "/* client a */ INSERT into t VALUES (2, 2);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ INSERT into t VALUES (3, 3);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ SET dolt_allow_commit_conflicts = on;", @@ -1222,7 +1223,7 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { Query: "/* client b */ INSERT into t VALUES (3, 3);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ COMMIT;", @@ -1250,19 +1251,19 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { Query: "/* client a */ UPDATE t SET col1 = -100 where pk = 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ UPDATE t SET col1 = 100 where pk = 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client a */ INSERT into KEYLESS VALUES (1);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ INSERT into KEYLESS VALUES (1), (1);", - Expected: []sql.Row{{sql.NewOkResult(2)}}, + Expected: []sql.Row{{types.NewOkResult(2)}}, }, { Query: "/* client a */ COMMIT;", @@ -1305,19 +1306,19 @@ var DoltConflictHandlingTests = []queries.TransactionTest{ }, { Query: "/* client a */ UPDATE t SET col1 = -100 where pk = 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ UPDATE t SET col1 = 100 where pk = 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client a */ INSERT into KEYLESS VALUES (1);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ INSERT into KEYLESS VALUES (1), (1);", - Expected: []sql.Row{{sql.NewOkResult(2)}}, + Expected: []sql.Row{{types.NewOkResult(2)}}, }, { Query: "/* client b */ COMMIT;", @@ -1463,11 +1464,11 @@ var DoltConstraintViolationTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ DELETE FROM parent where pk = 1;", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ INSERT INTO child VALUES (1, 1);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ COMMIT;", @@ -1541,7 +1542,7 @@ var DoltConstraintViolationTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ DELETE FROM PARENT where v1 = 2;", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ COMMIT;", @@ -1575,11 +1576,11 @@ var DoltConstraintViolationTransactionTests = []queries.TransactionTest{ }, { Query: "/* client a */ DELETE FROM PARENT where v1 = 2;", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client b */ INSERT INTO parent VALUES (30, 3);", - Expected: []sql.Row{{sql.NewOkResult(1)}}, + Expected: []sql.Row{{types.NewOkResult(1)}}, }, { Query: "/* client a */ COMMIT;", diff --git a/go/libraries/doltcore/sqle/enginetest/sysbench_test.go b/go/libraries/doltcore/sqle/enginetest/sysbench_test.go index c211e59d12..87e90489e1 100644 --- a/go/libraries/doltcore/sqle/enginetest/sysbench_test.go +++ b/go/libraries/doltcore/sqle/enginetest/sysbench_test.go @@ -21,6 +21,7 @@ import ( "github.com/dolthub/go-mysql-server/enginetest/queries" "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/plan" + "github.com/dolthub/go-mysql-server/sql/types" ) func TestSysbenchTransactionCV(t *testing.T) { @@ -141,27 +142,27 @@ s_dist_07, s_dist_08, s_dist_09, s_dist_10, s_ytd, s_order_cnt, s_remote_cnt, s_ }, { Query: "/* client a */ UPDATE warehouse1 SET w_ytd = w_ytd + 622 WHERE w_id = 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client a */ UPDATE district1 SET d_ytd = d_ytd + 622 WHERE d_w_id = 1 AND d_id= 10;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client a */ UPDATE customer1 SET c_balance=-632.000000, c_ytd_payment=632.000000 WHERE c_w_id = 1 AND c_d_id=1 AND c_id=2786;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ UPDATE district1 SET d_next_o_id = 3002 WHERE d_id = 7 AND d_w_id= 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ INSERT INTO orders1 (o_id, o_d_id, o_w_id, o_c_id, o_entry_d, o_ol_cnt, o_all_local) VALUES (3001,7,1,2561,NOW(),12,1);", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "/* client a */ INSERT INTO history1 (h_c_d_id, h_c_w_id, h_c_id, h_d_id, h_w_id, h_date, h_amount, h_data) VALUES (1,1,2786,10,1,NOW(),622,'name-zcsld name-mmsod ');", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "/* client a */ COMMIT;", @@ -169,103 +170,103 @@ s_dist_07, s_dist_08, s_dist_09, s_dist_10, s_ytd, s_order_cnt, s_remote_cnt, s_ }, { Query: "/* client b */ INSERT INTO new_orders1 (no_o_id, no_d_id, no_w_id) VALUES (3001,7,1);", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "/* client b */ UPDATE stock1 SET s_quantity = 65 WHERE s_i_id = 42365 AND s_w_id= 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ INSERT INTO order_line1 (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_dist_info) VALUES (3001,7,1,1,42365,1,1,7,'xxxxxxxxxxxxxxxxxxxxxxxx');", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "/* client b */ UPDATE stock1 SET s_quantity = 53 WHERE s_i_id = 84125 AND s_w_id= 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ INSERT INTO order_line1 (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_dist_info) VALUES (3001,7,1,2,84125,1,6,232,'nnnnnnnnnnnnnnnnnnnnnnnn');", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "/* client b */ UPDATE stock1 SET s_quantity = 24 WHERE s_i_id = 29168 AND s_w_id= 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ INSERT INTO order_line1 (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_dist_info) VALUES (3001,7,1,3,29168,1,8,372,'mmmmmmmmmmmmmmmmmmmmmmmm');", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "/* client b */ UPDATE stock1 SET s_quantity = 31 WHERE s_i_id = 70752 AND s_w_id= 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ INSERT INTO order_line1 (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_dist_info) VALUES (3001,7,1,4,70752,1,8,491,'llllllllllllllllllllllll');", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "/* client b */ UPDATE stock1 SET s_quantity = 52 WHERE s_i_id = 3115 AND s_w_id= 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ INSERT INTO order_line1 (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_dist_info) VALUES (3001,7,1,5,3115,1,8,60,'tttttttttttttttttttttttt');", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "/* client b */ UPDATE stock1 SET s_quantity = 58 WHERE s_i_id = 60995 AND s_w_id= 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ INSERT INTO order_line1 (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_dist_info) VALUES (3001,7,1,6,60995,1,9,334,'qqqqqqqqqqqqqqqqqqqqqqqq');", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "/* client b */ UPDATE stock1 SET s_quantity = 23 WHERE s_i_id = 87468 AND s_w_id= 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ INSERT INTO order_line1 (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_dist_info) VALUES (3001,7,1,7,87468,1,6,224,'gggggggggggggggggggggggg');", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "/* client b */ UPDATE stock1 SET s_quantity = 45 WHERE s_i_id = 26507 AND s_w_id= 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ INSERT INTO order_line1 (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_dist_info) VALUES (3001,7,1,8,26507,1,7,231,'zzzzzzzzzzzzzzzzzzzzzzzz');", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "/* client b */ UPDATE stock1 SET s_quantity = 61 WHERE s_i_id = 38702 AND s_w_id= 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ INSERT INTO order_line1 (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_dist_info) VALUES (3001,7,1,9,38702,1,6,300,'xxxxxxxxxxxxxxxxxxxxxxxx');", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "/* client b */ UPDATE stock1 SET s_quantity = 38 WHERE s_i_id = 39823 AND s_w_id= 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ INSERT INTO order_line1 (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_dist_info) VALUES (3001,7,1,10,39823,1,5,167,'mmmmmmmmmmmmmmmmmmmmmmmm');", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "/* client b */ UPDATE stock1 SET s_quantity = 62 WHERE s_i_id = 53534 AND s_w_id= 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ INSERT INTO order_line1 (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_dist_info) VALUES (3001,7,1,11,53534,1,7,380,'pppppppppppppppppppppppp');", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "/* client b */ UPDATE stock1 SET s_quantity = 61 WHERE s_i_id = 62631 AND s_w_id= 1;", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1, Info: plan.UpdateInfo{Matched: 1, Updated: 1}}}}, }, { Query: "/* client b */ INSERT INTO order_line1 (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_dist_info) VALUES (3001,7,1,12,62631,1,6,171,'gggggggggggggggggggggggg');", - Expected: []sql.Row{{sql.OkResult{RowsAffected: 1}}}, + Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}}, }, { Query: "/* client b */ COMMIT;", diff --git a/go/libraries/doltcore/sqle/expreval/expression_evaluator.go b/go/libraries/doltcore/sqle/expreval/expression_evaluator.go index 21afc8efce..3072fcd05c 100644 --- a/go/libraries/doltcore/sqle/expreval/expression_evaluator.go +++ b/go/libraries/doltcore/sqle/expreval/expression_evaluator.go @@ -19,6 +19,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + types2 "github.com/dolthub/go-mysql-server/sql/types" "gopkg.in/src-d/go-errors.v1" "github.com/dolthub/dolt/go/libraries/doltcore/schema" @@ -109,7 +110,7 @@ func getExpFunc(nbf *types.NomsBinFormat, sch schema.Schema, exp sql.Expression) } return newNotFunc(expFunc), nil case *expression.IsNull: - return newComparisonFunc(EqualsOp{}, expression.BinaryExpression{Left: typedExpr.Child, Right: expression.NewLiteral(nil, sql.Null)}, sch) + return newComparisonFunc(EqualsOp{}, expression.BinaryExpression{Left: typedExpr.Child, Right: expression.NewLiteral(nil, types2.Null)}, sch) } return nil, errNotImplemented.New(exp.Type().String()) diff --git a/go/libraries/doltcore/sqle/expreval/expression_evaluator_test.go b/go/libraries/doltcore/sqle/expreval/expression_evaluator_test.go index 3806e1a8cf..55202dd643 100644 --- a/go/libraries/doltcore/sqle/expreval/expression_evaluator_test.go +++ b/go/libraries/doltcore/sqle/expreval/expression_evaluator_test.go @@ -20,8 +20,8 @@ import ( "testing" "time" - "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -30,12 +30,12 @@ import ( ) func TestGetComparisonType(t *testing.T) { - getId := expression.NewGetField(0, sql.Int64, "id", false) - getMedian := expression.NewGetField(1, sql.Int64, "median", false) - getAverage := expression.NewGetField(2, sql.Float64, "average", false) - litOne := expression.NewLiteral(int64(1), sql.Int64) - litTwo := expression.NewLiteral(int64(1), sql.Int64) - litThree := expression.NewLiteral(int64(1), sql.Int64) + getId := expression.NewGetField(0, types2.Int64, "id", false) + getMedian := expression.NewGetField(1, types2.Int64, "median", false) + getAverage := expression.NewGetField(2, types2.Float64, "average", false) + litOne := expression.NewLiteral(int64(1), types2.Int64) + litTwo := expression.NewLiteral(int64(1), types2.Int64) + litThree := expression.NewLiteral(int64(1), types2.Int64) tests := []struct { name string @@ -244,8 +244,8 @@ func TestNewComparisonFunc(t *testing.T) { name: "compare int literals -1 and -1", sch: testSch, be: expression.BinaryExpression{ - Left: expression.NewLiteral(int8(-1), sql.Int8), - Right: expression.NewLiteral(int64(-1), sql.Int64), + Left: expression.NewLiteral(int8(-1), types2.Int8), + Right: expression.NewLiteral(int64(-1), types2.Int64), }, expectNewErr: false, testVals: []funcTestVal{ @@ -269,8 +269,8 @@ func TestNewComparisonFunc(t *testing.T) { name: "compare int literals -5 and 5", sch: testSch, be: expression.BinaryExpression{ - Left: expression.NewLiteral(int8(-5), sql.Int8), - Right: expression.NewLiteral(uint8(5), sql.Uint8), + Left: expression.NewLiteral(int8(-5), types2.Int8), + Right: expression.NewLiteral(uint8(5), types2.Uint8), }, expectNewErr: false, testVals: []funcTestVal{ @@ -294,8 +294,8 @@ func TestNewComparisonFunc(t *testing.T) { name: "compare string literals b and a", sch: testSch, be: expression.BinaryExpression{ - Left: expression.NewLiteral("b", sql.Text), - Right: expression.NewLiteral("a", sql.Text), + Left: expression.NewLiteral("b", types2.Text), + Right: expression.NewLiteral("a", types2.Text), }, expectNewErr: false, testVals: []funcTestVal{ @@ -319,8 +319,8 @@ func TestNewComparisonFunc(t *testing.T) { name: "compare int value to numeric string literals", sch: testSch, be: expression.BinaryExpression{ - Left: expression.NewGetField(0, sql.Int64, "col0", false), - Right: expression.NewLiteral("1", sql.Text), + Left: expression.NewGetField(0, types2.Int64, "col0", false), + Right: expression.NewLiteral("1", types2.Text), }, expectNewErr: false, testVals: []funcTestVal{ @@ -351,8 +351,8 @@ func TestNewComparisonFunc(t *testing.T) { name: "compare date value to date string literals", sch: testSch, be: expression.BinaryExpression{ - Left: expression.NewGetField(2, sql.Datetime, "date", false), - Right: expression.NewLiteral("2000-01-01", sql.Text), + Left: expression.NewGetField(2, types2.Datetime, "date", false), + Right: expression.NewLiteral("2000-01-01", types2.Text), }, expectNewErr: false, testVals: []funcTestVal{ @@ -395,8 +395,8 @@ func TestNewComparisonFunc(t *testing.T) { name: "compare col1 and col0", sch: testSch, be: expression.BinaryExpression{ - Left: expression.NewGetField(1, sql.Int64, "col1", false), - Right: expression.NewGetField(0, sql.Int64, "col0", false), + Left: expression.NewGetField(1, types2.Int64, "col1", false), + Right: expression.NewGetField(0, types2.Int64, "col0", false), }, expectNewErr: false, testVals: []funcTestVal{ @@ -445,8 +445,8 @@ func TestNewComparisonFunc(t *testing.T) { name: "compare const and unknown column variable", sch: testSch, be: expression.BinaryExpression{ - Left: expression.NewGetField(0, sql.Int64, "unknown", false), - Right: expression.NewLiteral("1", sql.Text), + Left: expression.NewGetField(0, types2.Int64, "unknown", false), + Right: expression.NewLiteral("1", types2.Text), }, expectNewErr: true, testVals: []funcTestVal{}, @@ -455,8 +455,8 @@ func TestNewComparisonFunc(t *testing.T) { name: "compare variables with first unknown", sch: testSch, be: expression.BinaryExpression{ - Left: expression.NewGetField(0, sql.Int64, "unknown", false), - Right: expression.NewGetField(1, sql.Int64, "col1", false), + Left: expression.NewGetField(0, types2.Int64, "unknown", false), + Right: expression.NewGetField(1, types2.Int64, "col1", false), }, expectNewErr: true, testVals: []funcTestVal{}, @@ -465,8 +465,8 @@ func TestNewComparisonFunc(t *testing.T) { name: "compare variables with second unknown", sch: testSch, be: expression.BinaryExpression{ - Left: expression.NewGetField(1, sql.Int64, "col1", false), - Right: expression.NewGetField(0, sql.Int64, "unknown", false), + Left: expression.NewGetField(1, types2.Int64, "col1", false), + Right: expression.NewGetField(0, types2.Int64, "unknown", false), }, expectNewErr: true, testVals: []funcTestVal{}, @@ -475,8 +475,8 @@ func TestNewComparisonFunc(t *testing.T) { name: "variable with literal that can't be converted", sch: testSch, be: expression.BinaryExpression{ - Left: expression.NewGetField(0, sql.Int64, "col0", false), - Right: expression.NewLiteral("not a number", sql.Text), + Left: expression.NewGetField(0, types2.Int64, "col0", false), + Right: expression.NewLiteral("not a number", types2.Text), }, expectNewErr: true, testVals: []funcTestVal{}, diff --git a/go/libraries/doltcore/sqle/expreval/literal_helpers.go b/go/libraries/doltcore/sqle/expreval/literal_helpers.go index 83ec55fb06..a44e1d3971 100644 --- a/go/libraries/doltcore/sqle/expreval/literal_helpers.go +++ b/go/libraries/doltcore/sqle/expreval/literal_helpers.go @@ -18,8 +18,8 @@ import ( "strconv" "time" - "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/types" ) @@ -246,7 +246,7 @@ func literalAsString(literal *expression.Literal) (string, error) { } func parseDate(s string) (time.Time, error) { - for _, layout := range sql.TimestampDatetimeLayouts { + for _, layout := range types2.TimestampDatetimeLayouts { res, err := time.Parse(layout, s) if err == nil { @@ -254,7 +254,7 @@ func parseDate(s string) (time.Time, error) { } } - return time.Time{}, sql.ErrConvertingToTime.New(s) + return time.Time{}, types2.ErrConvertingToTime.New(s) } func literalAsTimestamp(literal *expression.Literal) (time.Time, error) { diff --git a/go/libraries/doltcore/sqle/expreval/literal_helpers_test.go b/go/libraries/doltcore/sqle/expreval/literal_helpers_test.go index e6ae268f9a..9535292158 100644 --- a/go/libraries/doltcore/sqle/expreval/literal_helpers_test.go +++ b/go/libraries/doltcore/sqle/expreval/literal_helpers_test.go @@ -18,8 +18,8 @@ import ( "testing" "time" - "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/stretchr/testify/assert" "github.com/dolthub/dolt/go/store/types" @@ -34,116 +34,116 @@ func TestLiteralAsInt64(t *testing.T) { }{ { "int8 literal", - expression.NewLiteral(int8(5), sql.Int8), + expression.NewLiteral(int8(5), types2.Int8), 5, false, }, { "int16 literal", - expression.NewLiteral(int16(5), sql.Int16), + expression.NewLiteral(int16(5), types2.Int16), 5, false, }, { "int32 literal", - expression.NewLiteral(int32(5), sql.Int32), + expression.NewLiteral(int32(5), types2.Int32), 5, false, }, { "int literal", - expression.NewLiteral(int(5), sql.Int32), + expression.NewLiteral(int(5), types2.Int32), 5, false, }, { "int64 literal", - expression.NewLiteral(int64(5), sql.Int64), + expression.NewLiteral(int64(5), types2.Int64), 5, false, }, { "uint8 literal", - expression.NewLiteral(uint8(5), sql.Uint8), + expression.NewLiteral(uint8(5), types2.Uint8), 5, false, }, { "uint16 literal", - expression.NewLiteral(uint16(5), sql.Uint16), + expression.NewLiteral(uint16(5), types2.Uint16), 5, false, }, { "uint32 literal", - expression.NewLiteral(uint32(5), sql.Uint32), + expression.NewLiteral(uint32(5), types2.Uint32), 5, false, }, { "uint literal", - expression.NewLiteral(uint(5), sql.Uint32), + expression.NewLiteral(uint(5), types2.Uint32), 5, false, }, { "uint64 literal", - expression.NewLiteral(uint64(5), sql.Uint64), + expression.NewLiteral(uint64(5), types2.Uint64), 5, false, }, { "true literal", - expression.NewLiteral(true, sql.Boolean), + expression.NewLiteral(true, types2.Boolean), 1, false, }, { "false literal", - expression.NewLiteral(false, sql.Boolean), + expression.NewLiteral(false, types2.Boolean), 0, false, }, { "float32 literal", - expression.NewLiteral(float32(32.0), sql.Float32), + expression.NewLiteral(float32(32.0), types2.Float32), 32, false, }, { "float64 literal", - expression.NewLiteral(float64(32.0), sql.Float64), + expression.NewLiteral(float64(32.0), types2.Float64), 32, false, }, { "string literal", - expression.NewLiteral("54321", sql.Text), + expression.NewLiteral("54321", types2.Text), 54321, false, }, { "uint literal too big", - expression.NewLiteral(uint64(0xFFFFFFFFFFFFFFFF), sql.Uint32), + expression.NewLiteral(uint64(0xFFFFFFFFFFFFFFFF), types2.Uint32), 0, true, }, { "float64 with fractional portion", - expression.NewLiteral(float64(5.0005), sql.Float64), + expression.NewLiteral(float64(5.0005), types2.Float64), 0, true, }, { "float32 with fractional portion", - expression.NewLiteral(float32(5.0005), sql.Float32), + expression.NewLiteral(float32(5.0005), types2.Float32), 0, true, }, { "string not a number", - expression.NewLiteral("not a number", sql.Text), + expression.NewLiteral("not a number", types2.Text), 0, true, }, @@ -170,139 +170,139 @@ func TestLiteralAsUint64(t *testing.T) { }{ { "int8 literal", - expression.NewLiteral(int8(5), sql.Int8), + expression.NewLiteral(int8(5), types2.Int8), 5, false, }, { "int16 literal", - expression.NewLiteral(int16(5), sql.Int16), + expression.NewLiteral(int16(5), types2.Int16), 5, false, }, { "int32 literal", - expression.NewLiteral(int32(5), sql.Int32), + expression.NewLiteral(int32(5), types2.Int32), 5, false, }, { "int literal", - expression.NewLiteral(int(5), sql.Int32), + expression.NewLiteral(int(5), types2.Int32), 5, false, }, { "int64 literal", - expression.NewLiteral(int64(5), sql.Int64), + expression.NewLiteral(int64(5), types2.Int64), 5, false, }, { "uint8 literal", - expression.NewLiteral(uint8(5), sql.Uint8), + expression.NewLiteral(uint8(5), types2.Uint8), 5, false, }, { "uint16 literal", - expression.NewLiteral(uint16(5), sql.Uint16), + expression.NewLiteral(uint16(5), types2.Uint16), 5, false, }, { "uint32 literal", - expression.NewLiteral(uint32(5), sql.Uint32), + expression.NewLiteral(uint32(5), types2.Uint32), 5, false, }, { "uint literal", - expression.NewLiteral(uint(5), sql.Uint32), + expression.NewLiteral(uint(5), types2.Uint32), 5, false, }, { "uint64 literal", - expression.NewLiteral(uint64(5), sql.Uint64), + expression.NewLiteral(uint64(5), types2.Uint64), 5, false, }, { "true literal", - expression.NewLiteral(true, sql.Boolean), + expression.NewLiteral(true, types2.Boolean), 1, false, }, { "false literal", - expression.NewLiteral(false, sql.Boolean), + expression.NewLiteral(false, types2.Boolean), 0, false, }, { "float32 literal", - expression.NewLiteral(float32(32.0), sql.Float32), + expression.NewLiteral(float32(32.0), types2.Float32), 32, false, }, { "float64 literal", - expression.NewLiteral(float64(32.0), sql.Float64), + expression.NewLiteral(float64(32.0), types2.Float64), 32, false, }, { "string literal", - expression.NewLiteral("54321", sql.Text), + expression.NewLiteral("54321", types2.Text), 54321, false, }, { "negative int8 literal", - expression.NewLiteral(int8(-1), sql.Int8), + expression.NewLiteral(int8(-1), types2.Int8), 0, true, }, { "negative int16 literal", - expression.NewLiteral(int16(-1), sql.Int16), + expression.NewLiteral(int16(-1), types2.Int16), 0, true, }, { "negative int32 literal", - expression.NewLiteral(int32(-1), sql.Int32), + expression.NewLiteral(int32(-1), types2.Int32), 0, true, }, { "negative int literal", - expression.NewLiteral(int(-1), sql.Int32), + expression.NewLiteral(int(-1), types2.Int32), 0, true, }, { "negative int64 literal", - expression.NewLiteral(int64(-1), sql.Int64), + expression.NewLiteral(int64(-1), types2.Int64), 0, true, }, { "float32 with fractional portion", - expression.NewLiteral(float32(5.0005), sql.Float32), + expression.NewLiteral(float32(5.0005), types2.Float32), 0, true, }, { "float64 with fractional portion", - expression.NewLiteral(float64(5.0005), sql.Float64), + expression.NewLiteral(float64(5.0005), types2.Float64), 0, true, }, { "string not a number", - expression.NewLiteral("not a number", sql.Text), + expression.NewLiteral("not a number", types2.Text), 0, true, }, @@ -329,91 +329,91 @@ func TestLiteralAsFloat64(t *testing.T) { }{ { "int8 literal", - expression.NewLiteral(int8(-5), sql.Int8), + expression.NewLiteral(int8(-5), types2.Int8), -5.0, false, }, { "int16 literal", - expression.NewLiteral(int16(-5), sql.Int16), + expression.NewLiteral(int16(-5), types2.Int16), -5.0, false, }, { "int32 literal", - expression.NewLiteral(int32(-5), sql.Int32), + expression.NewLiteral(int32(-5), types2.Int32), -5.0, false, }, { "int literal", - expression.NewLiteral(int(-5), sql.Int32), + expression.NewLiteral(int(-5), types2.Int32), -5.0, false, }, { "int64 literal", - expression.NewLiteral(int64(-5), sql.Int64), + expression.NewLiteral(int64(-5), types2.Int64), -5.0, false, }, { "uint8 literal", - expression.NewLiteral(uint8(5), sql.Uint8), + expression.NewLiteral(uint8(5), types2.Uint8), 5.0, false, }, { "uint16 literal", - expression.NewLiteral(uint16(5), sql.Uint16), + expression.NewLiteral(uint16(5), types2.Uint16), 5.0, false, }, { "uint32 literal", - expression.NewLiteral(uint32(5), sql.Uint32), + expression.NewLiteral(uint32(5), types2.Uint32), 5.0, false, }, { "uint literal", - expression.NewLiteral(uint(5), sql.Uint32), + expression.NewLiteral(uint(5), types2.Uint32), 5.0, false, }, { "uint64 literal", - expression.NewLiteral(uint64(5), sql.Uint64), + expression.NewLiteral(uint64(5), types2.Uint64), 5.0, false, }, { "bool literal", - expression.NewLiteral(true, sql.Boolean), + expression.NewLiteral(true, types2.Boolean), 0.0, true, }, { "float32 literal", - expression.NewLiteral(float32(32.0), sql.Float32), + expression.NewLiteral(float32(32.0), types2.Float32), 32.0, false, }, { "float64 literal", - expression.NewLiteral(float64(32.0), sql.Float64), + expression.NewLiteral(float64(32.0), types2.Float64), 32.0, false, }, { "string literal", - expression.NewLiteral("-54.321", sql.Text), + expression.NewLiteral("-54.321", types2.Text), -54.321, false, }, { "non numeric string", - expression.NewLiteral("test", sql.Text), + expression.NewLiteral("test", types2.Text), 0, true, }, @@ -440,92 +440,92 @@ func TestLiteralAsBool(t *testing.T) { }{ { "int8 literal", - expression.NewLiteral(int8(0), sql.Int8), + expression.NewLiteral(int8(0), types2.Int8), false, false, }, { "int16 literal", - expression.NewLiteral(int16(1), sql.Int16), + expression.NewLiteral(int16(1), types2.Int16), true, false, }, { "int32 literal", - expression.NewLiteral(int32(0), sql.Int32), + expression.NewLiteral(int32(0), types2.Int32), false, false, }, { "int literal", - expression.NewLiteral(int(1), sql.Int32), + expression.NewLiteral(int(1), types2.Int32), true, false, }, { "int64 literal", - expression.NewLiteral(int64(0), sql.Int64), + expression.NewLiteral(int64(0), types2.Int64), false, false, }, { "uint8 literal", - expression.NewLiteral(uint8(1), sql.Uint8), + expression.NewLiteral(uint8(1), types2.Uint8), true, false, }, { "uint16 literal", - expression.NewLiteral(uint16(0), sql.Uint16), + expression.NewLiteral(uint16(0), types2.Uint16), false, false, }, { "uint32 literal", - expression.NewLiteral(uint32(1), sql.Uint32), + expression.NewLiteral(uint32(1), types2.Uint32), true, false, }, { "uint literal", - expression.NewLiteral(uint(0), sql.Uint32), + expression.NewLiteral(uint(0), types2.Uint32), false, false, }, { "uint64 literal", - expression.NewLiteral(uint64(1), sql.Uint64), + expression.NewLiteral(uint64(1), types2.Uint64), true, false, }, { "bool literal", - expression.NewLiteral(true, sql.Boolean), + expression.NewLiteral(true, types2.Boolean), true, false, }, { "float literal not supported", - expression.NewLiteral(float32(32.0), sql.Float32), + expression.NewLiteral(float32(32.0), types2.Float32), false, true, }, { "string literal false", - expression.NewLiteral("false", sql.Text), + expression.NewLiteral("false", types2.Text), false, false, }, { "string literal 1", - expression.NewLiteral("1", sql.Text), + expression.NewLiteral("1", types2.Text), true, false, }, { "non numeric non bool string", - expression.NewLiteral("test", sql.Text), + expression.NewLiteral("test", types2.Text), false, true, }, @@ -552,31 +552,31 @@ func TestLiteralAsString(t *testing.T) { }{ { "int literal", - expression.NewLiteral(5, sql.Int16), + expression.NewLiteral(5, types2.Int16), "5", false, }, { "uint literal", - expression.NewLiteral(uint32(5), sql.Uint32), + expression.NewLiteral(uint32(5), types2.Uint32), "5", false, }, { "bool literal", - expression.NewLiteral(true, sql.Boolean), + expression.NewLiteral(true, types2.Boolean), "true", false, }, { "float literal", - expression.NewLiteral(float32(-2.5), sql.Float32), + expression.NewLiteral(float32(-2.5), types2.Float32), "-2.5", false, }, { "string literal", - expression.NewLiteral("test", sql.Text), + expression.NewLiteral("test", types2.Text), "test", false, }, @@ -642,25 +642,25 @@ func TestLiteralAsTimestamp(t *testing.T) { }{ { "YYYY-MM-DD", - expression.NewLiteral("2006-01-02", sql.Text), + expression.NewLiteral("2006-01-02", types2.Text), time.Date(2006, 1, 2, 0, 0, 0, 0, time.UTC), false, }, { "YYYY-MM-DD HH:MM:SS", - expression.NewLiteral("2006-01-02 15:04:05", sql.Text), + expression.NewLiteral("2006-01-02 15:04:05", types2.Text), time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC), false, }, { "Invalid format", - expression.NewLiteral("not a date", sql.Text), + expression.NewLiteral("not a date", types2.Text), time.Time{}, true, }, { "int literal", - expression.NewLiteral(5, sql.Int8), + expression.NewLiteral(5, types2.Int8), time.Time{}, true, }, @@ -685,24 +685,24 @@ func TestLiteralToNomsValue(t *testing.T) { expected types.Value expectErr bool }{ - {"int", expression.NewLiteral(-1, sql.Int32), types.Int(-1), false}, - {"int err", expression.NewLiteral(uint64(0xFFFFFFFFFFFFFFFF), sql.Uint64), types.Int(0), true}, - {"uint", expression.NewLiteral(1, sql.Uint32), types.Uint(1), false}, - {"uint err", expression.NewLiteral(-1, sql.Int16), types.Uint(1), true}, - {"float", expression.NewLiteral(1.5, sql.Float32), types.Float(1.5), false}, - {"float err", expression.NewLiteral("not a valid float", sql.Text), types.Float(1.5), true}, - {"bool", expression.NewLiteral(true, sql.Boolean), types.Bool(true), false}, - {"bool err", expression.NewLiteral("not a valid bool", sql.Text), types.Bool(true), true}, - {"string", expression.NewLiteral("this is a test", sql.Text), types.String("this is a test"), false}, + {"int", expression.NewLiteral(-1, types2.Int32), types.Int(-1), false}, + {"int err", expression.NewLiteral(uint64(0xFFFFFFFFFFFFFFFF), types2.Uint64), types.Int(0), true}, + {"uint", expression.NewLiteral(1, types2.Uint32), types.Uint(1), false}, + {"uint err", expression.NewLiteral(-1, types2.Int16), types.Uint(1), true}, + {"float", expression.NewLiteral(1.5, types2.Float32), types.Float(1.5), false}, + {"float err", expression.NewLiteral("not a valid float", types2.Text), types.Float(1.5), true}, + {"bool", expression.NewLiteral(true, types2.Boolean), types.Bool(true), false}, + {"bool err", expression.NewLiteral("not a valid bool", types2.Text), types.Bool(true), true}, + {"string", expression.NewLiteral("this is a test", types2.Text), types.String("this is a test"), false}, { "date", - expression.NewLiteral("1900-01-01", sql.Text), + expression.NewLiteral("1900-01-01", types2.Text), types.Timestamp(time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC)), false, }, { "date err", - expression.NewLiteral("not a valid date", sql.Text), + expression.NewLiteral("not a valid date", types2.Text), types.Timestamp(time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC)), true, }, diff --git a/go/libraries/doltcore/sqle/globalstate/auto_increment_tracker.go b/go/libraries/doltcore/sqle/globalstate/auto_increment_tracker.go index 6996179879..1c05a61e79 100644 --- a/go/libraries/doltcore/sqle/globalstate/auto_increment_tracker.go +++ b/go/libraries/doltcore/sqle/globalstate/auto_increment_tracker.go @@ -20,7 +20,7 @@ import ( "strings" "sync" - "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/schema" @@ -116,7 +116,7 @@ func CoerceAutoIncrementValue(val interface{}) (uint64, error) { } var err error - val, err = sql.Uint64.Convert(val) + val, err = types.Uint64.Convert(val) if err != nil { return 0, err } diff --git a/go/libraries/doltcore/sqle/history_table.go b/go/libraries/doltcore/sqle/history_table.go index 2f3bd35b4a..ad37b6ae5d 100644 --- a/go/libraries/doltcore/sqle/history_table.go +++ b/go/libraries/doltcore/sqle/history_table.go @@ -22,6 +22,7 @@ import ( "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" "github.com/dolthub/go-mysql-server/sql/transform" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" @@ -47,10 +48,10 @@ const ( var ( // CommitHashColType is the sql type of the commit hash column - CommitHashColType = sql.MustCreateString(sqltypes.Char, 32, sql.Collation_ascii_bin) + CommitHashColType = types.MustCreateString(sqltypes.Char, 32, sql.Collation_ascii_bin) // CommitterColType is the sql type of the committer column - CommitterColType = sql.MustCreateString(sqltypes.VarChar, 1024, sql.Collation_ascii_bin) + CommitterColType = types.MustCreateString(sqltypes.VarChar, 1024, sql.Collation_ascii_bin) ) var _ sql.Table = (*HistoryTable)(nil) @@ -124,7 +125,7 @@ func historyTableSchema(tableName string, table *DoltTable) sql.Schema { &sql.Column{ Name: CommitDateCol, Source: tableName, - Type: sql.Datetime, + Type: types.Datetime, }, ) return newSch @@ -306,7 +307,7 @@ func (ht *HistoryTable) Schema() sql.Schema { projectedSch[i] = &sql.Column{ Name: CommitDateCol, Source: ht.Name(), - Type: sql.Datetime, + Type: types.Datetime, } } else { panic("column not found") diff --git a/go/libraries/doltcore/sqle/index/dolt_index_test.go b/go/libraries/doltcore/sqle/index/dolt_index_test.go index d926c1f19d..5143ba8846 100644 --- a/go/libraries/doltcore/sqle/index/dolt_index_test.go +++ b/go/libraries/doltcore/sqle/index/dolt_index_test.go @@ -25,6 +25,7 @@ import ( "time" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/shopspring/decimal" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -174,11 +175,11 @@ var typesTests = []struct { } var ( - typesTableRow1 = sql.Row{int32(-3), uint64(1), mustTime("2020-05-14 12:00:00"), mustDecimal("-3.30000"), uint16(2), -3.3, uint64(1), sql.Timespan(-183000000), "a", int16(1980)} - typesTableRow2 = sql.Row{int32(-1), uint64(2), mustTime("2020-05-14 12:00:01"), mustDecimal("-1.10000"), uint16(3), -1.1, uint64(3), sql.Timespan(-61000000), "b", int16(1990)} - typesTableRow3 = sql.Row{int32(0), uint64(3), mustTime("2020-05-14 12:00:02"), mustDecimal("0.00000"), uint16(4), 0.0, uint64(4), sql.Timespan(0), "c", int16(2000)} - typesTableRow4 = sql.Row{int32(1), uint64(4), mustTime("2020-05-14 12:00:03"), mustDecimal("1.10000"), uint16(5), 1.1, uint64(5), sql.Timespan(61000000), "d", int16(2010)} - typesTableRow5 = sql.Row{int32(3), uint64(5), mustTime("2020-05-14 12:00:04"), mustDecimal("3.30000"), uint16(6), 3.3, uint64(6), sql.Timespan(183000000), "e", int16(2020)} + typesTableRow1 = sql.Row{int32(-3), uint64(1), mustTime("2020-05-14 12:00:00"), mustDecimal("-3.30000"), uint16(2), -3.3, uint64(1), types.Timespan(-183000000), "a", int16(1980)} + typesTableRow2 = sql.Row{int32(-1), uint64(2), mustTime("2020-05-14 12:00:01"), mustDecimal("-1.10000"), uint16(3), -1.1, uint64(3), types.Timespan(-61000000), "b", int16(1990)} + typesTableRow3 = sql.Row{int32(0), uint64(3), mustTime("2020-05-14 12:00:02"), mustDecimal("0.00000"), uint16(4), 0.0, uint64(4), types.Timespan(0), "c", int16(2000)} + typesTableRow4 = sql.Row{int32(1), uint64(4), mustTime("2020-05-14 12:00:03"), mustDecimal("1.10000"), uint16(5), 1.1, uint64(5), types.Timespan(61000000), "d", int16(2010)} + typesTableRow5 = sql.Row{int32(3), uint64(5), mustTime("2020-05-14 12:00:04"), mustDecimal("3.30000"), uint16(6), 3.3, uint64(6), types.Timespan(183000000), "e", int16(2020)} ) func TestDoltIndexEqual(t *testing.T) { @@ -1470,7 +1471,7 @@ func TestSplitNullsFromRange(t *testing.T) { }) t.Run("ThreeColumnNoNullsRange", func(t *testing.T) { - r := sql.Range{sql.LessThanRangeColumnExpr(10, sql.Int8), sql.GreaterThanRangeColumnExpr(16, sql.Int8), sql.NotNullRangeColumnExpr(sql.Int8)} + r := sql.Range{sql.LessThanRangeColumnExpr(10, types.Int8), sql.GreaterThanRangeColumnExpr(16, types.Int8), sql.NotNullRangeColumnExpr(types.Int8)} rs, err := index.SplitNullsFromRange(r) assert.NoError(t, err) assert.NotNil(t, rs) @@ -1480,7 +1481,7 @@ func TestSplitNullsFromRange(t *testing.T) { }) t.Run("LastColumnOnlyNull", func(t *testing.T) { - r := sql.Range{sql.LessThanRangeColumnExpr(10, sql.Int8), sql.GreaterThanRangeColumnExpr(16, sql.Int8), sql.NullRangeColumnExpr(sql.Int8)} + r := sql.Range{sql.LessThanRangeColumnExpr(10, types.Int8), sql.GreaterThanRangeColumnExpr(16, types.Int8), sql.NullRangeColumnExpr(types.Int8)} rs, err := index.SplitNullsFromRange(r) assert.NoError(t, err) assert.NotNil(t, rs) @@ -1490,7 +1491,7 @@ func TestSplitNullsFromRange(t *testing.T) { }) t.Run("LastColumnAll", func(t *testing.T) { - r := sql.Range{sql.LessThanRangeColumnExpr(10, sql.Int8), sql.GreaterThanRangeColumnExpr(16, sql.Int8), sql.AllRangeColumnExpr(sql.Int8)} + r := sql.Range{sql.LessThanRangeColumnExpr(10, types.Int8), sql.GreaterThanRangeColumnExpr(16, types.Int8), sql.AllRangeColumnExpr(types.Int8)} rs, err := index.SplitNullsFromRange(r) assert.NoError(t, err) assert.NotNil(t, rs) @@ -1499,12 +1500,12 @@ func TestSplitNullsFromRange(t *testing.T) { assert.Len(t, rs[1], 3) assert.Equal(t, r[:2], rs[0][:2]) assert.Equal(t, r[:2], rs[1][:2]) - assert.Equal(t, sql.NullRangeColumnExpr(sql.Int8), rs[0][2]) - assert.Equal(t, sql.NotNullRangeColumnExpr(sql.Int8), rs[1][2]) + assert.Equal(t, sql.NullRangeColumnExpr(types.Int8), rs[0][2]) + assert.Equal(t, sql.NotNullRangeColumnExpr(types.Int8), rs[1][2]) }) t.Run("FirstColumnAll", func(t *testing.T) { - r := sql.Range{sql.AllRangeColumnExpr(sql.Int8), sql.LessThanRangeColumnExpr(10, sql.Int8), sql.GreaterThanRangeColumnExpr(16, sql.Int8)} + r := sql.Range{sql.AllRangeColumnExpr(types.Int8), sql.LessThanRangeColumnExpr(10, types.Int8), sql.GreaterThanRangeColumnExpr(16, types.Int8)} rs, err := index.SplitNullsFromRange(r) assert.NoError(t, err) assert.NotNil(t, rs) @@ -1513,12 +1514,12 @@ func TestSplitNullsFromRange(t *testing.T) { assert.Len(t, rs[1], 3) assert.Equal(t, r[1:], rs[0][1:]) assert.Equal(t, r[1:], rs[1][1:]) - assert.Equal(t, sql.NullRangeColumnExpr(sql.Int8), rs[0][0]) - assert.Equal(t, sql.NotNullRangeColumnExpr(sql.Int8), rs[1][0]) + assert.Equal(t, sql.NullRangeColumnExpr(types.Int8), rs[0][0]) + assert.Equal(t, sql.NotNullRangeColumnExpr(types.Int8), rs[1][0]) }) t.Run("AllColumnAll", func(t *testing.T) { - r := sql.Range{sql.AllRangeColumnExpr(sql.Int8), sql.AllRangeColumnExpr(sql.Int8), sql.AllRangeColumnExpr(sql.Int8)} + r := sql.Range{sql.AllRangeColumnExpr(types.Int8), sql.AllRangeColumnExpr(types.Int8), sql.AllRangeColumnExpr(types.Int8)} rs, err := index.SplitNullsFromRange(r) assert.NoError(t, err) assert.NotNil(t, rs) diff --git a/go/libraries/doltcore/sqle/index/prolly_fields.go b/go/libraries/doltcore/sqle/index/prolly_fields.go index 6decc3ad80..82b53dfdc3 100644 --- a/go/libraries/doltcore/sqle/index/prolly_fields.go +++ b/go/libraries/doltcore/sqle/index/prolly_fields.go @@ -24,7 +24,7 @@ import ( "math" "time" - "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/shopspring/decimal" "github.com/dolthub/dolt/go/store/hash" @@ -70,7 +70,7 @@ func GetField(ctx context.Context, td val.TupleDesc, i int, tup val.Tuple, ns tr var t int64 t, ok = td.GetSqlTime(i, tup) if ok { - v = sql.Timespan(t) + v = types.Timespan(t) } case val.DatetimeEnc: v, ok = td.GetDatetime(i, tup) @@ -86,7 +86,7 @@ func GetField(ctx context.Context, td val.TupleDesc, i int, tup val.Tuple, ns tr var buf []byte buf, ok = td.GetJSON(i, tup) if ok { - var doc sql.JSONDocument + var doc types.JSONDocument err = json.Unmarshal(buf, &doc.Val) v = doc } @@ -164,7 +164,7 @@ func PutField(ctx context.Context, ns tree.NodeStore, tb *val.TupleBuilder, i in case val.DateEnc: tb.PutDate(i, v.(time.Time)) case val.TimeEnc: - tb.PutSqlTime(i, int64(v.(sql.Timespan))) + tb.PutSqlTime(i, int64(v.(types.Timespan))) case val.DatetimeEnc: tb.PutDatetime(i, v.(time.Time)) case val.EnumEnc: @@ -273,23 +273,23 @@ func convUint(v interface{}) uint { } func deserializeGeometry(buf []byte) (v interface{}) { - srid, _, typ, _ := sql.DeserializeEWKBHeader(buf) - buf = buf[sql.EWKBHeaderSize:] + srid, _, typ, _ := types.DeserializeEWKBHeader(buf) + buf = buf[types.EWKBHeaderSize:] switch typ { - case sql.WKBPointID: - v, _, _ = sql.DeserializePoint(buf, false, srid) - case sql.WKBLineID: - v, _, _ = sql.DeserializeLine(buf, false, srid) - case sql.WKBPolyID: - v, _, _ = sql.DeserializePoly(buf, false, srid) - case sql.WKBMultiPointID: - v, _, _ = sql.DeserializeMPoint(buf, false, srid) - case sql.WKBMultiLineID: - v, _, _ = sql.DeserializeMLine(buf, false, srid) - case sql.WKBMultiPolyID: - v, _, _ = sql.DeserializeMPoly(buf, false, srid) - case sql.WKBGeomCollID: - v, _, _ = sql.DeserializeGeomColl(buf, false, srid) + case types.WKBPointID: + v, _, _ = types.DeserializePoint(buf, false, srid) + case types.WKBLineID: + v, _, _ = types.DeserializeLine(buf, false, srid) + case types.WKBPolyID: + v, _, _ = types.DeserializePoly(buf, false, srid) + case types.WKBMultiPointID: + v, _, _ = types.DeserializeMPoint(buf, false, srid) + case types.WKBMultiLineID: + v, _, _ = types.DeserializeMLine(buf, false, srid) + case types.WKBMultiPolyID: + v, _, _ = types.DeserializeMPoly(buf, false, srid) + case types.WKBGeomCollID: + v, _, _ = types.DeserializeGeomColl(buf, false, srid) default: panic(fmt.Sprintf("unknown geometry type %d", typ)) } @@ -298,7 +298,7 @@ func deserializeGeometry(buf []byte) (v interface{}) { func serializeGeometry(v interface{}) []byte { switch t := v.(type) { - case sql.GeometryValue: + case types.GeometryValue: return t.Serialize() default: panic(fmt.Sprintf("unknown geometry %v", v)) @@ -316,9 +316,9 @@ func serializeBytesToAddr(ctx context.Context, ns tree.NodeStore, r io.Reader, d } func convJson(v interface{}) (buf []byte, err error) { - v, err = sql.JSON.Convert(v) + v, err = types.JSON.Convert(v) if err != nil { return nil, err } - return json.Marshal(v.(sql.JSONDocument).Val) + return json.Marshal(v.(types.JSONDocument).Val) } diff --git a/go/libraries/doltcore/sqle/index/prolly_fields_test.go b/go/libraries/doltcore/sqle/index/prolly_fields_test.go index 75884c9bf5..74cbf073d0 100644 --- a/go/libraries/doltcore/sqle/index/prolly_fields_test.go +++ b/go/libraries/doltcore/sqle/index/prolly_fields_test.go @@ -21,8 +21,8 @@ import ( "testing" "time" - "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression/function" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/shopspring/decimal" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -219,11 +219,11 @@ func mustParseGeometryType(t *testing.T, s string) (v interface{}) { return } -func mustParseJson(t *testing.T, s string) sql.JSONDocument { +func mustParseJson(t *testing.T, s string) types.JSONDocument { var v interface{} err := json.Unmarshal([]byte(s), &v) require.NoError(t, err) - return sql.JSONDocument{Val: v} + return types.JSONDocument{Val: v} } func mustParseDecimal(s string) decimal.Decimal { @@ -234,8 +234,8 @@ func mustParseDecimal(s string) decimal.Decimal { return d } -func mustParseTime(t *testing.T, s string) sql.Timespan { - val, err := sql.Time.ConvertToTimespan(s) +func mustParseTime(t *testing.T, s string) types.Timespan { + val, err := types.Time.ConvertToTimespan(s) require.NoError(t, err) return val } diff --git a/go/libraries/doltcore/sqle/json/noms_json_value.go b/go/libraries/doltcore/sqle/json/noms_json_value.go index 471abf35ff..bb714a60c7 100644 --- a/go/libraries/doltcore/sqle/json/noms_json_value.go +++ b/go/libraries/doltcore/sqle/json/noms_json_value.go @@ -20,6 +20,7 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/types" ) @@ -35,10 +36,10 @@ const ( // logic to be kept separate from the storage-layer code in pkg types. type NomsJSON types.JSON -var _ sql.JSONValue = NomsJSON{} +var _ types2.JSONValue = NomsJSON{} // NomsJSONFromJSONValue converts a sql.JSONValue to a NomsJSON value. -func NomsJSONFromJSONValue(ctx context.Context, vrw types.ValueReadWriter, val sql.JSONValue) (NomsJSON, error) { +func NomsJSONFromJSONValue(ctx context.Context, vrw types.ValueReadWriter, val types2.JSONValue) (NomsJSON, error) { if noms, ok := val.(NomsJSON); ok { return noms, nil } @@ -134,18 +135,18 @@ func marshalJSONObject(ctx context.Context, vrw types.ValueReadWriter, obj map[s } // Unmarshall implements the sql.JSONValue interface. -func (v NomsJSON) Unmarshall(ctx *sql.Context) (doc sql.JSONDocument, err error) { +func (v NomsJSON) Unmarshall(ctx *sql.Context) (doc types2.JSONDocument, err error) { nomsVal, err := types.JSON(v).Inner() if err != nil { - return sql.JSONDocument{}, err + return types2.JSONDocument{}, err } val, err := unmarshalJSON(ctx, nomsVal) if err != nil { - return sql.JSONDocument{}, err + return types2.JSONDocument{}, err } - return sql.JSONDocument{Val: val}, nil + return types2.JSONDocument{Val: val}, nil } func unmarshalJSON(ctx context.Context, val types.Value) (interface{}, error) { @@ -191,7 +192,7 @@ func unmarshalJSONObject(ctx context.Context, m types.Map) (obj map[string]inter } // Compare implements the sql.JSONValue interface. -func (v NomsJSON) Compare(ctx *sql.Context, other sql.JSONValue) (cmp int, err error) { +func (v NomsJSON) Compare(ctx *sql.Context, other types2.JSONValue) (cmp int, err error) { noms, ok := other.(NomsJSON) if !ok { doc, err := v.Unmarshall(ctx) diff --git a/go/libraries/doltcore/sqle/json/noms_json_value_test.go b/go/libraries/doltcore/sqle/json/noms_json_value_test.go index 93d6aa1e85..fc68d989e0 100644 --- a/go/libraries/doltcore/sqle/json/noms_json_value_test.go +++ b/go/libraries/doltcore/sqle/json/noms_json_value_test.go @@ -21,6 +21,7 @@ import ( "testing" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -32,47 +33,47 @@ import ( func TestJSONValueMarshallingRoundTrip(t *testing.T) { tests := []struct { name string - doc sql.JSONDocument + doc types2.JSONDocument }{ { name: "smoke", - doc: sql.MustJSON(`[]`), + doc: types2.MustJSON(`[]`), }, { name: "null", - doc: sql.MustJSON(`null`), + doc: types2.MustJSON(`null`), }, { name: "boolean", - doc: sql.MustJSON(`false`), + doc: types2.MustJSON(`false`), }, { name: "string", - doc: sql.MustJSON(`"lorem ipsum"`), + doc: types2.MustJSON(`"lorem ipsum"`), }, { name: "number", - doc: sql.MustJSON(`2.71`), + doc: types2.MustJSON(`2.71`), }, { name: "type homogenous object", - doc: sql.MustJSON(`{"a": 2, "b": 3, "c": 4}`), + doc: types2.MustJSON(`{"a": 2, "b": 3, "c": 4}`), }, { name: "type heterogeneous object", - doc: sql.MustJSON(`{"a": 2, "b": "two", "c": false}`), + doc: types2.MustJSON(`{"a": 2, "b": "two", "c": false}`), }, { name: "homogenous array", - doc: sql.MustJSON(`[1, 2, 3]`), + doc: types2.MustJSON(`[1, 2, 3]`), }, { name: "heterogeneous array", - doc: sql.MustJSON(`[1, "two", false]`), + doc: types2.MustJSON(`[1, "two", false]`), }, { name: "nested", - doc: sql.MustJSON(`[{"a":1}, {"b":2}, null, [false, 3.14, [], {"c": [0]}], ""]`), + doc: types2.MustJSON(`[{"a":1}, {"b":2}, null, [false, 3.14, [], {"c": [0]}], ""]`), }, } @@ -98,7 +99,7 @@ func TestJSONValueMarshallingRoundTrip(t *testing.T) { err = js.Unmarshal([]byte(str), &val) assert.NoError(t, err) - jsDoc = sql.JSONDocument{Val: val} + jsDoc = types2.JSONDocument{Val: val} assert.Equal(t, test.doc.Val, jsDoc.Val) }) } diff --git a/go/libraries/doltcore/sqle/json/testutils.go b/go/libraries/doltcore/sqle/json/testutils.go index 6cce0a0caf..6afad80ab6 100644 --- a/go/libraries/doltcore/sqle/json/testutils.go +++ b/go/libraries/doltcore/sqle/json/testutils.go @@ -17,7 +17,7 @@ package json import ( "context" - "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/types" ) @@ -29,7 +29,7 @@ func MustNomsJSON(str string) NomsJSON { func MustNomsJSONWithVRW(vrw types.ValueReadWriter, str string) NomsJSON { ctx := context.Background() - doc := sql.MustJSON(str) + doc := types2.MustJSON(str) noms, err := NomsJSONFromJSONValue(ctx, vrw, doc) if err != nil { panic(err) diff --git a/go/libraries/doltcore/sqle/read_replica_database.go b/go/libraries/doltcore/sqle/read_replica_database.go index c4011e3eb3..7398fd5abd 100644 --- a/go/libraries/doltcore/sqle/read_replica_database.go +++ b/go/libraries/doltcore/sqle/read_replica_database.go @@ -22,6 +22,7 @@ import ( "sync" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/sysvars" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/env" @@ -100,12 +101,12 @@ func (rrd ReadReplicaDatabase) InitialDBState(ctx context.Context, branch string } func (rrd ReadReplicaDatabase) PullFromRemote(ctx *sql.Context) error { - _, headsArg, ok := sql.SystemVariables.GetGlobal(dsess.ReplicateHeads) + _, headsArg, ok := variables.SystemVariables.GetGlobal(dsess.ReplicateHeads) if !ok { return sql.ErrUnknownSystemVariable.New(dsess.ReplicateHeads) } - _, allHeads, ok := sql.SystemVariables.GetGlobal(dsess.ReplicateAllHeads) + _, allHeads, ok := variables.SystemVariables.GetGlobal(dsess.ReplicateAllHeads) if !ok { return sql.ErrUnknownSystemVariable.New(dsess.ReplicateAllHeads) } diff --git a/go/libraries/doltcore/sqle/replication.go b/go/libraries/doltcore/sqle/replication.go index 5f122b9553..968a070f01 100644 --- a/go/libraries/doltcore/sqle/replication.go +++ b/go/libraries/doltcore/sqle/replication.go @@ -20,6 +20,7 @@ import ( "io" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/sysvars" "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" @@ -30,7 +31,7 @@ import ( ) func getPushOnWriteHook(ctx context.Context, bThreads *sql.BackgroundThreads, dEnv *env.DoltEnv, logger io.Writer) (doltdb.CommitHook, error) { - _, val, ok := sql.SystemVariables.GetGlobal(dsess.ReplicateToRemote) + _, val, ok := variables.SystemVariables.GetGlobal(dsess.ReplicateToRemote) if !ok { return nil, sql.ErrUnknownSystemVariable.New(dsess.ReplicateToRemote) } else if val == "" { @@ -61,7 +62,7 @@ func getPushOnWriteHook(ctx context.Context, bThreads *sql.BackgroundThreads, dE if err != nil { return nil, err } - if _, val, ok = sql.SystemVariables.GetGlobal(dsess.AsyncReplication); ok && val == dsess.SysVarTrue { + if _, val, ok = variables.SystemVariables.GetGlobal(dsess.AsyncReplication); ok && val == dsess.SysVarTrue { return doltdb.NewAsyncPushOnWriteHook(bThreads, ddb, tmpDir, logger) } @@ -130,7 +131,7 @@ func ApplyReplicationConfig(ctx context.Context, bThreads *sql.BackgroundThreads } dEnv.DoltDB.SetCommitHooks(ctx, postCommitHooks) - if _, remote, ok := sql.SystemVariables.GetGlobal(dsess.ReadReplicaRemote); ok && remote != "" { + if _, remote, ok := variables.SystemVariables.GetGlobal(dsess.ReadReplicaRemote); ok && remote != "" { remoteName, ok := remote.(string) if !ok { return nil, sql.ErrInvalidSystemVariableValue.New(remote) diff --git a/go/libraries/doltcore/sqle/replication_test.go b/go/libraries/doltcore/sqle/replication_test.go index 86db21775c..47f91fc37f 100644 --- a/go/libraries/doltcore/sqle/replication_test.go +++ b/go/libraries/doltcore/sqle/replication_test.go @@ -19,6 +19,7 @@ import ( "testing" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/sysvars" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/zap/buffer" @@ -33,8 +34,8 @@ func TestCommitHooksNoErrors(t *testing.T) { require.NoError(t, err) AddDoltSystemVariables() - sql.SystemVariables.SetGlobal(dsess.SkipReplicationErrors, true) - sql.SystemVariables.SetGlobal(dsess.ReplicateToRemote, "unknown") + variables.SystemVariables.SetGlobal(dsess.SkipReplicationErrors, true) + variables.SystemVariables.SetGlobal(dsess.ReplicateToRemote, "unknown") bThreads := sql.NewBackgroundThreads() hooks, err := GetCommitHooks(context.Background(), bThreads, dEnv, &buffer.Buffer{}) assert.NoError(t, err) diff --git a/go/libraries/doltcore/sqle/schema_table.go b/go/libraries/doltcore/sqle/schema_table.go index fd47100465..bb42ad48fa 100644 --- a/go/libraries/doltcore/sqle/schema_table.go +++ b/go/libraries/doltcore/sqle/schema_table.go @@ -20,6 +20,7 @@ import ( "time" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb/durable" @@ -355,7 +356,7 @@ func getSchemaFragmentsOfType(ctx *sql.Context, tbl *WritableDoltTable, fragType } func getCreatedTime(ctx *sql.Context, row sql.Row) (int64, error) { - doc, err := row[4].(sql.JSONValue).Unmarshall(ctx) + doc, err := row[4].(types2.JSONValue).Unmarshall(ctx) if err != nil { return 0, err } diff --git a/go/libraries/doltcore/sqle/schema_table_test.go b/go/libraries/doltcore/sqle/schema_table_test.go index 6a425afcb2..879224aa28 100644 --- a/go/libraries/doltcore/sqle/schema_table_test.go +++ b/go/libraries/doltcore/sqle/schema_table_test.go @@ -19,6 +19,7 @@ import ( "testing" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -51,9 +52,9 @@ func TestSchemaTableRecreationOlder(t *testing.T) { ctx.SetCurrentDatabase(db.Name()) err = db.createSqlTable(ctx, doltdb.SchemasTableName, sql.NewPrimaryKeySchema(sql.Schema{ // schema of dolt_schemas table before the change - {Name: doltdb.SchemasTablesTypeCol, Type: sql.Text, Source: doltdb.SchemasTableName, PrimaryKey: true}, - {Name: doltdb.SchemasTablesNameCol, Type: sql.Text, Source: doltdb.SchemasTableName, PrimaryKey: true}, - {Name: doltdb.SchemasTablesFragmentCol, Type: sql.Text, Source: doltdb.SchemasTableName, PrimaryKey: false}, + {Name: doltdb.SchemasTablesTypeCol, Type: types2.Text, Source: doltdb.SchemasTableName, PrimaryKey: true}, + {Name: doltdb.SchemasTablesNameCol, Type: types2.Text, Source: doltdb.SchemasTableName, PrimaryKey: true}, + {Name: doltdb.SchemasTablesFragmentCol, Type: types2.Text, Source: doltdb.SchemasTableName, PrimaryKey: false}, }), sql.Collation_Default) require.NoError(t, err) sqlTbl, found, err := db.GetTableInsensitive(ctx, doltdb.SchemasTableName) @@ -137,10 +138,10 @@ func TestSchemaTableRecreation(t *testing.T) { // This is the schema of dolt_schemas table after the change adding the ID column, but before adding the extra column err = db.createSqlTable(ctx, doltdb.SchemasTableName, sql.NewPrimaryKeySchema(sql.Schema{ // - {Name: doltdb.SchemasTablesTypeCol, Type: sql.Text, Source: doltdb.SchemasTableName, PrimaryKey: true}, - {Name: doltdb.SchemasTablesNameCol, Type: sql.Text, Source: doltdb.SchemasTableName, PrimaryKey: true}, - {Name: doltdb.SchemasTablesFragmentCol, Type: sql.Text, Source: doltdb.SchemasTableName, PrimaryKey: false}, - {Name: doltdb.SchemasTablesIdCol, Type: sql.Int64, Source: doltdb.SchemasTableName, PrimaryKey: false}, + {Name: doltdb.SchemasTablesTypeCol, Type: types2.Text, Source: doltdb.SchemasTableName, PrimaryKey: true}, + {Name: doltdb.SchemasTablesNameCol, Type: types2.Text, Source: doltdb.SchemasTableName, PrimaryKey: true}, + {Name: doltdb.SchemasTablesFragmentCol, Type: types2.Text, Source: doltdb.SchemasTableName, PrimaryKey: false}, + {Name: doltdb.SchemasTablesIdCol, Type: types2.Int64, Source: doltdb.SchemasTableName, PrimaryKey: false}, }), sql.Collation_Default) require.NoError(t, err) sqlTbl, found, err := db.GetTableInsensitive(ctx, doltdb.SchemasTableName) diff --git a/go/libraries/doltcore/sqle/sqlddl_test.go b/go/libraries/doltcore/sqle/sqlddl_test.go index 24cbd53807..3c54d156e5 100644 --- a/go/libraries/doltcore/sqle/sqlddl_test.go +++ b/go/libraries/doltcore/sqle/sqlddl_test.go @@ -21,6 +21,7 @@ import ( "testing" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -48,23 +49,23 @@ func TestCreateTable(t *testing.T) { query: "create table testTable (id int primary key)", expectedTable: "testTable", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, true, schema.NotNullConstraint{})), + schemaNewColumn(t, "id", 4817, types2.Int32, true, schema.NotNullConstraint{})), }, { name: "Test create two column schema", query: "create table testTable (id int primary key, age int)", expectedTable: "testTable", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "age", 7208, sql.Int32, false)), + schemaNewColumn(t, "id", 4817, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "age", 7208, types2.Int32, false)), }, { name: "Test create two column keyless schema", query: "create table testTable (id int, age int)", expectedTable: "testTable", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, false), - schemaNewColumn(t, "age", 7208, sql.Int32, false)), + schemaNewColumn(t, "id", 4817, types2.Int32, false), + schemaNewColumn(t, "age", 7208, types2.Int32, false)), }, { name: "Test syntax error", @@ -102,10 +103,10 @@ func TestCreateTable(t *testing.T) { is_married boolean) `, expectedTable: "testTable", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "age", 7208, sql.Int32, false), - schemaNewColumn(t, "first_name", 3264, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false), - schemaNewColumn(t, "is_married", 14626, sql.Boolean, false)), + schemaNewColumn(t, "id", 4817, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "age", 7208, types2.Int32, false), + schemaNewColumn(t, "first_name", 3264, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false), + schemaNewColumn(t, "is_married", 14626, types2.Boolean, false)), }, { name: "Test all supported types", @@ -135,33 +136,33 @@ func TestCreateTable(t *testing.T) { c25 mediumint unsigned, c26 bigint unsigned)`, expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "c0", 594, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "c1", 601, sql.Int8, false), - schemaNewColumn(t, "c2", 14542, sql.Int16, false), - schemaNewColumn(t, "c3", 13309, sql.Int24, false), - schemaNewColumn(t, "c4", 15884, sql.Int32, false), - schemaNewColumn(t, "c5", 14619, sql.Int64, false), - schemaNewColumn(t, "c6", 13192, sql.Boolean, false), - schemaNewColumn(t, "c7", 5981, sql.Boolean, false), - schemaNewColumn(t, "c8", 14871, sql.MustCreateBitType(10), false), - schemaNewColumn(t, "c9", 4167, sql.Text, false), - schemaNewColumn(t, "c10", 1965, sql.TinyText, false), - schemaNewColumn(t, "c11", 12860, sql.MediumText, false), - schemaNewColumn(t, "c12", 7155, sql.LongText, false), + schemaNewColumn(t, "c0", 594, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "c1", 601, types2.Int8, false), + schemaNewColumn(t, "c2", 14542, types2.Int16, false), + schemaNewColumn(t, "c3", 13309, types2.Int24, false), + schemaNewColumn(t, "c4", 15884, types2.Int32, false), + schemaNewColumn(t, "c5", 14619, types2.Int64, false), + schemaNewColumn(t, "c6", 13192, types2.Boolean, false), + schemaNewColumn(t, "c7", 5981, types2.Boolean, false), + schemaNewColumn(t, "c8", 14871, types2.MustCreateBitType(10), false), + schemaNewColumn(t, "c9", 4167, types2.Text, false), + schemaNewColumn(t, "c10", 1965, types2.TinyText, false), + schemaNewColumn(t, "c11", 12860, types2.MediumText, false), + schemaNewColumn(t, "c12", 7155, types2.LongText, false), //schemaNewColumn(t, "c13", 113, sql.TinyBlob, false), //schemaNewColumn(t, "c14", 114, sql.Blob, false), //schemaNewColumn(t, "c15", 115, sql.LongBlob, false), - schemaNewColumn(t, "c16", 15859, sql.MustCreateStringWithDefaults(sqltypes.Char, 5), false), - schemaNewColumn(t, "c17", 11710, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false), - schemaNewColumn(t, "c18", 6838, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), - schemaNewColumn(t, "c19", 9377, sql.Float32, false), - schemaNewColumn(t, "c20", 15979, sql.Float64, false), + schemaNewColumn(t, "c16", 15859, types2.MustCreateStringWithDefaults(sqltypes.Char, 5), false), + schemaNewColumn(t, "c17", 11710, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false), + schemaNewColumn(t, "c18", 6838, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), + schemaNewColumn(t, "c19", 9377, types2.Float32, false), + schemaNewColumn(t, "c20", 15979, types2.Float64, false), //schemaNewColumn(t, "c21", 121, sql.MustCreateDecimalType(10, 5), false), - schemaNewColumn(t, "c22", 2910, sql.Uint32, false), - schemaNewColumn(t, "c23", 8740, sql.Uint8, false), - schemaNewColumn(t, "c24", 8689, sql.Uint16, false), - schemaNewColumn(t, "c25", 5243, sql.Uint24, false), - schemaNewColumn(t, "c26", 9338, sql.Uint64, false), + schemaNewColumn(t, "c22", 2910, types2.Uint32, false), + schemaNewColumn(t, "c23", 8740, types2.Uint8, false), + schemaNewColumn(t, "c24", 8689, types2.Uint16, false), + schemaNewColumn(t, "c25", 5243, types2.Uint24, false), + schemaNewColumn(t, "c26", 9338, types2.Uint64, false), ), }, { @@ -174,10 +175,10 @@ func TestCreateTable(t *testing.T) { primary key (id, age))`, expectedTable: "testTable", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "age", 7208, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "first_name", 3264, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), - schemaNewColumn(t, "is_married", 14626, sql.Boolean, false)), + schemaNewColumn(t, "id", 4817, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "age", 7208, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "first_name", 3264, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), + schemaNewColumn(t, "is_married", 14626, types2.Boolean, false)), }, { name: "Test not null constraints", @@ -189,10 +190,10 @@ func TestCreateTable(t *testing.T) { primary key (id, age))`, expectedTable: "testTable", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "age", 7208, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "first_name", 3264, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false, schema.NotNullConstraint{}), - schemaNewColumn(t, "is_married", 14626, sql.Boolean, false)), + schemaNewColumn(t, "id", 4817, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "age", 7208, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "first_name", 3264, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false, schema.NotNullConstraint{}), + schemaNewColumn(t, "is_married", 14626, types2.Boolean, false)), }, { name: "Test quoted columns", @@ -204,10 +205,10 @@ func TestCreateTable(t *testing.T) { "primary key (`id`, `age`))", expectedTable: "testTable", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "age", 7208, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "timestamp", 10168, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), - schemaNewColumn(t, "is married", 14626, sql.Boolean, false)), + schemaNewColumn(t, "id", 4817, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "age", 7208, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "timestamp", 10168, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), + schemaNewColumn(t, "is married", 14626, types2.Boolean, false)), }, { name: "Test tag comments", @@ -215,8 +216,8 @@ func TestCreateTable(t *testing.T) { id int primary key, age int)`, expectedTable: "testTable", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "age", 7208, sql.Int32, false)), + schemaNewColumn(t, "id", 4817, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "age", 7208, types2.Int32, false)), }, // Real world examples for regression testing { @@ -227,8 +228,8 @@ func TestCreateTable(t *testing.T) { PRIMARY KEY (ip));`, expectedTable: "ip2nation", expectedSchema: dtestutils.CreateSchema( - schemaNewColumnWDefVal(t, "ip", 7265, sql.Uint32, true, "0", schema.NotNullConstraint{}), - schemaNewColumnWDefVal(t, "country", 6630, sql.MustCreateStringWithDefaults(sqltypes.Char, 2), false, `''`, schema.NotNullConstraint{})), + schemaNewColumnWDefVal(t, "ip", 7265, types2.Uint32, true, "0", schema.NotNullConstraint{}), + schemaNewColumnWDefVal(t, "country", 6630, types2.MustCreateStringWithDefaults(sqltypes.Char, 2), false, `''`, schema.NotNullConstraint{})), }, { name: "Test ip2nationCountries", @@ -243,13 +244,13 @@ func TestCreateTable(t *testing.T) { lon float NOT NULL default 0.0, PRIMARY KEY (code));`, expectedSchema: dtestutils.CreateSchema( - schemaNewColumnWDefVal(t, "code", 7802, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 4), true, `''`, schema.NotNullConstraint{}), - schemaNewColumnWDefVal(t, "iso_code_2", 9266, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 2), false, `''`, schema.NotNullConstraint{}), - schemaNewColumnWDefVal(t, "iso_code_3", 8427, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 3), false, `''`), - schemaNewColumnWDefVal(t, "iso_country", 7151, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false, `''`, schema.NotNullConstraint{}), - schemaNewColumnWDefVal(t, "country", 879, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false, `''`, schema.NotNullConstraint{}), - schemaNewColumnWDefVal(t, "lat", 3502, sql.Float32, false, "0.0", schema.NotNullConstraint{}), - schemaNewColumnWDefVal(t, "lon", 9907, sql.Float32, false, "0.0", schema.NotNullConstraint{})), + schemaNewColumnWDefVal(t, "code", 7802, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 4), true, `''`, schema.NotNullConstraint{}), + schemaNewColumnWDefVal(t, "iso_code_2", 9266, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 2), false, `''`, schema.NotNullConstraint{}), + schemaNewColumnWDefVal(t, "iso_code_3", 8427, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 3), false, `''`), + schemaNewColumnWDefVal(t, "iso_country", 7151, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false, `''`, schema.NotNullConstraint{}), + schemaNewColumnWDefVal(t, "country", 879, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false, `''`, schema.NotNullConstraint{}), + schemaNewColumnWDefVal(t, "lat", 3502, types2.Float32, false, "0.0", schema.NotNullConstraint{}), + schemaNewColumnWDefVal(t, "lon", 9907, types2.Float32, false, "0.0", schema.NotNullConstraint{})), }, } @@ -369,49 +370,49 @@ func TestAddColumn(t *testing.T) { name: "alter add string column no default", query: "alter table people add (newColumn varchar(80))", expectedSchema: dtestutils.AddColumnToSchema(PeopleTestSchema, - schemaNewColumn(t, "newColumn", 4208, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false)), + schemaNewColumn(t, "newColumn", 4208, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false)), expectedRows: addColToRows(t, AllPeopleRows, 4208, nil), }, { name: "alter add float column without default", query: "alter table people add (newColumn float)", expectedSchema: dtestutils.AddColumnToSchema(PeopleTestSchema, - schemaNewColumn(t, "newColumn", 4208, sql.Float32, false)), + schemaNewColumn(t, "newColumn", 4208, types2.Float32, false)), expectedRows: addColToRows(t, AllPeopleRows, 4208, nil), }, { name: "alter add uint column without default", query: "alter table people add (newColumn bigint unsigned)", expectedSchema: dtestutils.AddColumnToSchema(PeopleTestSchema, - schemaNewColumn(t, "newColumn", 4208, sql.Uint64, false)), + schemaNewColumn(t, "newColumn", 4208, types2.Uint64, false)), expectedRows: addColToRows(t, AllPeopleRows, 4208, nil), }, { name: "alter add int column default", query: "alter table people add (newColumn int default 2)", expectedSchema: dtestutils.AddColumnToSchema(PeopleTestSchema, - schemaNewColumnWDefVal(t, "newColumn", 2803, sql.Int32, false, "2")), + schemaNewColumnWDefVal(t, "newColumn", 2803, types2.Int32, false, "2")), expectedRows: addColToRows(t, AllPeopleRows, 2803, types.Int(int32(2))), }, { name: "alter add uint column default", query: "alter table people add (newColumn bigint unsigned default 20)", expectedSchema: dtestutils.AddColumnToSchema(PeopleTestSchema, - schemaNewColumnWDefVal(t, "newColumn", 517, sql.Uint64, false, "20")), + schemaNewColumnWDefVal(t, "newColumn", 517, types2.Uint64, false, "20")), expectedRows: addColToRows(t, AllPeopleRows, 517, types.Uint(uint64(20))), }, { name: "alter add string column with default", query: "alter table people add (newColumn varchar(80) default 'hi')", expectedSchema: dtestutils.AddColumnToSchema(PeopleTestSchema, - schemaNewColumnWDefVal(t, "newColumn", 13690, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false, `'hi'`)), + schemaNewColumnWDefVal(t, "newColumn", 13690, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false, `'hi'`)), expectedRows: addColToRows(t, AllPeopleRows, 13690, types.String("hi")), }, { name: "alter add column first", query: "alter table people add newColumn varchar(80) first", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "newColumn", 4208, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), + schemaNewColumn(t, "newColumn", 4208, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), schema.NewColumn("id", IdTag, types.IntKind, true, schema.NotNullConstraint{}), schema.NewColumn("first_name", FirstNameTag, types.StringKind, false, schema.NotNullConstraint{}), schema.NewColumn("last_name", LastNameTag, types.StringKind, false, schema.NotNullConstraint{}), @@ -430,7 +431,7 @@ func TestAddColumn(t *testing.T) { schema.NewColumn("id", IdTag, types.IntKind, true, schema.NotNullConstraint{}), schema.NewColumn("first_name", FirstNameTag, types.StringKind, false, schema.NotNullConstraint{}), schema.NewColumn("last_name", LastNameTag, types.StringKind, false, schema.NotNullConstraint{}), - schemaNewColumn(t, "newColumn", 4208, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), + schemaNewColumn(t, "newColumn", 4208, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), schema.NewColumn("is_married", IsMarriedTag, types.IntKind, false), schema.NewColumn("age", AgeTag, types.IntKind, false), schema.NewColumn("rating", RatingTag, types.FloatKind, false), @@ -443,21 +444,21 @@ func TestAddColumn(t *testing.T) { name: "alter add column not null", query: "alter table people add (newColumn varchar(80) not null default 'default')", expectedSchema: dtestutils.AddColumnToSchema(PeopleTestSchema, - schemaNewColumnWDefVal(t, "newColumn", 13690, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false, `'default'`, schema.NotNullConstraint{})), + schemaNewColumnWDefVal(t, "newColumn", 13690, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false, `'default'`, schema.NotNullConstraint{})), expectedRows: addColToRows(t, AllPeopleRows, 13690, types.String("default")), }, { name: "alter add column not null with expression default", query: "alter table people add (newColumn int not null default (2+2/2))", expectedSchema: dtestutils.AddColumnToSchema(PeopleTestSchema, - schemaNewColumnWDefVal(t, "newColumn", 2803, sql.Int32, false, "((2 + (2 / 2)))", schema.NotNullConstraint{})), + schemaNewColumnWDefVal(t, "newColumn", 2803, types2.Int32, false, "((2 + (2 / 2)))", schema.NotNullConstraint{})), expectedRows: addColToRows(t, AllPeopleRows, 2803, types.Int(3)), }, { name: "alter add column not null with negative expression", query: "alter table people add (newColumn float not null default -1.1)", expectedSchema: dtestutils.AddColumnToSchema(PeopleTestSchema, - schemaNewColumnWDefVal(t, "newColumn", 12469, sql.Float32, false, "-1.1", schema.NotNullConstraint{})), + schemaNewColumnWDefVal(t, "newColumn", 12469, types2.Float32, false, "-1.1", schema.NotNullConstraint{})), expectedRows: addColToRows(t, AllPeopleRows, 12469, types.Float(float32(-1.1))), }, { @@ -479,21 +480,21 @@ func TestAddColumn(t *testing.T) { name: "alter add column not null without default", query: "alter table people add (newColumn varchar(80) not null)", expectedSchema: dtestutils.AddColumnToSchema(PeopleTestSchema, - schemaNewColumnWDefVal(t, "newColumn", 13690, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false, "", schema.NotNullConstraint{})), + schemaNewColumnWDefVal(t, "newColumn", 13690, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false, "", schema.NotNullConstraint{})), expectedRows: addColToRows(t, AllPeopleRows, 13690, types.String("")), }, { name: "alter add column nullable", query: "alter table people add (newColumn bigint)", expectedSchema: dtestutils.AddColumnToSchema(PeopleTestSchema, - schemaNewColumn(t, "newColumn", 4435, sql.Int64, false)), + schemaNewColumn(t, "newColumn", 4435, types2.Int64, false)), expectedRows: AllPeopleRows, }, { name: "alter add column with optional column keyword", query: "alter table people add column (newColumn varchar(80))", expectedSchema: dtestutils.AddColumnToSchema(PeopleTestSchema, - schemaNewColumn(t, "newColumn", 4208, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false)), + schemaNewColumn(t, "newColumn", 4208, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false)), expectedRows: AllPeopleRows, }, { @@ -879,22 +880,22 @@ func TestParseCreateTableStatement(t *testing.T) { query: "create table testTable (id int primary key)", expectedTable: "testTable", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, true, schema.NotNullConstraint{})), + schemaNewColumn(t, "id", 4817, types2.Int32, true, schema.NotNullConstraint{})), }, { name: "Test create table starting with number", query: "create table 123table (id int primary key)", expectedTable: "`123table`", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, true, schema.NotNullConstraint{})), + schemaNewColumn(t, "id", 4817, types2.Int32, true, schema.NotNullConstraint{})), }, { name: "Test create two column schema", query: "create table testTable (id int primary key, age int)", expectedTable: "testTable", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "age", 7208, sql.Int32, false)), + schemaNewColumn(t, "id", 4817, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "age", 7208, types2.Int32, false)), }, { name: "Test syntax error", @@ -911,10 +912,10 @@ func TestParseCreateTableStatement(t *testing.T) { is_married boolean) `, expectedTable: "testTable", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "age", 7208, sql.Int32, false), - schemaNewColumn(t, "first_name", 3264, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false), - schemaNewColumn(t, "is_married", 14626, sql.Boolean, false)), + schemaNewColumn(t, "id", 4817, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "age", 7208, types2.Int32, false), + schemaNewColumn(t, "first_name", 3264, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false), + schemaNewColumn(t, "is_married", 14626, types2.Boolean, false)), }, { name: "Test all supported types", @@ -944,33 +945,33 @@ func TestParseCreateTableStatement(t *testing.T) { c25 mediumint unsigned, c26 bigint unsigned)`, expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "c0", 594, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "c1", 601, sql.Int8, false), - schemaNewColumn(t, "c2", 14542, sql.Int16, false), - schemaNewColumn(t, "c3", 13309, sql.Int24, false), - schemaNewColumn(t, "c4", 15884, sql.Int32, false), - schemaNewColumn(t, "c5", 14619, sql.Int64, false), - schemaNewColumn(t, "c6", 13192, sql.Boolean, false), - schemaNewColumn(t, "c7", 5981, sql.Boolean, false), - schemaNewColumn(t, "c8", 14871, sql.MustCreateBitType(10), false), - schemaNewColumn(t, "c9", 4167, sql.Text, false), - schemaNewColumn(t, "c10", 1965, sql.TinyText, false), - schemaNewColumn(t, "c11", 12860, sql.MediumText, false), - schemaNewColumn(t, "c12", 7155, sql.LongText, false), + schemaNewColumn(t, "c0", 594, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "c1", 601, types2.Int8, false), + schemaNewColumn(t, "c2", 14542, types2.Int16, false), + schemaNewColumn(t, "c3", 13309, types2.Int24, false), + schemaNewColumn(t, "c4", 15884, types2.Int32, false), + schemaNewColumn(t, "c5", 14619, types2.Int64, false), + schemaNewColumn(t, "c6", 13192, types2.Boolean, false), + schemaNewColumn(t, "c7", 5981, types2.Boolean, false), + schemaNewColumn(t, "c8", 14871, types2.MustCreateBitType(10), false), + schemaNewColumn(t, "c9", 4167, types2.Text, false), + schemaNewColumn(t, "c10", 1965, types2.TinyText, false), + schemaNewColumn(t, "c11", 12860, types2.MediumText, false), + schemaNewColumn(t, "c12", 7155, types2.LongText, false), //schemaNewColumn(t, "c13", 113, sql.TinyBlob, false), //schemaNewColumn(t, "c14", 114, sql.Blob, false), //schemaNewColumn(t, "c15", 115, sql.LongBlob, false), - schemaNewColumn(t, "c16", 15859, sql.MustCreateStringWithDefaults(sqltypes.Char, 5), false), - schemaNewColumn(t, "c17", 11710, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false), - schemaNewColumn(t, "c18", 6838, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), - schemaNewColumn(t, "c19", 9377, sql.Float32, false), - schemaNewColumn(t, "c20", 15979, sql.Float64, false), + schemaNewColumn(t, "c16", 15859, types2.MustCreateStringWithDefaults(sqltypes.Char, 5), false), + schemaNewColumn(t, "c17", 11710, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false), + schemaNewColumn(t, "c18", 6838, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), + schemaNewColumn(t, "c19", 9377, types2.Float32, false), + schemaNewColumn(t, "c20", 15979, types2.Float64, false), //schemaNewColumn(t, "c21", 121, sql.MustCreateDecimalType(10, 5), false), - schemaNewColumn(t, "c22", 2910, sql.Uint32, false), - schemaNewColumn(t, "c23", 8740, sql.Uint8, false), - schemaNewColumn(t, "c24", 8689, sql.Uint16, false), - schemaNewColumn(t, "c25", 5243, sql.Uint24, false), - schemaNewColumn(t, "c26", 9338, sql.Uint64, false), + schemaNewColumn(t, "c22", 2910, types2.Uint32, false), + schemaNewColumn(t, "c23", 8740, types2.Uint8, false), + schemaNewColumn(t, "c24", 8689, types2.Uint16, false), + schemaNewColumn(t, "c25", 5243, types2.Uint24, false), + schemaNewColumn(t, "c26", 9338, types2.Uint64, false), ), }, { @@ -983,10 +984,10 @@ func TestParseCreateTableStatement(t *testing.T) { primary key (id, age))`, expectedTable: "testTable", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "age", 7208, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "first_name", 3264, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), - schemaNewColumn(t, "is_married", 14626, sql.Boolean, false)), + schemaNewColumn(t, "id", 4817, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "age", 7208, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "first_name", 3264, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), + schemaNewColumn(t, "is_married", 14626, types2.Boolean, false)), }, { name: "Test not null constraints", @@ -998,10 +999,10 @@ func TestParseCreateTableStatement(t *testing.T) { primary key (id, age))`, expectedTable: "testTable", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "age", 7208, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "first_name", 3264, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false, schema.NotNullConstraint{}), - schemaNewColumn(t, "is_married", 14626, sql.Boolean, false)), + schemaNewColumn(t, "id", 4817, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "age", 7208, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "first_name", 3264, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false, schema.NotNullConstraint{}), + schemaNewColumn(t, "is_married", 14626, types2.Boolean, false)), }, { name: "Test quoted columns", @@ -1013,10 +1014,10 @@ func TestParseCreateTableStatement(t *testing.T) { "primary key (`id`, `age`))", expectedTable: "testTable", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "age", 7208, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "timestamp", 10168, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), - schemaNewColumn(t, "is married", 14626, sql.Boolean, false)), + schemaNewColumn(t, "id", 4817, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "age", 7208, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "timestamp", 10168, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 80), false), + schemaNewColumn(t, "is married", 14626, types2.Boolean, false)), }, { name: "Test tag comments", @@ -1024,8 +1025,8 @@ func TestParseCreateTableStatement(t *testing.T) { id int primary key, age int)`, expectedTable: "testTable", expectedSchema: dtestutils.CreateSchema( - schemaNewColumn(t, "id", 4817, sql.Int32, true, schema.NotNullConstraint{}), - schemaNewColumn(t, "age", 7208, sql.Int32, false)), + schemaNewColumn(t, "id", 4817, types2.Int32, true, schema.NotNullConstraint{}), + schemaNewColumn(t, "age", 7208, types2.Int32, false)), }, // Real world examples for regression testing { @@ -1036,8 +1037,8 @@ func TestParseCreateTableStatement(t *testing.T) { PRIMARY KEY (ip));`, expectedTable: "ip2nation", expectedSchema: dtestutils.CreateSchema( - schemaNewColumnWDefVal(t, "ip", 7265, sql.Uint32, true, "0", schema.NotNullConstraint{}), - schemaNewColumnWDefVal(t, "country", 6630, sql.MustCreateStringWithDefaults(sqltypes.Char, 2), false, `''`, schema.NotNullConstraint{})), + schemaNewColumnWDefVal(t, "ip", 7265, types2.Uint32, true, "0", schema.NotNullConstraint{}), + schemaNewColumnWDefVal(t, "country", 6630, types2.MustCreateStringWithDefaults(sqltypes.Char, 2), false, `''`, schema.NotNullConstraint{})), }, { name: "Test ip2nationCountries", @@ -1052,13 +1053,13 @@ func TestParseCreateTableStatement(t *testing.T) { lon float NOT NULL default 0.0, PRIMARY KEY (code));`, expectedSchema: dtestutils.CreateSchema( - schemaNewColumnWDefVal(t, "code", 7802, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 4), true, `''`, schema.NotNullConstraint{}), - schemaNewColumnWDefVal(t, "iso_code_2", 9266, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 2), false, `''`, schema.NotNullConstraint{}), - schemaNewColumnWDefVal(t, "iso_code_3", 8427, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 3), false, `''`), - schemaNewColumnWDefVal(t, "iso_country", 7151, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false, `''`, schema.NotNullConstraint{}), - schemaNewColumnWDefVal(t, "country", 879, sql.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false, `''`, schema.NotNullConstraint{}), - schemaNewColumnWDefVal(t, "lat", 3502, sql.Float32, false, "0.0", schema.NotNullConstraint{}), - schemaNewColumnWDefVal(t, "lon", 9907, sql.Float32, false, "0.0", schema.NotNullConstraint{})), + schemaNewColumnWDefVal(t, "code", 7802, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 4), true, `''`, schema.NotNullConstraint{}), + schemaNewColumnWDefVal(t, "iso_code_2", 9266, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 2), false, `''`, schema.NotNullConstraint{}), + schemaNewColumnWDefVal(t, "iso_code_3", 8427, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 3), false, `''`), + schemaNewColumnWDefVal(t, "iso_country", 7151, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false, `''`, schema.NotNullConstraint{}), + schemaNewColumnWDefVal(t, "country", 879, types2.MustCreateStringWithDefaults(sqltypes.VarChar, 255), false, `''`, schema.NotNullConstraint{}), + schemaNewColumnWDefVal(t, "lat", 3502, types2.Float32, false, "0.0", schema.NotNullConstraint{}), + schemaNewColumnWDefVal(t, "lon", 9907, types2.Float32, false, "0.0", schema.NotNullConstraint{})), }, } diff --git a/go/libraries/doltcore/sqle/sqlpersist_test.go b/go/libraries/doltcore/sqle/sqlpersist_test.go index e81614ec8a..43d34cdf51 100644 --- a/go/libraries/doltcore/sqle/sqlpersist_test.go +++ b/go/libraries/doltcore/sqle/sqlpersist_test.go @@ -19,6 +19,7 @@ import ( "testing" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/sysvars" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -101,7 +102,7 @@ func testPersistQuery(t *testing.T, test PersistTest) { test.AdditionalSetup(t, dEnv) } - sql.InitSystemVariables() + variables.InitSystemVariables() root, _ := dEnv.WorkingRoot(context.Background()) root, err = executeModify(t, context.Background(), dEnv, root, test.PersistQuery) diff --git a/go/libraries/doltcore/sqle/sqlselect_test.go b/go/libraries/doltcore/sqle/sqlselect_test.go index 0bee758c27..3189adb1c0 100644 --- a/go/libraries/doltcore/sqle/sqlselect_test.go +++ b/go/libraries/doltcore/sqle/sqlselect_test.go @@ -20,6 +20,7 @@ import ( "time" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -467,7 +468,7 @@ func BasicSelectTests() []SelectTest { Query: "select is_married and age >= 40 from people where last_name = 'Simpson' order by id limit 2", ExpectedRows: []sql.Row{{true}, {false}}, ExpectedSqlSchema: sql.Schema{ - &sql.Column{Name: "is_married and age >= 40", Type: sql.Int8}, + &sql.Column{Name: "is_married and age >= 40", Type: types2.Int8}, }, }, { @@ -481,7 +482,7 @@ func BasicSelectTests() []SelectTest { }, ExpectedSqlSchema: sql.Schema{ &sql.Column{Name: "first_name", Type: typeinfo.StringDefaultType.ToSqlType()}, - &sql.Column{Name: "not_marge", Type: sql.Int8}, + &sql.Column{Name: "not_marge", Type: types2.Int8}, }, }, { @@ -719,7 +720,7 @@ func BasicSelectTests() []SelectTest { ExpectedSqlSchema: sql.Schema{ &sql.Column{ Name: "1", - Type: sql.Int8, + Type: types2.Int8, }, }, ExpectedRows: []sql.Row{{int8(1)}}, @@ -758,11 +759,11 @@ func BasicSelectTests() []SelectTest { }, }, ExpectedSqlSchema: sql.Schema{ - &sql.Column{Name: "commit_hash", Type: sql.Text}, - &sql.Column{Name: "committer", Type: sql.Text}, - &sql.Column{Name: "email", Type: sql.Text}, - &sql.Column{Name: "date", Type: sql.Datetime}, - &sql.Column{Name: "message", Type: sql.Text}, + &sql.Column{Name: "commit_hash", Type: types2.Text}, + &sql.Column{Name: "committer", Type: types2.Text}, + &sql.Column{Name: "email", Type: types2.Text}, + &sql.Column{Name: "date", Type: types2.Datetime}, + &sql.Column{Name: "message", Type: types2.Text}, }, }, { @@ -770,8 +771,8 @@ func BasicSelectTests() []SelectTest { Query: "select * from dolt_conflicts", ExpectedRows: []sql.Row{}, ExpectedSqlSchema: sql.Schema{ - &sql.Column{Name: "table", Type: sql.Text}, - &sql.Column{Name: "num_conflicts", Type: sql.Uint64}, + &sql.Column{Name: "table", Type: types2.Text}, + &sql.Column{Name: "num_conflicts", Type: types2.Uint64}, }, }, { @@ -787,23 +788,23 @@ func BasicSelectTests() []SelectTest { }, }, ExpectedSqlSchema: sql.Schema{ - &sql.Column{Name: "name", Type: sql.Text}, - &sql.Column{Name: "hash", Type: sql.Text}, - &sql.Column{Name: "latest_committer", Type: sql.Text}, - &sql.Column{Name: "latest_committer_email", Type: sql.Text}, - &sql.Column{Name: "latest_commit_date", Type: sql.Datetime}, - &sql.Column{Name: "latest_commit_message", Type: sql.Text}, + &sql.Column{Name: "name", Type: types2.Text}, + &sql.Column{Name: "hash", Type: types2.Text}, + &sql.Column{Name: "latest_committer", Type: types2.Text}, + &sql.Column{Name: "latest_committer_email", Type: types2.Text}, + &sql.Column{Name: "latest_commit_date", Type: types2.Datetime}, + &sql.Column{Name: "latest_commit_message", Type: types2.Text}, }, }, } } var sqlDiffSchema = sql.Schema{ - &sql.Column{Name: "to_id", Type: sql.Int64}, + &sql.Column{Name: "to_id", Type: types2.Int64}, &sql.Column{Name: "to_first_name", Type: typeinfo.StringDefaultType.ToSqlType()}, &sql.Column{Name: "to_last_name", Type: typeinfo.StringDefaultType.ToSqlType()}, &sql.Column{Name: "to_addr", Type: typeinfo.StringDefaultType.ToSqlType()}, - &sql.Column{Name: "from_id", Type: sql.Int64}, + &sql.Column{Name: "from_id", Type: types2.Int64}, &sql.Column{Name: "from_first_name", Type: typeinfo.StringDefaultType.ToSqlType()}, &sql.Column{Name: "from_last_name", Type: typeinfo.StringDefaultType.ToSqlType()}, &sql.Column{Name: "from_addr", Type: typeinfo.StringDefaultType.ToSqlType()}, diff --git a/go/libraries/doltcore/sqle/system_variables.go b/go/libraries/doltcore/sqle/system_variables.go index 1ea6db324d..1a7ffefcf4 100644 --- a/go/libraries/doltcore/sqle/system_variables.go +++ b/go/libraries/doltcore/sqle/system_variables.go @@ -16,6 +16,8 @@ package sqle import ( "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/sysvars" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" ) @@ -25,13 +27,13 @@ func init() { } func AddDoltSystemVariables() { - sql.SystemVariables.AddSystemVariables([]sql.SystemVariable{ + variables.SystemVariables.AddSystemVariables([]sql.SystemVariable{ { Name: dsess.ReplicateToRemote, Scope: sql.SystemVariableScope_Global, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemStringType(dsess.ReplicateToRemote), + Type: types.NewSystemStringType(dsess.ReplicateToRemote), Default: "", }, { @@ -39,7 +41,7 @@ func AddDoltSystemVariables() { Scope: sql.SystemVariableScope_Global, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemStringType(dsess.ReplicationRemoteURLTemplate), + Type: types.NewSystemStringType(dsess.ReplicationRemoteURLTemplate), Default: "", }, { @@ -47,7 +49,7 @@ func AddDoltSystemVariables() { Scope: sql.SystemVariableScope_Global, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemStringType(dsess.ReadReplicaRemote), + Type: types.NewSystemStringType(dsess.ReadReplicaRemote), Default: "", }, { @@ -55,7 +57,7 @@ func AddDoltSystemVariables() { Scope: sql.SystemVariableScope_Global, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemStringType(dsess.ReadReplicaForcePull), + Type: types.NewSystemStringType(dsess.ReadReplicaForcePull), Default: int8(0), }, { @@ -63,7 +65,7 @@ func AddDoltSystemVariables() { Scope: sql.SystemVariableScope_Global, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemBoolType(dsess.SkipReplicationErrors), + Type: types.NewSystemBoolType(dsess.SkipReplicationErrors), Default: int8(0), }, { @@ -71,7 +73,7 @@ func AddDoltSystemVariables() { Scope: sql.SystemVariableScope_Global, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemStringType(dsess.ReplicateHeads), + Type: types.NewSystemStringType(dsess.ReplicateHeads), Default: "", }, { @@ -79,7 +81,7 @@ func AddDoltSystemVariables() { Scope: sql.SystemVariableScope_Global, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemBoolType(dsess.ReplicateAllHeads), + Type: types.NewSystemBoolType(dsess.ReplicateAllHeads), Default: int8(0), }, { @@ -87,7 +89,7 @@ func AddDoltSystemVariables() { Scope: sql.SystemVariableScope_Global, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemBoolType(dsess.AsyncReplication), + Type: types.NewSystemBoolType(dsess.AsyncReplication), Default: int8(0), }, { // If true, causes a Dolt commit to occur when you commit a transaction. @@ -95,7 +97,7 @@ func AddDoltSystemVariables() { Scope: sql.SystemVariableScope_Both, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemBoolType(dsess.DoltCommitOnTransactionCommit), + Type: types.NewSystemBoolType(dsess.DoltCommitOnTransactionCommit), Default: int8(0), }, { @@ -103,7 +105,7 @@ func AddDoltSystemVariables() { Scope: sql.SystemVariableScope_Session, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemBoolType(dsess.TransactionsDisabledSysVar), + Type: types.NewSystemBoolType(dsess.TransactionsDisabledSysVar), Default: int8(0), }, { // If true, disables the conflict and constraint violation check when you commit a transaction. @@ -111,7 +113,7 @@ func AddDoltSystemVariables() { Scope: sql.SystemVariableScope_Both, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemBoolType(dsess.ForceTransactionCommit), + Type: types.NewSystemBoolType(dsess.ForceTransactionCommit), Default: int8(0), }, { @@ -119,7 +121,7 @@ func AddDoltSystemVariables() { Scope: sql.SystemVariableScope_Session, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemIntType(dsess.CurrentBatchModeKey, -9223372036854775808, 9223372036854775807, false), + Type: types.NewSystemIntType(dsess.CurrentBatchModeKey, -9223372036854775808, 9223372036854775807, false), Default: int64(0), }, { // If true, disables the conflict violation check when you commit a transaction. @@ -127,7 +129,7 @@ func AddDoltSystemVariables() { Scope: sql.SystemVariableScope_Session, Dynamic: true, SetVarHintApplies: false, - Type: sql.NewSystemBoolType(dsess.AllowCommitConflicts), + Type: types.NewSystemBoolType(dsess.AllowCommitConflicts), Default: int8(0), }, { @@ -135,7 +137,7 @@ func AddDoltSystemVariables() { Scope: sql.SystemVariableScope_Session, Dynamic: false, SetVarHintApplies: false, - Type: sql.NewSystemStringType(dsess.AwsCredsFile), + Type: types.NewSystemStringType(dsess.AwsCredsFile), Default: nil, }, { @@ -143,7 +145,7 @@ func AddDoltSystemVariables() { Scope: sql.SystemVariableScope_Session, Dynamic: false, SetVarHintApplies: false, - Type: sql.NewSystemStringType(dsess.AwsCredsProfile), + Type: types.NewSystemStringType(dsess.AwsCredsProfile), Default: nil, }, { @@ -151,14 +153,14 @@ func AddDoltSystemVariables() { Scope: sql.SystemVariableScope_Session, Dynamic: false, SetVarHintApplies: false, - Type: sql.NewSystemStringType(dsess.AwsCredsRegion), + Type: types.NewSystemStringType(dsess.AwsCredsRegion), Default: nil, }, }) } func ReadReplicaForcePull() bool { - _, forcePull, ok := sql.SystemVariables.GetGlobal(dsess.ReadReplicaForcePull) + _, forcePull, ok := variables.SystemVariables.GetGlobal(dsess.ReadReplicaForcePull) if !ok { panic("dolt system variables not loaded") } diff --git a/go/libraries/doltcore/sqle/tables.go b/go/libraries/doltcore/sqle/tables.go index b0afc4dcea..09d730cda1 100644 --- a/go/libraries/doltcore/sqle/tables.go +++ b/go/libraries/doltcore/sqle/tables.go @@ -29,6 +29,7 @@ import ( "sync" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/branch_control" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" @@ -407,9 +408,9 @@ func (t *DoltTable) DataLength(ctx *sql.Context) (uint64, error) { switch n := col.Type.(type) { case sql.NumberType: numBytesPerRow += 8 - case sql.StringType: + case types2.StringType: numBytesPerRow += uint64(n.MaxByteLength()) - case sql.BitType: + case types2.BitType: numBytesPerRow += 1 case sql.DatetimeType: numBytesPerRow += 8 @@ -421,7 +422,7 @@ func (t *DoltTable) DataLength(ctx *sql.Context) (uint64, error) { numBytesPerRow += 20 case sql.NullType: numBytesPerRow += 1 - case sql.TimeType: + case types2.TimeType: numBytesPerRow += 16 case sql.YearType: numBytesPerRow += 8 @@ -1314,7 +1315,7 @@ func (t *AlterableDoltTable) RewriteInserter( if strings.ToLower(oldColumn.Name) == strings.ToLower(colName) { colNames = append(colNames, newColumn.Name) if len(prefixLengths) > 0 { - if !sql.IsText(newColumn.Type) { + if !types2.IsText(newColumn.Type) { // drop prefix lengths if column is not a string type prefixLengths[i] = 0 } else if uint32(prefixLengths[i]) > newColumn.Type.MaxTextResponseByteLength() { @@ -1502,7 +1503,7 @@ func validateSchemaChange( ) error { for _, idxCol := range idxCols { col := newSchema.Schema[newSchema.Schema.IndexOfColName(idxCol.Name)] - if col.PrimaryKey && idxCol.Length > 0 && sql.IsText(col.Type) { + if col.PrimaryKey && idxCol.Length > 0 && types2.IsText(col.Type) { return sql.ErrUnsupportedIndexPrefix.New(col.Name) } } diff --git a/go/libraries/doltcore/table/typed/json/writer.go b/go/libraries/doltcore/table/typed/json/writer.go index bbe2dfb566..2d2f1b27f5 100644 --- a/go/libraries/doltcore/table/typed/json/writer.go +++ b/go/libraries/doltcore/table/typed/json/writer.go @@ -22,6 +22,7 @@ import ( "io" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" "github.com/dolthub/dolt/go/libraries/doltcore/schema" @@ -34,7 +35,7 @@ const jsonHeader = `{"rows": [` const jsonFooter = `]}` var WriteBufSize = 256 * 1024 -var defaultString = sql.MustCreateStringWithDefaults(sqltypes.VarChar, 16383) +var defaultString = types.MustCreateStringWithDefaults(sqltypes.VarChar, 16383) type RowWriter struct { closer io.Closer diff --git a/go/libraries/doltcore/table/typed/parquet/reader.go b/go/libraries/doltcore/table/typed/parquet/reader.go index 8cf3009b3f..28c8349c3a 100644 --- a/go/libraries/doltcore/table/typed/parquet/reader.go +++ b/go/libraries/doltcore/table/typed/parquet/reader.go @@ -21,6 +21,7 @@ import ( "time" "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/xitongsys/parquet-go-source/local" "github.com/xitongsys/parquet-go/common" "github.com/xitongsys/parquet-go/reader" @@ -110,7 +111,7 @@ func (pr *ParquetReader) ReadSqlRow(ctx context.Context) (sql.Row, error) { case typeinfo.DatetimeTypeIdentifier: val = time.UnixMicro(val.(int64)) case typeinfo.TimeTypeIdentifier: - val = sql.Timespan(time.Duration(val.(int64)).Microseconds()) + val = types2.Timespan(time.Duration(val.(int64)).Microseconds()) } } diff --git a/go/libraries/doltcore/table/typed/parquet/writer.go b/go/libraries/doltcore/table/typed/parquet/writer.go index 5945c8063e..c618b1c14b 100644 --- a/go/libraries/doltcore/table/typed/parquet/writer.go +++ b/go/libraries/doltcore/table/typed/parquet/writer.go @@ -20,6 +20,7 @@ import ( "time" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/xitongsys/parquet-go-source/local" "github.com/xitongsys/parquet-go/source" "github.com/xitongsys/parquet-go/writer" @@ -108,12 +109,12 @@ func (pwr *ParquetWriter) WriteSqlRow(ctx context.Context, r sql.Row) error { switch colT.TypeInfo.GetTypeIdentifier() { case typeinfo.DatetimeTypeIdentifier: val = val.(time.Time).UnixMicro() - sqlType = sql.Int64 + sqlType = types.Int64 case typeinfo.TimeTypeIdentifier: - val = int64(val.(sql.Timespan).AsTimeDuration()) - sqlType = sql.Int64 + val = int64(val.(types.Timespan).AsTimeDuration()) + sqlType = types.Int64 case typeinfo.BitTypeIdentifier: - sqlType = sql.Uint64 + sqlType = types.Uint64 } v, err := sqlutil.SqlColToStr(sqlType, val) if err != nil { diff --git a/go/libraries/doltcore/table/untyped/csv/writer.go b/go/libraries/doltcore/table/untyped/csv/writer.go index 7f0493cda2..4716f81e1a 100644 --- a/go/libraries/doltcore/table/untyped/csv/writer.go +++ b/go/libraries/doltcore/table/untyped/csv/writer.go @@ -25,6 +25,7 @@ import ( "unicode/utf8" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/libraries/doltcore/schema" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlutil" @@ -90,7 +91,7 @@ func (csvw *CSVWriter) WriteSqlRow(ctx context.Context, r sql.Row) error { var err error colType := csvw.sch.GetAllCols().GetByIndex(i).TypeInfo.ToSqlType() // Due to BIT's unique output, we special-case writing the integer specifically for CSV - if _, ok := colType.(sql.BitType); ok { + if _, ok := colType.(types.BitType); ok { v = strconv.FormatUint(val.(uint64), 10) } else { v, err = sqlutil.SqlColToStr(colType, val) diff --git a/go/libraries/doltcore/table/untyped/tabular/fixedwidth_conflict_tablewriter.go b/go/libraries/doltcore/table/untyped/tabular/fixedwidth_conflict_tablewriter.go index 20597b8a35..f443c82bf9 100644 --- a/go/libraries/doltcore/table/untyped/tabular/fixedwidth_conflict_tablewriter.go +++ b/go/libraries/doltcore/table/untyped/tabular/fixedwidth_conflict_tablewriter.go @@ -19,6 +19,7 @@ import ( "io" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/fatih/color" "github.com/dolthub/dolt/go/libraries/doltcore/diff" @@ -38,12 +39,12 @@ func NewFixedWidthConflictTableWriter(schema sql.Schema, wr io.WriteCloser, numS // diff type: *, -, + &sql.Column{ Name: " ", - Type: sql.Text, + Type: types.Text, }, // version name: base, ours, theirs &sql.Column{ Name: " ", - Type: sql.Text, + Type: types.Text, }, }, schema...) diff --git a/go/libraries/doltcore/table/untyped/tabular/fixedwidth_diff_tablewriter.go b/go/libraries/doltcore/table/untyped/tabular/fixedwidth_diff_tablewriter.go index 41e62833ba..d963d0c623 100755 --- a/go/libraries/doltcore/table/untyped/tabular/fixedwidth_diff_tablewriter.go +++ b/go/libraries/doltcore/table/untyped/tabular/fixedwidth_diff_tablewriter.go @@ -20,6 +20,7 @@ import ( "io" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/fatih/color" "github.com/dolthub/dolt/go/libraries/doltcore/diff" @@ -35,7 +36,7 @@ func NewFixedWidthDiffTableWriter(schema sql.Schema, wr io.WriteCloser, numSampl // leading diff type column with empty name schema = append(sql.Schema{&sql.Column{ Name: " ", - Type: sql.Text, + Type: types.Text, }}, schema...) tableWriter := NewFixedWidthTableWriter(schema, wr, numSamples) diff --git a/go/libraries/doltcore/table/untyped/tabular/fixedwidth_tablewriter_test.go b/go/libraries/doltcore/table/untyped/tabular/fixedwidth_tablewriter_test.go index 8d3cae8269..0a2e2f0a24 100755 --- a/go/libraries/doltcore/table/untyped/tabular/fixedwidth_tablewriter_test.go +++ b/go/libraries/doltcore/table/untyped/tabular/fixedwidth_tablewriter_test.go @@ -20,6 +20,7 @@ import ( "testing" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/stretchr/testify/assert" ) @@ -39,9 +40,9 @@ func (*StringBuilderCloser) Close() error { func TestFixedWidthWriter(t *testing.T) { sch := sql.Schema{ - {Name: nameColName, Type: sql.Text}, - {Name: ageColName, Type: sql.Int64}, - {Name: titleColName, Type: sql.Text}, + {Name: nameColName, Type: types.Text}, + {Name: ageColName, Type: types.Int64}, + {Name: titleColName, Type: types.Text}, } names := []interface{}{ diff --git a/go/performance/import_benchmarker/testdef.go b/go/performance/import_benchmarker/testdef.go index 3d1fa8704d..3f144b02ff 100644 --- a/go/performance/import_benchmarker/testdef.go +++ b/go/performance/import_benchmarker/testdef.go @@ -30,6 +30,7 @@ import ( "github.com/cespare/xxhash" "github.com/creasty/defaults" sql2 "github.com/dolthub/go-mysql-server/sql" + types2 "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/vitess/go/sqltypes" ast "github.com/dolthub/vitess/go/vt/sqlparser" "github.com/stretchr/testify/require" @@ -635,7 +636,7 @@ func parseTableAndSchema(q string) (string, []string, []sql2.Type) { table = n.Table.String() for _, col := range n.TableSpec.Columns { names = append(names, col.Name.String()) - typ, err := sql2.ColumnTypeToType(&col.Type) + typ, err := types2.ColumnTypeToType(&col.Type) if err != nil { panic(fmt.Sprintf("unexpected error reading type: %s", err)) } diff --git a/go/store/prolly/tree/blob_builder.go b/go/store/prolly/tree/blob_builder.go index 21ed38fb6a..b8f97ffa20 100644 --- a/go/store/prolly/tree/blob_builder.go +++ b/go/store/prolly/tree/blob_builder.go @@ -21,7 +21,7 @@ import ( "errors" "io" - "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/dolt/go/store/hash" "github.com/dolthub/dolt/go/store/prolly/message" @@ -272,15 +272,15 @@ func NewJSONDoc(addr hash.Hash, ns NodeStore) *JSONDoc { return &JSONDoc{ImmutableTree{Addr: addr, ns: ns}} } -func (b *JSONDoc) ToJSONDocument(ctx context.Context) (sql.JSONDocument, error) { +func (b *JSONDoc) ToJSONDocument(ctx context.Context) (types.JSONDocument, error) { buf, err := b.bytes(ctx) if err != nil { - return sql.JSONDocument{}, err + return types.JSONDocument{}, err } - var doc sql.JSONDocument + var doc types.JSONDocument err = json.Unmarshal(buf, &doc.Val) if err != nil { - return sql.JSONDocument{}, err + return types.JSONDocument{}, err } return doc, err } diff --git a/go/store/types/read_geometry.go b/go/store/types/read_geometry.go index a75bb2231d..d3b23a014f 100644 --- a/go/store/types/read_geometry.go +++ b/go/store/types/read_geometry.go @@ -15,7 +15,7 @@ package types import ( - "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" ) func ConvertTypesGeometryToSQLGeometry(g Geometry) interface{} { @@ -39,52 +39,52 @@ func ConvertTypesGeometryToSQLGeometry(g Geometry) interface{} { } } -func ConvertTypesPointToSQLPoint(p Point) sql.Point { - return sql.Point{SRID: p.SRID, X: p.X, Y: p.Y} +func ConvertTypesPointToSQLPoint(p Point) types.Point { + return types.Point{SRID: p.SRID, X: p.X, Y: p.Y} } -func ConvertTypesLineStringToSQLLineString(l LineString) sql.LineString { - points := make([]sql.Point, len(l.Points)) +func ConvertTypesLineStringToSQLLineString(l LineString) types.LineString { + points := make([]types.Point, len(l.Points)) for i, p := range l.Points { points[i] = ConvertTypesPointToSQLPoint(p) } - return sql.LineString{SRID: l.SRID, Points: points} + return types.LineString{SRID: l.SRID, Points: points} } -func ConvertTypesPolygonToSQLPolygon(p Polygon) sql.Polygon { - lines := make([]sql.LineString, len(p.Lines)) +func ConvertTypesPolygonToSQLPolygon(p Polygon) types.Polygon { + lines := make([]types.LineString, len(p.Lines)) for i, l := range p.Lines { lines[i] = ConvertTypesLineStringToSQLLineString(l) } - return sql.Polygon{SRID: p.SRID, Lines: lines} + return types.Polygon{SRID: p.SRID, Lines: lines} } -func ConvertTypesMultiPointToSQLMultiPoint(p MultiPoint) sql.MultiPoint { - points := make([]sql.Point, len(p.Points)) +func ConvertTypesMultiPointToSQLMultiPoint(p MultiPoint) types.MultiPoint { + points := make([]types.Point, len(p.Points)) for i, point := range p.Points { points[i] = ConvertTypesPointToSQLPoint(point) } - return sql.MultiPoint{SRID: p.SRID, Points: points} + return types.MultiPoint{SRID: p.SRID, Points: points} } -func ConvertTypesMultiLineStringToSQLMultiLineString(l MultiLineString) sql.MultiLineString { - lines := make([]sql.LineString, len(l.Lines)) +func ConvertTypesMultiLineStringToSQLMultiLineString(l MultiLineString) types.MultiLineString { + lines := make([]types.LineString, len(l.Lines)) for i, l := range l.Lines { lines[i] = ConvertTypesLineStringToSQLLineString(l) } - return sql.MultiLineString{SRID: l.SRID, Lines: lines} + return types.MultiLineString{SRID: l.SRID, Lines: lines} } -func ConvertTypesMultiPolygonToSQLMultiPolygon(p MultiPolygon) sql.MultiPolygon { - polys := make([]sql.Polygon, len(p.Polygons)) +func ConvertTypesMultiPolygonToSQLMultiPolygon(p MultiPolygon) types.MultiPolygon { + polys := make([]types.Polygon, len(p.Polygons)) for i, p := range p.Polygons { polys[i] = ConvertTypesPolygonToSQLPolygon(p) } - return sql.MultiPolygon{SRID: p.SRID, Polygons: polys} + return types.MultiPolygon{SRID: p.SRID, Polygons: polys} } -func ConvertTypesGeomCollToSQLGeomColl(g GeomColl) sql.GeomColl { - geoms := make([]sql.GeometryValue, len(g.Geometries)) +func ConvertTypesGeomCollToSQLGeomColl(g GeomColl) types.GeomColl { + geoms := make([]types.GeometryValue, len(g.Geometries)) for i, geom := range g.Geometries { switch geo := geom.(type) { case Point: @@ -103,35 +103,35 @@ func ConvertTypesGeomCollToSQLGeomColl(g GeomColl) sql.GeomColl { geoms[i] = ConvertTypesGeomCollToSQLGeomColl(geo) } } - return sql.GeomColl{SRID: g.SRID, Geoms: geoms} + return types.GeomColl{SRID: g.SRID, Geoms: geoms} } func ConvertSQLGeometryToTypesGeometry(p interface{}) Value { switch inner := p.(type) { - case sql.Point: + case types.Point: return ConvertSQLPointToTypesPoint(inner) - case sql.LineString: + case types.LineString: return ConvertSQLLineStringToTypesLineString(inner) - case sql.Polygon: + case types.Polygon: return ConvertSQLPolygonToTypesPolygon(inner) - case sql.MultiPoint: + case types.MultiPoint: return ConvertSQLMultiPointToTypesMultiPoint(inner) - case sql.MultiLineString: + case types.MultiLineString: return ConvertSQLMultiLineStringToTypesMultiLineString(inner) - case sql.MultiPolygon: + case types.MultiPolygon: return ConvertSQLMultiPolygonToTypesMultiPolygon(inner) - case sql.GeomColl: + case types.GeomColl: return ConvertSQLGeomCollToTypesGeomColl(inner) default: panic("used an invalid type sql.Geometry.Inner") } } -func ConvertSQLPointToTypesPoint(p sql.Point) Point { +func ConvertSQLPointToTypesPoint(p types.Point) Point { return Point{SRID: p.SRID, X: p.X, Y: p.Y} } -func ConvertSQLLineStringToTypesLineString(l sql.LineString) LineString { +func ConvertSQLLineStringToTypesLineString(l types.LineString) LineString { points := make([]Point, len(l.Points)) for i, p := range l.Points { points[i] = ConvertSQLPointToTypesPoint(p) @@ -139,7 +139,7 @@ func ConvertSQLLineStringToTypesLineString(l sql.LineString) LineString { return LineString{SRID: l.SRID, Points: points} } -func ConvertSQLPolygonToTypesPolygon(p sql.Polygon) Polygon { +func ConvertSQLPolygonToTypesPolygon(p types.Polygon) Polygon { lines := make([]LineString, len(p.Lines)) for i, l := range p.Lines { lines[i] = ConvertSQLLineStringToTypesLineString(l) @@ -147,7 +147,7 @@ func ConvertSQLPolygonToTypesPolygon(p sql.Polygon) Polygon { return Polygon{SRID: p.SRID, Lines: lines} } -func ConvertSQLMultiPointToTypesMultiPoint(p sql.MultiPoint) MultiPoint { +func ConvertSQLMultiPointToTypesMultiPoint(p types.MultiPoint) MultiPoint { points := make([]Point, len(p.Points)) for i, point := range p.Points { points[i] = ConvertSQLPointToTypesPoint(point) @@ -155,7 +155,7 @@ func ConvertSQLMultiPointToTypesMultiPoint(p sql.MultiPoint) MultiPoint { return MultiPoint{SRID: p.SRID, Points: points} } -func ConvertSQLMultiLineStringToTypesMultiLineString(p sql.MultiLineString) MultiLineString { +func ConvertSQLMultiLineStringToTypesMultiLineString(p types.MultiLineString) MultiLineString { lines := make([]LineString, len(p.Lines)) for i, l := range p.Lines { lines[i] = ConvertSQLLineStringToTypesLineString(l) @@ -163,7 +163,7 @@ func ConvertSQLMultiLineStringToTypesMultiLineString(p sql.MultiLineString) Mult return MultiLineString{SRID: p.SRID, Lines: lines} } -func ConvertSQLMultiPolygonToTypesMultiPolygon(p sql.MultiPolygon) MultiPolygon { +func ConvertSQLMultiPolygonToTypesMultiPolygon(p types.MultiPolygon) MultiPolygon { polys := make([]Polygon, len(p.Polygons)) for i, p := range p.Polygons { polys[i] = ConvertSQLPolygonToTypesPolygon(p) @@ -171,23 +171,23 @@ func ConvertSQLMultiPolygonToTypesMultiPolygon(p sql.MultiPolygon) MultiPolygon return MultiPolygon{SRID: p.SRID, Polygons: polys} } -func ConvertSQLGeomCollToTypesGeomColl(g sql.GeomColl) GeomColl { +func ConvertSQLGeomCollToTypesGeomColl(g types.GeomColl) GeomColl { geoms := make([]Value, len(g.Geoms)) for i, geom := range g.Geoms { switch geo := geom.(type) { - case sql.Point: + case types.Point: geoms[i] = ConvertSQLPointToTypesPoint(geo) - case sql.LineString: + case types.LineString: geoms[i] = ConvertSQLLineStringToTypesLineString(geo) - case sql.Polygon: + case types.Polygon: geoms[i] = ConvertSQLPolygonToTypesPolygon(geo) - case sql.MultiPoint: + case types.MultiPoint: geoms[i] = ConvertSQLMultiPointToTypesMultiPoint(geo) - case sql.MultiLineString: + case types.MultiLineString: geoms[i] = ConvertSQLMultiLineStringToTypesMultiLineString(geo) - case sql.MultiPolygon: + case types.MultiPolygon: geoms[i] = ConvertSQLMultiPolygonToTypesMultiPolygon(geo) - case sql.GeomColl: + case types.GeomColl: geoms[i] = ConvertSQLGeomCollToTypesGeomColl(geo) } } @@ -197,63 +197,63 @@ func ConvertSQLGeomCollToTypesGeomColl(g sql.GeomColl) GeomColl { // TODO: all methods here just defer to their SQL equivalents, and assume we always receive good data func DeserializeEWKBHeader(buf []byte) (uint32, bool, uint32, error) { - return sql.DeserializeEWKBHeader(buf) + return types.DeserializeEWKBHeader(buf) } func DeserializeWKBHeader(buf []byte) (bool, uint32, error) { - return sql.DeserializeWKBHeader(buf) + return types.DeserializeWKBHeader(buf) } -func DeserializePoint(buf []byte, isBig bool, srid uint32) sql.Point { - p, _, err := sql.DeserializePoint(buf, isBig, srid) +func DeserializePoint(buf []byte, isBig bool, srid uint32) types.Point { + p, _, err := types.DeserializePoint(buf, isBig, srid) if err != nil { panic(err) } return p } -func DeserializeLine(buf []byte, isBig bool, srid uint32) sql.LineString { - l, _, err := sql.DeserializeLine(buf, isBig, srid) +func DeserializeLine(buf []byte, isBig bool, srid uint32) types.LineString { + l, _, err := types.DeserializeLine(buf, isBig, srid) if err != nil { panic(err) } return l } -func DeserializePoly(buf []byte, isBig bool, srid uint32) sql.Polygon { - p, _, err := sql.DeserializePoly(buf, isBig, srid) +func DeserializePoly(buf []byte, isBig bool, srid uint32) types.Polygon { + p, _, err := types.DeserializePoly(buf, isBig, srid) if err != nil { panic(err) } return p } -func DeserializeMPoint(buf []byte, isBig bool, srid uint32) sql.MultiPoint { - p, _, err := sql.DeserializeMPoint(buf, isBig, srid) +func DeserializeMPoint(buf []byte, isBig bool, srid uint32) types.MultiPoint { + p, _, err := types.DeserializeMPoint(buf, isBig, srid) if err != nil { panic(err) } return p } -func DeserializeMLine(buf []byte, isBig bool, srid uint32) sql.MultiLineString { - p, _, err := sql.DeserializeMLine(buf, isBig, srid) +func DeserializeMLine(buf []byte, isBig bool, srid uint32) types.MultiLineString { + p, _, err := types.DeserializeMLine(buf, isBig, srid) if err != nil { panic(err) } return p } -func DeserializeMPoly(buf []byte, isBig bool, srid uint32) sql.MultiPolygon { - p, _, err := sql.DeserializeMPoly(buf, isBig, srid) +func DeserializeMPoly(buf []byte, isBig bool, srid uint32) types.MultiPolygon { + p, _, err := types.DeserializeMPoly(buf, isBig, srid) if err != nil { panic(err) } return p } -func DeserializeGeomColl(buf []byte, isBig bool, srid uint32) sql.GeomColl { - g, _, err := sql.DeserializeGeomColl(buf, isBig, srid) +func DeserializeGeomColl(buf []byte, isBig bool, srid uint32) types.GeomColl { + g, _, err := types.DeserializeGeomColl(buf, isBig, srid) if err != nil { panic(err) } diff --git a/go/store/types/write_geometry.go b/go/store/types/write_geometry.go index ded388fb9c..fe914adad6 100644 --- a/go/store/types/write_geometry.go +++ b/go/store/types/write_geometry.go @@ -15,39 +15,39 @@ package types import ( - "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/types" ) const ( - CartesianSRID = sql.CartesianSRID - GeoSpatialSRID = sql.GeoSpatialSRID + CartesianSRID = types.CartesianSRID + GeoSpatialSRID = types.GeoSpatialSRID ) const ( - SRIDSize = sql.SRIDSize - EndianSize = sql.EndianSize - TypeSize = sql.TypeSize - EWKBHeaderSize = sql.EWKBHeaderSize + SRIDSize = types.SRIDSize + EndianSize = types.EndianSize + TypeSize = types.TypeSize + EWKBHeaderSize = types.EWKBHeaderSize - PointSize = sql.PointSize - CountSize = sql.CountSize + PointSize = types.PointSize + CountSize = types.CountSize ) const ( - WKBUnknown = sql.WKBUnknown - WKBPointID = sql.WKBPointID - WKBLineID = sql.WKBLineID - WKBPolyID = sql.WKBPolyID - WKBMultiPointID = sql.WKBMultiPointID - WKBMultiLineID = sql.WKBMultiLineID - WKBMultiPolyID = sql.WKBMultiPolyID - WKBGeomCollID = sql.WKBGeomCollID + WKBUnknown = types.WKBUnknown + WKBPointID = types.WKBPointID + WKBLineID = types.WKBLineID + WKBPolyID = types.WKBPolyID + WKBMultiPointID = types.WKBMultiPointID + WKBMultiLineID = types.WKBMultiLineID + WKBMultiPolyID = types.WKBMultiPolyID + WKBGeomCollID = types.WKBGeomCollID ) // TODO: all methods here just defer to their SQL equivalents, and assume we always receive good data func WriteEWKBHeader(buf []byte, srid, typ uint32) { - sql.WriteEWKBHeader(buf, srid, typ) + types.WriteEWKBHeader(buf, srid, typ) } func SerializePoint(p Point) []byte {