Commit Graph

3346 Commits (f581584148c5e51c1d05b1418e9ad24d96512220)

Author SHA1 Message Date
Alexey Palazhchenko f581584148 Use Go 1.19's lists for proper formatting 2023-01-23 19:54:30 -06:00
Jack Christensen e48e7a7189 Fix scanning json column into **string
refs https://github.com/jackc/pgx/issues/1470
2023-01-20 18:38:11 -06:00
Mark Chambers 516300aabf spelling: successfully, compatibility 2023-01-16 20:06:01 -06:00
Mark Chambers 62a7e19a04 func multiInsert returns nil when err != nil
I suspect it should return err.
2023-01-16 20:06:01 -06:00
Mark Chambers 672431c0bd Replace deprecated "io/ioutil"
ioutil.TempFile: Deprecated: As of Go 1.17, this function simply calls os.CreateTemp.

ioutil.ReadFile: Deprecated: As of Go 1.16, this function simply calls os.ReadFile.
2023-01-16 20:06:01 -06:00
Mark Chambers 7c0c7dc01e Remove unused test struct. 2023-01-16 20:06:01 -06:00
Jack Christensen fcec008a4c Update CI to test on Go 1.19 2023-01-14 09:37:11 -06:00
Jack Christensen d993cfa8fd Use puddle with Go 1.19 atomics instead of uber atomics
Doing this a bit early to resolve
https://github.com/jackc/pgx/issues/1465. Won't actually tag the release
until Go 1.20 is released to comply with pgx's versioning policy.
2023-01-14 09:31:38 -06:00
Jack Christensen a95cfe5cc5 Fix connect with multiple hostnames when one can't be resolved
If multiple hostnames are provided and one cannot be resolved the others
should still be tried.

Longterm, it would be nice for the connect process to return a list of
errors rather than just one.

fixes https://github.com/jackc/pgx/issues/1464
2023-01-14 09:19:00 -06:00
Mark Chambers c46d792c93 Numeric numberTextBytes() workaround...
This seems a bit of a hack. It fixes the problems demonstrated in my previous commit.

Maybe there's a cleaner way?

Associated: https://github.com/jackc/pgx/issues/1426
2023-01-14 08:42:42 -06:00
Mark Chambers 37c6f97b11 pgtype.Numeric numberTextBytes() encoding bug
Demonstrate the problem with the tests:

...for negative decimal values e.g. -0.01

This causes errors when encoding to JSON:

    "json: error calling MarshalJSON for type pgtype.Numeric"

It also causes scan failures of sql.NullFloat64:

    "converting driver.Value type string ("0.-1") to a float64"

As reported here: https://github.com/jackc/pgx/issues/1426
2023-01-14 08:42:42 -06:00
Alex Goncharov 74f9b9f0a4 Bump github.com/jackc/pgservicefile to v0.0.0-20221227161230-091c0ba34f0a to get rid of vulnerable version of gopkg.in/yaml.v2
Signed-off-by: Alex Goncharov <github@b4bay.com>
2022-12-27 17:31:07 -06:00
Stephen Afam-Osemene 5177e1a8df Add `stephenafamo/scan` reference to README.md 2022-12-27 10:13:36 -06:00
Jack Christensen d4fcd4a897 Support sql.Scanner on renamed base type
https://github.com/jackc/pgtype/issues/197
2022-12-23 14:22:59 -06:00
Wagner Camarao c514b2e0c3 add `pmx` module reference to the readme file 2022-12-23 13:51:59 -06:00
Jack Christensen e66ad1bcec Fix encode to json ignoring driver.Valuer
https://github.com/jackc/pgx/issues/1430
2022-12-23 13:44:09 -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
Jack Christensen 456a242f5c Unregistered OIDs are handled the same as unknown OIDs
This improves handling of unregistered types. In general, they should
"just work". But there are performance benefits gained and some edge
cases avoided by registering types. Updated documentation to mention
this.

https://github.com/jackc/pgx/issues/1445
2022-12-23 13:14:56 -06:00
Jack Christensen d737852654 Fix: driver.Value representation of bytea should be []byte not string
https://github.com/jackc/pgx/issues/1445
2022-12-21 17:54:42 -06:00
Ben Weintraub 29ad306e47 Make MaxConnLifetimeJitter setting actually jitter 2022-12-20 20:18:26 -06:00
Jack Christensen f42af35884 Add support for single dimensional arrays
https://github.com/jackc/pgx/issues/1442
2022-12-20 20:12:12 -06:00
Yevgeny Pats 11fa083a0d fix: Improve errors in batch modes 2022-12-20 19:33:46 -06:00
Mark Chambers 1ce3e0384a pgtype Int fix minimum error message.
Previously on the minimum condition the error would be:

  "is greater than maximum"

