Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: benburkert/pq
base: e91b0486fb
...
head fork: benburkert/pq
compare: 391c3224c0
  • 2 commits
  • 2 files changed
  • 1 commit comment
  • 1 contributor
Commits on Apr 07, 2012
@benburkert Send the Termination message when closing a connection.
The Postgresql server expects the client to end the connection by
first sending a Termination message ('X') followed up by closing the
socket. The server logs a "unexpected EOF on client connection" warning
if the socket is closed without the preceding Termination message.
5a88b67
@benburkert Close Rows in tests.
The sql.DB.Close() function only closes connections that are marked as
free. The sql.Rows.Close() function marks the Row's connection as free,
so it must be invoked to cleanly close the DB.
391c322
Showing with 11 additions and 5 deletions.
  1. +2 −0  conn.go
  2. +9 −5 conn_test.go
View
2  conn.go
@@ -200,6 +200,8 @@ func (cn *conn) Prepare(q string) (_ driver.Stmt, err error) {
}
func (cn *conn) Close() error {
+ cn.send(newWriteBuf('X'))
+
return cn.c.Close()
}
View
14 conn_test.go
@@ -67,6 +67,7 @@ func TestStatment(t *testing.T) {
if err != nil {
t.Fatal(err)
}
+ defer r.Close()
if !r.Next() {
t.Fatal("expected row")
@@ -84,19 +85,20 @@ func TestStatment(t *testing.T) {
// st1
- r, err = st1.Query()
+ r1, err := st1.Query()
if err != nil {
t.Fatal(err)
}
+ defer r1.Close()
- if !r.Next() {
+ if !r1.Next() {
if r.Err() != nil {
- t.Fatal(r.Err())
+ t.Fatal(r1.Err())
}
t.Fatal("expected row")
}
- err = r.Scan(&i)
+ err = r1.Scan(&i)
if err != nil {
t.Fatal(err)
}
@@ -282,6 +284,7 @@ func TestErrorOnQuery(t *testing.T) {
if err != nil {
t.Fatal(err)
}
+ defer r.Close()
if r.Next() {
t.Fatal("unexpected row, want error")
@@ -317,10 +320,11 @@ func TestBindError(t *testing.T) {
}
// Should not get error here
- _, err = db.Query("select * from test where i=$1", 1)
+ r, err := db.Query("select * from test where i=$1", 1)
if err != nil {
t.Fatal(err)
}
+ defer r.Close()
}
func TestParseEnviron(t *testing.T) {

Showing you all comments on commits in this comparison.

@bmizerany

Awesome. The send method panics so you'll need to defer errRecover before it. Can you update this commit?

Something went wrong with that request. Please try again.