39 Commits

Author SHA1 Message Date
Jack Christensen
5ed95dcd1c Expose wrap functions on ConnInfo
- Remove rarely used ScanPlan.Scan arguments
- Plus other refactorings and fixes that fell out of this change.
- Plus rows Scan now handles checking for changed type.
2022-01-22 17:50:19 -06:00
Jack Christensen
2b395f3730 pgtype.DataType.Codec can never be nil 2022-01-22 12:21:16 -06:00
Jack Christensen
db95cee40c Remove pgtype.Value interface 2022-01-22 12:18:40 -06:00
Jack Christensen
4cf6dc9447 Remove BinaryEncoder and TextEncoder 2022-01-22 12:16:02 -06:00
Jack Christensen
f573cde09c Convert bytea to Codec 2022-01-08 18:33:08 -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
9fc8f9b3a8 Initial passing tests for main pgx package 2021-12-30 18:12:47 -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
Jack Christensen
a49f4bb135 Use errors instead of golang.org/x/xerrors 2021-03-25 09:55:12 -04:00
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