256 Commits

Author SHA1 Message Date
Jack Christensen
7d5a3969d0 Improve docs and tests 2023-11-18 07:44:24 -06:00
Jack Christensen
e5015e2fac pgx.Conn.Deallocate uses PgConn.Deallocate
This uses the PostgreSQL protocol to deallocate a prepared statement
instead of a SQL statement. This allows it to work even in an aborted
transaction.
2023-11-18 07:44:24 -06:00
Jack Christensen
bbe2653bc5 Prepare chooses statement name based on sql if name == sql
This makes it easier to explicitly manage prepared statements.

refs #1716
2023-09-23 08:40:06 -05:00
Jack Christensen
1a9b2a53a5 Fix staticcheck issues 2023-07-28 18:04:31 -05:00
Jack Christensen
05440f9d3f Drastically increase allowed test times for potato CI
The context timeouts for tests are designed to give a better error
message when something hangs rather than the test just timing out.
Unfortunately, the potato CI frequently has some test or another
randomly take a long time. While the increased times are somewhat less
than optimal on a real computer, hopefully this will solve the
flickering CI.
2023-07-11 21:16:08 -05:00
Dan McGee
0328d314ea Use bytes.Equal rather than bytes.Compare ==/!= 0
As recommended by go-staticcheck, but also might be a bit more efficient
for the compiler to implement, since we don't care about which slice of
bytes is greater than the other one.
2023-07-08 12:08:05 -05:00
Jack Christensen
9f00b6f750 Use context timeouts in more tests
Tests should timeout in a reasonable time if something is stuck. In
particular this is important when testing deadlock conditions such as
can occur with the copy protocol if both the client and the server are
blocked writing until the other side does a read.
2023-05-29 10:25:57 -05:00
Evan Jones
9de41fac75 ParseConfig: default_query_exec_mode: Return arg in error
If the default_query_exec_mode is unknown, the returned error
previously was:

    invalid default_query_exec_mode: <nil>

