Skip to content

Commit fcd0998

Browse files
committed
add comments with references
1 parent f630c48 commit fcd0998

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

embulk-output-mysql/src/main/java/org/embulk/output/mysql/MySQLOutputConnection.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ private String buildSwapTableSql(TableIdentifier fromTable, TableIdentifier toTa
107107
{
108108
String suffix = "_embulk_swap_tmp";
109109
String uniqueName = String.format("%016x", System.currentTimeMillis()) + suffix;
110+
// NOTE: The table name should be always shorter than 64 characters
111+
// See also: https://dev.mysql.com/doc/refman/8.0/en/identifier-length.html
110112
TableIdentifier tmpTable = new TableIdentifier(fromTable.getDatabase(), fromTable.getSchemaName(), uniqueName);
111113

112114
StringBuilder sb = new StringBuilder();
@@ -133,6 +135,8 @@ public void replaceTable(TableIdentifier fromTable, JdbcSchema schema, TableIden
133135
{
134136
Statement stmt = connection.createStatement();
135137
try {
138+
// "DROP TABLE" causes an implicit commit in MySQL, so we rename the table at first.
139+
// See also: https://dev.mysql.com/doc/refman/8.0/en/implicit-commit.html
136140
executeUpdate(stmt, buildSwapTableSql(fromTable, toTable));
137141

138142
dropTableIfExists(stmt, fromTable);

0 commit comments

Comments
 (0)