3382 Commits

Author SHA1 Message Date
Jack Christensen
e48596555e Add Windows non-blocking IO 2023-02-25 11:43:21 -06:00
Jack Christensen
38e09bda4c Fix *wrapSliceEncodePlan[T].Encode
It should pass a FlatArray[T] to the next step instead of a
anySliceArrayReflect. By using a anySliceArrayReflect, an encode of
[]github.com/google/uuid.UUID followed by []string into a PostgreSQL
uuid[] would crash. This was caused by a EncodePlan cache collision
where the second encoding used part of the cached plan of the first.

In proper usage a cache collision shouldn't be able to occur. If this
assertion proves incorrect it will be necessary to add an optional
interface to ScanPlan and EncodePlan that marks the plan as ineligable
for caching. But I have been unable to construct a failing case, and
given that ScanPlans have been cached for quite some time now without
incident I do not think it is possible. This issue only occurred due to
the bug in *wrapSliceEncodePlan[T].Encode.

https://github.com/jackc/pgx/issues/1502
2023-02-21 21:04:30 -06:00
Ch. König
9567297815 add mgx module reference to the readme file 2023-02-17 08:58:34 -06:00
Jack Christensen
42d327f660 Add text format jsonpath support 2023-02-14 19:52:47 -06:00
Jack Christensen
f17c743c3c Unwatch at end of test
https://github.com/jackc/pgx/issues/1505
2023-02-14 09:03:41 -06:00
Jack Christensen
a6ace8969b Fix: Prefer sql.Scanner before TryWrapScanPlanFuncs
This was already the case when the data type was unknown but should also
be the case when it is known.
2023-02-14 09:03:41 -06: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
Jack Christensen
c5daa3a814 Release v5.3.0 v5.3.0 2023-02-11 09:15:31 -06:00
Jack Christensen
f5d2da7a19 Upgrade golang.org/x/crypto and golang.org/x/text 2023-02-11 08:59:51 -06:00
Jack Christensen
b8262ace75 Upgrade to puddle v2.2.0 2023-02-11 08:57:19 -06:00
Jack Christensen
2100a64dbe Fix broken benchmarks 2023-02-10 20:26:18 -06:00
Jack Christensen
4484831550 Prefer binary format for arrays
This improves performance decoding text[].
2023-02-10 20:21:25 -06:00
Jack Christensen
1f43e2e490 Fix text format array decoding with a string of "NULL"
It was incorrectly being treated as NULL instead of 'NULL'.

fixes https://github.com/jackc/pgx/issues/1494
2023-02-10 19:59:03 -06:00
Jack Christensen
b707faea8f Fix flickering test TestBufferNonBlockingRead 2023-02-10 19:40:31 -06:00
Vitalii Solodilov
255f16b00f Register pgx driver using major version
Fixed: #1480
2023-02-10 19:18:45 -06:00
Felix Röhrich
a47e836471 make TestPointerPointerStructScan easier to read 2023-02-10 19:06:20 -06:00
Felix Röhrich
5cd8468b99 replace erroneous reflect.New with reflect.Zero in TryWrapStructScanPlan 2023-02-10 19:06:20 -06:00
Felix Röhrich
fa5fbed497 add filter for dropped attributes in getCompositeType 2023-02-07 08:45:56 -06:00
Jack Christensen
190c05cc24 CI fix: Go versions are strings
Otherwise Go 1.20 was being treated as Go 1.2.
2023-02-04 07:32:13 -06:00
Jack Christensen
c875abea84 Fix encode []any to array
https://github.com/jackc/pgx/issues/1488
2023-02-04 07:28:52 -06:00
Jack Christensen
98543e0354 Update supported Go versions and add 1.20 to CI 2023-02-04 07:01:03 -06:00
Jack Christensen
32c29a6edd Update issue template to use pgx v5 2023-02-01 19:40:25 -06:00
Jack Christensen
9963c32d4f Only count when bytes actually read 2023-01-31 20:35:44 -06:00
Jack Christensen
6bc327b3ce Find fastest possible read time for fakeNonblockingReadWaitDuration
The first 5 fake non-blocking reads are limited to 1 byte. This should
ensure that there is a measurement of a read where bytes are already
waiting in Go or the OS's read buffer.
2023-01-31 20:25:57 -06:00
Jack Christensen
f46d35610e Only set c.fakeNonblockingReadWaitDuration when it will be decreased 2023-01-31 20:25:17 -06:00
Jack Christensen
cf78472ce5 Use unix build tag
With Go 1.19 available we can use a simpler build tag.
2023-01-31 20:10:34 -06:00
Yumin Xia
766d2bba4f add UnmarshalJSON for pgtype Numeric 2023-01-30 21:33:02 -06:00
Jack Christensen
384a581e99 Avoid slightly overflowing the send copy buffer
This avoids send buffer sequences such as 65531, 13, 65531, 13, 65531,
13, 65531, 13.
2023-01-30 20:59:54 -06:00
Jack Christensen
898891a6ee Fake non-blocking read adapts its max wait time
The reason for a high max wait time was to ensure that reads aren't
cancelled when there is data waiting for it in Go or the OS's receive
buffer. Unfortunately, there is no way to know ahead of time how long
this should take.

This new code uses 2x the fastest successful read time as the max read
time. This allows the code to adapt to whatever host it is running on.

https://github.com/jackc/pgx/issues/1481
2023-01-28 09:35:52 -06:00
Jack Christensen
7019ed1edf Fix tests for iobufpool optimization 2023-01-28 09:30:12 -06:00
Jack Christensen
eee854fb06 iobufpool uses *[]byte instead of []byte to reduce allocations 2023-01-28 08:02:49 -06:00
Jack Christensen
bc754291c1 Save memory on non blocking read path
Only create RawConn.Read callback once and have it use NetConn fields.
Avoids the closure and some allocations.

https://github.com/jackc/pgx/issues/1481
2023-01-27 20:53:30 -06:00
Jack Christensen
2c7d86a543 Only create RawConn.Write callback once
This saves an allocation on every call.

https://github.com/jackc/pgx/issues/1481
2023-01-27 20:34:21 -06:00
Jack Christensen
42a47194a2 Memoize encode plans
This significantly reduces memory allocations in paths that repeatedly
encode the same type of values such as CopyFrom.

https://github.com/jackc/pgx/issues/1481
2023-01-27 20:19:06 -06:00
Jack Christensen
7941518809 BufferReadUntilBlock should release buf when no bytes read
This was causing allocations every time there was a non-blocking read
with nothing to read.

https://github.com/jackc/pgx/issues/1481
2023-01-27 18:03:38 -06:00
Alexey Palazhchenko
f839d501a7 Apply gofmt -s
And add CI check for that.
2023-01-24 07:55:00 -06:00
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