Commit Graph

300 Commits (c844a2402bef2bff7616a8cf15c1a6b602a22ec2)

Author SHA1 Message Date
Murat Kabilov d9f21d02a5 mind PreferSimpleProtocol parameter in the config Merge method 2018-07-24 16:03:26 +02:00
Jack Christensen 6556ef67cb Fix data race in domain handling 2018-04-07 14:26:26 -05:00
Jack Christensen db7df79e10 Add domain support
fixes #407
2018-04-07 14:04:16 -05:00
Jack Christensen a487caf45f Merge branch 'scheme-agnostic-uri' of https://github.com/sean-/pgx into sean--scheme-agnostic-uri 2018-02-03 11:43:46 -06:00
Jack Christensen f911070f68 Add new SSL config to envvar parsing 2018-02-03 11:20:42 -06:00
Sean Chittenden 6cfb436397
Parse URI-encoded connection strings as URIs.
CockroachDB is frequently referenced as: `cockroachdb://` as its
scheme.  Be scheme name agnostic.
2018-02-02 16:19:58 -08:00
Sean Chittenden 6a4303120f
Only read in TLS certs when the key and cert are present. 2018-02-02 08:37:23 -08:00
Sean Chittenden f0dc593c2f
Only initialize the CA if the path is not an empty string. 2018-02-02 08:24:41 -08:00
Sean Chittenden 8078930406
Add TLS arg parsing to ParseDSN().
Factor out the TLS cert handling and add it to `configTLS()` via a
`struct` argument.
2018-02-01 23:51:50 -08:00
Sean Chittenden d7f24b91f4
Make ParseURI() compatible with lib/pq's TLS keywords.
Add support for:

- `sslrootcert`
- `sslcert`
- `sslkey`

All three arguments, like thir `gitub.com/lib/pq` counterparts,
are filesystem paths.
2018-02-01 22:58:14 -08:00
Sean Chittenden 4506a3e359
Gratuitously rename `configSSL()` to `configTLS()`.
SSL is dead, Jim.
2018-02-01 15:07:59 -08:00
Jack Christensen 2c07b03087 Parse connect_timeout into Dial func
Instead of adding Timeout field which could conflict with custom Dial
func.
2018-01-13 18:02:13 -06:00
Jack Christensen 9281f057ae Merge branch 'timeout' of https://github.com/cyberdelia/pgx into cyberdelia-timeout 2018-01-13 17:31:22 -06:00
Jack Christensen bd76a96882 Add ConnConfig.PreferSimpleProtocol
Allows configuring on a connection basis to prefer the simple protocol /
disable implicit prepared statements.

refs #331
2018-01-13 12:05:33 -06:00
Timothée Peignier 1bec450326
Handle timeout parameters 2017-12-16 19:18:33 -08:00
James Lawrence 393e9f4fd3 allow overriding connection info 2017-12-16 18:02:21 -05:00
Felix Geisendörfer 4dec986171 Fix CrateDB support (regression in ab9a1af)
See https://github.com/jackc/pgx/issues/320#issuecomment-338457176
2017-11-09 13:53:58 +01:00
Jack Christensen ab9a1af65b Add support for array of enum
fixes #338
2017-10-17 20:31:11 -05:00
Felix Geisendörfer 52bec9bec5 Support CrateDB 2017-09-27 18:32:18 +02:00
Jack Christensen fd7b776540 Merge pull request #323 from kelseyfrancis/namespace-oids
Prefix types in namespaces other than pg_catalog or public
2017-09-14 13:59:51 -05:00
Kelsey Francis 953e08df99 Prefix types in namespaces other than pg_catalog or public
It's possible to define a type (e.g., an enum) with the same name in two
different schemas. When initializing data types after connecting, types
defined within schemas other than pg_catalog or public should be
qualified with their schema name to disambiguate them and ensure all
types with the same base name get added to the map of OID to type.

Prior to this commit, the last type scanned would "win", and all others
with the same name would be missing from the ConnInfo type maps, which
would subsequently cause any PREPARE involving columns of those missing
types to return the error "unknown oid".
2017-09-11 11:29:42 -07:00
Jack Christensen 9eb21591ee Update sslmode docs 2017-09-09 11:05:39 -05:00
Johan Brandhorst 30fa7cc37f Skip certificate verification for sslmode "require"
This more appropriately aligns the behaviour of the library with
that advertised by the postgres documentation.

According to the table on the official documentation page
https://www.postgresql.org/docs/current/static/libpq-ssl.html,
the "require" mode should be used when:

"I want my data to be encrypted, and I accept the overhead. I trust that the network will make sure I always connect to the server I want."

