@@ -18,12 +18,15 @@ import (
18
18
"fmt"
19
19
"strconv"
20
20
"strings"
21
+ "sync"
21
22
"testing"
22
23
"time"
23
24
25
+ "github.com/pingcap/tidb/pkg/errno"
24
26
"github.com/pingcap/tidb/pkg/executor"
25
27
"github.com/pingcap/tidb/pkg/sessionctx/binloginfo"
26
28
"github.com/pingcap/tidb/pkg/testkit"
29
+ "github.com/pingcap/tidb/pkg/testkit/testfailpoint"
27
30
"github.com/stretchr/testify/require"
28
31
)
29
32
@@ -694,3 +697,40 @@ func TestSavepointWithBinlog(t *testing.T) {
694
697
tk .MustExec ("commit" )
695
698
tk .MustQuery ("select * from t" ).Check (testkit .Rows ("1 1" ))
696
699
}
700
+
701
+ func TestColumnNotMatchError (t * testing.T ) {
702
+ store := testkit .CreateMockStore (t )
703
+ tk := testkit .NewTestKit (t , store )
704
+ tk .Session ().GetSessionVars ().BinlogClient = binloginfo .MockPumpsClient (& testkit.MockPumpClient {})
705
+ tk .MustExec ("set @@global.tidb_enable_metadata_lock=0" )
706
+ tk .MustExec ("use test" )
707
+ tk2 := testkit .NewTestKit (t , store )
708
+ tk2 .MustExec ("use test" )
709
+ tk .MustExec ("create table t(id int primary key, a int)" )
710
+ tk .MustExec ("insert into t values(1, 2)" )
711
+
712
+ testfailpoint .EnableCall (t , "github.com/pingcap/tidb/pkg/ddl/onAddColumnStateWriteReorg" , func () {
713
+ tk .MustExec ("begin;" )
714
+ })
715
+ var wg sync.WaitGroup
716
+ wg .Add (1 )
717
+ go func () {
718
+ tk2 .MustExec ("alter table t add column wait_notify int" )
719
+ wg .Done ()
720
+ }()
721
+ wg .Wait ()
722
+ tk .MustExec ("delete from t where id=1" )
723
+ tk .MustGetErrCode ("commit" , errno .ErrInfoSchemaChanged )
724
+
725
+ testfailpoint .EnableCall (t , "github.com/pingcap/tidb/pkg/ddl/onDropColumnStateWriteOnly" , func () {
726
+ tk .MustExec ("begin;" )
727
+ })
728
+ wg .Add (1 )
729
+ go func () {
730
+ tk2 .MustExec ("alter table t drop column wait_notify" )
731
+ wg .Done ()
732
+ }()
733
+ wg .Wait ()
734
+ tk .MustExec ("delete from t where id=1" )
735
+ tk .MustGetErrCode ("commit" , errno .ErrInfoSchemaChanged )
736
+ }
0 commit comments