This changes it to return the argument. Add a test that unknown modes
fail to parse and include this string.
2023-05-20 08:09:35 -05:00
Jack Christensen
80eb6e1859 Remove sleeps in test
Sleeping for a microsecond on Windows actually takes 10ms. This caused
the test to never finish. Instead use channel to ensure the two
goroutines start working at the same time and remove the sleeps.
2023-02-27 20:32:51 -06:00
Felix Röhrich
fa5fbed497 add filter for dropped attributes in getCompositeType 2023-02-07 08:45:56 -06:00
Vitalii Solodilov
88b373f9ee Skipped multirange tests for postgres less than 14 version 2022-12-01 19:33:33 -06:00
Vitalii Solodilov
8e2de2fefa Conn.LoadType supports range and multirange types (#1393)
Closes #1393
2022-12-01 19:33:33 -06:00
Bodo Kaiser
56633b3d51 removed unnecessary name argument from DeallocateAll 2022-11-17 19:41:18 -06:00
Bodo Kaiser
c94c47f584 added DeallocateAll to pgx.Conn to clear prepared statement cache 2022-11-12 10:57:31 -06:00
Jack Christensen
5b6fb75669 Conn.LoadType supports domain types
If the underlying type is registered then use the same Codec.

fixes https://github.com/jackc/pgx/issues/1373
2022-11-12 08:11:37 -06:00
Jack Christensen
7d3b9c1e44 QueryRewriter.RewriteQuery now returns an error
https://github.com/jackc/pgx/issues/1186#issuecomment-1288207250
2022-10-29 09:33:13 -05:00
Baptiste Fontaine
7a9e70d1e0 Fix some bad rows.Err() handlings in tests 2022-10-14 19:02:44 -05:00
Jack Christensen
78875bb95a Add tracing support
Replaces existing logging support. Package tracelog provides adapter for
old style logging.

https://github.com/jackc/pgx/issues/1061
2022-07-16 12:27:10 -05:00
Jack Christensen
759e47dba3 Merge branch 'master' into v5-dev 2022-07-12 07:26:00 -05:00
Jack Christensen
731daea586 Skip test on CockroachDB 2022-07-09 21:08:15 -05:00
Jack Christensen
80a529fcb7 Test LoadType disambiguate name by schema 2022-07-09 17:48:46 -05:00
Jack Christensen
3dafb5d4ee Skip test with non-standard CRDB behavior 2022-07-09 10:21:17 -05:00
Jack Christensen
e7aa76ccf9 SendBatch now uses pipeline mode to prepare and describe statements
Previously, a batch with 10 unique parameterized statements executed
100 times would entail 11 network round trips. 1 for each prepare /
describe and 1 for executing them all. Now pipeline mode is used to
prepare / describe all statements in a single network round trip. So it
would only take 2 round trips.
2022-07-09 09:32:36 -05:00
Gabor Szabad
396195466c Add logger func wrapper 2022-06-23 20:15:20 -05:00
Jack Christensen
a89a400b69 Fix documentation for Rows.RawValues and test new behavior 2022-04-30 08:27:57 -05:00
Jack Christensen
e8f81bb7de Merge branch 'master' into v5-dev
Rewrite fix for https://github.com/jackc/pgx/issues/1196 for pgx v5.
2022-04-28 08:06:34 -05:00
Jack Christensen
7ceeea6fe6 Fix explicitly prepared statements with describe statement cache mode
fixes https://github.com/jackc/pgx/issues/1196
2022-04-28 07:58:24 -05:00
Jack Christensen
107196ab0c Add NamedArgs
https://github.com/jackc/pgx/issues/1186
https://github.com/jackc/pgx/issues/387
2022-04-23 18:45:38 -05:00
Jack Christensen
b72b0daa5a Add QueryRewriter interface 2022-04-23 17:26:42 -05:00
Jack Christensen
f14fb3d692 Replace interface{} with any 2022-04-09 09:12:55 -05:00
Jack Christensen
829babcea9 Better number to string handling
Avoid ambiguity of stringWrapper implementing Int64Scanner and
Float64Scanner.
2022-04-09 09:09:46 -05:00
Jack Christensen
83e50f21e8 Extract SkipCockroachDB to pgxtest 2022-04-02 10:35:13 -05:00
Jack Christensen
e18d76b798 Initial extraction of pgxtest
- Introduce ConnTestRunner
- RunWithQueryExecModes
2022-04-02 10:26:47 -05:00
Jack Christensen
1390a11fe2 Query supports QueryExecMode
Fixed QueryExecModeExec as it must only use text format without
specifying param OIDs.
2022-03-12 14:15:39 -06:00
Jack Christensen
46966227bc Enable all QueryExecModes for exec path 2022-03-12 10:04:02 -06:00
Jack Christensen
8e341e20f3 Remove ConnConfig.BuildStatementCache 2022-03-12 09:23:40 -06:00
Jack Christensen
f27178ba85 Initial privatization of stmtcache
ConnConfig.BuildStatementCache is pending removal once connections
always have separate caches for prepared and described statements.
2022-03-12 08:35:31 -06:00
Jack Christensen
0d8e109c21 Test every QueryExecMode 2022-03-05 14:04:51 -06:00
Jack Christensen
aad3d65e16 Initial restructure of simple protocol to query exec mode 2022-03-05 10:27:15 -06:00
Jack Christensen
1f2f239d09 Renamed pgtype.ConnInfo to pgtype.Map 2022-02-21 09:13:09 -06:00
Jack Christensen
bda10b2ec9 Rename pgtype.DataType to pgtype.Type 2022-02-21 09:01:48 -06:00
Jack Christensen
a3c351d11a RegisterDataType now accepts *DataType 2022-02-21 08:49:04 -06:00
Jack Christensen
9c5dfbdfb3 pgconn.CommandTag is now an opaque type
It now makes a copy instead of retaining driver memory. This is in
preparation to reuse the driver read buffer.
2022-02-12 10:26:26 -06:00
Jack Christensen
a14f3f291f Re-enable domain type test 2022-02-12 09:35:52 -06:00
Jack Christensen
b9b5e35d0f Convert numeric to Codec 2022-01-22 09:31:59 -06:00
Jack Christensen
fcc9dcc960 Convert text to Codec
This also entailed updating and deleting types that depended on Text.
2022-01-08 13:13:26 -06:00
Jack Christensen
0c0e28a70a Convert int4 and int8 to new system
Note: purposely disabled some tests and composite support that needs to
be restored later in v5 development.
2022-01-01 17:26:39 -06:00
Jack Christensen
72cc95e4dd Bump module version to v5 2021-12-11 13:29:03 -06:00
Jack Christensen
0e293b966c Finish import of pgconn 2021-12-04 14:06:57 -06:00
Jack Christensen
7e13db4538 Finish import of pgtype repo
Fix some tests that broke by merging repos
Tweak readme wording
2021-12-04 13:45:57 -06:00