128 Commits

Author SHA1 Message Date
Jack Christensen
340bfece2c Do not asyncClose in response to a FATAL PG error
This will reduce spurious server log messages on authentication
failures. See https://github.com/jackc/pgconn/pull/53.
2020-10-29 21:20:28 -05:00
Jack Christensen
0d4f029683 Exec(Params|Prepared) return ResultReader with FieldDescriptions loaded
Previously, it wasn't loaded until NextRow was called the first time.
2020-09-05 13:14:14 -05:00
Sebastiaan Mannem
5db484908c Changing SendBytesWithResults to ReceiveResults (that only does the reading). 2020-08-22 20:38:04 -05:00
Sebastiaan Mannem
1debbfeec4 Adding SendBytesWithResults option to receive data after sending a message (used by copy-both) 2020-08-22 20:38:04 -05:00
Jack Christensen
fdfc783345 Rename CleanupChan to CleanupDone 2020-08-20 22:08:40 -05:00
Jack Christensen
3eb5432c47 Add PgConn.CleanupChan 2020-08-20 22:00:21 -05:00
Jack Christensen
4e4c4ea541 Fix deadlock on error after CommandComplete but before ReadyForQuery
See: https://github.com/jackc/pgx/issues/800
2020-07-29 21:47:23 -05:00
Jack Christensen
2647eff567 Fix ValidateConnect with cancelable context
fixes #40
2020-05-25 11:49:37 -05:00
Jack Christensen
8c33aa2443 Remove CPU wasting empty default statement
fixes #39
2020-05-23 11:47:42 -05:00
Jack Christensen
2ccb66fe21 Doc fix 2020-05-16 18:48:05 -05:00
Jack Christensen
fafefa6063 Merge branch 'improve-connect-timeout' of git://github.com/georgysavva/pgconn into georgysavva-improve-connect-timeout 2020-05-13 07:43:15 -05:00
georgysavva
2d5a17beab Add comment. 2020-05-02 16:39:51 +03:00
georgysavva
391e1ef2ce Parse connect timeout setting into Config. Restrict context timeout via Config.ConnectTimeout on .Connect() call. 2020-05-02 16:35:22 +03:00
Tobias Salzmann
8d9293e1e7
Update pgconn.go 2020-04-30 11:27:01 +02:00
Tobias Salzmann
8f3f335b0f
concludeCommand should not throw away fieldDescriptions 2020-04-30 11:22:43 +02:00
Jack Christensen
5d2be99c25 Fix panic when closing conn during cancellable query
fixes #29
2020-04-07 19:38:21 -05:00
Jack Christensen
911e727d78 ExecParams and ExecPrepared handle empty query
An empty query does not return CommandComplete. Instead it returns
EmptyQueryResponse.
2020-03-07 10:55:29 -06:00
Jack Christensen
ac364e7a43 Use writeError for Write error 2020-02-07 15:40:50 -06:00
Jack Christensen
c9abb86f21 Ensure write failure in CopyFrom closes connection 2020-01-25 20:40:21 -06:00
Jack Christensen
67f2418279 Make copyErrChan buffered so goroutine can always terminate
It is possible the goroutine that is reading from copyErrChan will not
read in case of error.
2020-01-25 20:39:18 -06:00
Jack Christensen
139342081e Fix CopyFrom deadlock when multiple NoticeResponse received during copy
fixes #21
2020-01-25 20:32:42 -06:00
Jack Christensen
5952524511 Add Hijack and Construct
fixes #9
2020-01-17 17:38:56 -06:00
Jack Christensen
2582879459 Fix typo - rename ayncClose to asyncClose 2020-01-12 16:28:56 -06:00
Jack Christensen
0df97353b8 Fix racy usage of pgConn.contextWatcher in ayncClose 2020-01-12 16:27:46 -06:00
Jack Christensen
fd2093cef8 Add statement type convenience methods to CommandTag and optimize
Added convenient way to check whether a statement was a select, insert,
update, or delete. These methods do not allocate.

