66 Commits

Author SHA1 Message Date
Jack Christensen
19c6689752 Add pgtype.Record and prerequisite restructuring
Because reading a record type requires the decoder to be able to look up oid
to type mapping and types such as hstore have types that are not fixed between
different PostgreSQL servers it was necessary to restructure the pgtype system
so all encoders and decodes take a *ConnInfo that includes oid/name/type
information.
2017-03-18 12:01:16 -05:00
Jack Christensen
94749e580f Remove CopyTo 2017-03-17 14:18:25 -05:00
Jack Christensen
ba5f97176a Move not null Oid to pgtype
In preparation to ConnInfo implementation.
2017-03-13 21:34:38 -05:00
Jack Christensen
743b98b298 Name PG types as words
Though this doesn't follow Go naming conventions exactly it makes names more
consistent with PostgreSQL and it is easier to read. For example, TIDOID becomes
TidOid. In addition this is one less breaking change in the move to V3.
2017-03-11 17:03:23 -06:00
Jack Christensen
b1fc8109db Remove AF_INET fetching system
Also remove old encode/decode inet/cidr code. This removed some functionality
from Rows.Values, but that entire system will soon change anyway.
2017-03-04 18:00:51 -06:00
Jack Christensen
908c439317 Use stdlib context 2017-03-03 16:01:06 -06:00
Jack Christensen
7fbff4a495 Merge branch 'context' into v3-experimental 2017-02-12 15:13:47 -06:00
Jack Christensen
72b6d32e2f Extracted more context handling 2017-02-07 21:49:58 -06:00
Jack Christensen
14eedb4fca Add ConnPool context methods 2017-02-06 18:54:49 -06:00
Jack Christensen
39dad2b795 Merge branch 'master' into v3-experimental 2017-02-04 11:27:12 -06:00
Jack Christensen
d398d95764 Explicitly close checked-in connections on ConnPool.Reset 2017-01-23 22:48:17 -06:00
Jack Christensen
69434056c6 Remove Conn.TxStatus 2017-01-07 14:10:11 -06:00
Jack Christensen
430d4943c7 Replace BeginIso with BeginEx
Adds support for read/write mode and deferrable modes.
2016-12-31 11:48:45 -06:00
Jack Christensen
93e5c68f69 Merge branch 'master' into v3-experimental 2016-12-10 12:21:08 -06:00
Alexander Staubo
f1de186a93 Connection pool timeout should return a consistent error value so clients can test for it. 2016-10-03 15:56:01 -04:00
Martin Hamrle
9f6b99e332 Cleanups
Cleanups suggested by gometalinter tools.
2016-08-30 20:05:44 +02:00
Jack Christensen
5f7d01778e Add CopyTo to support PostgreSQL copy protocol
fixes #102
2016-08-10 16:27:44 -05:00
Jack Christensen
7e43eca3d3 Remove one allocation per pool query 2016-08-08 16:31:01 -05:00
Jack Christensen
390f75c0e1 Reduce Logger interface to Log method 2016-08-02 14:42:31 -05:00
Jack Christensen
214443deb7 Rename Oid to OID 2016-08-02 13:31:55 -05:00
Jack Christensen
ecf158b086 Track and check number of in-progress acquires 2016-07-15 14:46:50 -05:00
konstantin
b96777edf3 Merge branch 'Non_blocking_ConnPool_Acquire' into tmp
Conflicts:
	conn_pool.go
2016-07-06 16:58:04 +03:00
konstantin
809be4bfcb Make ConnPool.Acquire() non blocking, feedback 2016-07-06 16:22:59 +03:00
konstantin
7f9373c7c0 Make ConnPool.Acquire() non blocking
When there was an issue with DB server ConnPool.Acquire() used to block
until it heard back from the server or its OpenTimeout hit. If we had
OpenTimeout set to 3 secs, and there were X go routines trying to aquire a
connection in parallel, the very last go routine would receive timeout
error in X*OpenTimeout seconds because of the blocking nature of the
ConnPool.Acquire().

