Repository navigation
Conversation
NewStmt runs an unanchored regex with `.*` on every non-PL/SQL statement, and without a statement cache it runs on every query. The regex can only match text containing both INTO and RETURN, so a substring pre-check skips it for the common case with no behavior change. NewStmt for a 29-column SELECT drops from ~13.6us to ~1.5us. Fixes sijms#789 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 #789
What
NewStmtruns(\bRETURNING\b|\bRETURN\b)\s+.*\s+\bINTO\bon every non-PL/SQL statement. Without a statement cache this happens on every query. The regex can only match text that contains bothINTOandRETURN, so astrings.Containspre-check now skips it in the common case.Applied to both
v2/command.goandv3/command.go. Behavior is unchanged: both checks run on the same upper-caseduCmdText, andRETURNINGcontainsRETURN.Tests
newstmt_test.go(in v2 and v3) adds:TestNewStmtReturnClause: 7 cases (UPDATE/DELETE ... RETURNING/RETURN ... INTO, lower-case SQL,INSERT ... SELECT,INSERT ... VALUES, string literal containingRETURNING x INTO y). It passes onmasterbefore and after this change.BenchmarkNewStmtSelect29ColsBenchmark
go1.26.3, darwin/arm64,
-benchtime 2s -count 3:Note
Several existing
_test.gofiles onmasterdo not compile (v2:result_set_test.go,parameter_encode_test.go,utils_test.go; v3: same three plusbulkcopy_test.go), so I ran the new test with those files moved aside locally. They are not touched in this PR. Happy to fix them in a separate PR.🤖 Generated with Claude Code