Skip to content

Commit 93eceb8

Browse files
committed
Don't cancel finished queries with spooling
When using spooling, wait up to 100ms to see if there's any more data to process. If there are no more query results, the query does not need to be cancelled.
1 parent fd5d591 commit 93eceb8

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

trino/trino.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,8 +1515,24 @@ func (qr *driverRows) Close() error {
15151515
return nil
15161516
}
15171517
qr.err = io.EOF
1518-
if !qr.stmt.usingSpooledProtocol && qr.nextURI == "" {
1519-
return qr.err
1518+
if !qr.stmt.usingSpooledProtocol {
1519+
err := qr.fetch()
1520+
if err != nil && err != io.EOF {
1521+
return err
1522+
}
1523+
if qr.nextURI == "" {
1524+
return nil
1525+
}
1526+
} else {
1527+
select {
1528+
case _, ok := <-qr.stmt.spoolingRowsChannel:
1529+
if !ok {
1530+
// channel is closed, all data has been consumed
1531+
return nil
1532+
}
1533+
case <-time.NewTimer(100 * time.Millisecond).C:
1534+
// no data is ready
1535+
}
15201536
}
15211537
hs := make(http.Header)
15221538
if qr.stmt.user != "" {

0 commit comments

Comments
 (0)