You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Set the limitation to a small value, make it easier to reach the limitation.
2667
+
atomic.StoreUint64(&kv.TxnTotalSizeLimit, 10240)
2668
+
tk.MustQuery("select sum(id) from t1").Check(testkit.Rows("32896"))
2669
+
// foreign key cascade behaviour will cause ErrTxnTooLarge.
2670
+
tk.MustGetDBError("update t1 set id=id+100000 where id=1", kv.ErrTxnTooLarge)
2671
+
tk.MustQuery("select sum(id) from t1").Check(testkit.Rows("32896"))
2672
+
tk.MustGetDBError("update t1 set id=id+100000 where id=1", kv.ErrTxnTooLarge)
2673
+
tk.MustQuery("select id,pid from t1 where id<3 order by id").Check(testkit.Rows("1 <nil>", "2 1"))
2674
+
tk.MustExec("set @@foreign_key_checks=0")
2675
+
tk.MustExec("update t1 set id=id+100000 where id=1")
2676
+
tk.MustQuery("select id,pid from t1 where id<3 or pid is null order by id").Check(testkit.Rows("2 1", "100001 <nil>"))
2677
+
}
2678
+
2679
+
funcTestForeignKeyAndLockView(t*testing.T) {
2680
+
store:=testkit.CreateMockStore(t)
2681
+
tk:=testkit.NewTestKit(t, store)
2682
+
tk.MustExec("use test")
2683
+
tk.MustExec("create table t1 (id int key)")
2684
+
tk.MustExec("create table t2 (id int key, foreign key (id) references t1(id) ON DELETE CASCADE ON UPDATE CASCADE)")
2685
+
tk.MustExec("insert into t1 values (1)")
2686
+
tk.MustExec("insert into t2 values (1)")
2687
+
tk.MustExec("begin pessimistic")
2688
+
tk.MustExec("set @@foreign_key_checks=0")
2689
+
tk.MustExec("update t2 set id=2")
2690
+
2691
+
tk2:=testkit.NewTestKit(t, store)
2692
+
tk2.MustExec("set @@foreign_key_checks=1")
2693
+
tk2.MustExec("use test")
2694
+
varwg sync.WaitGroup
2695
+
wg.Add(1)
2696
+
gofunc() {
2697
+
deferwg.Done()
2698
+
tk2.MustExec("begin pessimistic")
2699
+
tk2.MustExec("update t1 set id=2 where id=1")
2700
+
tk2.MustExec("commit")
2701
+
}()
2702
+
time.Sleep(time.Millisecond*200)
2703
+
_, digest:=parser.NormalizeDigest("update t1 set id=2 where id=1")
2704
+
tk.MustQuery("select CURRENT_SQL_DIGEST from information_schema.tidb_trx where state='LockWaiting' and db='test'").Check(testkit.Rows(digest.String()))
2705
+
tk.MustGetErrMsg("update t1 set id=2", "[executor:1213]Deadlock found when trying to get lock; try restarting transaction")
2706
+
wg.Wait()
2707
+
}
2708
+
2709
+
funcTestForeignKeyAndMemoryTracker(t*testing.T) {
2710
+
store:=testkit.CreateMockStore(t)
2711
+
tk:=testkit.NewTestKit(t, store)
2712
+
tk.MustExec("set @@foreign_key_checks=1")
2713
+
tk.MustExec("use test")
2714
+
tk.MustExec("create table t1 (id int auto_increment key, pid int, name varchar(200), index(pid));")
2715
+
tk.MustExec("insert into t1 (name) values ('abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz');")
2716
+
fori:=0; i<8; i++ {
2717
+
tk.MustExec("insert into t1 (name) select name from t1;")
2718
+
}
2719
+
tk.MustQuery("select count(*) from t1").Check(testkit.Rows("256"))
0 commit comments