This maps reasonably well to a TLS config that skips certificate verification.
2017-09-08 20:44:10 +01:00
Kelsey Francis ea740fb316 Fix some invalid one round trip execs failing to return non-nil error
Prior to this commit, execEx() would write the one round trip exec to
the connection before first calling ensureConnectionReadyForQuery, which
ultimately caused any errors to be suppressed if the exec followed a
valid query, because the receive message processing would finish
successfully as soon as it received the ReadyForQuery that actually
belonged to the preceding query. So, the exec would never actually
receive the error message that it caused, leaving it to be incorrectly
received by the first subsequent query sent.
2017-08-28 18:51:35 -07:00
Jack Christensen f65776f084 Fix typo 2017-08-25 13:31:50 -05:00
Jack Christensen 4d0f8f041b Fix pid logging
fixes #300
2017-08-12 17:43:54 -05:00
Jack Christensen 53b4280456 Automatically register enum types
fixes #287
2017-07-04 11:38:50 -05:00
Jack Christensen 8f4178b3d3 Use github.com/pkg/errors 2017-06-04 21:30:03 -05:00
Jack Christensen 3ea41e6972 Remove unused global error 2017-06-04 21:22:34 -05:00
Jack Christensen fb90fb2729 Add notification response hook
refs #239
2017-06-04 21:18:26 -05:00
Jack Christensen 27ab289096 Use Go casing convention for OID 2017-06-03 11:53:49 -05:00
Jack Christensen fe0af9b357 Happy-path batch query mode 2017-06-02 14:54:17 -05:00
Jack Christensen dcf3ee2781 Fix sendPreparedQuery write error hang
If the Write call in sendPreparedQuery encountered a non-fatal error - which means it sent
no bytes. It still was marking the connection as not ready for query. That caused the next
call to hang.
2017-05-31 18:33:01 -05:00
Jack Christensen 90975ab5c2 Extract append message functions.
In general, pgproto3 types should be used. But these functions may be easier to
without incurring additional memory allocations.
2017-05-29 10:01:07 -05:00
Jack Christensen 4ee21a15de Use pgproto3 for startup message 2017-05-29 09:19:41 -05:00
Jack Christensen dd5de3e49e Add single round-trip mode for ExecEx 2017-05-29 09:11:52 -05:00
Jack Christensen 749fdfe7d5 Resolve race on conn.Close/die
Use sync.Mutex instead of atomic operations for clarity.
2017-05-21 19:35:37 -05:00
Jack Christensen 8a7165dd98 Add ctx to PrepareEx
Remove PrepareExContext
2017-05-20 18:03:59 -05:00
Jack Christensen 2df4b1406b Do not double call termContext in QueryEx
QueryEx was calling termContext and rows.fatal on err of sendPreparedQuery.
rows.fatal calls rows.Close which already calls termContext. This sequence of
calls was causing underlying io timeout errors to be returned instead of context
errors.

In addition, added fatalWriteErr helper method to allow recovery of write
timeout errors where no bytes were written.

This should solve flickering errors on Travis.
2017-05-20 10:58:44 -05:00
Jack Christensen e1397613fd Ping only makes sense with a context for timeout 2017-05-19 08:02:51 -05:00
Jack Christensen 8b6c32d13a Add ConnConfig.Merge 2017-05-06 15:20:40 -05:00
Jack Christensen 458dd24a9f Remove unneeded WriteBuf 2017-05-02 21:39:23 -05:00
Jack Christensen 280bce7078 Added log adapter for logrus
Also changed standard logger interface to take a map instead of varargs for
extra data.
2017-04-29 21:28:38 -05:00
Jack Christensen 855b735eae Add log adapters for testing and log15
Make LogLevel a type for Stringer interface.
2017-04-29 20:33:52 -05:00
Jack Christensen f04c58338b Introduce pgproto3 package
pgproto3 will wrap the message encoding and decoding for the PostgreSQL
frontend/backend protocol version 3.
2017-04-29 10:02:38 -05:00
Jack Christensen 7b1f461ec3 Add simple protocol suuport with (Query|Exec)Ex 2017-04-10 08:58:51 -05:00
James Lawrence c5d247830c enable sql.Open to support both DSN and URI based connection strings 2017-04-01 08:50:48 -05:00
Jack Christensen 7eae904eba Add int4range 2017-03-23 18:41:52 -05:00
Jack Christensen 9ab59a74a9 Remove oid constants from pgx 2017-03-18 14:59:34 -05:00
Jack Christensen a636ef31a4 Refactor encoding parameters for prepared statements 2017-03-18 14:23:04 -05:00