Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pkg/database/mysql/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how things were in https://github.com/databacker/mysql-backup/pull/473/files#diff-70e106267ef4a71652c95e6eee62fa5d5c435cbb66d47f1afb4474b8fdcb30fd
And logically it makes sense. We should first truncate and then check if "INSERT" should be added or not.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a misplaced section? Ouch.


if insert.Len() == 0 {
_, _ = fmt.Fprint(&insert, strings.Join(
// extra "" at the end so we get an extra whitespace as needed
Expand All @@ -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 {
Expand Down