Skip to content

Commit

Permalink
Merge pull request #6754 from dolthub/aaron/replicate-drop-database
Browse files Browse the repository at this point in the history
go/libraries/doltcore/sqle/cluster: Replicate `DROP DATABASE` statements so that a dropped database is also dropped on replicas.
  • Loading branch information
reltuk authored Oct 2, 2023
2 parents 74cac7d + aabb4b6 commit 44abb30
Show file tree
Hide file tree
Showing 7 changed files with 391 additions and 40 deletions.
26 changes: 19 additions & 7 deletions go/cmd/dolt/commands/engine/sqlengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,19 @@ func NewSqlEngine(

config.ClusterController.RegisterStoredProcedures(pro)
pro.InitDatabaseHook = cluster.NewInitDatabaseHook(config.ClusterController, bThreads, pro.InitDatabaseHook)
pro.DropDatabaseHook = config.ClusterController.DropDatabaseHook

sqlEngine := &SqlEngine{}

var dropDatabase = func(ctx context.Context, name string) error {
sqlCtx, err := sqlEngine.NewDefaultContext(ctx)
if err != nil {
return err
}
return pro.DropDatabase(sqlCtx, name)
}

config.ClusterController.SetDropDatabase(dropDatabase)
pro.DropDatabaseHook = config.ClusterController.DropDatabaseHook()

// Create the engine
engine := gms.New(analyzer.NewBuilder(pro).WithParallelism(parallelism).Build(), &gms.Config{
Expand Down Expand Up @@ -223,12 +235,12 @@ func NewSqlEngine(
}
}

return &SqlEngine{
provider: pro,
contextFactory: sqlContextFactory(),
dsessFactory: sessFactory,
engine: engine,
}, nil
sqlEngine.provider = pro
sqlEngine.contextFactory = sqlContextFactory()
sqlEngine.dsessFactory = sessFactory
sqlEngine.engine = engine

return sqlEngine, nil
}

// NewRebasedSqlEngine returns a smalled rebased engine primarily used in filterbranch.
Expand Down
191 changes: 159 additions & 32 deletions go/gen/proto/dolt/services/replicationapi/v1alpha1/replication.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 44abb30

Please sign in to comment.