From 9525314208a2ac6f890731bc4dc82b80e6e18fab Mon Sep 17 00:00:00 2001 From: Anton Sergeev Date: Mon, 18 Jul 2022 13:52:36 -0400 Subject: [PATCH 1/2] Added SetTableCache method to set new schema for a table without loading it from the source database. --- canal/canal.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/canal/canal.go b/canal/canal.go index fec6040d8..9e8d795ee 100644 --- a/canal/canal.go +++ b/canal/canal.go @@ -380,6 +380,18 @@ func (c *Canal) ClearTableCache(db []byte, table []byte) { c.tableLock.Unlock() } +// SetTableCache sets table cache value for the given key +func (c *Canal) SetTableCache(db []byte, table []byte, schema *schema.Table) { + key := fmt.Sprintf("%s.%s", db, table) + c.tableLock.Lock() + c.tables[key] = schema + if c.cfg.DiscardNoMetaRowEvent { + // if get table info success, delete this key from errorTablesGetTime + delete(c.errorTablesGetTime, key) + } + c.tableLock.Unlock() +} + // CheckBinlogRowImage checks MySQL binlog row image, must be in FULL, MINIMAL, NOBLOB func (c *Canal) CheckBinlogRowImage(image string) error { // need to check MySQL binlog row image? full, minimal or noblob? From cc2bb58b8898ff4da656a64f8b23af4307720272 Mon Sep 17 00:00:00 2001 From: Anton Sergeev Date: Tue, 19 Jul 2022 10:29:58 -0400 Subject: [PATCH 2/2] Fixing comment --- canal/canal.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/canal/canal.go b/canal/canal.go index 9e8d795ee..4784fe4b2 100644 --- a/canal/canal.go +++ b/canal/canal.go @@ -380,7 +380,7 @@ func (c *Canal) ClearTableCache(db []byte, table []byte) { c.tableLock.Unlock() } -// SetTableCache sets table cache value for the given key +// SetTableCache sets table cache value for the given table func (c *Canal) SetTableCache(db []byte, table []byte, schema *schema.Table) { key := fmt.Sprintf("%s.%s", db, table) c.tableLock.Lock()