diff --git a/query.go b/query.go index 862e842a..835829cc 100644 --- a/query.go +++ b/query.go @@ -196,6 +196,10 @@ func (rows *Rows) nextColumn() (*ValueReader, bool) { return nil, false } + if rows.vr.Len() > 0 { + rows.mr.readBytes(rows.vr.Len()) + } + fd := &rows.fields[rows.columnIdx] rows.columnIdx++ size := rows.mr.readInt32() diff --git a/query_test.go b/query_test.go index e8e6db19..1484fa32 100644 --- a/query_test.go +++ b/query_test.go @@ -786,3 +786,23 @@ func TestQueryRowCoreStringSlice(t *testing.T) { ensureConnValid(t, conn) } + +func TestReadingValueAfterEmptyArray(t *testing.T) { + conn := mustConnect(t, *defaultConnConfig) + defer closeConn(t, conn) + + var a []string + var b int32 + err := conn.QueryRow("select '{}'::text[], 42::integer").Scan(&a, &b) + if err != nil { + t.Fatalf("conn.QueryRow failed: ", err) + } + + if len(a) != 0 { + t.Errorf("Expected 'a' to have length 0, but it was: ", len(a)) + } + + if b != 42 { + t.Errorf("Expected 'b' to 42, but it was: ", b) + } +}