PostgreSQL has microsecond precision. If more than this precision is
supplied in the text format it is rounded. This was inconsistent with
the binary format.
See https://github.com/jackc/pgx/issues/699 for original issue.
This is a big improvement because it can directly link to the v4 docs
instead of the pre-modules v3. The badge should be changed once the new
pkg.go.dev badge is available.
ParseConfig currently treats the libpq "verify-ca" SSL mode as
"verify-full". This is okay from a security standpoint because
"verify-full" performs certificate verification and hostname
verification, whereas "verify-ca" only performs certificate
verification.
The downside to this approach is that checking the hostname is
unnecessary when the server's certificate has been signed by a private
CA. It can also cause the SSL handshake to fail when connecting to an
instance by IP. For example, a Google Cloud SQL instance typically
doesn't have a hostname and uses its own private CA to sign its
server and client certs.
This change uses the tls.Config.VerifyPeerCertificate function to
perform certificate verification without checking the hostname when the
"verify-ca" SSL mode is set. This brings pgconn's behavior closer to
that of libpq.
See https://github.com/golang/go/issues/21971#issuecomment-332693931
and https://pkg.go.dev/crypto/tls?tab=doc#example-Config-VerifyPeerCertificate
for more details on how this is implemented.
Previously Set would always return an error when called on a range type.
Now it will accept an instance of itself, a pointer to an instance of
itself, a string, or nil. Strings are parsed with the same logic as
DecodeText.
This makes the API slightly easier to use when number of calls to
Queue() cannot be trivially computed.
For example, if the program contains the loop like the following,
a separate variable counting the iterations is needed:
numHeaders := 0
for _, header := range prepareHeadersForInsert(*res.Headers) {
headerBatch.Queue("INSERT ...", ...)
numHeaders++
}
headerBatchResult := tx.SendBatch(ctx, headerBatch)
for i := 0; i < numHeaders; i++ {
_, err := headerBatchResult.Exec()
// ...
}
With method Len(), this extra variable can be eliminated.
Methods defined on T are also available on *T. Thought this technically
changes the interface, because *T will be automatically dereferenced as
needed it shouldn't be a breaking change.
See a8802b16cc593842f5c69b0f7cfb0de11d5cd3a8 for similar change.
In case of an error it was possible for the goroutine that builds the
copy stream to still be running after CopyFrom returned. Since that
goroutine uses the connections ConnInfo data types to encode the copy
data it was possible for those types to be concurrently used in an
unsafe fashion.
CopyFrom will no longer return until that goroutine has completed.
If a connection is in a transaction or has an open result set then
close the connection when returning it to database/sql. When next
database/sql attempts to use it the connection will return
driver.ErrBadConn and database/sql will remove it from the pool.
fixes#673