@@ -21,6 +21,7 @@ import (
21
21
"testing"
22
22
"time"
23
23
24
+ "github.com/pingcap/tidb/pkg/ddl"
24
25
"github.com/pingcap/tidb/pkg/executor"
25
26
"github.com/pingcap/tidb/pkg/sessionctx/binloginfo"
26
27
"github.com/pingcap/tidb/pkg/testkit"
@@ -694,3 +695,32 @@ func TestSavepointWithBinlog(t *testing.T) {
694
695
tk .MustExec ("commit" )
695
696
tk .MustQuery ("select * from t" ).Check (testkit .Rows ("1 1" ))
696
697
}
698
+
699
+ func TestColumnNotMatchError (t * testing.T ) {
700
+ ddl .WaitChan = make (chan struct {})
701
+ store := testkit .CreateMockStore (t )
702
+ tk := testkit .NewTestKit (t , store )
703
+ tk .Session ().GetSessionVars ().BinlogClient = binloginfo .MockPumpsClient (& testkit.MockPumpClient {})
704
+ tk .MustExec ("set @@global.tidb_enable_metadata_lock=0" )
705
+ tk .MustExec ("use test" )
706
+ tk2 := testkit .NewTestKit (t , store )
707
+ tk2 .MustExec ("use test" )
708
+ tk .MustExec ("create table t(id int primary key, a int)" )
709
+ tk .MustExec ("insert into t values(1, 2)" )
710
+ go func () {
711
+ tk2 .MustExec ("alter table t add column wait_notify int" )
712
+ close (ddl .WaitChan )
713
+ }()
714
+ // wait the ddl stage to the reorg
715
+ <- ddl .WaitChan
716
+ // begin to make sure the table t in txn contains a no public column
717
+ tk .MustExec ("begin" )
718
+ // continue ddl and wait it finished to avoid some necessary error log
719
+ ddl .WaitChan <- struct {}{}
720
+ <- ddl .WaitChan
721
+ // this statement will fail because:
722
+ // - schema in the plan includes the non-public column -> data contains non-public column
723
+ // - table.Cols() does not contain the non-public column
724
+ tk .MustExec ("delete from t where id=1" )
725
+ tk .MustExec ("commit" )
726
+ }
0 commit comments