176 Commits

Author SHA1 Message Date
Jack Christensen
00d123a944 Prune methods that delegated to *pgconn.PgConn 2019-04-25 14:25:16 -05:00
Jack Christensen
1b8f0016e9 Split pgtype into own repo 2019-04-20 19:20:00 -05:00
Jack Christensen
efb333df6b Fix go modules
Wow. This is fun. Sure is easy to get modules wrong when upgrading a v2+
project.
2019-04-20 17:41:08 -05:00
Jack Christensen
b7e56b003a Replace lastStmtSent with pgconn support 2019-04-20 17:12:20 -05:00
Jack Christensen
66625e6489 Prepare takes context
Also remove PrepareEx. It's primary usage was for context. Supplying
parameter OIDs is unnecessary when you can type cast in the query SQL.
If it does become necessary or desirable to add options back it can be
added in a backwards compatible way by adding a varargs as last
argument.
2019-04-20 11:47:16 -05:00
Jack Christensen
95756b1d7f Deallocate takes context 2019-04-20 11:34:52 -05:00
Jack Christensen
2978a7440a Use pgconn for more conn status 2019-04-19 16:18:47 -05:00
Jack Christensen
5cc4796c96 Test domains when registered and unregistered
Fix bug assigning to unknown type.
2019-04-13 17:09:51 -05:00
Jack Christensen
a6bdd8fd49 Hard code standard PostgreSQL types
Instead of needing to instrospect the database on connection preload the
standard OID / type map. Types from extensions (like hstore) and custom
types can be registered by the application developer. Otherwise, they
will be treated as strings.
2019-04-13 16:45:52 -05:00
Jack Christensen
c53c9e6eb5 Remove simple protocol and one round trip query options
It is impossible to guarantee that the a query executed with the simple
protocol will behave the same as with the extended protocol. This is
because the normal pgx path relies on knowing the OID of query
parameters. Without this encoding a value can only be determined by the
value instead of the combination of value and PostgreSQL type. For
example, how should a []int32 be encoded? It might be encoded into a
PostgreSQL int4[] or json.

Removal also simplifies the core query path.

The primary reason for the simple protocol is for servers like PgBouncer
that may not be able to support normal prepared statements. After
further research it appears that issuing a "flush" instead "sync" after
preparing the unnamed statement would allow PgBouncer to work.

The one round trip mode can be better handled with prepared statements.

As a last resort, all original server functionality can still be accessed by
dropping down to PgConn.
2019-04-13 11:39:01 -05:00
Jack Christensen
3e87a8b363 Conn.Close takes context 2019-04-10 14:56:14 -05:00
Jack Christensen
7718ee6207 Remove Ex versions of Query and QueryRow
Always require context and prepend options to arguments if necessary.
2019-04-10 12:12:22 -05:00
Jack Christensen
b69179cebb Remove Conn.Listen and Conn.Unlisten
Use Conn.Exec instead to listen or unlisten.
2019-04-10 11:21:40 -05:00
Jack Christensen
1715b17abb Handle too many params in pgconn 2019-04-05 12:09:15 -05:00
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