Commit Graph

234 Commits (da192291f75eb9effbb1ab8e6e2e182c3929d1bb)

Author SHA1 Message Date
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
Jack Christensen 6a4284a30c Add test for no-op Exec 2014-09-27 14:40:13 -05:00
Jack Christensen b06d71f684 Update test to work on Windows 2014-07-26 09:50:43 -05:00
Jack Christensen 61bf7d841a Always use bound parameters
PostgreSQL has two string syntaxes, one that allows backslash escapes and one
that does not (SQL standard conforming strings). By default PostgreSQL uses
standard conforming strings. QuoteString was only designed for use with
standard conforming strings. If PostgreSQL was configured with certain
combinations of the standard_conforming_strings and backslash_quote settings,
QuoteString may not correctly sanitize strings. QuoteString was only used in
unprepared queries, bound parameters are used for prepared queries.

This commit alters pgx to use always use bound parameters.

As a consequence of never doing string interpolation there is no need to have
separate Text and Binary encoders. There is now only the Encoder interface.

This change had a negative effect on the performance of simple unprepared
queries, but prepared statements should already be used for performance.

fixes #26

https://github.com/jackc/pgx/issues/26
2014-07-18 16:51:11 -05:00
Jack Christensen c108378973 Reorganize code 2014-07-12 08:50:30 -05:00
Jack Christensen f31665c5db wip 2014-07-12 07:11:16 -05:00
Jack Christensen 19537badff Add Rows.Values 2014-07-11 16:55:45 -05:00
Jack Christensen 294c05efcc Add test for date 2014-07-11 14:39:06 -05:00
Jack Christensen 93677e40dd Add test for timestamptz 2014-07-11 14:37:16 -05:00
Jack Christensen 12861ff7f1 Remove unused code 2014-07-11 14:36:58 -05:00
Jack Christensen 7ca95d7f73 Add NullString
Changes EncodeText interface to work for null values in SQL interpolation
and in prepared statements text format.
2014-07-11 14:16:25 -05:00
Jack Christensen 24395d98df Add more testing of Encode*
Handle case where TextEncoder is used to a core type that the driver
could otherwise have handled as binary.
2014-07-11 11:16:12 -05:00
Jack Christensen 6884fdfb52 Move Query tests together 2014-07-11 08:33:09 -05:00
Jack Christensen 986f9a1e66 Run TestConnQueryReadTooManyValues in parallel 2014-07-11 08:29:57 -05:00
Jack Christensen 646136fb44 Rename *Rows.NextRow to *Rows.Next
Conform closer to database/sql
2014-07-11 08:26:01 -05:00
Jack Christensen d7529600e0 Rename QueryResult to Rows
This helps conform closer to database/sql
2014-07-11 08:21:29 -05:00
Jack Christensen 01f261c71c Conform closer to database/sql style and add no rows test 2014-07-11 08:16:21 -05:00
Jack Christensen 566d713285 More tests and bug fixes 2014-07-11 07:50:44 -05:00
Jack Christensen 009cdfa0b1 Use Scan and Encode* instead of ValueTranscoders 2014-07-09 07:56:48 -05:00
Jack Christensen 43dcd47a92 Move to Scan interface
Remove SelectValue
2014-07-05 18:23:19 -05:00
Jack Christensen 5b345e80e1 Remove SelectValueTo
Benchmarks revealed that it is no longer performant enough to pull
its own wait. Using go_db_bench to copy JSON results to HTTP responses
it was ~20% *slower* for ~4BK responses and less than 10% faster for
+1MB responses.

The the performance problem was in io.CopyN / io.Copy. io.Copy
allocates a 32KB buffer if it doesn't have io.WriterTo or io.ReaderFrom
available. This extra alloc on every request was more expensive than
just reading the result into a string and writing it out to the response
body.

