mirror of https://github.com/jackc/pgx.git
connect_timeout given in conn string was not obeyed if sslmode is not specified (default is prefer) or equals sslmode=allow|prefer. It took twice the amount of time specified by connect_timeout in conn string. While this behavior is correct if multi-host is provided in conn string, it doesn't look correct in case of single host. This behavior was also not matching with libpq. The root cause was to implement sslmode=allow|prefer conn are tried twice. First with TLSConfig and if that doesn't work then without TLSConfig. The fix for this issue now uses the same context if same host is being tried out. This change won't affect the existing multi-host behavior. This PR goal is to close issue [jackc/pgx/issues/1672](https://github.com/jackc/pgx/issues/1672) |
||
---|---|---|
.. | ||
internal | ||
README.md | ||
auth_scram.go | ||
benchmark_private_test.go | ||
benchmark_test.go | ||
config.go | ||
config_test.go | ||
defaults.go | ||
defaults_windows.go | ||
doc.go | ||
errors.go | ||
errors_test.go | ||
export_test.go | ||
helper_test.go | ||
krb5.go | ||
pgconn.go | ||
pgconn_private_test.go | ||
pgconn_stress_test.go | ||
pgconn_test.go |
README.md
pgconn
Package pgconn is a low-level PostgreSQL database driver. It operates at nearly the same level as the C library libpq. It is primarily intended to serve as the foundation for higher level libraries such as https://github.com/jackc/pgx. Applications should handle normal queries with a higher level library and only use pgconn directly when required for low-level access to PostgreSQL functionality.
Example Usage
pgConn, err := pgconn.Connect(context.Background(), os.Getenv("DATABASE_URL"))
if err != nil {
log.Fatalln("pgconn failed to connect:", err)
}
defer pgConn.Close(context.Background())
result := pgConn.ExecParams(context.Background(), "SELECT email FROM users WHERE id=$1", [][]byte{[]byte("123")}, nil, nil, nil)
for result.NextRow() {
fmt.Println("User 123 has email:", string(result.Values()[0]))
}
_, err = result.Close()
if err != nil {
log.Fatalln("failed reading result:", err)
}
Testing
See CONTRIBUTING.md for setup instructions.