diff --git a/go/cmd/dolt/dolt.go b/go/cmd/dolt/dolt.go index dd2c1f25ea..a0c72cf2ad 100644 --- a/go/cmd/dolt/dolt.go +++ b/go/cmd/dolt/dolt.go @@ -66,7 +66,7 @@ import ( ) const ( - Version = "1.30.4" + Version = "1.30.5" ) var dumpDocsCommand = &commands.DumpDocsCmd{} diff --git a/go/libraries/doltcore/sqle/database.go b/go/libraries/doltcore/sqle/database.go index ec77c754cf..e516f7930f 100644 --- a/go/libraries/doltcore/sqle/database.go +++ b/go/libraries/doltcore/sqle/database.go @@ -1699,7 +1699,7 @@ func (db Database) LoadRebasePlan(ctx *sql.Context) (*rebase.RebasePlan, error) // SaveRebasePlan implements the rebase.RebasePlanDatabase interface func (db Database) SaveRebasePlan(ctx *sql.Context, plan *rebase.RebasePlan) error { - pkSchema := sql.NewPrimaryKeySchema(dprocedures.DoltRebaseSystemTableSchema, 2) + pkSchema := sql.NewPrimaryKeySchema(dprocedures.DoltRebaseSystemTableSchema) // we use createSqlTable, instead of CreateTable to avoid the "dolt_" reserved prefix table name check err := db.createSqlTable(ctx, doltdb.RebaseTableName, pkSchema, sql.Collation_Default) if err != nil { diff --git a/go/libraries/doltcore/sqle/dprocedures/dolt_rebase.go b/go/libraries/doltcore/sqle/dprocedures/dolt_rebase.go index 9fb8d3f02c..b4bb1a4013 100644 --- a/go/libraries/doltcore/sqle/dprocedures/dolt_rebase.go +++ b/go/libraries/doltcore/sqle/dprocedures/dolt_rebase.go @@ -55,9 +55,10 @@ var RebaseActionEnumType = types.MustCreateEnumType([]string{ var DoltRebaseSystemTableSchema = []*sql.Column{ { - Name: "rebase_order", - Type: types.MustCreateDecimalType(6, 2), - Nullable: false, + Name: "rebase_order", + Type: types.MustCreateDecimalType(6, 2), + Nullable: false, + PrimaryKey: true, }, { Name: "action", @@ -247,6 +248,10 @@ func startRebase(ctx *sql.Context, upstreamPoint string) error { // Create the rebase plan and save it in the database rebasePlan, err := rebase.CreateDefaultRebasePlan(ctx, startCommit, upstreamCommit) if err != nil { + abortErr := abortRebase(ctx) + if abortErr != nil { + return fmt.Errorf("%s: unable to cleanly abort rebase: %s", err.Error(), abortErr.Error()) + } return err } rdb, ok := db.(rebase.RebasePlanDatabase) diff --git a/go/libraries/doltcore/sqle/enginetest/dolt_queries_rebase.go b/go/libraries/doltcore/sqle/enginetest/dolt_queries_rebase.go index dc138c1614..ecbd988f42 100644 --- a/go/libraries/doltcore/sqle/enginetest/dolt_queries_rebase.go +++ b/go/libraries/doltcore/sqle/enginetest/dolt_queries_rebase.go @@ -169,6 +169,10 @@ var DoltRebaseScriptTests = []queries.ScriptTest{ "adjust the rebase plan in the dolt_rebase table, then " + "continue rebasing by calling dolt_rebase('--continue')"}}, }, + { + Query: "update dolt_rebase set rebase_order=1.0 where rebase_order=2.0;", + ExpectedErrStr: "duplicate primary key given: [1]", + }, { Query: "update dolt_rebase set action='squash';", Expected: []sql.Row{{gmstypes.OkResult{ @@ -235,6 +239,51 @@ var DoltRebaseScriptTests = []queries.ScriptTest{ }, }, }, + { + Name: "dolt_rebase: no commits to rebase", + SetUpScript: []string{ + "create table t (pk int primary key);", + "call dolt_commit('-Am', 'creating table t');", + "call dolt_branch('branch1');", + + "insert into t values (0);", + "call dolt_commit('-am', 'inserting row 0');", + + "call dolt_checkout('branch1');", + "insert into t values (1);", + "call dolt_commit('-am', 'inserting row 1');", + "insert into t values (10);", + "call dolt_commit('-am', 'inserting row 10');", + "insert into t values (100);", + "call dolt_commit('-am', 'inserting row 100');", + "insert into t values (1000);", + "call dolt_commit('-am', 'inserting row 1000');", + "insert into t values (10000);", + "call dolt_commit('-am', 'inserting row 10000');", + "insert into t values (100000);", + "call dolt_commit('-am', 'inserting row 100000');", + }, + Assertions: []queries.ScriptTestAssertion{ + { + Query: "select active_branch();", + Expected: []sql.Row{{"branch1"}}, + }, + { + Query: "call dolt_rebase('-i', 'HEAD');", + ExpectedErrStr: "didn't identify any commits!", + }, + { + // if the rebase doesn't start, then we should remain on the original branch + Query: "select active_branch();", + Expected: []sql.Row{{"branch1"}}, + }, + { + // and the rebase working branch shouldn't be present + Query: "select * from dolt_branches where name='dolt_rebase_branch1';", + Expected: []sql.Row{}, + }, + }, + }, { Name: "dolt_rebase: abort properly cleans up", SetUpScript: []string{