trino-go-client: Panic: runtime error: index out of range in driverRows.Next
I’m hitting a panic that I reproduce pretty well, but not always, it sometimes panics and sometimes doesn’t.
I’m using a pretty simple query: SELECT 1, NULL, 'abc'", but I’m not sure if it’s relevant.
The relevant part of the backtrace:
panic: runtime error: index out of range [1] with length 1
goroutine 125 [running]:
github.com/trinodb/trino-go-client/trino.(*driverRows).Next(0x14000708160, {0x140000aa3f0, 0x9, 0x10667fbb0?})
/Users/thomas/go/pkg/mod/github.com/trinodb/trino-go-client@v0.308.0/trino/trino.go:1028 +0x2a0
After that it’s my code calling trino.driverRows.Next directly.
Code where the panic happens: https://github.com/trinodb/trino-go-client/blob/565ca64bac1a1fc78d2413736a4abf6d9d38e85c/trino/trino.go#L1028
This is the state of trino.driverRows:
// First call to trino.driverRows.Next (Ok):
&{
ctx:0x14000117980
stmt:0x140001153e0
queryID:20230104_135631_01766_ysbyr
nextURI:https://localhost:8443/v1/statement/queued/20230104_135631_01766_ysbyr/y235c9529065f1ef1da71af639ccea62d7e95fe9e/1
err:<nil>
rowindex:0
columns:[_col0 _col1 _col2]
coltype:[0x140001a67e0 0x140001a68c0 0x140001a6930]
data:[[1 <nil> abc]]
rowsAffected:0
statsCh:<nil>
doneCh:0x1400056e360
}
// Second call (panics):
&{
ctx:0x14000117980
stmt:0x140001153e0
queryID:20230104_135631_01766_ysbyr
nextURI:https://localhost:8443/v1/statement/queued/20230104_135631_01766_ysbyr/y235c9529065f1ef1da71af639ccea62d7e95fe9e/1
err:<nil>
rowindex:1
columns:[_col0 _col1 _col2]
coltype:[0x140001a67e0 0x140001a68c0 0x140001a6930]
data:[[1 <nil> abc]]
rowsAffected:0
statsCh:<nil>
doneCh:0x1400056e360
}
I think the following line is incorrect: https://github.com/trinodb/trino-go-client/blob/565ca64bac1a1fc78d2413736a4abf6d9d38e85c/trino/trino.go#L1010
I think
>= should be changed to > since indexing is zero based.But what I can’t figure out why the current code works sometimes, but panics in the next test run… Incorrect.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (7 by maintainers)
@nineinchnick I didn’t quite follow all the changes you were suggestion so I tried my approach first and it seems to work, see https://github.com/trinodb/trino-go-client/pull/66. If you still prefer your approach I can make the changes, let me know.
Definitely yes, there should be an actionable error message returned in this case. Would you like to give it a shot and open a PR?