From b081966f6e481ff4c1db8226487355481ef3fd0e Mon Sep 17 00:00:00 2001 From: Bibek Shrestha Date: Mon, 27 Oct 2025 17:01:30 -0700 Subject: [PATCH] Fix bug when long lines are truncated with extended inserts Signed-off-by: Bibek Shrestha --- pkg/database/mysql/table.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/database/mysql/table.go b/pkg/database/mysql/table.go index 880c1de..104a5e0 100644 --- a/pkg/database/mysql/table.go +++ b/pkg/database/mysql/table.go @@ -325,6 +325,13 @@ func (table *baseTable) Stream() <-chan string { continue } + // Truncate our insert if it won't fit + if insert.Len() != 0 && insert.Len()+b.Len() > table.data.MaxAllowedPacket-1 { + _, _ = insert.WriteString(";") + valueOut <- insert.String() + insert.Reset() + } + if insert.Len() == 0 { _, _ = fmt.Fprint(&insert, strings.Join( // extra "" at the end so we get an extra whitespace as needed @@ -334,13 +341,6 @@ func (table *baseTable) Stream() <-chan string { _, _ = insert.WriteString(",") } - // Truncate our insert if it won't fit - if insert.Len() != 0 && insert.Len()+b.Len() > table.data.MaxAllowedPacket-1 { - _, _ = insert.WriteString(";") - valueOut <- insert.String() - insert.Reset() - } - _, _ = b.WriteTo(&insert) } if insert.Len() != 0 {