@@ -89,7 +89,6 @@ func mockWriteKVSnapOnDisk(db *pebble.DB, snapTs uint64, dbInfos map[int64]*mode
89
89
tablesInKVSnap [tableInfo .ID ] = & BasicTableInfo {
90
90
SchemaID : dbInfo .ID ,
91
91
Name : tableInfo .Name .O ,
92
- InKVSnap : true ,
93
92
}
94
93
tableInfoValue , err := json .Marshal (tableInfo )
95
94
if err != nil {
@@ -211,23 +210,24 @@ func TestBuildVersionedTableInfoStore(t *testing.T) {
211
210
require .Nil (t , err )
212
211
}
213
212
214
- // // create another table
215
- // tableID2 := tableID + 1
216
- // {
217
- // ddlEvent := PersistedDDLEvent{
218
- // Type: byte(model.ActionCreateTable),
219
- // SchemaID: schemaID,
220
- // TableID: tableID,
221
- // SchemaVersion: 3000,
222
- // TableInfo: &model.TableInfo{
223
- // ID: tableID,
224
- // Name: model.NewCIStr("t2"),
225
- // },
226
- // FinishedTs: renameVersion,
227
- // }
228
- // err = pStorage.handleSortedDDLEvents(ddlEvent)
229
- // require.Nil(t, err)
230
- // }
213
+ // create another table
214
+ tableID2 := tableID + 1
215
+ createVersion := renameVersion + 200
216
+ {
217
+ ddlEvent := PersistedDDLEvent {
218
+ Type : byte (model .ActionCreateTable ),
219
+ SchemaID : schemaID ,
220
+ TableID : tableID2 ,
221
+ SchemaVersion : 3500 ,
222
+ TableInfo : & model.TableInfo {
223
+ ID : tableID2 ,
224
+ Name : model .NewCIStr ("t3" ),
225
+ },
226
+ FinishedTs : createVersion ,
227
+ }
228
+ err = pStorage .handleSortedDDLEvents (ddlEvent )
229
+ require .Nil (t , err )
230
+ }
231
231
232
232
upperBound := UpperBoundMeta {
233
233
FinishedDDLTs : 3000 ,
@@ -263,6 +263,16 @@ func TestBuildVersionedTableInfoStore(t *testing.T) {
263
263
require .Nil (t , err )
264
264
require .Equal (t , "t3" , tableInfo3 .Name .O )
265
265
}
266
+
267
+ {
268
+ store := newEmptyVersionedTableInfoStore (tableID2 )
269
+ pStorage .buildVersionedTableInfoStore (store )
270
+ require .Equal (t , 1 , len (store .infos ))
271
+ tableInfo , err := store .getTableInfo (createVersion )
272
+ require .Nil (t , err )
273
+ require .Equal (t , "t3" , tableInfo .Name .O )
274
+ require .Equal (t , tableID2 , tableInfo .ID )
275
+ }
266
276
}
267
277
268
278
func TestHandleCreateDropSchemaTableDDL (t * testing.T ) {
@@ -453,7 +463,6 @@ func TestHandleRenameTable(t *testing.T) {
453
463
require .Equal (t , 2 , len (pStorage .databaseMap ))
454
464
require .Equal (t , 1 , len (pStorage .databaseMap [schemaID1 ].Tables ))
455
465
require .Equal (t , 0 , len (pStorage .databaseMap [schemaID2 ].Tables ))
456
- require .Equal (t , false , pStorage .tableMap [tableID ].InKVSnap )
457
466
require .Equal (t , schemaID1 , pStorage .tableMap [tableID ].SchemaID )
458
467
require .Equal (t , "t1" , pStorage .tableMap [tableID ].Name )
459
468
}
@@ -475,7 +484,6 @@ func TestHandleRenameTable(t *testing.T) {
475
484
require .Equal (t , 2 , len (pStorage .databaseMap ))
476
485
require .Equal (t , 0 , len (pStorage .databaseMap [schemaID1 ].Tables ))
477
486
require .Equal (t , 1 , len (pStorage .databaseMap [schemaID2 ].Tables ))
478
- require .Equal (t , false , pStorage .tableMap [tableID ].InKVSnap )
479
487
require .Equal (t , schemaID2 , pStorage .tableMap [tableID ].SchemaID )
480
488
require .Equal (t , "t2" , pStorage .tableMap [tableID ].Name )
481
489
}
@@ -883,13 +891,11 @@ func TestGC(t *testing.T) {
883
891
884
892
require .Equal (t , 3 , len (pStorage .tableTriggerDDLHistory ))
885
893
require .Equal (t , 3 , len (pStorage .tablesDDLHistory ))
886
- require .Equal (t , false , pStorage .tableMap [tableID3 ].InKVSnap )
887
894
pStorage .cleanObseleteDataInMemory (newGcTs , tablesInKVSnap )
888
895
require .Equal (t , 1 , len (pStorage .tableTriggerDDLHistory ))
889
896
require .Equal (t , uint64 (605 ), pStorage .tableTriggerDDLHistory [0 ])
890
897
require .Equal (t , 1 , len (pStorage .tablesDDLHistory ))
891
898
require .Equal (t , 1 , len (pStorage .tablesDDLHistory [tableID1 ]))
892
- require .Equal (t , true , pStorage .tableMap [tableID3 ].InKVSnap )
893
899
tableInfoT1 , err := pStorage .getTableInfo (tableID1 , newGcTs )
894
900
require .Nil (t , err )
895
901
require .Equal (t , "t1" , tableInfoT1 .Name .O )
@@ -906,7 +912,6 @@ func TestGC(t *testing.T) {
906
912
require .Equal (t , uint64 (605 ), pStorage .tableTriggerDDLHistory [0 ])
907
913
require .Equal (t , 1 , len (pStorage .tablesDDLHistory ))
908
914
require .Equal (t , 1 , len (pStorage .tablesDDLHistory [tableID1 ]))
909
- require .Equal (t , true , pStorage .tableMap [tableID3 ].InKVSnap )
910
915
}
911
916
912
917
// TODO: test obsolete data can be removed
0 commit comments