Simon Paredes
89d699c2e8
wrap errors instead of just formatting them
2023-12-01 18:23:23 -06:00
Sam Whited
94e56e61ba
Fix usage of logger in stdlib docs
...
The documentation previously showed the old way of logging and not the
newer tracer adapter. This patch updates the example to build correctly
with pgx/v5.
Signed-off-by: Sam Whited <sam@samwhited.com>
2023-11-22 08:15:05 -06:00
Jack Christensen
cf6ef75f91
stdlib: Use Ping instead of CheckConn in ResetSession
...
CheckConn is deprecated. It doesn't detect all network outages. It
causes a 1ms delay while it tries to read the connection. Ping incurs a
round trip but that means it is a much stronger guarantee that the
connection is usable. In addition, if the application and the database
are on the same network it will actually be faster as round trip times
are typically a few hundred microseconds.
2023-10-26 20:41:44 -05:00
Jack Christensen
7a2b93323c
Prevent prematurely closing statements in database/sql
...
This error was introduced by 0f0d236599
.
If the same statement was prepared multiple times then whenever Close
was called on one of the statements the underlying prepared statement
would be closed even if other statements were still using it.
https://github.com/jackc/pgx/issues/1754#issuecomment-1752004634
2023-10-10 21:56:26 -05:00
Jack Christensen
0f0d236599
database/sql prepared statement names are deterministically generated
...
stdlib now uses the functionality introduced in
bbe2653bc5
for prepared statements. This
means that the prepared statement name is stable for a given query even
across connections and program executions.
It also makes tracing easier.
See https://github.com/jackc/pgx/issues/1754
2023-10-07 10:16:25 -05:00
Vincent Le Goff
d93f31b8fa
docs: GetPoolConnector
2023-09-25 08:51:12 -05:00
Lev Zakharov
b301530a5f
add doc for OpenDBFromPool
2023-09-09 08:13:56 -05:00
Lev Zakharov
f42824cab3
update docs
2023-09-09 08:13:56 -05:00
Lev Zakharov
18856482c4
remove before/after acquire hooks
2023-09-09 08:13:56 -05:00
Lev Zakharov
3e716c4b06
add example to the doc
2023-09-09 08:13:56 -05:00
Lev Zakharov
51ade172e5
refactor to use the same connection implementation
2023-09-09 08:13:56 -05:00
Tomáš Procházka
c2e278e5d4
simplify duplicate `pgx` registration guard
...
The binary search is overkill here.
Readability first.
2023-02-13 21:08:42 -06:00
Vitalii Solodilov
255f16b00f
Register pgx driver using major version
...
Fixed : #1480
2023-02-10 19:18:45 -06:00
Alexey Palazhchenko
f839d501a7
Apply `gofmt -s`
...
And add CI check for that.
2023-01-24 07:55:00 -06:00
Jack Christensen
3595561d9a
More doc improvements
2022-07-23 09:29:25 -05:00
Jack Christensen
03da9fcec6
Check conn liveness before using when idle for more than 1 second
...
Implemented in pgxpool.Pool and database/sql.
https://github.com/jackc/pgx/issues/672
2022-06-25 17:58:53 -05:00
Jack Christensen
e94cf1fbaa
Remove AcquireConn and ReleaseConn
...
Superseded by (*sql.Conn) Raw()
2022-04-16 14:07:59 -05:00
Jack Christensen
fccaebc93d
Add pgtype.Map.SQLScanner
...
This enables compatibility with database/sql for types that cannot
implement Scan themselves.
2022-04-16 13:38:27 -05:00
Jack Christensen
f14fb3d692
Replace interface{} with any
2022-04-09 09:12:55 -05: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
4b6d527b0b
Merge branch 'master' into v5-dev
2022-02-12 09:22:37 -06:00
Isabel Jimenez
71da600c3a
exposing stdlib DB connector
2022-02-12 09:11:56 -06:00
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
8b27725f5b
Convert json and jsonb to Codec
2022-01-18 16:04:25 -06:00
Jack Christensen
eec82c9433
Replace CID, OID, OIDValue, and XID with Uint32
2022-01-09 00:35:49 -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
Dmytro Haranzha
cabb58cc40
ResetSession hook is called before a connection is reused from pool for another query.
2021-06-12 13:48:31 -05:00
dkinder
00feeaa5c9
stdlib: style nit in RandomizeHostOrderFunc
2021-05-10 08:17:53 -05:00
dkinder
a8020a21e8
stdlib: add OptionBeforeConnect and randomizer
...
Fixes https://github.com/jackc/pgconn/issues/71
2021-05-10 08:17:53 -05:00
Andrew Kimball
3ab8941921
stdlib: Do not reuse ConnConfig strings
...
Previously, stdlib.RegisterConnConfig would sometimes reuse the same connection
string for different ConnConfig options (specifically, it happened when a connection
was open and then closed, and then a new, different connection was opened). This
behavior interferes with callers that expect that two connections with the same data
source name are connecting to the same backend database in the same way.
This fix updates stdlib.RegisterConnConfig to use an incrementing sequence
counter to uniquify all returned connection strings.
Fixes #947
2021-04-03 10:52:37 -05:00
Jonathan Amsterdam
88ede6efb5
stdlib: implement Conn.ResetSession
...
This prevents closed connections from being returned
by `database.sql.DB.Conn`.
Fixes #974 .
2021-03-26 10:25:07 -05:00
Jack Christensen
a49f4bb135
Use errors instead of golang.org/x/xerrors
2021-03-25 09:55:12 -04:00
Jack Christensen
e93da6c744
Fix ignored deferred error with database/sql QueryRow
...
fixes #958
2021-03-13 06:52:58 -06:00
Jack Christensen
82bac82213
stdlib: consider any Ping failure as fatal
...
refs #672
2020-12-03 19:41:03 -06:00
Jack Christensen
4ebf1d2e0b
Passthrough all parameters directly to pgx
2020-07-18 08:44:57 -05:00
Jack Christensen
c8a9da960c
Revert "stdlib: close connection on Tx commit or rollback that doesn't end Tx"
...
This reverts commit 2583134306
.
This fix should actually be on the main Tx implementation.
2020-07-13 22:48:28 -05:00
Jack Christensen
2583134306
stdlib: close connection on Tx commit or rollback that doesn't end Tx
...
refs #787
2020-07-13 22:40:42 -05:00
zikaeroh
84510c4590
Cache column names in stdlib Rows
2020-06-29 10:20:13 -07:00
Jack Christensen
bf47a3d0a4
Fix stdlib decoding error with certain order and combination of fields
...
fixes #781
2020-06-29 09:38:53 -05:00
Jack Christensen
4e50623069
Fix stdlib number size conversions
2020-06-06 09:54:19 -05:00
Jack Christensen
81140f6c27
Improve stdlib performance with large results
2020-06-06 09:49:14 -05:00
Jack Christensen
8dee3382f7
Improve unknown type support for database/sql
...
- Return unknown type OID instead of empty string for type name.
- ScanType is string instead of empty interface for unknown types.
fixes #759
2020-05-30 13:27:25 -05:00
Jack Christensen
837704dc7d
Update stdlib docs to point to Conn.Raw instead of AcquireConn
2020-05-30 13:27:25 -05:00
Jack Christensen
2bd26ec7fa
Expose stdlib.Conn.Conn() to enable database/sql.Conn.Raw()
2020-05-30 13:27:25 -05:00
Jack Christensen
64789acf46
Merge pull request #734 from georgysavva/stdlib-timeouts
...
Improve Stdlib context timeouts
2020-05-13 07:45:18 -05:00
Jack Christensen
c44cda4bb4
Clean up old Go 1.10 build tags
...
pgx requires Go modules which requires at least Go 1.11 so there is no
use in build tags to support older Go versions.
2020-05-08 12:18:09 -05:00
Jack Christensen
c03ac1519e
Improve stdlib performance with large result sets
...
In a hot path type assertions are expensive. Cache the already correctly
typed interfaces. ~20% improvement with 1000 rows.
Before:
jack@glados ~/dev/pgx/stdlib ±master » PGX_BENCH_SELECT_ROWS_COUNTS='1 10 1000' got ./... -bench=SelectRows -benchmem
goos: darwin
goarch: amd64
pkg: github.com/jackc/pgx/v4/stdlib
BenchmarkSelectRowsScanSimple/1_rows-16 21465 55060 ns/op 1679 B/op 40 allocs/op
BenchmarkSelectRowsScanSimple/10_rows-16 16692 71176 ns/op 3827 B/op 148 allocs/op
BenchmarkSelectRowsScanSimple/1000_rows-16 800 1369547 ns/op 248855 B/op 12938 allocs/op
BenchmarkSelectRowsScanNull/1_rows-16 20306 57883 ns/op 1940 B/op 54 allocs/op
BenchmarkSelectRowsScanNull/10_rows-16 15942 74729 ns/op 4294 B/op 171 allocs/op
BenchmarkSelectRowsScanNull/1000_rows-16 829 1326788 ns/op 261291 B/op 13051 allocs/op
PASS
ok github.com/jackc/pgx/v4/stdlib 10.429s
After:
jack@glados ~/dev/pgx/stdlib ±master⚡ » PGX_BENCH_SELECT_ROWS_COUNTS='1 10 1000' got ./... -bench=SelectRows -benchmem
goos: darwin
goarch: amd64
pkg: github.com/jackc/pgx/v4/stdlib
BenchmarkSelectRowsScanSimple/1_rows-16 21327 55097 ns/op 2127 B/op 43 allocs/op
BenchmarkSelectRowsScanSimple/10_rows-16 16724 69496 ns/op 4276 B/op 151 allocs/op
BenchmarkSelectRowsScanSimple/1000_rows-16 1009 1124573 ns/op 250037 B/op 12941 allocs/op
BenchmarkSelectRowsScanNull/1_rows-16 20577 58117 ns/op 2396 B/op 57 allocs/op
BenchmarkSelectRowsScanNull/10_rows-16 16402 72533 ns/op 4750 B/op 174 allocs/op
BenchmarkSelectRowsScanNull/1000_rows-16 1010 1161437 ns/op 261735 B/op 13054 allocs/op
PASS
ok github.com/jackc/pgx/v4/stdlib 10.363s
2020-05-08 00:06:42 -05:00