Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: do not flush tables when dumping an empty database (#2460)

Yilong Li47c907bc2937
diff --git a/plugin/db/mysql/dump.go b/plugin/db/mysql/dump.go
index ebcbd89e57..95f95d303f 100644
--- a/plugin/db/mysql/dump.go
+++ b/plugin/db/mysql/dump.go
@@ -164,10 +164,12 @@ func FlushTablesWithReadLock(ctx context.Context, conn *sql.Conn, database strin
}
tableNames = append(tableNames, fmt.Sprintf("`%s`", table.Name))
}
- flushTableStmt := fmt.Sprintf("FLUSH TABLES %s WITH READ LOCK;", strings.Join(tableNames, ", "))
- if _, err := txn.ExecContext(ctxWithTimeout, flushTableStmt); err != nil {
- return err
+ if len(tableNames) != 0 {
+ flushTableStmt := fmt.Sprintf("FLUSH TABLES %s WITH READ LOCK;", strings.Join(tableNames, ", "))
+ if _, err := txn.ExecContext(ctxWithTimeout, flushTableStmt); err != nil {
+ return err
+ }
}
return txn.Commit()