Commit Graph

120 Commits (d1fd222ca574df832934c4b4ada8fd9efd47d25d)

Author SHA1 Message Date
Jack Christensen 280bce7078 Added log adapter for logrus
Also changed standard logger interface to take a map instead of varargs for
extra data.
2017-04-29 21:28:38 -05:00
Jack Christensen 855b735eae Add log adapters for testing and log15
Make LogLevel a type for Stringer interface.
2017-04-29 20:33:52 -05:00
Jack Christensen 7b1f461ec3 Add simple protocol suuport with (Query|Exec)Ex 2017-04-10 08:58:51 -05:00
James Lawrence c5d247830c enable sql.Open to support both DSN and URI based connection strings 2017-04-01 08:50:48 -05:00
Jack Christensen d7973d87dd Fix TestParseEnvLibpq when PGSSLMODE is set 2017-03-24 13:27:04 -05:00
Jack Christensen 9ab59a74a9 Remove oid constants from pgx 2017-03-18 14:59:34 -05:00
Jack Christensen 5eb19bc66a Add *Conn.CopyFrom
This replaces *Conn.CopyTo. CopyTo was named incorrectly. In PostgreSQL
COPY FROM is the command that copies from the client to the server. In
addition, CopyTo does not accept a schema qualified table name. This
commit introduces the Identifier type which handles multi-part names and
correctly quotes/sanitizes them. The new CopyFrom method uses this
Identifier type.

Conn.CopyTo is deprecated.

refs #243 and #190
2017-03-17 08:25:49 -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 908c439317 Use stdlib context 2017-03-03 16:01:06 -06:00
Jack Christensen ccc65c361a Privatize Conn.SecretKey 2017-02-16 18:31:34 -06:00
Jack Christensen e390ac33f5 Fix Fatal -> Fatalf 2017-02-16 18:12:42 -06:00
Jack Christensen 11b82b3ca4 msgReader implemented in terms of ChunkReader
This should substantially reduce memory allocations and memory copies.

It also means that PostgreSQL messages are always entirely buffered in memory
before processing begins. This simplifies the message processing code.

In particular, Conn.WaitForNotification is dramatically simplified by this
change.
2017-02-13 20:45:42 -06:00
Jack Christensen 7fbff4a495 Merge branch 'context' into v3-experimental 2017-02-12 15:13:47 -06:00
Jack Christensen e4f9108e82 wip 2017-02-11 14:59:16 -06:00
Jack Christensen a9e7e3acbc Extract connection dead on server test 2017-02-04 16:03:20 -06:00
Jack Christensen 78adfb13d7 Add Ping, PingContext, and ExecContext 2017-02-04 14:20:00 -06:00
Jack Christensen ec513248ac Conn.PID accessed through method 2017-01-07 13:37:36 -06:00
Jack Christensen 93e5c68f69 Merge branch 'master' into v3-experimental 2016-12-10 12:21:08 -06:00
Martin Hamrle 9f6b99e332 Cleanups
Cleanups suggested by gometalinter tools.
2016-08-30 20:05:44 +02:00
Jack Christensen 73124171e2 Rename Pid to PID 2016-08-02 15:10:00 -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 40f00f4a82 Pass PrepareEx opts as pointer and DRY implementation 2016-05-20 08:30:10 -05:00
Jack Christensen 129ff96567 TestFatalRxError expects multiple error types 2016-03-24 16:22:27 -05:00
Jack Christensen 9ce1b2b16e Fix Listen/Unlisten with special characters
fixes #132
2016-03-24 15:26:44 -05:00
Jack Christensen d88242b0ca Tweak error reporting on TestFatalRxError 2016-03-15 08:28:07 -05:00
Jack Christensen 9d7cf39563 Fix go vet identified format strings 2016-02-15 12:32:24 -06:00
Jack Christensen 0f7bf19387 Add *Conn.SetLogLevel
Allow changing log level after connection is established. Because
log level and loggers can be set independently, it is now possible
to have a log level above none when there is a nil logger. This
means all log statements need to check for nil logger and an
appropriate log level. This check has been factored out into
*Conn.shouldLog.
2016-02-13 10:13:10 -06:00
Jack Christensen cffae7ff5d Add SetLogger to *Conn
Allow replacing logger after connection is established. Also
refactor internals of logging such that there is a log method that
adds the pid to all log calls instead of making a new logger object.
The reason for this is so pid will be logged regardless of whether
loggers are replaced and restored.
2016-02-12 17:49:04 -06:00
Jack Christensen ec8f6259e6 ParseEnvLibpq extracts PGAPPNAME 2015-10-16 16:13:15 -05:00
Jack Christensen 829d61ce40 ParseDSN extracts RuntimeParams 2015-10-16 15:48:24 -05:00
Jack Christensen 5b0550c1cb ParseURI extracts run-time parameters
refs #99
2015-10-16 15:37:49 -05:00
Jack Christensen 1fb63a4b41 Add RuntimeParams to ConnConfig 2015-10-16 15:37:32 -05:00
Jack Christensen 984eace2b5 Make *Conn.Prepare idempotent.
fixes #94
2015-10-16 14:17:07 -05:00
Jack Christensen 36fb7a3aec Use Skip when skipping tests rather than just return 2015-09-26 13:29:40 -05:00
Jack Christensen 9fd5c7e6ab Add test for Unlisten 2015-09-21 08:05:53 -05:00
Jack Christensen 90b2e0acb7 Add additional testing around listen/notify 2015-09-17 17:40:04 -05:00
Jack Christensen 86837e5576 Add guards against usage of busy connection 2015-09-16 10:22:16 -05:00
Jack Christensen 6e5fa60c4c Fix cases where net conn write failure was not marking connection as dead
Also added loop to run these timing sensitive tests multiple times.
2015-09-12 19:32:55 -05:00
Rick Snyder 6413491657 Add support for specifying sslmode in connection strings
Add tests for sslmode parameter when calling ParseURI.  Fix existing tests to work since default sslmode is 'prefer'

Make sure we default to prefer if sslmode is not provided in ParseDSN

Fix existing tests for ParseDSN to expect TLS configuration for prefer since prefer is the default sslmode; also, add tests for ParseDSN when specifying sslmode parameter on connection string
2015-08-19 11:33:12 -04:00
Jack Christensen 07a11abc07 Add basic PGSSLMODE support to ParseEnvLibpq 2015-05-23 13:49:26 -05:00
Jack Christensen 51d6d1a3a6 Add ParseEnvLibpq with support for basic envvars 2015-05-23 12:46:36 -05:00
Jack Christensen dd9d960ba3 Add fallback TLS ConnConfig option
This is in preparation for supporting libpq style SSL options.
2015-05-23 11:57:36 -05:00
Lewis Marshall 784d12cbbc Support using a custom dialer
For example I may want to use a dialer which retries transient network
errors (e.g. DNS issues).

Signed-off-by: Lewis Marshall <lewis@lmars.net>
2015-04-18 22:42:55 +01:00
deoxxa 36d1a58b42 add tests for ParseDSN 2015-04-08 14:55:15 +10:00
Jack Christensen 28ef19702f Detect too many parameters on Prepare
refs #65
2015-03-14 18:58:09 -05:00
Karl Seguin 67292290cf support for inserting []time.Time into timestamp[] columns 2014-12-21 13:35:39 +07:00
Karl Seguin d1b42d1c8e support inserting into bool[] 2014-12-21 13:01:24 +07:00
Karl Seguin e5b2fbd819 select; is valid in 9.4. This causes the two tests to exec successfully when
we're trying to get a syntax error.
2014-11-17 21:21:08 +07:00