From d927344205b1ff63a0ba44ca9efe55de5b161457 Mon Sep 17 00:00:00 2001 From: Alex Giurgiu Date: Mon, 13 Nov 2023 21:28:14 +0200 Subject: [PATCH] using the concurrentmap Map constructor in order to properly initialise the map everywhere it is used --- go/libraries/doltcore/env/repo_state.go | 2 +- go/libraries/doltcore/sqle/clusterdb/database.go | 2 ++ go/libraries/doltcore/sqle/database.go | 2 +- go/libraries/doltcore/sqle/database_provider.go | 3 +++ go/libraries/doltcore/sqle/user_space_database.go | 2 ++ 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/go/libraries/doltcore/env/repo_state.go b/go/libraries/doltcore/env/repo_state.go index 26f5754847..8f69b15f70 100644 --- a/go/libraries/doltcore/env/repo_state.go +++ b/go/libraries/doltcore/env/repo_state.go @@ -181,7 +181,7 @@ func CreateRepoState(fs filesys.ReadWriteFS, br string) (*RepoState, error) { rs := &RepoState{ Head: ref.MarshalableRef{Ref: headRef}, - Remotes: &concurrentmap.Map[string, Remote]{}, + Remotes: concurrentmap.New[string, Remote](), Branches: make(map[string]BranchConfig), Backups: make(map[string]Remote), } diff --git a/go/libraries/doltcore/sqle/clusterdb/database.go b/go/libraries/doltcore/sqle/clusterdb/database.go index 62b2824a7f..35527c7151 100644 --- a/go/libraries/doltcore/sqle/clusterdb/database.go +++ b/go/libraries/doltcore/sqle/clusterdb/database.go @@ -26,6 +26,7 @@ import ( "github.com/dolthub/dolt/go/libraries/doltcore/ref" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" "github.com/dolthub/dolt/go/libraries/doltcore/table/editor" + "github.com/dolthub/dolt/go/libraries/utils/concurrentmap" ) const DoltClusterDbName = "dolt_cluster" @@ -111,6 +112,7 @@ func (db database) InitialDBState(ctx *sql.Context) (dsess.InitialDbState, error Rsw: noopRepoStateWriter{}, }, ReadOnly: true, + Remotes: concurrentmap.New[string, env.Remote](), }, nil } diff --git a/go/libraries/doltcore/sqle/database.go b/go/libraries/doltcore/sqle/database.go index a8bed17f91..9fc33cf6de 100644 --- a/go/libraries/doltcore/sqle/database.go +++ b/go/libraries/doltcore/sqle/database.go @@ -417,7 +417,7 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds sess := dsess.DSessFromSess(ctx.Session) adapter := dsess.NewSessionStateAdapter( sess, db.RevisionQualifiedName(), - &concurrentmap.Map[string, env.Remote]{}, + concurrentmap.New[string, env.Remote](), map[string]env.BranchConfig{}, map[string]env.Remote{}) ws, err := sess.WorkingSet(ctx, db.RevisionQualifiedName()) diff --git a/go/libraries/doltcore/sqle/database_provider.go b/go/libraries/doltcore/sqle/database_provider.go index 43fe6084d4..059f1945d3 100644 --- a/go/libraries/doltcore/sqle/database_provider.go +++ b/go/libraries/doltcore/sqle/database_provider.go @@ -37,6 +37,7 @@ import ( "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" "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" "github.com/dolthub/dolt/go/libraries/utils/filesys" "github.com/dolthub/dolt/go/libraries/utils/lockutil" "github.com/dolthub/dolt/go/store/datas" @@ -1443,6 +1444,7 @@ func initialStateForTagDb(ctx context.Context, srcDb ReadOnlyDatabase) (dsess.In Rsw: srcDb.DbData().Rsw, Rsr: srcDb.DbData().Rsr, }, + Remotes: concurrentmap.New[string, env.Remote](), // todo: should we initialize // - Remotes // - Branches @@ -1493,6 +1495,7 @@ func initialStateForCommit(ctx context.Context, srcDb ReadOnlyDatabase) (dsess.I Rsw: srcDb.DbData().Rsw, Rsr: srcDb.DbData().Rsr, }, + Remotes: concurrentmap.New[string, env.Remote](), // todo: should we initialize // - Remotes // - Branches diff --git a/go/libraries/doltcore/sqle/user_space_database.go b/go/libraries/doltcore/sqle/user_space_database.go index 4b2f311f08..3853a927d4 100644 --- a/go/libraries/doltcore/sqle/user_space_database.go +++ b/go/libraries/doltcore/sqle/user_space_database.go @@ -21,6 +21,7 @@ import ( "github.com/dolthub/dolt/go/libraries/doltcore/env" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" "github.com/dolthub/dolt/go/libraries/doltcore/table/editor" + "github.com/dolthub/dolt/go/libraries/utils/concurrentmap" ) // UserSpaceDatabase in an implementation of sql.Database for root values. Does not expose any of the internal dolt tables. @@ -84,6 +85,7 @@ func (db *UserSpaceDatabase) InitialDBState(ctx *sql.Context) (dsess.InitialDbSt DbData: env.DbData{ Rsw: noopRepoStateWriter{}, }, + Remotes: concurrentmap.New[string, env.Remote](), }, nil }