(patternTBS []*common.DataSource, schemaName string, tableName string)
| 1317 | } |
| 1318 | |
| 1319 | func (b *BinlogReader) matchTable(patternTBS []*common.DataSource, schemaName string, tableName string) bool { |
| 1320 | if schemaName == "" { |
| 1321 | return false |
| 1322 | } |
| 1323 | |
| 1324 | for _, pdb := range patternTBS { |
| 1325 | if pdb.TableSchema == "" && pdb.TableSchemaRegex == "" { // invalid pattern |
| 1326 | continue |
| 1327 | } |
| 1328 | if pdb.TableSchema != "" && pdb.TableSchema != schemaName { |
| 1329 | continue |
| 1330 | } |
| 1331 | if pdb.TableSchemaRegex != "" { |
| 1332 | reg := regexp.MustCompile(pdb.TableSchemaRegex) |
| 1333 | if !reg.MatchString(schemaName) { |
| 1334 | continue |
| 1335 | } |
| 1336 | } |
| 1337 | |
| 1338 | if tableName == "" || len(pdb.Tables) == 0 { // match all tables within the db if length of pdb.Tables is 0 |
| 1339 | return true |
| 1340 | } |
| 1341 | |
| 1342 | for _, ptb := range pdb.Tables { |
| 1343 | if ptb.TableName == "" && ptb.TableRegex == "" { // invalid pattern |
| 1344 | continue |
| 1345 | } |
| 1346 | if ptb.TableName != "" && ptb.TableName == tableName { |
| 1347 | return true |
| 1348 | } |
| 1349 | if ptb.TableRegex != "" { |
| 1350 | reg := regexp.MustCompile(ptb.TableRegex) |
| 1351 | if reg.MatchString(tableName) { |
| 1352 | return true |
| 1353 | } |
| 1354 | } |
| 1355 | } |
| 1356 | return false |
| 1357 | } |
| 1358 | return false |
| 1359 | } |
| 1360 | |
| 1361 | func (b *BinlogReader) Close() error { |
| 1362 | b.logger.Debug("BinlogReader.Close") |
no outgoing calls