2734 Commits

Author SHA1 Message Date
Jack Christensen
11d9f4e54f Update golang.org/x/crypto for security fix 2020-03-30 11:09:29 -05:00
Jack Christensen
d3d80cd2de Merge branch 'rwelin-rw_format' 2020-03-27 16:10:54 -05:00
Jack Christensen
65bb544ba9 Merge branch 'rw_format' of git://github.com/rwelin/pgtype into rwelin-rw_format 2020-03-27 16:10:37 -05:00
Jack Christensen
75f79ebc0f Merge branch 'anicoll-microsecond_accuracy' 2020-03-27 16:03:14 -05:00
Jack Christensen
523cdad66f Truncate nanoseconds in EncodeText for Timestamptz and Timestamp
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.
2020-03-27 15:59:54 -05:00
Robert Welin
43bf713180 Use correct format verb for unknown type error 2020-03-27 13:20:33 +00:00
Andrew Nicoll
816e95d3ee sanatize time to within microsecond accuracy 2020-03-27 13:03:36 +00:00
Jack Christensen
af03592c0f Merge branch 'treebeardcpu-patch-2' 2020-03-25 20:26:13 -05:00
Jack Christensen
fef3ffc391 Link to pkg.go.dev instead of godoc.org
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.
2020-03-25 20:24:20 -05:00
Jack Christensen
1dc45f1fa0 README.md tweaks 2020-03-25 20:23:04 -05:00
treebeardcpu
7ca7515087
README: improve flow and readability
Some grammatical changes, some formatting, some new text.
pgx is an excellent driver and deserves an excellent README :)
2020-03-25 19:59:24 -04:00
Jack Christensen
87c8ddd0d1
Merge pull request #32 from gcurtis/verify-ca
Implement "verify-ca" SSL mode
2020-03-21 11:13:55 -05:00
Jack Christensen
844dccf412
Merge pull request #692 from basvanbeek/early_bail
bail early if preloading rows.Next() results in rows.Err()
2020-03-21 10:58:16 -05:00
Jack Christensen
ed50e535c7 Update example readme 2020-03-19 20:50:11 -05:00
Greg Curtis
4ed48d05d2 Implement "verify-ca" SSL mode
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.
2020-03-17 23:36:06 -07:00
Bas van Beek
e75d315079 bail early if preloading rows.Next() results in rows.Err() 2020-03-17 19:50:23 +01:00
Jack Christensen
9e700ff067 Date.Set parses string 2020-03-09 10:40:40 -05:00
Jack Christensen
576f99a35e Release v4.5.0 v4.5.0 2020-03-07 13:32:17 -06:00
Jack Christensen
95907c29ce Update pgconn and pull in fix for QueryRow with empty SQL 2020-03-07 13:27:01 -06:00
Jack Christensen
ccf634cf2e Release 1.4.0 2020-03-07 13:21:51 -06:00
Jack Christensen
cfbd2519e3 Add PGSERVICE and PGSERVICEFILE support 2020-03-07 13:17:39 -06:00
Jack Christensen
911e727d78 ExecParams and ExecPrepared handle empty query
An empty query does not return CommandComplete. Instead it returns
EmptyQueryResponse.
2020-03-07 10:55:29 -06:00
Jack Christensen
8117205a75 Range types Set method supports its own type, string, and nil
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.
2020-03-03 15:25:57 -06:00
Jack Christensen
9e495df1d5 Add test for rollback failure 2020-02-29 09:48:16 -06:00
Jack Christensen
710ddf7134
Merge pull request #682 from WGH-/batch-len
Add Len() method to *pgx.Batch
2020-02-22 09:21:21 -06:00
Jack Christensen
edf1229fba
Merge pull request #681 from benjamin-bader/log_batched_queries
Add query logging for individual batch items
2020-02-22 09:19:34 -06:00
WGH
c01721e3ba Add Len() method to *pgx.Batch
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.
2020-02-21 22:28:34 +03:00
Jack Christensen
55a56add23 Set will call Get on src if possible 2020-02-19 11:58:49 -06:00
Jack Christensen
666bd514e2 Add standard nil test to gofrs-uuid.UUID.Set 2020-02-19 10:50:58 -06:00
Jack Christensen
f3816bd1c0 Get implemented on T instead of *T
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.
2020-02-19 10:48:09 -06:00
Ben Bader
a10b89ebc0 Add query logging for individual batch items 2020-02-18 16:22:29 -08:00
Jack Christensen
542c9a97f1 Release v4.4.1 v4.4.1 2020-02-14 17:59:33 -06:00
Jack Christensen
8848816c13 Update pgconn to v1.3.2 for better default buffer size 2020-02-14 17:58:38 -06:00
Jack Christensen
6db848c6fc Update chunkreader to v2.0.1 2020-02-14 17:56:59 -06:00
Jack Christensen
3b9f79e2f3 Fix race condition in CopyFrom
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.
2020-02-14 17:30:44 -06:00
Jack Christensen
8c9d1cc15b Add test case for #677 2020-02-07 16:07:43 -06:00
Jack Christensen
ac364e7a43 Use writeError for Write error 2020-02-07 15:40:50 -06:00
Jack Christensen
06c4e181b1 go mod tidy 2020-02-05 11:49:40 -06:00
Jack Christensen
ea0eacc0b6 Release v4.4.0 v4.4.0 2020-02-05 11:31:22 -06:00
Jack Christensen
22ad987698 Add a timeout to pgxpool min connection creation
Ensure that CreateResource can't hang.
2020-02-05 11:25:15 -06:00
Jack Christensen
cb1a1ebefa Update pgconn, pgtype, and puddle 2020-02-05 11:16:59 -06:00
Jack Christensen
282b7936a2 Release 1.2.0 2020-02-05 11:10:17 -06:00
Jack Christensen
406afa0eb7 Release v1.3.1 2020-02-05 11:06:09 -06:00
Jack Christensen
efe9315b5b
Merge pull request #674 from ellulpatrick/min-connections
Implements MinConns, the minimum size of the connection pool
2020-02-03 17:07:04 -06:00
Patrick Ellul
a01827732f Implements MinConns, the minimum size of the connection pool.
The health check will increase the number of connections to this amount if it had dropped below.
2020-02-04 08:17:53 +11:00
Jack Christensen
77c1076d39 stdlib.ReleaseConn closes connections left in invalid state
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
2020-02-01 12:00:26 -06:00
Jack Christensen
06c3181836 Merge branch 'ellulpatrick-max-conn-idle-time' 2020-02-01 09:45:37 -06:00
Jack Christensen
2d20ba7ba4 Add doc for pool_max_conn_idle_time option 2020-02-01 09:45:20 -06:00
Jack Christensen
0ab69ce885 Merge branch 'freb-json_marshaling' 2020-01-29 09:26:45 -06:00
Patrick Ellul
5082e30c4c Implement maximum connection idle time (MaxConnIdleTime) for pgxpool.
If a connection has been idle for longer than maxConnIdleTime, the health check will destroy it.
2020-01-28 16:36:34 +11:00