493 Commits

Author SHA1 Message Date
Jack Christensen
5f28621394 Add docs clarifying that FieldDescriptions may return nil
https://github.com/jackc/pgx/issues/1634
2023-06-14 07:42:11 -05:00
Jack Christensen
3ea2f57d8b Deprecate CheckConn in favor of Ping 2023-06-12 09:39:26 -05:00
Jack Christensen
490f70fc5f Fix docs for QueryExecModeDescribeExec with connection poolers
https://github.com/jackc/pgx/issues/1635
2023-06-11 08:26:02 -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
Evan Jones
0292edecb0 pgx.Conn: Fix memory leak: Delete items from preparedStatements
Previously, items were never removed from the preparedStatements map.
This means workloads that send a large number of unique queries could
run out of memory. Delete items from the map when sending the
deallocate command to Postgres. Add a test to verify this works.

Fixes https://github.com/jackc/pgx/issues/1456
2023-05-20 08:06:37 -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
67f2a41587 Fix scanning a table type into a struct
Table types have system / hidden columns like tableoid, cmax, xmax, etc.
These are not included when sending or receiving composite types.

https://github.com/jackc/pgx/issues/1576
2023-04-20 20:13:37 -05:00
Felix Röhrich
fa5fbed497 add filter for dropped attributes in getCompositeType 2023-02-07 08:45:56 -06:00
Alexey Palazhchenko
f581584148 Use Go 1.19's lists for proper formatting 2023-01-23 19:54:30 -06:00
Alejandro Do Nascimento Mora
c4ac6d810f Use DefaultQueryExecMode in CopyFrom
CopyFrom had to create a prepared statement to get the OIDs of the data
types that were going to be copied into the table. Every COPY operation
required an extra round trips to retrieve the type information. There
was no way to customize this behavior.

By leveraging the QueryExecMode feature, like in `Conn.Query`, users can
specify if they want to cache the prepared statements, execute
them on every request (like the old behavior), or bypass the prepared
statement relying on the pgtype.Map to get the type information.

The `QueryExecMode` behave exactly like in `Conn.Query` in the way the
data type OIDs are fetched, meaning that:

- `QueryExecModeCacheStatement`: caches the statement.
- `QueryExecModeCacheDescribe`: caches the statement and assumes they do
  not change.
- `QueryExecModeDescribeExec`: gets the statement description on every
  execution. This is like to the old behavior of `CopyFrom`.
- `QueryExecModeExec` and `QueryExecModeSimpleProtocol`: maintain the
  same behavior as before, which is the same as `QueryExecModeDescribeExec`.
  It will keep getting the statement description on every execution

The `QueryExecMode` can only be set via
`ConnConfig.DefaultQueryExecMode`, unlike `Conn.Query` there's no
support for specifying the `QueryExecMode` via optional arguments
in the function signature.
2022-12-23 13:22:26 -06:00
Yevgeny Pats
11fa083a0d fix: Improve errors in batch modes 2022-12-20 19:33:46 -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
3520c2ea43 updated DeallocateAll to also reset client-side statement and description cache 2022-11-12 10:57:31 -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
6f90866f58 Expose underlying pgconn GetSSLPassword support to pgx
pgconn supports a GetSSLPassword function but the pgx connection
functions did not expose a means of using it.

See PR #1233 for more context.
2022-11-03 20:09:52 -05: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
Jack Christensen
1819959d07 Merge branch 'master' into v5-dev 2022-08-06 06:41:33 -05:00
Jack Christensen
f3e04b28cc Go 1.19 go fmt 2022-08-06 06:20:50 -05:00
Jack Christensen
9a61fc250f Recommend CollectRows in ConnQuery docs 2022-07-23 08:31:37 -05:00
Jack Christensen
178a84261f Improve Query docs 2022-07-23 07:53:02 -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
9201cc0341 ConnectConfig copies config 2022-07-16 08:58:43 -05:00
Jack Christensen
786de2bda8 Use correct cache 2022-07-11 20:42:55 -05:00
Jack Christensen
90c2dc6f68 Rename ForEachScannedRow to ForEachRow 2022-07-09 16:47:28 -05:00
Jack Christensen
c31b89a3f2 Delay handling invalidated statements when in transaction 2022-07-09 10:20:54 -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
1168b375e4 Expose pgx functionality for manual integration with pgconn
This is primarily useful for using pipeline mode.
2022-07-04 13:29:49 -05:00
Stepan Rabotkin
4099b447b9 feat: add batch logging 2022-05-12 19:05:08 -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
1f4b34f932 Merge branch 'master' into v5-dev 2022-04-23 11:05:24 -05:00
Jack Christensen
097b6aacb7 Add time to logging failed Exec
fixes #1189
2022-04-21 19:26:25 -05:00
Jack Christensen
f14fb3d692 Replace interface{} with any 2022-04-09 09:12:55 -05:00
Jack Christensen
ee93440ac1 pgtype uses pgxtest
Added ValueRoundTripTest to pgxtest
Removed pgtype/testutil

pgtype tests now run with all (applicable) query modes. This gives
better coverage than before and revealed several bugs which are also
fixed in this commit.
2022-04-02 14:34:19 -05:00
Jack Christensen
500c0721d7 Improve error messages for query argument encoding 2022-04-01 18:00:25 -05:00
Jack Christensen
72b72b9ae9 Remove dead code 2022-03-12 15:07:32 -06:00
Jack Christensen
cb721dfb5b SendBatch supports default QueryExecMode 2022-03-12 15:06:13 -06: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
fe21cc7486 Use Map.Encode path for simple protocol 2022-03-05 21:40:49 -06:00
Jack Christensen
c4b08378f2 Handle driver.Valuers inside Map.Encode 2022-03-05 21:27:17 -06:00