Commit Graph

62 Commits (fd0c65478e18be837b77c7ef24d7220f50540d49)

Author SHA1 Message Date
Jack Christensen fd0c65478e Fix prepared statement already exists on batch prepare failure
When a batch successfully prepared some statements, but then failed to
prepare others, the prepared statements that were successfully prepared
were not properly cleaned up. This could lead to a "prepared statement
already exists" error on subsequent attempts to prepare the same
statement.

https://github.com/jackc/pgx/issues/1847#issuecomment-2347858887
2024-09-13 08:03:37 -05:00
Jack Christensen dced53f796 Better error message when reading past end of batch
https://github.com/jackc/pgx/issues/1801
2024-07-03 22:39:29 -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
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
Jack Christensen 6defa2a607 Fix error when using BatchResults.Exec
...on a select that returns an error after some rows.

This was initially found in by a failure with CockroachDB because it
seems to send a RowDescription before an error even when no rows are
returned. PostgreSQL doesn't.
2023-04-20 21:43:59 -05:00
Jack Christensen 09371981f9 Fix pipeline batch results not closing pipeline
when error occurs while reading directly from results instead of using
a callback.

https://github.com/jackc/pgx/issues/1578
2023-04-20 20:58:04 -05:00
Jack Christensen 29254180ca Add callback functions to queued queries
Improve batch query ergonomics by allowing the code to handle the
results of a query to be right next to the query.
2022-07-16 17:46:47 -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 90c2dc6f68 Rename ForEachScannedRow to ForEachRow 2022-07-09 16:47:28 -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
Jack Christensen 76946fb5a3 Replace QueryFunc with ForEachScannedRow 2022-07-07 20:29:04 -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 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 cb721dfb5b SendBatch supports default QueryExecMode 2022-03-12 15:06:13 -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 aad3d65e16 Initial restructure of simple protocol to query exec mode 2022-03-05 10:27:15 -06:00
Jack Christensen 318018504a Merge branch 'master' into v5-dev 2022-02-07 11:22:01 -06:00
Jack Christensen d02b2ed013 Add batch test for QueryRow without any rows
refs #1150
2022-02-05 20:12:35 -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 38cd1b40aa Add QueryFunc to BatchResults
https://github.com/jackc/pgx/issues/1048#issuecomment-915123822
2021-09-11 10:32:02 -05:00
Jack Christensen 1dc7133a63 Simplify CockroachDB detection 2021-02-27 10:40:06 -06:00
Jack Christensen ff6ab48e00 Skip tests with parameter description server issues 2021-02-27 09:52:51 -06:00
Jack Christensen 5a16bad252 Skip deferred constraint tests on CockroachDB 2021-02-27 09:52:51 -06:00
Jack Christensen c4e66b05de Test accepts bigint vs int for CockroachDB 2021-02-27 09:52:51 -06:00
Jack Christensen f29aef4409 Skip test with serial on CockroachDB 2021-02-27 09:52:51 -06:00
Jack Christensen 7c47415150 Fix SendBatch of all prepared statements with statement cache disabled
fixes #856
2020-10-29 20:28:57 -05:00
Jack Christensen 72bba7fb42 Move batch simple protocol test to batch_test.go 2020-05-25 11:36:18 -05:00
Ben Bader a10b89ebc0 Add query logging for individual batch items 2020-02-18 16:22:29 -08:00
Jack Christensen 178b4c1a64 Add test for larger batches 2019-10-12 10:46:09 -05:00
Jack Christensen d5a6a5e7e0 Remove Results suffix from BatchResults methods 2019-08-24 23:41:28 -05:00
Jack Christensen 64b07f0d66 Batch uses statement cache.
This streamlines Queue's interface as well.
2019-08-24 23:40:21 -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 c3e41872a8 Resplit Begin and BeginEx
This is in preparation for a Begin / Tx interface that will similate
nested transactions with savepoints.

In addition, this passes the TxOptions struct by value and thereby
removes an allocation.
2019-08-17 15:53:55 -05:00
Jack Christensen faa980a256 Add tests for deferred constraint errors
Port tests from v3.

Fix is implemented in pgconn f0b479097a.
2019-08-06 17:17:54 -05:00
Jack Christensen 7b1272d254 Add SendBatch to pool 2019-04-25 15:07:35 -05:00
Jack Christensen aed6b822d9 Split batch command and result 2019-04-24 16:39:06 -05:00
Jack Christensen 2263521f70 Only have a single Begin transaction method 2019-04-24 13:35:27 -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 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 1f010f412d Simplify Batch.Queue for prepared statements 2019-04-20 11:29:28 -05:00
Jack Christensen 54c6ddc2f0 Commit and Rollback take context
Remove Ex versions.
2019-04-10 12:22:12 -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 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