28 Commits

Author SHA1 Message Date
Pau Sanchez
9b58ab2db8 Make ScanArgError fields public 2021-02-20 08:43:57 -06:00
Pau Sanchez
8ad672475a Make ScanArgError public to allow identification of offending column
fixes #931
2021-02-13 08:56:11 -06:00
Jack Christensen
9b0e57c4a9 Fix panic on query error with nil stmtcache
fixes #895
2020-12-19 10:17:41 -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
Jack Christensen
2ec377350b Update Rows.Scan documentation to reflect reality.
Previously, the Scan documentation stated that scanning into a []byte
will skip the decoding process and directly copy the raw bytes received
from PostgreSQL.

This has not been true for at least 2 months. It is also undesirable
behavior in some cases such as a binary formatted jsonb. In that case
the '1' prefix needs to be stripped to have valid JSON. If the raw
bytes are desired this can easily be accomplished by scanning into
pgtype.GenericBinary or using Rows.RawValues.

In light of the fact that the new behavior is superior, and that it has
been in place for a significant amount of time, I have decided to
document the new behavior rather than change back to the old behavior.
2020-09-05 11:26:19 -05:00
Jack Christensen
43ce317556 Plan scans even if destination is nil
fixes #810
2020-08-21 18:34:52 -05:00
Jack Christensen
11428bbc02 Document methods on Rows allowed to be called after Close() 2020-07-02 18:35:47 -05:00
Jack Christensen
2758cbc0c4 Remove unnecessary allocation in rows.Values()
This was originally done to fix #386. But subsequent changes to pgtype
render the allocation unnecessary. Tests put in place with the original
fix still pass.
2020-06-06 10:39:33 -05:00
Jack Christensen
81140f6c27 Improve stdlib performance with large results 2020-06-06 09:49:14 -05:00
Jack Christensen
4b95a747d7 Use pgtype.NewValue instead of reflect for Values()
This is both cleaner and necessary for pgtype.TypeValue types.
2020-05-30 13:32:15 -05:00
Igor V. Kozinov
4043edafe7 Add error field to logger on rows close 2020-05-27 14:44:53 +06:00
Jack Christensen
94ba730bb1 Use simplified pgtype ScanPlan 2020-05-10 14:09:26 -05:00
Jack Christensen
aabe5538a8 Optimize large result sets 2020-05-09 23:57:20 -05:00
Jack Christensen
fd4e692323 Add Rows.Values support for unknown types 2020-01-23 20:50:21 -06:00
Jack Christensen
f6feb39655 Fix Rows.Values() fallback to generic decoder
fixes #666
2020-01-23 20:41:22 -06:00
Jack Christensen
15ea38aae5 Document interfaces that may have methods added in the future 2019-10-12 09:35:29 -05:00
Jack Christensen
7d053e4d5c Replace RowsFromResultReader with ScanRow function 2019-09-10 18:38:10 -05:00
Jack Christensen
76348773bd Make Conn.ConnInfo private 2019-09-10 18:09:21 -05:00
Jack Christensen
a8691a7066 Add RawValues to Rows 2019-09-10 17:58:24 -05:00
Jack Christensen
b5ce0220f8 Add CommandTag to Rows interface
This allows handling queries where it is unknown if there will be a
result set or not. If it is not a result set returning query the
command tag will still be available.
2019-09-02 09:53:26 -05:00
Jack Christensen
53921a0a22 Allow reading a result row multiple times
refs #478
2019-08-31 10:50:14 -05:00
Jack Christensen
4a320500cf Remove barely used ProtocolError type 2019-08-27 18:31: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
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
29f02807b0 Restore simple protocol support 2019-05-20 20:36:03 -05:00
Jack Christensen
583c8d3b25 Use pgproto3.FieldDescription instead of pgx version
This allows removing a malloc and memcpy.
2019-05-04 13:47:18 -05:00
Jack Christensen
c7d03eb555 Add RowsFromResultReader 2019-04-24 15:57:50 -05:00
Jack Christensen
a19ca0638f Reorganize conn and rows 2019-04-24 14:16:52 -05:00