Skip to content

Conversation

@bibstha
Copy link
Contributor

@bibstha bibstha commented Oct 28, 2025

#473 introduced a bug where if we ARE using extended insert (default) and the table is long that the data needs to be truncated, then it wasn't getting truncated properly.

If a single line exceeds the MaxAllowedPacket, the next line should start with INSERT INTO tablename... but it doesn't.

This is what it looks like
Screenshot 2025-10-27 at 5 20 24 PM

But it should instead be like this
Screenshot 2025-10-27 at 5 20 12 PM

I haven't tested this, but looking the old PR's diff, this is how it should be?

_, _ = 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.

Signed-off-by: Bibek Shrestha <bibekshrestha@gmail.com>
@bibstha bibstha force-pushed the bibstha/fix-long-line-export branch from 6e4c4a3 to b081966 Compare October 28, 2025 00:12
@bibstha bibstha changed the title Fix bug when long lines are truncated with extended inserts [URGENT] Fix bug when long lines are truncated with extended inserts Oct 28, 2025
@bibstha
Copy link
Contributor Author

bibstha commented Oct 28, 2025

Pinging @deitch as this will be breaking exports for many people.

@deitch
Copy link
Collaborator

deitch commented Oct 29, 2025

Let's see if I get this. Originally, we assumed we always could do extended insert. So each table's insert was one large:

INSERT INTO table (<fields>) VALUES (...), (...), .... (...);

All of the records, from 1 row to however many are in the table, were after the VALUES. The only limit is the MaxAllowedPacket. Once we hit that, create a new INSERT row, and keep going.

#473 aded support for skip-extended-insert, which means, "do not do a super long INSERT, rather insert each row individually."

I think you are saying that skip-extended-insert works fine, creating a new INSERT INTO... for each row. But in the default case, where we have one long INSERT until we hit MaxAllowedPacket, then we broke it by no longer creating the INSERT INTO for the next inserts?

Copy link
Collaborator

@deitch deitch left a comment

Choose a reason for hiding this comment

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

It would be nice to get a proper test for this. But this is too urgent to hold up. I will kick off CI. If you can think of a sane way to test, please add it.

@deitch deitch merged commit ef94a7f into databacker:master Nov 1, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants