zeroshade commented on code in PR #828:
URL: https://github.com/apache/arrow-adbc/pull/828#discussion_r1237191815
##########
go/adbc/driver/snowflake/driver.go:
##########
@@ -162,7 +162,11 @@ func errToAdbcErr(code adbc.Status, err error) error {
if errors.As(err, &sferr) {
var sqlstate [5]byte
if len(sferr.SQLState) > 0 {
- copy(sqlstate[:], sferr.SQLState[:5])
+ if len(sferr.SQLState) <= 5 {
+ copy(sqlstate[:], sferr.SQLState)
+ } else {
+ copy(sqlstate[:], sferr.SQLState[:5])
Review Comment:
I found this because if `len(sferr.SQLState) < 5` the slicing will actually
panic.
Currently and we can't just embed the sqlstate if the error message is
longer than 5 because the `AdbcError` struct defines `sqlstate` to be a
`char[5]` in the header file. That said, now that I think about it, the
semantics of `copy` should only copy as much as the destination will allow, so
we can probably do this without the slicing here and `copy` will automatically
truncate for us since the destination is a `[5]byte`. I'll update this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]