2
0

Do not double call termContext in QueryEx

QueryEx was calling termContext and rows.fatal on err of sendPreparedQuery.
rows.fatal calls rows.Close which already calls termContext. This sequence of
calls was causing underlying io timeout errors to be returned instead of context
errors.

In addition, added fatalWriteErr helper method to allow recovery of write
timeout errors where no bytes were written.

This should solve flickering errors on Travis.
This commit is contained in:
Jack Christensen
2017-05-20 10:58:44 -05:00
parent b8c043780d
commit 2df4b1406b
2 changed files with 19 additions and 7 deletions
+2 -3
View File
@@ -398,16 +398,15 @@ func (c *Conn) QueryEx(ctx context.Context, sql string, options *QueryExOptions,
err = c.initContext(ctx)
if err != nil {
rows.fatal(err)
return rows, err
return rows, rows.err
}
err = c.sendPreparedQuery(ps, args...)
if err != nil {
rows.fatal(err)
err = c.termContext(err)
}
return rows, err
return rows, rows.err
}
func (c *Conn) sanitizeAndSendSimpleQuery(sql string, args ...interface{}) (err error) {