Skip to content

Test that restore accepts a query exactly at --max-query-size - #1491

Closed
Trenyx wants to merge 1 commit into
planetscale:mainfrom
Trenyx:test/loader-max-query-size-bound
Closed

Trenyx wants to merge 1 commit into
planetscale:mainfrom
Trenyx:test/loader-max-query-size-bound

Conversation

@Trenyx

@Trenyx Trenyx commented Oct 26, 2026

Copy link
Copy Markdown

Tests only: one test (+48 lines) in internal/dumper/loader_test.go. No change to library code.

pscale database restore-dump --max-query-size is documented as "the maximum size allowed for each individual query", and the loader rejects a query only when it "is larger than N bytes". So a query of exactly N bytes should restore. No loader test sends a query on the limit, so if the queryBytes <= l.cfg.MaxQuerySize check in restoreTable became <, a dump with a statement of exactly the configured size would fail to restore while every test passed.

TestRestoreTable_QueryAtMaxQuerySize sets MaxQuerySize to the length of one INSERT and checks that restoreTable runs it against the mock MySQL server. It sets a Printer because the over-limit path prints before returning its error.

How it was checked

On a clone of current main (9971335), with this test as the one commit on top (0d07a74):

  • go test -count=1 -v ./internal/dumper/ passes: 27 tests (33 with subtests).
  • With queryBytes < l.cfg.MaxQuerySize in restoreTable, this new test is the only one that fails (query is larger than 27 bytes in size for a 27-byte query). The other 32 pass.
  • gofmt -l and go vet are clean on the package.

This test was written with Claude Code during a planted-bug run by Trenyx.

--max-query-size is the maximum size allowed for each query, but no test
restores a query sitting exactly on the limit. Changing <= to < in
restoreTable would reject it and fail the restore with every test passing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Trenyx
Trenyx requested a review from a team as a code owner October 26, 2026 17:24
@nickvanw

Copy link
Copy Markdown
Contributor

Founder of Trenyx. We plant realistic bugs in your code and check whether your tests catch them. trenyx.io

No thanks.

@nickvanw nickvanw closed this Oct 26, 2026
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