3937 Commits

Author SHA1 Message Date
Jack Christensen
95fc31294f Add link to github.com/KoNekoD/pgx-colon-query-rewriter 2025-08-31 08:38:21 -05:00
Jack Christensen
5534fa9a02 Improve Rows docs
fixes https://github.com/jackc/pgx/issues/2373
2025-08-31 08:24:22 -05:00
Jack Christensen
a295d68811
Merge pull request #2368 from zeghong/zeronull-int-valuer
Implement Int64Valuer for zeronull int types
2025-08-30 18:51:03 -05:00
Jack Christensen
03f32c06bd
Merge branch 'master' into zeronull-int-valuer 2025-08-30 18:50:54 -05:00
Jack Christensen
82fbe49fec
Merge pull request #2372 from WGH-/improve-batch-doc
Add note about QueuedQuery.Exec and BatchResults.Close
2025-08-30 18:40:12 -05:00
Jack Christensen
594d9d65dc
Merge pull request #2367 from zeghong/zeronull-int-scanner
Ensure zeronull int types implement Int64Scanner
2025-08-30 18:40:05 -05:00
Jack Christensen
5a18241971
Merge branch 'master' into zeronull-int-scanner 2025-08-30 18:36:19 -05:00
Jack Christensen
cc34da5884
Merge pull request #2370 from Saurabh2402/improvement/setup-linters
Improvement/setup formatters
2025-08-30 18:24:13 -05:00
Jack Christensen
dd81f81e2f
Merge pull request #2369 from zeghong/go-doc-links
Add support for Go doc comment links
2025-08-30 18:00:27 -05:00
Jack Christensen
839acbaf18 Disable test on CRDB 2025-08-30 17:57:10 -05:00
Jack Christensen
d1a00a6cd4
Merge pull request #2361 from Jk1484/statementCacheBug
invalidate cache on batch error for batchResults and pipelineBatchResults
2025-08-30 17:54:41 -05:00
Jack Christensen
81c0db4f49 Skip TestConnCopyFromConnectionTerminated on CRDB 2025-08-30 17:44:07 -05:00
Jack Christensen
1516fb8125 Fix race condition in test 2025-08-30 17:26:34 -05:00
Jack Christensen
b1ef6d90c0 Merge commit 'cec5ebac' 2025-08-30 12:45:04 -05:00
Jack Christensen
59c73af6bb Add failing test for CopyFrom connection terminated
https://github.com/jackc/pgx/issues/2364
2025-08-30 12:39:12 -05:00
WGH
248afe61b1 Add note about QueuedQuery.Exec and BatchResults.Close
When reviewing my own old code, I noticed several monstrosities like
this:

    batchResult := tx.SendBatch(ctx, batch)
    defer batchResult.Close()
    for range batch.Len() {
            if _, err := batchResult.Exec(); err != nil {
                    return err
            }
    }
    return nil

All of them can replaced with just this:

    return tx.SendBatch(ctx, batch).Close()

So I thought it might be a good idea to give a hint in the docs
explicitly. This trick is not so apparent, after all.
2025-08-20 09:41:06 +03:00
Saurabh2402
88500ac027 format code as per the configuration in .golangci-lint.yaml file 2025-08-16 02:05:40 +05:30
Saurabh2402
f1c8fcd5c2 add formatter configuration in golangci-lint 2025-08-16 02:04:39 +05:30
Li Zeghong
fc289cbbe8 Add support for Go doc comment links 2025-08-15 19:58:19 +08:00
Li Zeghong
5cb495fb94 Implement Int64Valuer for zeronull int types 2025-08-15 17:11:20 +08:00
Li Zeghong
562761a083 Ensure zeronull int types implement Int64Scanner
Also correct error string when comparing minimum value.
2025-08-15 16:04:45 +08:00
Muhammadali Nazarov
fce1a04dbf passing err by value 2025-08-10 21:45:32 -05:00
Jack Christensen
25cba15299
Merge pull request #2362 from christiankiely/shouldping
Support configurable ShouldPing func when acquiring conns
2025-08-09 09:20:46 -05:00
Michal Drausowski
cec5ebac5b Workaround panic crash when receiving terminate connection message while performing CopyFrom 2025-08-06 19:28:53 +02:00
Christian Kiely
f43091fc80
Support configurable ShouldPing func when acquiring conns 2025-08-06 16:06:03 +10:00
Jack Christensen
a11da9a629
Merge pull request #2357 from pkoutsovasilis/master
Add MarshalJSON and UnmarshalJSON for UINT32
2025-08-02 18:30:24 -05:00
Jack Christensen
2f77a63ce2
Merge pull request #2356 from philippgille/patch-1
Fix typo in Godoc
2025-08-02 18:28:21 -05:00
Jack Christensen
39b85ce8d1
Merge pull request #2352 from flimzy/fixGoDoc
Correction and further clarification of PrepareConn GoDoc comment
2025-08-02 08:21:47 -05:00
Muhammadali Nazarov
e04a6de072 invalidate cache on batch error for batchResults and pipelineBatchResults 2025-07-31 05:27:02 -05:00
Panos Koutsovasilis
c39a0608a3
Add MarshalJSON and UnmarshalJSON for UINT32 2025-07-28 09:09:03 +03:00
Philipp Gillé
f661c47dc8
Fix typo in Godoc 2025-07-22 20:18:33 +02:00
Jack Christensen
e68ff102de
Merge pull request #2349 from dominiquelefevre/fewer-allocations-in-QueryContext
Make fewer allocations in QueryContext().
2025-07-12 15:40:16 -05:00
Jonathan Hall
30ff631878 Correction and further clarification of PrepareConn GoDoc comment 2025-07-08 11:45:25 -04:00
Dominique Lefevre
69934dcd95 Make fewer allocations in QueryContext().
For a simple query like `SELECT * FROM t WHERE id = $1`,
QueryContext() used to make 6 allocations on average.
Reduce that to 4 by avoiding two allocations that
are immediately discarded:

  // the variadic arguments of c.conn.Query() escape,
  // so args is heap-allocated
  args := []any{databaseSQLResultFormats}
  // append() reallocates args to add enough space +
  // an array returned by namedValueToInterface()
  // is immediately discarded
  args = append(args, namedValueToInterface(argsV)...)
2025-07-04 14:11:46 +03:00
Jack Christensen
ecc9203ef4
Merge pull request #2336 from pashagolub/fix-docs-links
fix documentation links
2025-06-25 19:44:25 -05:00
Pavlo Golub
33163eefca fix documentation links 2025-06-12 16:01:14 +02:00
Jack Christensen
d2ee7464e8
Merge pull request #2335 from flimzy/acquireBailOut
Attempt to acquire a connection MaxConns + 1 times before aborting
2025-06-03 17:17:42 -05:00
Jack Christensen
1320d13f8a
Merge pull request #2333 from costela/patch-1
chore(docs): add mention to otelpgx lib
2025-06-03 17:14:33 -05:00
Jonathan Hall
f118bb6033 Attempt to acquire a connection MaxConns + 1 times before aborting 2025-06-03 15:09:37 -04:00
Leo Antunes
b0572f79e6
chore(docs): add mention to otelpgx lib 2025-06-03 09:05:22 +02:00
Jack Christensen
4015a0c123
Merge pull request #2329 from flimzy/prepareConn
Add PrepareConn hook, which extends BeforeAcquire's behavior to allow…
2025-05-31 09:55:27 -05:00
Jonathan Hall
48d27a9fff Add PrepareConn hook, which extends BeforeAcquire's behavior to allow canceling the instigating query
- BeforeAcquire now marked as deprecated, and re-implemented in terms of PrepareConn
- PrepareConn now takes precidence over BeforeAcquire if both are provided
- New tests added, so both old and new behavior are tested
- One niggle: AcquireAllIdle does not return an error, so the only recourse
  that seems reasonable when PrepareConn returns an error in that context,
  is to destroy the connection.  This more or less retains the spirit of
  existing functionality, without changing the public API of that method.
  Although maybe an error-returning variant would be a useful addition as
  well.
2025-05-21 11:41:04 -04:00
Jack Christensen
fc334e4c75
Merge pull request #2322 from Nomlsbad/better-parse-config-errors
Use `ParseConfigError` in `pgx.ParseConfig` and `pgxpool.ParseConfig`
2025-05-18 09:03:38 -05:00
Yurasov Ilia
3f5509fe98 fix: remove fmt import from the pgxpool 2025-05-18 02:28:24 +03:00
Jack Christensen
15bca4a4e1 Release v5.7.5 v5.7.5 2025-05-17 17:14:14 -05:00
Jack Christensen
1d557f9116 Remove PlanScan memoization
Previously, PlanScan used a cache to improve performance. However, the
cache could get confused in certain cases. For example, the following
would fail:

m := pgtype.NewMap()
var err error

var tags any
err = m.Scan(pgtype.TextArrayOID, pgx.TextFormatCode, []byte("{foo,bar,baz}"), &tags)
require.NoError(t, err)

var cells [][]string
err = m.Scan(pgtype.TextArrayOID, pgx.TextFormatCode, []byte("{{foo,bar},{baz,quz}}"), &cells)
require.NoError(t, err)

This commit removes the memoization and adds a test to ensure that this
case works.

The benchmarks were also updated to include an array of strings to
ensure this path is benchmarked. As it turned out, there was next to no
performance difference between the cached and non-cached versions.

It's possible there may be a performance impact in certain complicated
cases, but I have not encountered any. If there are any performance
issues, we can optimize the narrower case rather than adding memoization
everywhere.
2025-05-17 16:34:01 -05:00
Jack Christensen
de7fe81d78 Use reflect.TypeFor instead of reflect.TypeOf
Simplified function became available in Go 1.22.
2025-05-17 09:11:31 -05:00
Jack Christensen
d9eb089bd7 Remove unused function 2025-05-17 09:09:07 -05:00
Jack Christensen
6be24eb08d Fix comment typo 2025-05-17 09:01:55 -05:00
Jack Christensen
07871c0a34 Zero internal baseRows references to allow GC earlier
See https://github.com/jackc/pgx/pull/2269
2025-05-17 08:39:54 -05:00