This programm worked last time it was tested (aprox 5 weeks ago )
package main
import (
"database/sql"
"fmt"
"time"
)
const connectString string = "user=postgres password=changed dbname=Rhedile sslmode=disable host=localhost"
var debug bool = true
var resultSet = make(map[string]*result)
type result struct {
fnr int
fname string
}
func main() {
rhediledb, err := sql.Open("postgres", connectString )
if err != nil {
//panic (err)
if debug {fmt.Println("sql.Open failed", err)}
}
if debug {fmt.Println("sql.Open returns no err", rhediledb)}
defer rhediledb.Close()
rows, qerr := rhediledb.Query("SELECT 'fnr','fname' FROM firmen limit 10")
//time.Sleep(10 * 1e9)
if qerr != nil {
if debug {fmt.Println("dbQuery failed", qerr)}
}
if debug {fmt.Println("select returned rows", rows)}
time.Sleep(10 * 1e9)
}
It returns this:
nigel@fossil:~/go$ go run testpsql.go
sql.Open returns no err &{0x18700218 user=postgres password=changed dbname=Rhedile sslmode=disable host=localhost {0 0} [] false}
select returned rows &{0x1872f150 0x18744410 0x18730c00 0x187004d0 false [] <nil> 0x1872ec80}
nigel@fossil:~/go$
This is incorrect, it should produce 10 rows or an error... it does neither.
The database records this:
2013-04-18 11:36:25 CEST LOG: connection received: host=127.0.0.1 port=60805
2013-04-18 11:36:25 CEST LOG: connection authorized: user=postgres database=Rhedile
2013-04-18 11:36:35 CEST LOG: unexpected EOF on client connection
2013-04-18 11:36:35 CEST LOG: disconnection: session time: 0:00:10.003 user=postgres database=Rhedile host=127.0.0.1 port=60805
Something is generating a io.EOF
It doesn't appear to be an elapsed time problem or a connection timeout.
ubuntu 12.04 , go from apt-get reports v1, postgres 9.1.9
Any pointers in the right direction, be they subtle or savage would be gratefully received,
Nigel Vickers