Also add encoding/json import into the .erb template as the import was
missing after running rake generate.
2022-12-17 09:10:02 -06:00
Alejandro Do Nascimento Mora e58381ac94 Enable some CopyFrom tests for cockroachDB
CockroachDB added support for COPY in version 20.2.

https://www.cockroachlabs.com/docs/v20.2/copy-from

There are some limitations on the implementation, that's why not all the
existing tests were enabled.
2022-12-12 18:22:32 -06:00
Jack Christensen 279c3c0a20 Fix: json values work with sql.Scanner
https://github.com/jackc/pgx/issues/1418
2022-12-06 19:44:55 -06:00
Jack Christensen 17f8f7af63 Release v5.2.0 2022-12-05 20:41:55 -06:00
Jack Christensen f0a73424b1 Fix: Scan uint and uint64 ScanNumeric
fixes https://github.com/jackc/pgx/issues/1414
2022-12-05 20:34:46 -06:00
Vitalii Solodilov 88b373f9ee Skipped multirange tests for postgres less than 14 version 2022-12-01 19:33:33 -06:00
Vitalii Solodilov 8e2de2fefa Conn.LoadType supports range and multirange types (#1393)
Closes #1393
2022-12-01 19:33:33 -06:00
Nazar Vovk 24c53259f8 Fix typo 2022-11-28 09:36:20 -06:00
ksco 8eb062f588 perf(tx): use strings.Builder to avoid the overhead of []byte -> string conversion 2022-11-25 12:39:22 -06:00
Petr Evdokimov fbfafb3edf Optimize 'beginSQL' runtime and memory allocations 2022-11-22 09:00:12 -06:00
Vitalii Solodilov 174224fa07 The tracelog.TraceLog implements the pgx.PrepareTracer interface
Allows Tracelog to log the Prepare queiries.

Fixes #1383

Unit tests:
* added logger.Clear method to cleanup old log messages
* added logger.FilterByMsg to get only specific logs for assertions. When quieries are executed using different query exec methods prepare query can be not executed. So we can get different number of logs using different exec methods.
2022-11-19 07:43:39 -06:00
Jack Christensen 8ad1394f4c Update changelog for v5.1.1 2022-11-17 19:47:09 -06:00
Bodo Kaiser 56633b3d51 removed unnecessary name argument from DeallocateAll 2022-11-17 19:41:18 -06:00
Jack Christensen ba4bbf92af Fix query sanitizer
...when query text has contains Unicode replacement character.
uft8.RuneError actually is a valid character.
2022-11-14 18:32:26 -06:00
Jack Christensen b4d2eae777 Update changelog 2022-11-12 11:02:55 -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 8678ed560f Update puddle to v2.1.2 2022-11-12 10:42:08 -06:00
Jack Christensen 05924a9d6b Update CONTRIBUTING.md 2022-11-12 10:42:02 -06:00
Jack Christensen 2e9e2865f9 Added more docs and tests 2022-11-12 10:13:20 -06:00
Pavlo Golub 14be51536b implement `RowToStructByName` and `RowToAddrOfStructByName` 2022-11-12 09:39:54 -06:00
Jack Christensen 1376a2c0ed Update Go doc badge 2022-11-12 09:23:07 -06:00
Jack Christensen 932f676cfd Remove PG 10 from CI and add PG 15 to CI
PG 10 is now out of support.
2022-11-12 09:20:48 -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 b265fedd75 Correct error message 2022-11-12 07:06:54 -06:00
Jack Christensen 871f14e43b Fix text decoding of dates with 5 digit years 2022-11-12 07:01:11 -06:00
Jack Christensen 071d1c9467 DateCodec.DecodeValue can return pgtype.InfinityModifier
Previously, an infinite value was returned as a string. Other types
that can be infinite such as Timestamptz return a
pgtype.InfinityModifier. This change brings them into alignment.
2022-11-12 06:27:41 -06:00
Jack Christensen 29109487ec DateCodec.DecodeDatabaseSQLValue returns time.Time when possible
Previously it returned a string. However, this was an unintended
behavior change from pgx v4.

89f69aaea9 (commitcomment-89173737)
2022-11-12 06:21:48 -06:00