mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-02 11:30:13 -05:00
Fix error message for DOLT_MERGE conflicts (#3413)
This commit is contained in:
@@ -38,6 +38,8 @@ const (
|
||||
)
|
||||
|
||||
var ErrRetryTransaction = errors.New("this transaction conflicts with a committed transaction from another client, please retry")
|
||||
var ErrUnresolvedConflictsCommit = errors.New("Merge conflict detected, transaction rolled back. Merge conflicts must be resolved using the dolt_conflicts tables before committing a transaction. To commit transactions with merge conflicts, set @@dolt_allow_commit_conflicts = 1")
|
||||
var ErrUnresolvedConstraintViolationsCommit = errors.New("Constraint violation from merge detected, cannot commit transaction. Constraint violations from a merge must be resolved using the dolt_constraint_violations table before committing a transaction. To commit transactions with constraint violations set @@dolt_force_transaction_commit=1")
|
||||
|
||||
func TransactionsDisabled(ctx *sql.Context) bool {
|
||||
enabled, err := ctx.GetSessionVariable(ctx, TransactionsDisabledSysVar)
|
||||
@@ -357,7 +359,7 @@ func (tx *DoltTransaction) validateWorkingSetForCommit(ctx *sql.Context, working
|
||||
return rollbackErr
|
||||
}
|
||||
|
||||
return doltdb.ErrUnresolvedConflicts
|
||||
return ErrUnresolvedConflictsCommit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,7 +371,7 @@ func (tx *DoltTransaction) validateWorkingSetForCommit(ctx *sql.Context, working
|
||||
return err
|
||||
}
|
||||
if hasConstraintViolations {
|
||||
return doltdb.ErrUnresolvedConstraintViolations
|
||||
return ErrUnresolvedConstraintViolationsCommit
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"github.com/dolthub/go-mysql-server/enginetest"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dfunctions"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess"
|
||||
@@ -889,7 +888,7 @@ var DoltMerge = []enginetest.ScriptTest{
|
||||
},
|
||||
{
|
||||
Query: "SELECT DOLT_MERGE('feature-branch')",
|
||||
ExpectedErrStr: doltdb.ErrUnresolvedConflicts.Error(),
|
||||
ExpectedErrStr: dsess.ErrUnresolvedConflictsCommit.Error(),
|
||||
},
|
||||
{
|
||||
Query: "SELECT count(*) from dolt_conflicts_test", // transaction has been rolled back, 0 results
|
||||
|
||||
@@ -20,8 +20,6 @@ import (
|
||||
"github.com/dolthub/go-mysql-server/sql/plan"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
|
||||
)
|
||||
|
||||
var DoltTransactionTests = []enginetest.TransactionTest{
|
||||
@@ -1141,7 +1139,7 @@ var DoltConflictHandlingTests = []enginetest.TransactionTest{
|
||||
},
|
||||
{
|
||||
Query: "/* client b */ commit",
|
||||
ExpectedErrStr: doltdb.ErrUnresolvedConflicts.Error(),
|
||||
ExpectedErrStr: dsess.ErrUnresolvedConflictsCommit.Error(),
|
||||
},
|
||||
{ // our transaction got rolled back, so we lose the above insert
|
||||
Query: "/* client b */ select * from test order by 1",
|
||||
@@ -1225,7 +1223,7 @@ var DoltSqlFuncTransactionTests = []enginetest.TransactionTest{
|
||||
},
|
||||
{
|
||||
Query: "/* client a */ SELECT DOLT_MERGE('feature-branch')",
|
||||
ExpectedErrStr: doltdb.ErrUnresolvedConflicts.Error(),
|
||||
ExpectedErrStr: dsess.ErrUnresolvedConflictsCommit.Error(),
|
||||
},
|
||||
{ // client rolled back on merge with conflicts
|
||||
Query: "/* client a */ SELECT count(*) from dolt_conflicts_test",
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// Copyright 2022 Dolthub, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
||||
@@ -642,7 +642,7 @@ SELECT DOLT_CHECKOUT('main');
|
||||
SELECT DOLT_MERGE('feature-branch');
|
||||
SQL
|
||||
[ $status -eq 1 ]
|
||||
[[ $output =~ "merge has unresolved conflicts" ]] || false
|
||||
[[ $output =~ "Merge conflict detected, transaction rolled back. Merge conflicts must be resolved using the dolt_conflicts tables before committing a transaction. To commit transactions with merge conflicts, set @@dolt_allow_commit_conflicts = 1" ]] || false
|
||||
|
||||
run dolt status
|
||||
[ $status -eq 0 ]
|
||||
@@ -693,7 +693,7 @@ CALL DOLT_CHECKOUT('main');
|
||||
CALL DOLT_MERGE('feature-branch');
|
||||
SQL
|
||||
[ $status -eq 1 ]
|
||||
[[ $output =~ "merge has unresolved conflicts" ]] || false
|
||||
[[ $output =~ "Merge conflict detected, transaction rolled back. Merge conflicts must be resolved using the dolt_conflicts tables before committing a transaction. To commit transactions with merge conflicts, set @@dolt_allow_commit_conflicts = 1" ]] || false
|
||||
|
||||
run dolt status
|
||||
[ $status -eq 0 ]
|
||||
@@ -743,7 +743,7 @@ SELECT DOLT_CHECKOUT('main');
|
||||
SELECT DOLT_MERGE('feature-branch');
|
||||
SQL
|
||||
[ $status -eq 1 ]
|
||||
[[ $output =~ "merge has unresolved conflicts" ]] || false
|
||||
[[ $output =~ "Merge conflict detected, transaction rolled back. Merge conflicts must be resolved using the dolt_conflicts tables before committing a transaction. To commit transactions with merge conflicts, set @@dolt_allow_commit_conflicts = 1" ]] || false
|
||||
|
||||
# back on the command line, our session state is clean
|
||||
run dolt status
|
||||
|
||||
Reference in New Issue
Block a user