33 Commits

Author SHA1 Message Date
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
d7c7ddc594 Fix Windows 386 atomic usage
https://github.com/jackc/pgx/issues/1307
2022-09-24 09:23:36 -05:00
Jack Christensen
906f709e0c Fix typo in Windows code
https://github.com/jackc/pgx/issues/1274
2022-08-11 20:59:37 -05:00
Jack Christensen
33b782a96d Potential fix for Windows
https://github.com/jackc/pgx/issues/1274
2022-08-11 20:55:50 -05:00
Jack Christensen
a5b4f888c2 Fix flickering test on CI
Ensure the conn reads everything expected before closing.
2022-07-16 18:16:19 -05:00
Jack Christensen
ca41a6a222 Update docs 2022-07-10 14:32:08 -05:00
Jack Christensen
e7aa76ccf9 SendBatch now uses pipeline mode to prepare and describe statements
Previously, a batch with 10 unique parameterized statements executed
100 times would entail 11 network round trips. 1 for each prepare /
describe and 1 for executing them all. Now pipeline mode is used to
prepare / describe all statements in a single network round trip. So it
would only take 2 round trips.
2022-07-09 09:32:36 -05:00
Jack Christensen
ed3e9f1dd4 Check for more specific error 2022-07-01 15:33:12 -05:00
Jack Christensen
9afd320b9e Fix flickering test in CI
While this test always worked on my machine, it flickered in CI. And to
be fair the test can't guarantee the condition it is testing. Work
around this by trying many times before admitting failure.
2022-06-25 16:05:20 -05:00
Jack Christensen
72b1dcff2f Add pgconn.CheckConn 2022-06-25 15:55:09 -05:00
Jack Christensen
811d855a35 Add non-blocking IO
This eliminates an edge case that can cause a deadlock and is a
prerequisite to cheaply testing connection liveness and to recoving a
connection after a timeout.

https://github.com/jackc/pgconn/issues/27

Squashed commit of the following:

commit 0d7b0dddea1575e9fd72592665badb8cbdd581cc
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 25 13:15:05 2022 -0500

    Add test for non-blocking IO preventing deadlock

commit 79d68d23d38bb03ddb8bf13cb45792430eaf959a
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 18 18:23:24 2022 -0500

    Release CopyFrom buf when done

commit 95a43139c7b0b7557898c4480e5b3e42417ee3c0
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 18 18:22:32 2022 -0500

    Avoid allocations with non-blocking write

commit 6b63ceee076794bc4380495a55dd414dbbd08a43
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 18 17:46:49 2022 -0500

    Simplify iobufpool usage

commit 60ecdda02e5a24c894df4f58d31c485b90de5d5b
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 18 11:51:59 2022 -0500

    Add true non-blocking IO

commit 7dd26a34a182d4aacaed3bf8c09f9cc48a7b6156
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 4 20:28:23 2022 -0500

    Fix block when reading more than buffered

commit afa702213f1b6d24c976406448301b2be53b7f70
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 4 20:10:23 2022 -0500

    More TLS support

commit 51655bf8f40321d5f89bc3c02dd55fba0ac6aa49
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 4 17:46:00 2022 -0500

    Steps toward TLS

commit 2b80beb1ed75f0f58db8188b87753dbc26b62098
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 4 13:06:29 2022 -0500

    Litle more TLS support

commit 765b2c6e7b034ff6ffab3974579fd6ee7add593b
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 4 12:29:30 2022 -0500

    Add testing of TLS

commit 5b64432afbed9224f9512cc46624c88e7ebec625
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 4 09:48:19 2022 -0500

    Introduce testVariants in prep for TLS

commit ecebd7b103d4a9125c61e83f3651b950658b0b84
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 4 09:32:14 2022 -0500

    Handle and test read of previously buffered data

commit 09c64d8cf3ca5be1a31bef46bf78fa5cb9fae831
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 4 09:04:48 2022 -0500

    Rename nbbconn to nbconn

commit 73398bc67a7b7bd1aa044fb9b0546f4198ef92d2
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 4 08:59:53 2022 -0500

    Remove backup files

commit f1df39a29d23ae4e5175b92c69697f2bf9b4e112
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 4 08:58:05 2022 -0500

    Initial passing tests

commit ea3cdab234343fc9761d9b7966c5346179cd1b01
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat Jun 4 08:38:57 2022 -0500

    Fix connect timeout

commit ca22396789d120ff556f9704f4470268fbc8c0d8
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Thu Jun 2 19:32:55 2022 -0500

    wip

