mirror of
https://github.com/dolthub/dolt.git
synced 2025-12-30 08:50:01 -06:00
[ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/update.sh
This commit is contained in:
@@ -17,9 +17,9 @@ package diff
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
|
||||
"github.com/dolthub/dolt/go/store/types"
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/row"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
|
||||
"github.com/dolthub/dolt/go/libraries/utils/set"
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"io"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb/durable"
|
||||
"github.com/dolthub/dolt/go/store/types"
|
||||
"github.com/dolthub/dolt/go/store/val"
|
||||
|
||||
@@ -665,7 +665,7 @@ func (root *rootValue) IterTables(ctx context.Context, cb func(name TableName, t
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
for _, schemaName := range schemaNames {
|
||||
tm, err := root.getTableMap(ctx, schemaName)
|
||||
if err != nil {
|
||||
@@ -690,7 +690,7 @@ func (root *rootValue) IterTables(ctx context.Context, cb func(name TableName, t
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -740,7 +740,7 @@ func ToTableNames(names []string, schemaName string) []TableName {
|
||||
return tbls
|
||||
}
|
||||
|
||||
// FlattenTableNames is a migration helper function that converts a slice of table names to a slice of strings by
|
||||
// FlattenTableNames is a migration helper function that converts a slice of table names to a slice of strings by
|
||||
// stripping off any schema elements.
|
||||
func FlattenTableNames(names []TableName) []string {
|
||||
tbls := make([]string, len(names))
|
||||
@@ -1045,7 +1045,7 @@ func GetAllTagsForRoots(ctx context.Context, roots ...RootValue) (tags schema.Ta
|
||||
func UnionTableNames(ctx context.Context, roots ...RootValue) ([]TableName, error) {
|
||||
seenTblNamesMap := make(map[TableName]bool)
|
||||
var tblNames []TableName
|
||||
|
||||
|
||||
for _, root := range roots {
|
||||
schemaNames, err := schemaNames(ctx, root)
|
||||
if err != nil {
|
||||
@@ -1228,4 +1228,3 @@ func ResolveDatabaseSchema(ctx *sql.Context, root RootValue, schemaName string)
|
||||
|
||||
return "", false, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ type TableNameSet struct {
|
||||
|
||||
func newTableNameSet(items []TableName, caseSensitive bool) *TableNameSet {
|
||||
s := &TableNameSet{
|
||||
items: make(map[TableName]bool, len(items)),
|
||||
items: make(map[TableName]bool, len(items)),
|
||||
caseSensitive: caseSensitive,
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ func (s *TableNameSet) Equals(other *TableNameSet) bool {
|
||||
sort.Slice(os, func(i, j int) bool {
|
||||
return os[i].Less(os[j])
|
||||
})
|
||||
|
||||
|
||||
for i := range ss {
|
||||
if ss[i] != os[i] {
|
||||
return false
|
||||
|
||||
@@ -178,7 +178,7 @@ func (m MergeState) IterSchemaConflicts(ctx context.Context, ddb *DoltDB, cb Sch
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sc.ToFks, _ = toFKs.KeysForTable(TableName{Name: name})
|
||||
sc.ToParentSchemas = toSchemas
|
||||
|
||||
|
||||
@@ -367,7 +367,7 @@ func mergeForeignKeyChanges(
|
||||
fksByTable := make(map[doltdb.TableName][]doltdb.ForeignKey)
|
||||
|
||||
conflicts := doltdb.NewTableNameSet(nil)
|
||||
|
||||
|
||||
err := newRoot.IterTables(ctx, func(tblName doltdb.TableName, tbl *doltdb.Table, sch schema.Schema) (stop bool, err error) {
|
||||
oldFksForTable, _ := oldFks.KeysForTable(tblName)
|
||||
newFksForTable, _ := newFks.KeysForTable(tblName)
|
||||
@@ -395,13 +395,13 @@ func mergeForeignKeyChanges(
|
||||
} else {
|
||||
conflicts.Add(tblName)
|
||||
}
|
||||
|
||||
|
||||
return false, nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
err = changedRoot.IterTables(ctx, func(tblName doltdb.TableName, table *doltdb.Table, sch schema.Schema) (stop bool, err error) {
|
||||
if _, exists := fksByTable[tblName]; !exists {
|
||||
oldKeys, _ := oldFks.KeysForTable(tblName)
|
||||
|
||||
2
go/libraries/doltcore/env/actions/staged.go
vendored
2
go/libraries/doltcore/env/actions/staged.go
vendored
@@ -86,7 +86,7 @@ func StageModifiedAndDeletedTables(ctx context.Context, roots doltdb.Roots) (dol
|
||||
return stageTables(ctx, roots, tbls)
|
||||
}
|
||||
|
||||
func stageTables(ctx context.Context, roots doltdb.Roots, tbls []doltdb.TableName, ) (doltdb.Roots, error) {
|
||||
func stageTables(ctx context.Context, roots doltdb.Roots, tbls []doltdb.TableName) (doltdb.Roots, error) {
|
||||
var err error
|
||||
err = ValidateTables(ctx, tbls, roots.Staged, roots.Working)
|
||||
if err != nil {
|
||||
|
||||
@@ -209,4 +209,4 @@ func AbortMerge(ctx *sql.Context, workingSet *doltdb.WorkingSet, roots doltdb.Ro
|
||||
workingSet = workingSet.ClearMerge()
|
||||
|
||||
return workingSet, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ func migrateRoot(ctx context.Context, menv Environment, oldParent, oldRoot, newP
|
||||
} else if ok && !menv.DropConflicts {
|
||||
return true, fmt.Errorf("cannot migrate table with conflicts (%s)", name)
|
||||
}
|
||||
|
||||
|
||||
// TODO: schema names
|
||||
newSch, err := migrateSchema(ctx, name.Name, sch)
|
||||
if err != nil {
|
||||
|
||||
@@ -35,7 +35,7 @@ func renameTable(ctx context.Context, root doltdb.RootValue, oldName, newName st
|
||||
panic("invalid parameters")
|
||||
}
|
||||
|
||||
// TODO: schema name
|
||||
// TODO: schema name
|
||||
return root.RenameTable(ctx, doltdb.TableName{Name: oldName}, doltdb.TableName{Name: newName})
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/resolve"
|
||||
sqle "github.com/dolthub/go-mysql-server"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
"github.com/dolthub/go-mysql-server/sql/analyzer"
|
||||
@@ -48,6 +47,7 @@ import (
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/globalstate"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/resolve"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlutil"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/table/editor"
|
||||
"github.com/dolthub/dolt/go/libraries/utils/concurrentmap"
|
||||
@@ -688,7 +688,7 @@ func (db Database) getTable(ctx *sql.Context, root doltdb.RootValue, tableName s
|
||||
return nil, false, nil
|
||||
}
|
||||
|
||||
// For the remainder of this method, we will use the schema name that was resolved and the table resolved
|
||||
// For the remainder of this method, we will use the schema name that was resolved and the table resolved
|
||||
// will inherit it
|
||||
db.schemaName = tblName.Schema
|
||||
} else {
|
||||
@@ -987,7 +987,7 @@ func (db Database) CreateTable(ctx *sql.Context, tableName string, sch sql.Prima
|
||||
if err := dsess.CheckAccessForDb(ctx, db, branch_control.Permissions_Write); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
if doltdb.HasDoltPrefix(tableName) && !doltdb.IsFullTextTable(tableName) {
|
||||
return ErrReservedTableName.New(tableName)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/resolve"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
|
||||
"github.com/dolthub/dolt/go/cmd/dolt/cli"
|
||||
@@ -37,6 +36,7 @@ import (
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dfunctions"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dprocedures"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/resolve"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqlserver"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/table/editor"
|
||||
"github.com/dolthub/dolt/go/libraries/utils/concurrentmap"
|
||||
@@ -266,7 +266,7 @@ func (p *DoltDatabaseProvider) SchemaDatabase(ctx *sql.Context, dbName, schemaNa
|
||||
if !ok {
|
||||
return nil, false, nil
|
||||
}
|
||||
|
||||
|
||||
return sdb.GetSchema(ctx, schemaName)
|
||||
}
|
||||
|
||||
@@ -482,7 +482,7 @@ func (p *DoltDatabaseProvider) CreateCollatedDatabase(ctx *sql.Context, name str
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If the search path is enabled, we need to create our initial schema object (public is available by default)
|
||||
if resolve.UseSearchPath {
|
||||
workingRoot, err := newEnv.WorkingRoot(ctx)
|
||||
|
||||
@@ -429,8 +429,8 @@ func getRowFromSummary(ds *diff.TableDeltaSummary) sql.Row {
|
||||
return sql.Row{
|
||||
ds.FromTableName.Name, // from_table_name
|
||||
ds.ToTableName.Name, // to_table_name
|
||||
ds.DiffType, // diff_type
|
||||
ds.DataChange, // data_change
|
||||
ds.SchemaChange, // schema_change
|
||||
ds.DiffType, // diff_type
|
||||
ds.DataChange, // data_change
|
||||
ds.SchemaChange, // schema_change
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/resolve"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
gmstypes "github.com/dolthub/go-mysql-server/sql/types"
|
||||
"gopkg.in/src-d/go-errors.v1"
|
||||
@@ -31,6 +30,7 @@ import (
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/resolve"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlutil"
|
||||
"github.com/dolthub/dolt/go/store/types"
|
||||
)
|
||||
@@ -486,7 +486,7 @@ func (dtf *DiffTableFunction) cacheTableDelta(ctx *sql.Context, fromCommitVal, t
|
||||
return diff.TableDelta{}, err
|
||||
}
|
||||
|
||||
fromTableName, fromTable, fromTableExists, err := resolve.Table(ctx, fromRefDetails.root, tableName)
|
||||
fromTableName, fromTable, fromTableExists, err := resolve.Table(ctx, fromRefDetails.root, tableName)
|
||||
if err != nil {
|
||||
return diff.TableDelta{}, err
|
||||
}
|
||||
|
||||
@@ -338,10 +338,10 @@ func (ds *SchemaDiffTableFunction) RowIter(ctx *sql.Context, row sql.Row) (sql.R
|
||||
}
|
||||
|
||||
row := sql.Row{
|
||||
fromName.Name, // 0
|
||||
toName.Name, // 1
|
||||
fromCreate, // 2
|
||||
toCreate, // 3
|
||||
fromName.Name, // 0
|
||||
toName.Name, // 1
|
||||
fromCreate, // 2
|
||||
toCreate, // 3
|
||||
}
|
||||
dataRows = append(dataRows, row)
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ func doDoltAdd(ctx *sql.Context, args []string) (int, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// If we are using the search path, we need to resolve the table names to their fully qualified names. This code
|
||||
// doesn't belong in Dolt, but because we resolve table names out of band at execution time like this, we don't
|
||||
// If we are using the search path, we need to resolve the table names to their fully qualified names. This code
|
||||
// doesn't belong in Dolt, but because we resolve table names out of band at execution time like this, we don't
|
||||
// have much of a choice.
|
||||
unqualifiedTableNames := apr.Args
|
||||
var tableNames []doltdb.TableName
|
||||
@@ -109,10 +109,10 @@ func doDoltAdd(ctx *sql.Context, args []string) (int, error) {
|
||||
missingTables = append(missingTables, name)
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
tableNames[i] = tblName
|
||||
}
|
||||
|
||||
|
||||
// This mirrors the logic in actions.StageTables
|
||||
if len(missingTables) > 0 {
|
||||
return 1, actions.NewTblNotExistError(missingTables)
|
||||
@@ -120,7 +120,7 @@ func doDoltAdd(ctx *sql.Context, args []string) (int, error) {
|
||||
} else {
|
||||
tableNames = doltdb.ToTableNames(unqualifiedTableNames, doltdb.DefaultSchemaName)
|
||||
}
|
||||
|
||||
|
||||
roots, err = actions.StageTables(ctx, roots, tableNames, !apr.Contains(cli.ForceFlag))
|
||||
if err != nil {
|
||||
return 1, err
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/resolve"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/diff"
|
||||
@@ -31,6 +30,7 @@ import (
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/expreval"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/index"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/resolve"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlutil"
|
||||
"github.com/dolthub/dolt/go/libraries/utils/set"
|
||||
"github.com/dolthub/dolt/go/store/datas"
|
||||
@@ -164,7 +164,7 @@ func (dt *DiffTable) Partitions(ctx *sql.Context) (sql.PartitionIter, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
exactName, t, exists, err := resolve.Table(ctx, dt.workingRoot, dt.name)
|
||||
exactName, t, exists, err := resolve.Table(ctx, dt.workingRoot, dt.name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ func newSchemaConflict(ctx context.Context, table string, baseRoot doltdb.RootVa
|
||||
if err != nil {
|
||||
return schemaConflict{}, err
|
||||
}
|
||||
|
||||
|
||||
// TODO: schema name
|
||||
baseFKs, _ := fkc.KeysForTable(doltdb.TableName{Name: table})
|
||||
|
||||
|
||||
@@ -15,16 +15,17 @@
|
||||
package resolve
|
||||
|
||||
import (
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
|
||||
)
|
||||
|
||||
// Table returns the schema-qualified name of the table given in the root provided, along with the table itself
|
||||
// Table returns the schema-qualified name of the table given in the root provided, along with the table itself
|
||||
// and whether it exists.
|
||||
func Table(
|
||||
ctx *sql.Context,
|
||||
root doltdb.RootValue,
|
||||
tableName string,
|
||||
ctx *sql.Context,
|
||||
root doltdb.RootValue,
|
||||
tableName string,
|
||||
) (doltdb.TableName, *doltdb.Table, bool, error) {
|
||||
if UseSearchPath {
|
||||
return TableWithSearchPath(ctx, root, tableName)
|
||||
@@ -37,9 +38,9 @@ func Table(
|
||||
|
||||
// TableWithSearchPath resolves a table name to a table in the root value, searching through the schemas in the
|
||||
func TableWithSearchPath(
|
||||
ctx *sql.Context,
|
||||
root doltdb.RootValue,
|
||||
tableName string,
|
||||
ctx *sql.Context,
|
||||
root doltdb.RootValue,
|
||||
tableName string,
|
||||
) (doltdb.TableName, *doltdb.Table, bool, error) {
|
||||
schemasToSearch, err := SearchPath(ctx)
|
||||
if err != nil {
|
||||
@@ -72,4 +73,3 @@ func TableWithSearchPath(
|
||||
|
||||
return doltdb.TableName{}, nil, false, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,9 @@ package resolve
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
|
||||
)
|
||||
|
||||
// UseSearchPath is a global variable that determines whether or not to use the search path when resolving table names.
|
||||
@@ -77,4 +78,3 @@ func FirstExistingSchemaOnSearchPath(ctx *sql.Context, root doltdb.RootValue) (s
|
||||
|
||||
return schemaName, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,6 @@ func nameMapFromTableNameMap(tableNameMap map[doltdb.TableName]schema.Schema) ma
|
||||
return nameMap
|
||||
}
|
||||
|
||||
|
||||
// generateNonCreateNonDropTableSqlSchemaDiff returns any schema diff in SQL statements that is NEITHER 'CREATE TABLE' NOR 'DROP TABLE' statements.
|
||||
// TODO: schema names
|
||||
func generateNonCreateNonDropTableSqlSchemaDiff(td diff.TableDelta, toSchemas map[string]schema.Schema, fromSch, toSch schema.Schema) ([]string, error) {
|
||||
@@ -447,10 +446,10 @@ func AlterTableDropForeignKeyStmt(tableName, fkName string) string {
|
||||
// possible.
|
||||
// TODO: schema names
|
||||
func GenerateCreateTableStatement(
|
||||
tblName string,
|
||||
sch schema.Schema,
|
||||
fks []doltdb.ForeignKey,
|
||||
fksParentSch map[string]schema.Schema,
|
||||
tblName string,
|
||||
sch schema.Schema,
|
||||
fks []doltdb.ForeignKey,
|
||||
fksParentSch map[string]schema.Schema,
|
||||
) (string, error) {
|
||||
colStmts := make([]string, sch.GetAllCols().Size())
|
||||
|
||||
|
||||
@@ -2513,7 +2513,7 @@ func (t *WritableDoltTable) createForeignKey(
|
||||
var ok bool
|
||||
var err error
|
||||
// TODO: the parent table can be in another schema
|
||||
|
||||
|
||||
refTbl, _, ok, err = doltdb.GetTableInsensitive(ctx, root, doltdb.TableName{Name: sqlFk.ParentTable, Schema: t.db.schemaName})
|
||||
if err != nil {
|
||||
return doltdb.ForeignKey{}, err
|
||||
@@ -2582,7 +2582,7 @@ func (t *AlterableDoltTable) AddForeignKey(ctx *sql.Context, sqlFk sql.ForeignKe
|
||||
if strings.ToLower(sqlFk.Database) != strings.ToLower(sqlFk.ParentDatabase) || strings.ToLower(sqlFk.Database) != strings.ToLower(t.db.Name()) {
|
||||
return fmt.Errorf("only foreign keys on the same database are currently supported")
|
||||
}
|
||||
|
||||
|
||||
root, err := t.getRoot(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -2741,7 +2741,7 @@ func (t *AlterableDoltTable) CreateIndexForForeignKey(ctx *sql.Context, idx sql.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
newRoot, err := root.PutTable(ctx, doltdb.TableName{Name: t.tableName, Schema: t.db.schemaName}, ret.NewTable)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user