From d5a3430933a36adfbb8d25568cae19b7e3af3813 Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Mon, 8 Jul 2024 07:45:49 -0600 Subject: [PATCH 1/2] Use dbconn.Exec in checkpoint --- pkg/migration/runner.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/migration/runner.go b/pkg/migration/runner.go index 722d63c..fa34204 100644 --- a/pkg/migration/runner.go +++ b/pkg/migration/runner.go @@ -896,10 +896,15 @@ func (r *Runner) dumpCheckpoint(ctx context.Context) error { // We believe this is OK but may change it in the future. Please do not // add any other fields to this log line. r.logger.Infof("checkpoint: low-watermark=%s log-file=%s log-pos=%d rows-copied=%d rows-copied-logical=%d", lowWatermark, binlog.Name, binlog.Pos, copyRows, logicalCopyRows) - query := fmt.Sprintf("INSERT INTO %s (low_watermark, binlog_name, binlog_pos, rows_copied, rows_copied_logical, alter_statement) VALUES (?, ?, ?, ?, ?, ?)", - r.checkpointTable.QuotedName) - _, err = r.db.ExecContext(ctx, query, lowWatermark, binlog.Name, binlog.Pos, copyRows, logicalCopyRows, r.migration.Alter) - return err + return dbconn.Exec(ctx, r.db, "INSERT INTO %n (low_watermark, binlog_name, binlog_pos, rows_copied, rows_copied_logical, alter_statement) VALUES (%?, %?, %?, %?, %?, %?)", + r.checkpointTable.QuotedName, + lowWatermark, + binlog.Name, + binlog.Pos, + copyRows, + logicalCopyRows, + r.migration.Alter, + ) } func (r *Runner) dumpCheckpointContinuously(ctx context.Context) { From 8407c585fad61a7ac4fb8b4ca719c253348750a7 Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Mon, 8 Jul 2024 07:56:21 -0600 Subject: [PATCH 2/2] fix quoted name --- pkg/migration/runner.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/migration/runner.go b/pkg/migration/runner.go index fa34204..13de267 100644 --- a/pkg/migration/runner.go +++ b/pkg/migration/runner.go @@ -896,8 +896,9 @@ func (r *Runner) dumpCheckpoint(ctx context.Context) error { // We believe this is OK but may change it in the future. Please do not // add any other fields to this log line. r.logger.Infof("checkpoint: low-watermark=%s log-file=%s log-pos=%d rows-copied=%d rows-copied-logical=%d", lowWatermark, binlog.Name, binlog.Pos, copyRows, logicalCopyRows) - return dbconn.Exec(ctx, r.db, "INSERT INTO %n (low_watermark, binlog_name, binlog_pos, rows_copied, rows_copied_logical, alter_statement) VALUES (%?, %?, %?, %?, %?, %?)", - r.checkpointTable.QuotedName, + return dbconn.Exec(ctx, r.db, "INSERT INTO %n.%n (low_watermark, binlog_name, binlog_pos, rows_copied, rows_copied_logical, alter_statement) VALUES (%?, %?, %?, %?, %?, %?)", + r.checkpointTable.SchemaName, + r.checkpointTable.TableName, lowWatermark, binlog.Name, binlog.Pos,