Skip to content

Commit c95f83a

Browse files
committed
support mysql 8.4
deal with deprecated sql
1 parent 94e8471 commit c95f83a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/main/java/com/zendesk/maxwell/MaxwellMysqlStatus.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ public boolean isMaria() {
3434
}
3535
}
3636

37+
public String getShowBinlogSQL() {
38+
try {
39+
DatabaseMetaData md = connection.getMetaData();
40+
if ( md.getDatabaseMajorVersion() >= 8 ) {
41+
return "SHOW BINARY LOG STATUS";
42+
}
43+
} catch ( SQLException e ) {
44+
}
45+
46+
return "SHOW MASTER STATUS";
47+
}
48+
49+
50+
51+
3752
public String getVariableState(String variableName, boolean throwOnMissing) throws SQLException, MaxwellCompatibilityError {
3853
try ( Statement stmt = connection.createStatement();
3954
ResultSet rs = stmt.executeQuery(sqlStatement(variableName)) ) {

src/main/java/com/zendesk/maxwell/replication/BinlogPosition.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ public BinlogPosition(long l, String file) {
4242
public static BinlogPosition capture(Connection c, boolean gtidMode) throws SQLException {
4343
MaxwellMysqlStatus m = new MaxwellMysqlStatus(c);
4444

45+
46+
47+
4548
try ( Statement stmt = c.createStatement();
46-
ResultSet rs = stmt.executeQuery("SHOW MASTER STATUS") ) {
49+
ResultSet rs = stmt.executeQuery(m.getShowBinlogSQL())) {
4750
rs.next();
4851
long l = rs.getInt(POSITION_COLUMN);
4952
String file = rs.getString(FILE_COLUMN);

0 commit comments

Comments
 (0)