250 Commits

Author SHA1 Message Date
Jack Christensen
a6d902777d Skip LISTEN / NOTIFY tests for CockroachDB 2021-02-27 09:52:51 -06:00
Ethan Pailes
1df45d758d fix stmtcache invalidation
This patch fixes jackc/pgx#841. The meat of the fix lives
in [a PR to the pgconn repo][1]. This change just checks
for errors after executing a prepared statement and informs
the underlying stmtcache about them so that it can properly
clean up. We don't try to get fancy with retries or anything
like that, just return the error and allow the application to handle it.

I had to make [some][1] [changes][2] to to the jackc/pgconn package as well
as this package.

Fixes #841

[1]: https://github.com/jackc/pgconn/pull/56
[2]: https://github.com/jackc/pgconn/pull/55
2020-11-12 08:15:13 -05:00
georgysavva
e29ce9f6d6 Add Config.Copy() in pgx and pgxpool packages. Conn.Config() and Pool.Config() return copy of the original config. 2020-06-02 13:35:05 +03:00
georgysavva
608451a215 Store original config in Conn before updating it. 2020-06-01 19:38:12 +03:00
Jack Christensen
ac6c49c39d Require access to ConnString via Config
A Config object may be created via ParseConfig and then further
modified. Requiring access to the original ConnString via the Config
helps indicate that the Config is the source of truth as to how the
connection was actually established.
2020-05-16 18:12:04 -05:00
georgysavva
20c6c44f9f Expose Conn.Config() and Pool.Config(). 2020-05-16 19:53:08 +03:00
georgysavva
33cbec368f rename ConnStr -> ConnString 2020-05-16 19:24:57 +03:00
georgysavva
a62de87342 Add ConnStr getter to Pool and Conn structs. 2020-05-16 18:10:29 +03:00
Jack Christensen
a66b09fbd8 Improve simple protocol / text format
Increased data type support for simple protocol. Improved test
coverage of simple protocol. This has the additional advantage of
exercising the text encoders and decoders.
2020-05-08 16:20:15 -05:00
malstoun
8dc8431ef9 Add arguments count check to execParamsAndPreparedPrefix 2020-01-04 12:41:49 +03:00
Adam Pantel
0a3cfab73e Eliminate race condition in TestListenNotifyWhileBusyIsSafe 2019-11-22 11:03:33 -05:00
Jack Christensen
76348773bd Make Conn.ConnInfo private 2019-09-10 18:09:21 -05:00
Jack Christensen
863b41aaa6 Remove unused sentinal error 2019-08-27 18:29:38 -05:00
Jack Christensen
8170eaf401 Update to latest version of pgconn
- Also remove a few tests of functionality that is handled by pgconn
2019-08-27 18:22:34 -05:00
Jack Christensen
a262126b5c Replace IsAlive with IsClosed
IsAlive is ambiguous because the connection may be dead and we do not
know it. It implies the possibility of a ping. IsClosed is clearer -- it
does not promise the connection is alive only that it hasn't been
closed.
2019-08-24 23:49:59 -05:00
Jack Christensen
6508934508 Rename PreparedStatementCache to StatementCache 2019-08-24 22:19:29 -05:00
Jack Christensen
0c3e59b07a Add automatic statement cache 2019-08-24 20:29:54 -05:00
Jack Christensen
6972a57421 pgtype.OID type should only be used for scanning and encoding values
It was a mistake to use it in other contexts. This made interop
difficult between pacakges that depended on pgtype such as pgx and
packages that did not like pgconn and pgproto3. In particular this was
awkward for prepared statements.

This is preparation for removing pgx.PreparedStatement in favor of
pgconn.PreparedStatement.
2019-08-24 13:55:57 -05:00
Jack Christensen
e9770d6ff9 Add listen / notify implemented with pgconn
fixes #553
2019-08-24 10:49:10 -05:00
Jack Christensen
b7b52ff079 Require conn and pool configs to be created by ParseConfig
This simplifies handling default values. Now there is no ambiguity
between a zero value and a default value. All default values are set by
ParseConfig and the user can modify them after the initial creation.

fixes #567
2019-08-24 09:53:38 -05:00
Jack Christensen
f3c703a102 Remove Conn SetLogger and SetLogLevel
Simplifying interface
2019-08-17 15:34:29 -05:00
Jack Christensen
3028821487 Add context.Context to Logger interface
This allows custom logger adapters to add additional fields to log
messages. For example, a HTTP server may with to log the request ID.

fixes #428
2019-08-03 16:16:21 -05:00
Jack Christensen
ab1edc79e0 Remove 0 bytes when sanitizing identifiers
Port of 95ea78048a9569250c078d1965a235a214239960 from v3.
2019-08-03 09:51:03 -05:00
Jack Christensen
29f02807b0 Restore simple protocol support 2019-05-20 20:36:03 -05:00
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