Skip to content

Commit d2abc39

Browse files
author
Guillem
committed
fix canal.GetMasterPos() for mariadb
1 parent 8f53f5c commit d2abc39

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

canal/sync.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,21 @@ func (c *Canal) WaitUntilPos(pos mysql.Position, timeout time.Duration) error {
325325
}
326326

327327
func (c *Canal) GetMasterPos() (mysql.Position, error) {
328-
showBinlogStatus := "SHOW BINARY LOG STATUS"
329-
if eq, err := c.conn.CompareServerVersion("8.4.0"); (err == nil) && (eq < 0) {
330-
showBinlogStatus = "SHOW MASTER STATUS"
328+
query := "SHOW BINARY LOG STATUS"
329+
switch c.cfg.Flavor {
330+
case mysql.MariaDBFlavor:
331+
query = "SHOW BINLOG STATUS"
332+
333+
if eq, err := c.conn.CompareServerVersion("10.5.2"); (err == nil) && (eq < 0) {
334+
query = "SHOW MASTER STATUS"
335+
}
336+
case mysql.MySQLFlavor:
337+
if eq, err := c.conn.CompareServerVersion("8.4.0"); (err == nil) && (eq < 0) {
338+
query = "SHOW MASTER STATUS"
339+
}
331340
}
332341

333-
rr, err := c.Execute(showBinlogStatus)
342+
rr, err := c.Execute(query)
334343
if err != nil {
335344
return mysql.Position{}, errors.Trace(err)
336345
}

0 commit comments

Comments
 (0)