v1.11.0
This version of pq requires Go 1.21 or newer.
pq now supports only maintained PostgreSQL releases, which is PostgreSQL 14 and newer. Previously PostgreSQL 8.4 and newer were supported.
Features
-
The
pq.Error.Error()text includes the position of the error (if reported by PostgreSQL) and SQLSTATE code (#1219, #1224):pq: column "columndoesntexist" does not exist at column 8 (42703) pq: syntax error at or near ")" at position 2:71 (42601) -
The
pq.Error.ErrorWithDetail()method prints a more detailed multiline message, with the Detail, Hint, and error position (if any) (#1219):ERROR: syntax error at or near ")" (42601) CONTEXT: line 12, column 1: 10 | name varchar, 11 | version varchar, 12 | ); ^ -
Add
Config,NewConfig(), andNewConnectorConfig()to supply connection details in a more structured way (#1240). -
Support
hostaddrand$PGHOSTADDR(#1243). -
Support multiple values in
host,port, andhostaddr, which are each tried in order, or randomly ifload_balance_hosts=randomis set (#1246). -
Support
target_session_attrsconnection parameter (#1246). -
Support
sslnegotiationto use SSL without negotiation (#1180). -
Allow using a custom
tls.Config, for example for encrypted keys (#1228). -
Add
PQGO_DEBUG=1print the communication with PostgreSQL to stderr, to aid in debugging, testing, and bug reports (#1223).
Fixes
-
Match HOME directory lookup logic with libpq: prefer $HOME over /etc/passwd, ignore ENOTDIR errors, and use APPDATA on Windows (#1214).
-
Fix
sslmode=verify-caverifying the hostname anyway when connecting to a DNS name (rather than IP) (#1226). -
Correctly detect pre-protocol errors such as the server not being able to fork or running out of memory (#1248).
-
Fix build with wasm (#1184), appengine (#745), and Plan 9 (#1133).
-
Deprecate and type alias
pq.NullTimetosql.NullTime(#1211). -
Enforce integer limits of the Postgres wire protocol (#1161).