mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-20 19:31:56 -05:00
Merge main
This commit is contained in:
@@ -112,6 +112,10 @@ func (db database) InitialDBState(ctx *sql.Context) (dsess.InitialDbState, error
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (db database) DoltDatabases() []*doltdb.DoltDB {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (db database) GetRoot(context *sql.Context) (*doltdb.RootValue, error) {
|
||||
return nil, errors.New("unimplemented")
|
||||
}
|
||||
|
||||
@@ -109,6 +109,10 @@ func (db Database) EditOptions() editor.Options {
|
||||
return db.editOpts
|
||||
}
|
||||
|
||||
func (db Database) DoltDatabases() []*doltdb.DoltDB {
|
||||
return []*doltdb.DoltDB{db.ddb}
|
||||
}
|
||||
|
||||
// NewDatabase returns a new dolt database to use in queries.
|
||||
func NewDatabase(ctx context.Context, name string, dbData env.DbData, editOpts editor.Options) (Database, error) {
|
||||
globalState, err := globalstate.NewGlobalStateStoreForDb(ctx, dbData.Ddb)
|
||||
|
||||
@@ -1196,10 +1196,7 @@ func (p DoltDatabaseProvider) ensureReplicaHeadExists(ctx *sql.Context, branch s
|
||||
|
||||
// isBranch returns whether a branch with the given name is in scope for the database given
|
||||
func isBranch(ctx context.Context, db dsess.SqlDatabase, branchName string) (string, bool, error) {
|
||||
ddbs, err := doltDbs(db)
|
||||
if err != nil {
|
||||
return "", false, err
|
||||
}
|
||||
ddbs := db.DoltDatabases()
|
||||
|
||||
brName, branchExists, err := isLocalBranch(ctx, ddbs, branchName)
|
||||
if err != nil {
|
||||
@@ -1220,21 +1217,6 @@ func isBranch(ctx context.Context, db dsess.SqlDatabase, branchName string) (str
|
||||
return "", false, nil
|
||||
}
|
||||
|
||||
func doltDbs(db dsess.SqlDatabase) ([]*doltdb.DoltDB, error) {
|
||||
var ddbs []*doltdb.DoltDB
|
||||
switch db := db.(type) {
|
||||
case ReadReplicaDatabase:
|
||||
ddbs = append(ddbs, db.ddb, db.srcDB)
|
||||
case Database:
|
||||
ddbs = append(ddbs, db.ddb)
|
||||
case ReadOnlyDatabase:
|
||||
ddbs = append(ddbs, db.ddb)
|
||||
default:
|
||||
return nil, fmt.Errorf("unrecognized type of database %T", db)
|
||||
}
|
||||
return ddbs, nil
|
||||
}
|
||||
|
||||
func isLocalBranch(ctx context.Context, ddbs []*doltdb.DoltDB, branchName string) (string, bool, error) {
|
||||
for _, ddb := range ddbs {
|
||||
brName, branchExists, err := ddb.HasBranch(ctx, branchName)
|
||||
@@ -1268,10 +1250,7 @@ func isRemoteBranch(ctx context.Context, ddbs []*doltdb.DoltDB, branchName strin
|
||||
|
||||
// isTag returns whether a tag with the given name is in scope for the database given
|
||||
func isTag(ctx context.Context, db dsess.SqlDatabase, tagName string) (bool, error) {
|
||||
ddbs, err := doltDbs(db)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
ddbs := db.DoltDatabases()
|
||||
|
||||
for _, ddb := range ddbs {
|
||||
tagExists, err := ddb.HasTag(ctx, tagName)
|
||||
|
||||
@@ -107,4 +107,6 @@ type SqlDatabase interface {
|
||||
GetRoot(*sql.Context) (*doltdb.RootValue, error)
|
||||
// TODO: remove ddb from the below, it's separable and is 95% of the uses of this method
|
||||
DbData() env.DbData
|
||||
// DoltDatabases returns all underlying DoltDBs for this database.
|
||||
DoltDatabases() []*doltdb.DoltDB
|
||||
}
|
||||
|
||||
@@ -98,6 +98,10 @@ func (rrd ReadReplicaDatabase) InitialDBState(ctx *sql.Context) (dsess.InitialDb
|
||||
return initialDBState(ctx, rrd, rrd.revision)
|
||||
}
|
||||
|
||||
func (rrd ReadReplicaDatabase) DoltDatabases() []*doltdb.DoltDB {
|
||||
return []*doltdb.DoltDB{rrd.ddb, rrd.srcDB}
|
||||
}
|
||||
|
||||
func (rrd ReadReplicaDatabase) PullFromRemote(ctx *sql.Context) error {
|
||||
_, headsArg, ok := sql.SystemVariables.GetGlobal(dsess.ReplicateHeads)
|
||||
if !ok {
|
||||
|
||||
@@ -87,6 +87,10 @@ func (db *UserSpaceDatabase) InitialDBState(ctx *sql.Context) (dsess.InitialDbSt
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (db *UserSpaceDatabase) DoltDatabases() []*doltdb.DoltDB {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (db *UserSpaceDatabase) GetRoot(*sql.Context) (*doltdb.RootValue, error) {
|
||||
return db.RootValue, nil
|
||||
}
|
||||
|
||||
@@ -289,7 +289,6 @@ func newServer(u driver.DoltUser, r driver.TestRepo) (*driver.SqlServer, error)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.Server.Args = append(r.Server.Args, "")
|
||||
server, err := MakeServer(repo, r.Server)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -555,8 +555,6 @@ func newServer(u driver.DoltUser, r driver.TestRepo, conf Config) (*driver.SqlSe
|
||||
if conf.Verbose {
|
||||
log.Printf("database at: '%s'", repo.Dir)
|
||||
}
|
||||
|
||||
r.Server.Args = append(r.Server.Args, "")
|
||||
server, err := MakeServer(repo, r.Server)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user