@@ -2648,3 +2648,31 @@ func (s *testPessimisticSuite) TestChangeLockToPut(c *C) {
26482648
26492649 tk .MustExec ("admin check table t1" )
26502650}
2651+
2652+ func (s * testPessimisticSuite ) TestIssue30940 (c * C ) {
2653+ tk := testkit .NewTestKitWithInit (c , s .store )
2654+ tk2 := testkit .NewTestKitWithInit (c , s .store )
2655+
2656+ tk .MustExec ("use test" )
2657+ tk2 .MustExec ("use test" )
2658+ tk .MustExec ("drop table if exists t" )
2659+ tk .MustExec ("create table t(id int primary key, v int)" )
2660+ tk .MustExec ("insert into t values(1, 1)" )
2661+
2662+ stmts := []string {
2663+ "update t set v = v + 1 where id = 1" ,
2664+ "delete from t where id = 1" ,
2665+ }
2666+ errCh := make (chan error , 1 )
2667+ for _ , stmt := range stmts {
2668+ tk .MustExec (fmt .Sprintf ("prepare t from '%s'" , stmt ))
2669+ tk2 .MustExec ("alter table t add column a int" )
2670+ c .Assert (failpoint .Enable ("github.com/pingcap/tidb/planner/optimizeExecuteStmt" , "pause" ), IsNil )
2671+ go func () {
2672+ errCh <- tk .ExecToErr ("execute t" )
2673+ }()
2674+ tk2 .MustExec ("alter table t drop column a" )
2675+ c .Assert (failpoint .Disable ("github.com/pingcap/tidb/planner/optimizeExecuteStmt" ), IsNil )
2676+ c .Assert (<- errCh , IsNil )
2677+ }
2678+ }
0 commit comments