Tests indicated that if MsgReader implemented a custom Copy that used a
shared buffer it might have a few percent performance advantage. But the
additional complexity is not worth the performance gain.
2014-07-05 09:32:47 -05:00
Jack Christensen b27d828311 Add RowReader.CopyBytes
Implement SelectValueTo in terms of RowReader.CopyBytes
2014-07-05 07:51:32 -05:00
Jack Christensen a1fc6f513a Remove dead space 2014-07-05 07:25:29 -05:00
Jack Christensen 78b8e0b6f2 Safely handle bad reads of QueryResult 2014-06-30 19:01:36 -05:00
Jack Christensen 1eb4f2e8b4 Correct spelling 2014-06-30 07:49:06 -05:00
Jack Christensen d30ef1b8b9 Replace SelectFunc with Query as core 2014-06-28 17:07:31 -05:00
Jack Christensen b6ac3ef2b0 Rename Execute to Exec 2014-06-27 14:56:27 -05:00
Jack Christensen 7d0e178424 Determine automatically if Host is socket
Instead of requiring user to specify either Host or Socket unify these fields.
It can be automatically determined whether it is a socket or not.
2014-06-21 12:53:38 -05:00
Jack Christensen b2c1a14fcc Update github.com/JackC to github.com/jackc 2014-06-21 08:36:20 -05:00
Jack Christensen 839ddcf75f Allow running tests in parallel 2014-06-20 15:27:49 -05:00
Jack Christensen 73b5c73c1c Do not share database connections between tests 2014-06-20 15:18:55 -05:00
Jack Christensen 247fd3be53 Fix CommandTag RowsAffected for INSERT 2014-06-20 13:38:01 -05:00
Jack Christensen 4efa61bf5b Prepare returns *PreparedStatement 2014-06-20 10:47:31 -05:00
Jack Christensen 928612917d Fix a couple go vet discovered issues 2014-06-11 07:59:43 -05:00
Jack Christensen f119d5221c Add CommandTag 2014-05-19 09:32:31 -05:00
Jack Christensen bc2a120301 Add constants for transaction isolation levels 2014-05-19 08:25:34 -05:00
Jack Christensen 1ff653ae15 Rename ConnectionParameters to ConnConfig 2014-05-17 13:38:13 -05:00
Jack Christensen 4eb597d20b Rename pgx.Connection to pgx.Conn 2014-05-17 13:11:30 -05:00
Jack Christensen 70e461b769 Renamed conn* to connection* 2013-04-20 11:55:13 -05:00
Jack Christensen 58ae1855cb Extract Connection.SelectAll* to own file 2013-04-20 11:34:52 -05:00
Jack Christensen e27511a4c5 Extract Connection.Select* to own file 2013-04-20 11:30:06 -05:00
Jack Christensen 0b1ac12c0e Added basic null handling
* Connection.SelectRows leaves null values empty
* Select* and SelectAll* now error on null

refs #4
2013-04-20 11:14:01 -05:00
Jack Christensen ee25d4a03a Rename Select to SelectFunc to conform to Go standard lib style 2013-04-19 16:35:44 -05:00
Jack Christensen 1752020d3e Update test name 2013-04-19 16:33:48 -05:00
Jack Christensen bf86100fec Rename Query to SelectRows 2013-04-19 16:18:11 -05:00
Jack Christensen 9a5c299563 Added Select to process rows as they come over the wire
This was accomplished by promoting private query function to
public Select.

fixes #12
2013-04-19 16:10:14 -05:00
Jack Christensen fa4c70907c Rename pgx.conn to pgx.Connection 2013-04-17 08:26:01 -05:00
Jack Christensen d306d42afb Added conn.Execute to run arbitrary SQL without a result set
fixed #13
2013-04-16 20:13:06 -05:00
Jack Christensen cbf03821e1 Revert making query methods automatically escape arguments.
Must now call SanitizeSql explicitly.

This was necessary because go supports variadic arguments but not
totally optional arguments. So it would require something to
always be passed in.
2013-04-16 19:55:01 -05:00
Jack Christensen 8392883350 Added SQL parameter sanitization
fixes #3
2013-04-15 20:22:28 -05:00
Jack Christensen 2a5ad27041 go fmt 2013-04-13 20:28:45 -05:00
Jack Christensen d2ad78b90e Added SelectAll*
fixes #2
2013-04-13 19:03:00 -05:00
Jack Christensen 8a0fa50882 Extracted Connect code from non-Connect tests 2013-04-13 18:08:45 -05:00
Jack Christensen f977a3fe80 Added Select* for individual typed values.
fixes #1
2013-04-12 16:50:13 -05:00
Jack Christensen 3a85bae314 package name is pgx not pqx 2013-04-12 08:07:05 -05:00
Jack Christensen 1a7cf8ccc4 Added connect with md5 password 2013-04-11 21:39:44 -05:00
Jack Christensen 9e9815ae5a Added plain text password authentication 2013-04-11 21:13:47 -05:00
Jack Christensen 431b44eefe Add test for connecting as correct user 2013-04-11 20:40:06 -05:00
Jack Christensen 0e8f00e11c Added understanding of error messages from server 2013-04-11 20:22:55 -05:00
Jack Christensen 3e5096afef Added ability to choose user to log in as 2013-04-11 19:42:24 -05:00
Jack Christensen 996aed65ee Added ability to connect to databases by name
Add documentation to readme on how to set up tests
2013-04-11 08:56:31 -05:00
Jack Christensen d1a586ed64 go fmt 2013-04-08 20:16:49 -05:00
Jack Christensen 86099237bd Add failing test for Conn.Query 2013-04-08 20:16:11 -05:00
Jack Christensen 98890b1a50 Store backend pid and secret key 2013-04-08 20:15:34 -05:00
Jack Christensen b04166bcf5 Add test for runtime parameter storage 2013-04-08 20:08:22 -05:00
Jack Christensen aff1eee892 Basic query functionality 2013-04-06 14:52:08 -04:00
Jack Christensen bc830d4a21 Added conn.Close 2013-03-30 21:53:56 -05:00
Jack Christensen 18e225b66d go fmt 2013-03-30 18:13:40 -05:00
Jack Christensen 5563e0c825 Extracting connection 2013-03-30 17:56:31 -05:00
Jack Christensen 6fb92c12b8 Use message names matching PostgreSQL docs 2013-03-30 17:13:35 -05:00
Jack Christensen 9c12da11f7 Added startup message 2013-03-30 16:50:36 -05:00