go/libraries/doltcore/sqle/dsess: transactions.go: When merging working sets on call dolt_commit, ensure new commit also gets the merged commit root value.

This commit is contained in:
Aaron Son
2023-01-20 14:52:24 -08:00
parent 1a4e590c06
commit d9671bd565
2 changed files with 10 additions and 0 deletions

View File

@@ -232,6 +232,9 @@ func (tx *DoltTransaction) doCommit(
}
var newCommit *doltdb.Commit
if commit != nil {
commit.Roots.Staged = mergedWorkingSet.WorkingRoot()
}
mergedWorkingSet, newCommit, err = writeFn(ctx, tx, commit, mergedWorkingSet, existingWSHash)
if err == datas.ErrOptimisticLockFailed {
// this is effectively a `continue` in the loop

View File

@@ -272,6 +272,13 @@ func TestDoltTransactionCommitTwoClients(t *testing.T) {
Query: "/* client c */ SELECT * FROM x ORDER BY y;",
Expected: []sql.Row{{1, 1}, {2, 2}, {3, 3}},
},
// After we commit both of these transactions, our working set should not have any pending changes.
// In the past, we have merged the working set but failed to land the merged root value in the
// commit itself.
{
Query: "/* client c */ SELECT COUNT(*) FROM DOLT_DIFF('HEAD', 'WORKING', 'x');",
Expected: []sql.Row{{0}},
},
},
})
_, err := harness.NewEngine(t)