Commit Graph

162 Commits (d2ad2ed5d8abb0f9c612324e68e0beba3e460075)

Author SHA1 Message Date
Jack Christensen d2ad2ed5d8 Remove tests context cancel
Context cancellation is now fatal so no need to test recovery.
2019-04-05 11:00:35 -05:00
Jack Christensen 858d00788a Use extracted packages with Go modules 2019-04-05 10:59:47 -05:00
Jack Christensen d3a2c1c107 Partial conversion of pgx to use pgconn 2019-01-26 16:46:30 -06:00
Jack Christensen 08bd2b612f Streamline test 2019-01-12 12:04:44 -06:00
Jack Christensen 19a8df16b6 Move notice handling to pgconn 2019-01-02 13:15:26 -06:00
Jack Christensen 89c3d8af5d Remove ExecEx 2019-01-02 12:52:37 -06:00
Jack Christensen 12857ad05b Implement pgx.Conn.Exec in terms of pgconn.PgConn.Exec 2019-01-02 12:32:36 -06:00
Jack Christensen 7f9540438c pgx uses pgconn.CommandTag instead of own definition 2019-01-01 16:55:48 -06:00
Jack Christensen 378ccb8945 PG error type is *pgconn.PgError 2018-12-31 17:46:56 -06:00
Jack Christensen c672c0d595 Use environment variables for test configuration 2018-12-30 21:52:33 -06:00
Jack Christensen 67a15e6f7f Move connection tests to pgconn 2018-12-30 21:10:06 -06:00
Jack Christensen b3c8a73dc7 Restructure connect process
- Moved lots of connection logic to pgconn from pgx
- Extracted pgpassfile package
2018-12-30 16:55:56 -06:00
Jack Christensen b63370e5d5 Rename base.Conn to base.PgConn
- pgx.Conn embeds base.PgConn privately
- Add pgx.Conn.ParameterStatus
2018-12-28 12:16:50 -06:00
Jack Christensen a9a178bc98 Merge branch 'master' into v4-experimental 2018-12-01 11:17:30 -06:00
James Hartig 6d336eccb1 Added LastStmtSent and use it to retry on errors if statement was not sent
Previously, a failed connection could be put back in a pool and when the
next query was attempted it would fail immediately trying to prepare the
query or reset the deadline. It wasn't clear if the Query or Exec call
could safely be retried since there was no way to know where it failed.

You can now call LastQuerySent and if it returns false then you're
guaranteed that the last call to Query(Ex)/Exec(Ex) didn't get far enough
to attempt to send the query. The call can be retried with a new
connection.

This is used in the stdlib to return a ErrBadConn if a network error
occurred and the statement was not attempted.

Fixes #427
2018-11-19 10:44:40 -05:00
Jack Christensen 2e72ca854a First extraction of base.Conn 2018-11-10 18:48:43 -06:00
Jörg Thalheim 3410ad9122
Add host query parameter to support unix sockets
Currently there is no way to specify unix sockets in the connection
url. This patch adds a `host` query parameter that allows to set the path.
2018-11-03 21:07:33 +00:00
Valery Krivchikov 1f054a77ea fix new variables on left side 2018-09-15 14:50:17 +03:00
Valery Krivchikov 0468c97a7e Fix undefined cancel 2018-09-15 14:27:29 +03:00
Valery Krivchikov c844a2402b Call context.WithTimeout cancel function 2018-09-15 13:23:09 +03:00
Jack Christensen 39bbc98d99 Do not use same tls.Config for fallback in test 2018-06-08 15:19:56 -05:00
Jack Christensen 7b6f0ffc8c Fix race in TLS tests 2018-06-08 15:14:45 -05:00
Jack Christensen e04f5443d5 Fix test with formatting directive 2018-05-17 16:45:01 -05:00
Jack Christensen 6044dcbe21 Fix race in TLS test 2018-05-17 16:43:15 -05:00
Jack Christensen db7df79e10 Add domain support
fixes #407
2018-04-07 14:04:16 -05: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
Jack Christensen 5f24beb4f0 Test database name in parsing tests 2018-01-15 11:47:59 -06: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
ferhat elmas 763deea17e Run gofmt with simplify flag 2017-12-21 23:45:26 +01:00
Timothée Peignier 1bec450326
Handle timeout parameters 2017-12-16 19:18:33 -08:00
Felix Geisendörfer 1bebe56697 travis: add connection test coverage for cratedb 2017-11-12 15:47:26 +01: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 a1e4d17e58 Fix sslmode require test 2017-09-09 11:05:27 -05: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 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 95c11a1fd1 Remove bad channel sync causing orphaned goroutine 2017-05-31 07:57:22 -05:00
Jack Christensen dd5de3e49e Add single round-trip mode for ExecEx 2017-05-29 09:11:52 -05:00
Jack Christensen 8a7165dd98 Add ctx to PrepareEx
Remove PrepareExContext
2017-05-20 18:03:59 -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 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 d7973d87dd Fix TestParseEnvLibpq when PGSSLMODE is set 2017-03-24 13:27:04 -05:00
Jack Christensen 9ab59a74a9 Remove oid constants from pgx 2017-03-18 14:59:34 -05:00
Jack Christensen 5eb19bc66a Add *Conn.CopyFrom
This replaces *Conn.CopyTo. CopyTo was named incorrectly. In PostgreSQL
COPY FROM is the command that copies from the client to the server. In
addition, CopyTo does not accept a schema qualified table name. This
commit introduces the Identifier type which handles multi-part names and
correctly quotes/sanitizes them. The new CopyFrom method uses this
Identifier type.

Conn.CopyTo is deprecated.

refs #243 and #190
2017-03-17 08:25:49 -05:00
Jack Christensen ba5f97176a Move not null Oid to pgtype
In preparation to ConnInfo implementation.
2017-03-13 21:34:38 -05:00