@@ -167,7 +167,7 @@ func TestColumnBasic(t *testing.T) {
167167 tk .MustExec (fmt .Sprintf ("insert into t1 values(%d, %d, %d)" , i , 10 * i , 100 * i ))
168168 }
169169
170- ctx := testNewContext (store )
170+ ctx := testNewContext (t , store )
171171 txn , err := newTxn (ctx )
172172 require .NoError (t , err )
173173
@@ -214,6 +214,8 @@ func TestColumnBasic(t *testing.T) {
214214
215215 h , err := tbl .AddRecord (ctx .GetTableCtx (), txn , types .MakeDatums (11 , 12 , 13 , 14 ))
216216 require .NoError (t , err )
217+ err = txn .Commit (context .Background ())
218+ require .NoError (t , err )
217219 _ , err = newTxn (ctx )
218220 require .NoError (t , err )
219221 values , err := tables .RowWithCols (tbl , ctx , h , tbl .Cols ())
@@ -379,7 +381,9 @@ func checkDeleteOnlyColumn(t *testing.T, ctx sessionctx.Context, tableID int64,
379381 newRow := types .MakeDatums (int64 (11 ), int64 (22 ), int64 (33 ))
380382 newHandle , err := tbl .AddRecord (ctx .GetTableCtx (), txn , newRow )
381383 require .NoError (t , err )
382- _ , err = newTxn (ctx )
384+ err = txn .Commit (context .Background ())
385+ require .NoError (t , err )
386+ txn , err = newTxn (ctx )
383387 require .NoError (t , err )
384388
385389 rows := [][]types.Datum {row , newRow }
@@ -401,7 +405,9 @@ func checkDeleteOnlyColumn(t *testing.T, ctx sessionctx.Context, tableID int64,
401405
402406 err = tbl .RemoveRecord (ctx .GetTableCtx (), txn , newHandle , newRow )
403407 require .NoError (t , err )
404- _ , err = newTxn (ctx )
408+ err = txn .Commit (context .Background ())
409+ require .NoError (t , err )
410+ txn , err = newTxn (ctx )
405411 require .NoError (t , err )
406412 i = 0
407413 err = tables .IterRecords (tbl , ctx , tbl .Cols (), func (_ kv.Handle , data []types.Datum , cols []* table.Column ) (bool , error ) {
@@ -441,7 +447,9 @@ func checkWriteOnlyColumn(t *testing.T, ctx sessionctx.Context, tableID int64, h
441447 newRow := types .MakeDatums (int64 (11 ), int64 (22 ), int64 (33 ))
442448 newHandle , err := tbl .AddRecord (ctx .GetTableCtx (), txn , newRow )
443449 require .NoError (t , err )
444- _ , err = newTxn (ctx )
450+ err = txn .Commit (context .Background ())
451+ require .NoError (t , err )
452+ txn , err = newTxn (ctx )
445453 require .NoError (t , err )
446454
447455 rows := [][]types.Datum {row , newRow }
@@ -463,7 +471,10 @@ func checkWriteOnlyColumn(t *testing.T, ctx sessionctx.Context, tableID int64, h
463471
464472 err = tbl .RemoveRecord (ctx .GetTableCtx (), txn , newHandle , newRow )
465473 require .NoError (t , err )
466- _ , err = newTxn (ctx )
474+
475+ err = txn .Commit (context .Background ())
476+ require .NoError (t , err )
477+ txn , err = newTxn (ctx )
467478 require .NoError (t , err )
468479
469480 i = 0
@@ -501,7 +512,9 @@ func checkReorganizationColumn(t *testing.T, ctx sessionctx.Context, tableID int
501512 newRow := types .MakeDatums (int64 (11 ), int64 (22 ), int64 (33 ))
502513 newHandle , err := tbl .AddRecord (ctx .GetTableCtx (), txn , newRow )
503514 require .NoError (t , err )
504- _ , err = newTxn (ctx )
515+ err = txn .Commit (context .Background ())
516+ require .NoError (t , err )
517+ txn , err = newTxn (ctx )
505518 require .NoError (t , err )
506519
507520 rows := [][]types.Datum {row , newRow }
@@ -524,7 +537,9 @@ func checkReorganizationColumn(t *testing.T, ctx sessionctx.Context, tableID int
524537
525538 err = tbl .RemoveRecord (ctx .GetTableCtx (), txn , newHandle , newRow )
526539 require .NoError (t , err )
527- _ , err = newTxn (ctx )
540+ err = txn .Commit (context .Background ())
541+ require .NoError (t , err )
542+ txn , err = newTxn (ctx )
528543 require .NoError (t , err )
529544
530545 i = 0
@@ -567,7 +582,9 @@ func checkPublicColumn(t *testing.T, ctx sessionctx.Context, tableID int64, newC
567582 }
568583 handle , err := tbl .AddRecord (ctx .GetTableCtx (), txn , newRow )
569584 require .NoError (t , err )
570- _ , err = newTxn (ctx )
585+ err = txn .Commit (context .Background ())
586+ require .NoError (t , err )
587+ txn , err = newTxn (ctx )
571588 require .NoError (t , err )
572589
573590 rows := [][]types.Datum {updatedRow , newRow }
@@ -587,8 +604,10 @@ func checkPublicColumn(t *testing.T, ctx sessionctx.Context, tableID int64, newC
587604
588605 err = tbl .RemoveRecord (ctx .GetTableCtx (), txn , handle , newRow )
589606 require .NoError (t , err )
607+ err = txn .Commit (context .Background ())
608+ require .NoError (t , err )
590609
591- _ , err = newTxn (ctx )
610+ txn , err = newTxn (ctx )
592611 require .NoError (t , err )
593612
594613 i = 0
@@ -605,7 +624,7 @@ func checkPublicColumn(t *testing.T, ctx sessionctx.Context, tableID int64, newC
605624}
606625
607626func checkAddColumn (t * testing.T , state model.SchemaState , tableID int64 , handle kv.Handle , newCol * table.Column , oldRow []types.Datum , columnValue any , dom * domain.Domain , store kv.Storage , columnCnt int ) {
608- ctx := testNewContext (store )
627+ ctx := testNewContext (t , store )
609628 switch state {
610629 case model .StateNone :
611630 checkNoneColumn (t , ctx , tableID , handle , newCol , columnValue , dom )
@@ -647,7 +666,7 @@ func TestAddColumn(t *testing.T) {
647666 tableID = int64 (tableIDi )
648667 tbl := testGetTable (t , dom , tableID )
649668
650- ctx := testNewContext (store )
669+ ctx := testNewContext (t , store )
651670 txn , err := newTxn (ctx )
652671 require .NoError (t , err )
653672 oldRow := types .MakeDatums (int64 (1 ), int64 (2 ), int64 (3 ))
@@ -712,7 +731,7 @@ func TestAddColumns(t *testing.T) {
712731 tableID = int64 (tableIDi )
713732 tbl := testGetTable (t , dom , tableID )
714733
715- ctx := testNewContext (store )
734+ ctx := testNewContext (t , store )
716735 txn , err := newTxn (ctx )
717736 require .NoError (t , err )
718737 oldRow := types .MakeDatums (int64 (1 ), int64 (2 ), int64 (3 ))
@@ -769,7 +788,7 @@ func TestDropColumnInColumnTest(t *testing.T) {
769788 tableID = int64 (tableIDi )
770789 tbl := testGetTable (t , dom , tableID )
771790
772- ctx := testNewContext (store )
791+ ctx := testNewContext (t , store )
773792 colName := "c4"
774793 defaultColValue := int64 (4 )
775794 row := types .MakeDatums (int64 (1 ), int64 (2 ), int64 (3 ))
@@ -823,7 +842,7 @@ func TestDropColumns(t *testing.T) {
823842 tableID = int64 (tableIDi )
824843 tbl := testGetTable (t , dom , tableID )
825844
826- ctx := testNewContext (store )
845+ ctx := testNewContext (t , store )
827846 txn , err := newTxn (ctx )
828847 require .NoError (t , err )
829848
0 commit comments