Repository navigation
fix: allow output parameters on prepared statements - #1789
Conversation
`connection.prepare()` attached a `returnValue` listener to the request to pick up the prepared statement's handle from `sp_prepare`, and never removed it. Besides adding another listener on every `prepare()`, the listener treated the output parameters of every later execution as unexpected output parameters of `sp_prepare`, and failed the execution with "Unexpected output parameter ... from sp_prepare" - so prepared statements with output parameters did not work at all. The `RequestTokenHandler` now stores the handle while the request is being prepared, so no listener is needed. The `returnValue` event for the handle is still emitted, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HGJsu1u44CHnt4nkkQ5ias
ReviewNice, focused fix — the root cause (the Code quality
Correctness
Test coverage
Security / performance: no concerns — this is a straightforward memory-leak/correctness fix with no new attack surface, and it removes an unbounded per- Overall this looks correct and well-tested. No blocking issues from my side. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1789 +/- ##
==========================================
+ Coverage 81.48% 82.49% +1.00%
==========================================
Files 95 95
Lines 4862 4862
Branches 913 914 +1
==========================================
+ Hits 3962 4011 +49
+ Misses 631 575 -56
- Partials 269 276 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
🎉 This PR is included in version 20.3.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Master now contains the push parser (#1794) that this branch was built on, and the fixes for output parameters of prepared statements (#1789) and for executing a request again after it was canceled (#1790), which this branch had earlier versions of. The branch's versions of the parser files are kept (they extend the merged parser), with the `process.nextTick` fix from #1794. `Request.callback` only resets `canceled` before calling back, like on master: resetting it afterwards would also clear the cancellation of an execution that was started from the callback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HGJsu1u44CHnt4nkkQ5ias
connection.prepare()adds areturnValuelistener to the request to pick up the handle thatsp_preparereturns, and never removes it (see theTODOit carried). This causes two problems:execute(). It treats each output parameter as an unexpected output parameter ofsp_prepare, so the execution fails withTedious > Unexpected output parameter out from sp_prepare.prepare()of the same request adds another listener.Changes
RequestTokenHandler.onReturnValuenow stores the handle itself while the request is preparing, and reports unexpected output parameters ofsp_preparethe same way as before.connection.prepare()no longer adds a listener.returnValueevent forhandleis still emitted, so existing listeners keep working.Tests
New integration tests in
test/integration/prepare-execute-statements-test.ts:Unexpected output parameter out from sp_prepare.returnValuelisteners when preparing a request fails on master withexpected 3 to equal +0.Checks
npm run lint(eslint andtsc)npm run buildInitiate Connect Test, which also fails on master in the local test environment.🤖 Generated with Claude Code
https://claude.ai/code/session_01HGJsu1u44CHnt4nkkQ5ias
Generated by Claude Code