lib/pq — pull request #244 by myitcv (2014-03-13 13:52:22+00:00)
Title: Fix handling of auth errors

Authentication errors previously returned a rather cryptic message:

```go
package main

import (
"database/sql"
_ "github.com/lib/pq"
"log"
)

func main() {
db, err := sql.Open("postgres", "postgres://myitcv:@localhost/myitcv")
if err != nil {
log.Fatal(err)
}

err = db.Ping()
if err != nil {
log.Fatal(err)
}
}
```

previously returned:

```
driver: bad connection
```

This PR fixes that such that the output is:

```
pq: password authentication failed for user "myitcv"
```

Test updated to cover this change.

Note that `conn_test.go` only covers the [`AuthenticationMD5Password` case of the auth switch](https://github.com/myitcv/pq/blob/8da4eb273c1b00983fdbd1a6b41a9d44350c4a0c/conn.go#L803). This PR does not attempt to increase coverage.

Indeed I'm at something of a loss to explain why this branch is even hit given the configuration in [`.travis.yml`](https://github.com/myitcv/pq/blob/master/.travis.yml) for `pg_hba.conf` - is MD5 something of a default?

Hence the `AuthenticationCleartextPassword` case remains untested.... because I can't work out how to test the other case.