RowsAffected now does not allocate even when a large number of rows are
affected. It also is multiple times faster, though the absolute change
is inconsequential.
2020-01-11 18:42:31 -06:00
Jack Christensen
ed1391568c Merge branch 'master' of git://github.com/bakape/pgconn into bakape-master 2020-01-11 18:08:34 -06:00
bakape
9decdbc2ec Revert nil context support 2020-01-11 16:53:50 +02:00
Jack Christensen
98b3c57584 Try to cancel any in-progress query when a conn is closed by ctx cancel
See https://github.com/jackc/pgx/issues/659
2020-01-08 10:03:54 -06:00
bakape
9372218107 Don't synchronize with context.Background() 2020-01-01 19:34:56 +02:00
bakape
89416dd805 Enable passing nil context 2020-01-01 13:09:50 +02:00
Jack Christensen
dd53b7488d Restart signalMessage when receiving non-error message in CopyFrom
fixes #21
2019-12-21 11:52:45 -06:00
Jack Christensen
eb81d2926b Ignore errors sending Terminate message while closing connection
This mimics the behavior of libpq PGfinish.

refs #637
2019-11-18 07:29:57 -06:00
Jack Christensen
fcfd7d09a9 Add PgConn.IsBusy() method 2019-10-12 10:21:46 -05:00
Artemiy Ryabinkov
e538885fa7
skip resolve for unix sockets
Signed-off-by: Artemiy Ryabinkov <getlag@ya.ru>
2019-09-13 17:52:01 +03:00
Artemiy Ryabinkov
b2ca5d8f52
validate all addresses resolved from hostname
Signed-off-by: Artemiy Ryabinkov <getlag@ya.ru>
2019-09-13 17:26:09 +03:00
Jack Christensen
2f6b8f3f56 Fix context timeout on connect 2019-08-31 17:01:54 -05:00
Jack Christensen
2fabfa3c18 Update to newest pgproto3 2019-08-31 15:44:54 -05:00
Jack Christensen
66aaed7c9e Remove public fields from PgConn
- Access TxStatus via method
- Make Config private

fixes #7
2019-08-27 18:11:50 -05:00
Jack Christensen
138254da5b Refactor errors
- Use strongly typed errors internally
- SafeToRetry(error) streamlines retry logic over ErrNoBytesSent
- Timeout(error) removes the need to choose between returning a context
  and an i/o error
2019-08-27 18:05:50 -05:00
Jack Christensen
595d09d6f1 Build fully operational Frontend 2019-08-24 23:57:24 -05:00
Jack Christensen
6feea0c1c5 Replace IsAlive with IsClosed
IsAlive is ambiguous because the connection may be dead and we do not
know it. It implies the possibility of a ping. IsClosed is clearer -- it
does not promise the connection is alive only that it hasn't been
closed.

fixes #2
2019-08-24 23:43:26 -05:00
Jack Christensen
da9fc85c44 Rename PreparedStatementDescription to StatementDescription
PreparedStatementDescription was too long. It also no longer entirely
represents its purpose now that it is also intended for use with
described statements.
2019-08-24 20:39:03 -05:00
Jack Christensen
beba629bb5 Fix result reader returned by locked conn 2019-08-24 17:18:29 -05:00
Jack Christensen
797a44bf04 Rename BuildFrontendFunc to BuildFrontend
For consistency with other functions supplied in Config.
2019-08-24 16:18:04 -05:00
Jack Christensen
760dd75542 Require Config to be created by ParseConfig 2019-08-24 09:28:44 -05:00
Jack Christensen
1558987979 ReceiveMessage returns context error instead of io error on cancel 2019-08-22 20:11:27 -05:00
Jack Christensen
11255efe7a Make ErrorResponseToPgError public 2019-08-20 15:49:57 -05:00
Jack Christensen
d364370a31 Add SendBytes and ReceiveMessage 2019-08-20 14:12:07 -05:00
Jack Christensen
0a2ed72cf7
Merge pull request #10 from furdarius/configurable-chunkreader-buf
Configurable chunkreader buffer size
2019-08-08 15:49:17 -05:00
Artemiy Ryabinkov
0a99b543c0
Add BuildFrontendFunc in Config
Signed-off-by: Artemiy Ryabinkov <getlag@ya.ru>
2019-08-08 11:46:25 +03:00