Skip to content

Commit 9525314

Browse files
author
Anton Sergeev
committed
Added SetTableCache method to set new schema for a table without loading it from the source database.
1 parent c855c26 commit 9525314

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

canal/canal.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,18 @@ func (c *Canal) ClearTableCache(db []byte, table []byte) {
380380
c.tableLock.Unlock()
381381
}
382382

383+
// SetTableCache sets table cache value for the given key
384+
func (c *Canal) SetTableCache(db []byte, table []byte, schema *schema.Table) {
385+
key := fmt.Sprintf("%s.%s", db, table)
386+
c.tableLock.Lock()
387+
c.tables[key] = schema
388+
if c.cfg.DiscardNoMetaRowEvent {
389+
// if get table info success, delete this key from errorTablesGetTime
390+
delete(c.errorTablesGetTime, key)
391+
}
392+
c.tableLock.Unlock()
393+
}
394+
383395
// CheckBinlogRowImage checks MySQL binlog row image, must be in FULL, MINIMAL, NOBLOB
384396
func (c *Canal) CheckBinlogRowImage(image string) error {
385397
// need to check MySQL binlog row image? full, minimal or noblob?

0 commit comments

Comments
 (0)