-
Notifications
You must be signed in to change notification settings - Fork 18k
database/sql: ColumnConverter is bypassed when NumInput returns -1 #68342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Change https://go.dev/cl/597115 mentions this issue: |
@bradfitz @kardianos per owners. |
Thanks for sending a CL -- |
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
Is there anything I can do to help move this forward? It's tagged as needs investigation, but I'm unsure what investigation is needed. If that can be clarified, I'm happy to do some legwork and report back. |
I'm concerned that passing // The column converter shouldn't be called on any index
// it isn't expecting. The final error will be thrown
// in the argument converter loop. Is there some reason to think that any arbitrary column converter will support Could your proxy return |
I don't believe it will ever pass -1 to ColumnConverter. The argument passed is
That does not solve the problem, because when NumInput() returns -1, the ColumnConverter is never even called, so that error isn't ever received for consideration. |
Oh, right. Thanks. The CL has picked up a merge conflict somewhere. |
CL updated to resolve conflicts. |
Go version
go version go1.22.0 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I wrote a
database/sql
driver that implements the optionalColumnConverter
interface for prepared statements, and for whichNumInputs()
returns -1.Technically, I wrote a
databse/sql
proxy driver, for the purpose of adding hooks to DB operations, to aide in debugging. See https://gitlab.com/flimzy/errsqlBut using this library with
modernc.org/sqlite
is what triggered the buggy behavior.modernc.org/sqlite
itself does not implement theColumnConverter
interface, but it does return -1 forNumInputs
. Because the proxy driver does implementColumnConverter
(because it must implement it for all drivers it proxies, or none), it triggers the observed behavior.What did you see happen?
The
ColumnConverter
method is never called, leading to the following error from sqlite:What did you expect to see?
I expected that
ColumnConverter
would be called.Analysis & Possible Fix
This line appears to be the culprit:
c.want
is set to the return value fromstmt.NumInputs()
, so is-1
in this case. The method containing this code is only executed whenColumnConverter
is implemented, as we can see here.I believe the solution is to change the above mentioned line to:
The text was updated successfully, but these errors were encountered: