Skip to content

Commit db9a729

Browse files
author
Guillem
committed
add getShowBinaryLogQuery
1 parent d2abc39 commit db9a729

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

canal/sync.go

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

327-
func (c *Canal) GetMasterPos() (mysql.Position, error) {
328-
query := "SHOW BINARY LOG STATUS"
327+
func (c *Canal) getShowBinaryLogQuery() string {
329328
switch c.cfg.Flavor {
330329
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"
330+
// Source: https://mariadb.com/kb/en/show-binlog-status/#:~:text=SHOW%20BINLOG%20STATUS%20%2D%2D-,From%20MariaDB%2010.5.2,-Description
331+
if eq, err := c.conn.CompareServerVersion("10.5.2"); (err == nil) && (eq >= 0) {
332+
return "SHOW BINLOG STATUS"
335333
}
336334
case mysql.MySQLFlavor:
337-
if eq, err := c.conn.CompareServerVersion("8.4.0"); (err == nil) && (eq < 0) {
338-
query = "SHOW MASTER STATUS"
335+
// Source: https://dev.mysql.com/doc/relnotes/mysql/8.4/en/news-8-4-0.html#:~:text=AND%20GTIDS)%3B-,SHOW%20MASTER%20STATUS,-(SHOW%20BINARY
336+
if eq, err := c.conn.CompareServerVersion("8.4.0"); (err == nil) && (eq >= 0) {
337+
return "SHOW BINARY LOG STATUS"
339338
}
340339
}
341340

341+
return "SHOW MASTER STATUS"
342+
}
343+
344+
func (c *Canal) GetMasterPos() (mysql.Position, error) {
345+
query := c.getShowBinaryLogQuery()
346+
342347
rr, err := c.Execute(query)
343348
if err != nil {
344349
return mysql.Position{}, errors.Trace(err)

0 commit comments

Comments
 (0)