优化SQL语句输出,修复处理进度中错误的表输入计数器。

This commit is contained in:
2025-01-03 10:17:25 +08:00
parent 27ea80d359
commit d2d7b21620
5 changed files with 14 additions and 11 deletions

View File

@@ -64,7 +64,7 @@ public partial class MySqlDestination : IDisposable, IAsyncDisposable
if (_recordCache.Count == 0)
return;
await using var cmd = _conn.CreateCommand();
var cmd = _conn.CreateCommand();
cmd.CommandTimeout = 0;
try
@@ -108,7 +108,7 @@ public partial class MySqlDestination : IDisposable, IAsyncDisposable
public IEnumerable<string> GetExecutionList(IDictionary<string, IList<DataRecord>> tableRecords, int maxAllowPacket)
{
var sb = new StringBuilder("SET AUTOCOMMIT = 1;\n");
var sb = new StringBuilder(_options.Value.FlushCount * 128);
var appendCount = 0;
foreach (var (tableName, records) in tableRecords)
{
@@ -117,6 +117,7 @@ public partial class MySqlDestination : IDisposable, IAsyncDisposable
var recordIdx = 0;
StartBuild:
sb.AppendLine("SET AUTOCOMMIT = 0;\n");
var noCommas = true;
// 标准列顺序,插入时的字段需要按照该顺序排列
@@ -212,7 +213,7 @@ public partial class MySqlDestination : IDisposable, IAsyncDisposable
TryAddForUpdateSuffix(tableName, sb);
sb.Append(';').AppendLine();
sb.Append("SET AUTOCOMMIT = 1;");
sb.Append("COMMIT;");
yield return sb.ToString();
sb.Clear();
goto StartBuild;