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.