Fix connection corruption when errored query closes early

refs #125
pull/126/head
Jack Christensen 2016-03-15 19:20:03 -05:00
parent d88242b0ca
commit 49b3582977
3 changed files with 21 additions and 0 deletions

View File

@ -5,6 +5,7 @@
* Fix unrecognized commit failure
* Fix msgReader.rxMsg bug when msgReader already has error
* Go float64 can no longer be encoded to a PostgreSQL float4
* Fix connection corruption when query with error is closed early
## Features

View File

@ -101,6 +101,11 @@ func (rows *Rows) readUntilReadyForQuery() {
case dataRow:
case commandComplete:
case bindComplete:
case errorResponse:
err = rows.conn.rxErrorResponse(r)
if rows.err == nil {
rows.err = err
}
default:
err = rows.conn.processContextFreeMsg(t, r)
if err != nil {

View File

@ -135,6 +135,21 @@ func TestConnQueryCloseEarly(t *testing.T) {
ensureConnValid(t, conn)
}
func TestConnQueryCloseEarlyWithErrorOnWire(t *testing.T) {
t.Parallel()
conn := mustConnect(t, *defaultConnConfig)
defer closeConn(t, conn)
rows, err := conn.Query("select 1/0")
if err != nil {
t.Fatalf("conn.Query failed: %v", err)
}
rows.Close()
ensureConnValid(t, conn)
}
// Test that a connection stays valid when query results read incorrectly
func TestConnQueryReadWrongTypeError(t *testing.T) {
t.Parallel()