Repository navigation
Fix wrangler d1 execute performance for local - #15557
Merged
NuroDev merged 4 commits intoSep 8, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: df355ea The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
workers-devprod
requested review from
a team and
NuroDev
and removed request for
a team
September 7, 2026 17:22
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 2 flags
Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
NuroDev
enabled auto-merge (squash)
September 8, 2026 14:00
workers-devprod
approved these changes
Sep 8, 2026
workers-devprod
left a comment
Contributor
There was a problem hiding this comment.
Codeowners reviews satisfied
Merged
mittalpk
added a commit
to mittalpk/workers-sdk
that referenced
this pull request
Sep 17, 2026
isCompoundStatementStart/End used [^A-Za-z0-9_] as the identifier boundary, but SQLite's own unquoted-identifier syntax allows $ and any code point at or above U+0080. An identifier like foo$CASE or ENDα was misread as the BEGIN/CASE/END keyword, corrupting the compound-statement nesting stack for the rest of the file. Extract the boundary into a single SQL_IDENTIFIER_CHAR class shared by both functions so they can't drift out of sync again -- that exact drift (one regex broadened, the other left narrow) is what caused the CASE/END regression this PR already fixes. Precompile both regexes at module scope: isCompoundStatementStart runs on every character of the input in the main split loop, so constructing a new RegExp inside the function would recompile it per character. Adds 2 regression tests. Also resolves the merge conflict with cloudflare#15557's consumeWhile windowing, which touched the same test file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15556.
Root cause
splitSqlIntoStatements()inpackages/wrangler/src/d1/splitter.tsconsumes quoted strings and comments character-by-character viaconsumeWhile()/consumeUntilMarker().Each iteration appends to an ever-growing
strand then evaluates the predicate against the whole accumulated string (e.g.str.endsWith(endMarker)), forcing the JS engine to flatten/copy the growing string on every character — O(n²) in the length of the quoted value or comment.This only bites the local path because remote file execution never runs the client-side splitter.
Measurements
Timing
splitSqlQuery()on a single 256 KB quoted value / a 256 KB--comment: