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 {