With this commit ConnPool.Acquire() is not blocking any more, and all
X requests will take about 1*OpenTimeout secs to fail.
2016-07-05 18:04:41 +03:00
Jack Christensen
40f00f4a82 Pass PrepareEx opts as pointer and DRY implementation 2016-05-20 08:30:10 -05:00
Jack Christensen
b06560aa03 Rename Preparex to PrepareEx 2016-05-20 08:14:56 -05:00
William King
2ba5bb405b Slight doc update 2016-05-18 13:27:22 -07:00
William King
e417cc2f15 Preparex 2016-05-18 13:15:15 -07:00
John Barker
a282d9df90 Cache connection properties in the pool
This is a quick attempt to improve connection startup time by caching
the properties that are loaded when a connection is ready in the pool,
so that further connections don't incur this cost.

I'm not entirely convinced by the interface here, perhaps these 3 items
could live in their own type and that be passed around for clearer code,
but the idea works well.
2016-05-10 18:34:26 -04:00
Jack Christensen
acd9c01bd6 Fix ConnPool.Deallocate 2016-04-30 12:22:26 -05:00
konstantin
d4258bb47f Add AcquireTimeout support 2016-04-11 13:35:16 -07:00
Jack Christensen
04e9fbcc55 Fix some golint errors
- Add comments
- Rename variables
- Remove unnecessary "else"
2016-03-29 15:18:09 -05:00
Jack Christensen
1ad4c0090a Add ConnPool Prepare and Deallocate
fixes #68
2016-03-04 16:26:27 -06:00
Jack Christensen
20d22a67e3 Prevent deadlock on ConnPool.Acquire with Reset
If no connections are available, and the pool is reset, there will
be no connections at all in the pool. So the pool needs to be able
to create a connection after waiting for a connection to be released.
2016-03-04 16:19:48 -06:00
Jack Christensen
a93025479d Add AfterClose and Conn to Rows 2016-02-13 13:03:06 -06:00
Jack Christensen
e8dcf5b3ac Add *Tx.AfterClose hook
ConnPool now implements its connection with Tx via this hook instead of
manipulating the internals of Tx.
2016-02-13 11:06:44 -06:00
Jack Christensen
f004f0802c Add ConnPool.Reset method
refs #110
2015-12-12 13:15:14 -06:00
Jack Christensen
20cf4f87ab Remove notifications when releasing Conn to Pool 2015-09-26 13:24:21 -05:00
Jack Christensen
ca16a4c98f Unlisten tweaks
- Use unlisten * when releasing connection with listeners to pool
- Only unlisten on releasing connection to pool when necessary
- Remove Unlisten("") as was to release all listeners
2015-09-21 08:18:10 -05:00
Joseph Glanville
eb5cadccf9 Track Listen/Unlisten and clear subscriptions on conn release 2015-09-21 07:56:45 -05:00
Jack Christensen
a1aa06c934 More efficient logging with log levels 2015-09-16 08:20:51 -05:00
Jack Christensen
93aa2b2e80 ConnPool.Begin retry logic checks connection IsAlive
ErrDeadConn is returned when calling an already dead connection. But the initial failure returns the real error. So we check for IsAlive instead of ErrDeadConn.

Added test for ConnPool.Begin retry logic.
2015-09-12 19:39:37 -05:00
Jack Christensen
bc4742b80a DRY ConnPool Begin and BeginIso 2015-09-12 19:12:55 -05:00
Jack Christensen
6ac98ef613 Add test for ConnPool.Begin retry
Also fix bug where conn is not released on non ErrDeadConn error
returned from Conn.Begin
2015-09-12 19:10:55 -05:00
Joseph Glanville
4868929ff1 ConnPool.Begin/BeginIso will retry if they Acquire a dead connection 2015-09-11 03:05:43 +10:00
Jack Christensen
db5300358a Allow ConnPool to have MaxConnections of 1 2015-05-25 09:54:56 -05:00
Jack Christensen
d2ce556450 ConnPool no longer creates connections just to release them. 2014-11-12 08:11:33 -06:00
Jack Christensen
efea92e8be Fix connection pool close
Close should close successfully acquired connections, not failures.

fixes #45
2014-11-11 17:59:13 -06:00
Jack Christensen
f5156ac4eb discardLogger should be private 2014-09-04 16:45:35 -05:00
Jack Christensen
98109c57bb Use interface for logging instead of log15 directly 2014-09-04 16:00:53 -05:00