commit 2e7b46d5d7454daf0859dd48f8a8e190995164c5
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Mon May 30 08:32:43 2022 -0500

    Update comments

commit 7d04dc5caa80cb147929b6f65bab60a27baaff89
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat May 28 19:43:23 2022 -0500

    Fix broken test

commit bf1edc77d70465b4097a59c08c581033d2033ac6
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat May 28 19:40:33 2022 -0500

    fixed putting wrong size bufs

commit 1f7a855b2e4d1e14f85ac5f5683e2b93db0a4bd9
Author: Jack Christensen <jack@jackchristensen.com>
Date:   Sat May 28 18:13:47 2022 -0500

    initial not quite working non-blocking conn
2022-06-25 13:15:31 -05:00
Jack Christensen
e12ba1b6b9 Extract iobufpool 2022-05-28 10:59:54 -05:00
Jack Christensen
5714896b10 Restructure sending messages
Use an internal buffer in pgproto3.Frontend and pgproto3.Backend instead
of directly writing to the underlying net.Conn. This will allow tracing
messages as well as simplify pipeline mode.
2022-05-21 11:06:44 -05:00
Jack Christensen
1f4b34f932 Merge branch 'master' into v5-dev 2022-04-23 11:05:24 -05:00
Jack Christensen
c323ab6662 Merge remote-tracking branch 'pgconn/master' into v5-dev 2022-04-23 10:48:44 -05:00
Jack Christensen
f14fb3d692 Replace interface{} with any 2022-04-09 09:12:55 -05:00
Jack Christensen
f27178ba85 Initial privatization of stmtcache
ConnConfig.BuildStatementCache is pending removal once connections
always have separate caches for prepared and described statements.
2022-03-12 08:35:31 -06:00
Jack Christensen
1cef9075d9 Simply typed nil and driver.Valuer handling
* Convert typed nils to untyped nils at beginning of encoding process.
* Restore v4 json/jsonb null behavior
* Add anynil internal package
2022-03-05 19:53:59 -06:00
Andrew Rusakow
a86ece025c Fix single line comment for line endings in mac when sanitizing. 2022-03-04 18:17:40 -06:00
Jack Christensen
2e0ec225de Make Chunkreader an internal implementation detail 2022-02-26 08:50:46 -06:00
Jack Christensen
d13f651810 Finish importing pgio as internal package 2022-02-21 14:35:20 -06:00
Jack Christensen
95cbbfe441 Import pgproto3
Also copy in pgmock as an internal package.
2022-02-21 13:22:42 -06:00
Jack Christensen
72cc95e4dd Bump module version to v5 2021-12-11 13:29:03 -06:00
Jack Christensen
162dc65eff Make ContextWatcher concurrency safe
fixes #94
2021-11-06 08:57:49 -05:00
Jack Christensen
a49f4bb135 Use errors instead of golang.org/x/xerrors 2021-03-25 09:55:12 -04:00
Rusakow Andrew
292539a590 Add comment support when sanitizing SQL queries 2021-03-13 07:31:56 -06:00
Jack Christensen
5d2be99c25 Fix panic when closing conn during cancellable query
fixes #29
2020-04-07 19:38:21 -05:00
Andrew Nicoll
816e95d3ee sanatize time to within microsecond accuracy 2020-03-27 13:03:36 +00:00
Jack Christensen
29f02807b0 Restore simple protocol support 2019-05-20 20:36:03 -05:00
Jack Christensen
1baf0ef57e Refactor context handling into ctxwatch package 2019-05-07 18:05:06 -05:00
Jack Christensen
c53c9e6eb5 Remove simple protocol and one round trip query options
It is impossible to guarantee that the a query executed with the simple
protocol will behave the same as with the extended protocol. This is
because the normal pgx path relies on knowing the OID of query
parameters. Without this encoding a value can only be determined by the
value instead of the combination of value and PostgreSQL type. For
example, how should a []int32 be encoded? It might be encoded into a
PostgreSQL int4[] or json.

Removal also simplifies the core query path.

The primary reason for the simple protocol is for servers like PgBouncer
that may not be able to support normal prepared statements. After
further research it appears that issuing a "flush" instead "sync" after
preparing the unnamed statement would allow PgBouncer to work.

The one round trip mode can be better handled with prepared statements.

As a last resort, all original server functionality can still be accessed by
dropping down to PgConn.
2019-04-13 11:39:01 -05:00
Jack Christensen
8f4178b3d3 Use github.com/pkg/errors 2017-06-04 21:30:03 -05:00
Jack Christensen
7b1f461ec3 Add simple protocol suuport with (Query|Exec)Ex 2017-04-10 08:58:51 -05:00