-
Notifications
You must be signed in to change notification settings - Fork 817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No field name in TABLE_MAP_EVENT? #24
Comments
Hi Jian, What do you mean by "field name"? It's not possible to "regenerate the SQL from WRITE_ROWS,UPDATE_ROWS,DELETE_ROWS". If you need to know original SQL you must either use SBR (binlog_format=STATEMENT) or turn on binlog_rows_query_log_events (available starting from MySQL 5.6.2). In case of the latter you would also have to add custom RowsQuery event data deserializer. |
Fields (SQL columns) are referenced by position within the table and not name. CREATE TABLE a ( b BIGINT, c VARCHAR(64) ); This will create a write row event for table a and it will contain the columns 0 and 1. (I'm not sure if it's 0 or 1 based atm). To reconstruct field names you'd have to get the schema of the master first. |
Thanks, Rene. Jian, to get the list of columns you could use something similar to: Connection connection = ...
DatabaseMetaData metaData = connection.getMetaData();
ResultSet tableResultSet = metaData.getTables(null, "public", null, new String[]{"TABLE"});
try {
while (tableResultSet.next()) {
String tableName = tableResultSet.getString("TABLE_NAME");
ResultSet columnResultSet = metaData.getColumns(null, "public", tableName, null);
try {
while (columnResultSet.next()) {
String columnName = columnResultSet.getString("COLUMN_NAME");
...
}
} finally {
columnResultSet.close();
}
}
} finally {
tableResultSet.close();
} |
Thanks guys. That helps me a lot. now i get understand. |
this dosen't work when mysql-binlog-connector-java have a large lag, because mysql binlog is old, but metadata is latest |
Hi.
This is not a problem about 'mysql-binlog-connector-java'.
I just find out that there is no field name in TableMapEventData. how can i regenerate the SQL from WRITE_ROWS,UPDATE_ROWS,DELETE_ROWS.or there is other method to update slave mysql database?
Thanks for help.
The text was updated successfully, but these errors were encountered: