168 Commits

Author SHA1 Message Date
Jack Christensen
5a16bad252 Skip deferred constraint tests on CockroachDB 2021-02-27 09:52:51 -06:00
Jack Christensen
5f58e0e443 Cockroach DB uses different error code 2021-02-27 09:52:51 -06:00
Jack Christensen
37884a20e7 Use testify and more forgiving numeric equality
PostgreSQL generate_series can return type int while CockroachDB always
returns bigint.
2021-02-27 09:52:51 -06:00
Jack Christensen
9b0e57c4a9 Fix panic on query error with nil stmtcache
fixes #895
2020-12-19 10:17:41 -06:00
Jack Christensen
e8f959e0e1 Add QueryFunc
refs #821
2020-12-12 09:39:58 -06:00
Jack Christensen
d4a300bd58 Fix: FieldDescriptions are available on Rows before calling Next 2020-09-05 13:24:57 -05:00
Jack Christensen
be9ceaefe6 Add native Go slice support for strings and numbers to simple protocol
[]string, []int16, []int32, []int64, []int, []uint16, []uint32,
[]uint64, []uint, []float32, and []float64 are now supported in the
simple protocol like they are in the normal usage of the extended
protocol.
2020-04-11 09:27:07 -05:00
Jack Christensen
cdec57523d Update to pgtype v1.3.0 2020-03-30 11:31:23 -05:00
Jack Christensen
95907c29ce Update pgconn and pull in fix for QueryRow with empty SQL 2020-03-07 13:27:01 -06:00
HowJMay
8e88d70eb3 fix: Fix typo
Fix some typos in codebase
2020-01-25 15:36:19 +08:00
Jack Christensen
fd4e692323 Add Rows.Values support for unknown types 2020-01-23 20:50:21 -06:00
Jack Christensen
f6feb39655 Fix Rows.Values() fallback to generic decoder
fixes #666
2020-01-23 20:41:22 -06:00
Jack Christensen
eb360b07be Tweak test for PG 12 compatibility 2019-12-23 11:08:21 -06:00
Adam Pantel
f989008ad5 Clarify error reporting in TestConnQueryErrorWhileReturningRows 2019-11-22 11:03:46 -05:00
Jack Christensen
2799739ef3 Update underlying packages to final release versions 2019-09-14 20:31:06 -05:00
Jack Christensen
7d053e4d5c Replace RowsFromResultReader with ScanRow function 2019-09-10 18:38:10 -05:00
Jack Christensen
76348773bd Make Conn.ConnInfo private 2019-09-10 18:09:21 -05:00
Jack Christensen
a8691a7066 Add RawValues to Rows 2019-09-10 17:58:24 -05:00
Jack Christensen
b5ce0220f8 Add CommandTag to Rows interface
This allows handling queries where it is unknown if there will be a
result set or not. If it is not a result set returning query the
command tag will still be available.
2019-09-02 09:53:26 -05:00
Jack Christensen
53921a0a22 Allow reading a result row multiple times
refs #478
2019-08-31 10:50:14 -05:00
Jack Christensen
8170eaf401 Update to latest version of pgconn
- Also remove a few tests of functionality that is handled by pgconn
2019-08-27 18:22:34 -05:00
Jack Christensen
6508934508 Rename PreparedStatementCache to StatementCache 2019-08-24 22:19:29 -05:00
Jack Christensen
0c3e59b07a Add automatic statement cache 2019-08-24 20:29:54 -05:00
Jack Christensen
6972a57421 pgtype.OID type should only be used for scanning and encoding values
It was a mistake to use it in other contexts. This made interop
difficult between pacakges that depended on pgtype such as pgx and
packages that did not like pgconn and pgproto3. In particular this was
awkward for prepared statements.

This is preparation for removing pgx.PreparedStatement in favor of
pgconn.PreparedStatement.
2019-08-24 13:55:57 -05:00
Jack Christensen
faa980a256 Add tests for deferred constraint errors
Port tests from v3.

Fix is implemented in pgconn f0b479097a4868d74e83c938131f5a24d25c49e8.
2019-08-06 17:17:54 -05:00
Jack Christensen
29f02807b0 Restore simple protocol support 2019-05-20 20:36:03 -05:00
Jack Christensen
c7d03eb555 Add RowsFromResultReader 2019-04-24 15:57:50 -05:00
Jack Christensen
1b8f0016e9 Split pgtype into own repo 2019-04-20 19:20:00 -05:00
Jack Christensen
efb333df6b Fix go modules
Wow. This is fun. Sure is easy to get modules wrong when upgrading a v2+
project.
2019-04-20 17:41:08 -05:00
Jack Christensen
b7e56b003a Replace lastStmtSent with pgconn support 2019-04-20 17:12:20 -05:00
Jack Christensen
5cc4796c96 Test domains when registered and unregistered
Fix bug assigning to unknown type.
2019-04-13 17:09:51 -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
7718ee6207 Remove Ex versions of Query and QueryRow
Always require context and prepend options to arguments if necessary.
2019-04-10 12:12:22 -05:00
Jack Christensen
d2ad2ed5d8 Remove tests context cancel
Context cancellation is now fatal so no need to test recovery.
2019-04-05 11:00:35 -05:00
Jack Christensen
858d00788a Use extracted packages with Go modules 2019-04-05 10:59:47 -05:00
Jack Christensen
d3a2c1c107 Partial conversion of pgx to use pgconn 2019-01-26 16:46:30 -06:00
Jack Christensen
12857ad05b Implement pgx.Conn.Exec in terms of pgconn.PgConn.Exec 2019-01-02 12:32:36 -06:00
Jack Christensen
7f9540438c pgx uses pgconn.CommandTag instead of own definition 2019-01-01 16:55:48 -06:00
Jack Christensen
378ccb8945 PG error type is *pgconn.PgError 2018-12-31 17:46:56 -06:00
Jack Christensen
c672c0d595 Use environment variables for test configuration 2018-12-30 21:52:33 -06:00
James Hartig
6d336eccb1 Added LastStmtSent and use it to retry on errors if statement was not sent
Previously, a failed connection could be put back in a pool and when the
next query was attempted it would fail immediately trying to prepare the
query or reset the deadline. It wasn't clear if the Query or Exec call
could safely be retried since there was no way to know where it failed.

You can now call LastQuerySent and if it returns false then you're
guaranteed that the last call to Query(Ex)/Exec(Ex) didn't get far enough
to attempt to send the query. The call can be retried with a new
connection.

This is used in the stdlib to return a ErrBadConn if a network error
occurred and the statement was not attempted.

Fixes #427
2018-11-19 10:44:40 -05:00
Jack Christensen
52fc785a43 Fix incorrect reuse of Value in Rows.Values()
fixes #386
2018-02-03 11:04:49 -06:00
Jack Christensen
119ba7a449 Fix go vet issues 2018-01-13 10:08:02 -06:00
Jack Christensen
82cd87d502 Support nil pointers to value implementing driver.Valuer
fixes #339
2017-10-26 21:37:06 -04:00
Jack Christensen
ac5d463e85 PostgreSQL 10 coerces unknown types to text
This is no longer an error. See PostgreSQL commit 1e7c4bb00.
2017-10-17 20:31:11 -05:00
Jack Christensen
9c8ef1acdd Fix pgtype types that can Set database/sql/driver.driver.Valuer
Bug was chooseParameterFormatCode would see that type could handle
binary format so binary format would be chosen. But
encodePreparedStatementArgument would see driver.Valuer first and
would encode with that -- which is text mode. So the server would
receive a text format value when expecting a binary format value.

Discovered while investigating #316
2017-09-01 16:00:47 -05:00
Kelsey Francis
fc18cc8d76 Always return non-nil *Rows from Query to fix QueryRow
Since QueryRow delegates to Query, it needs Query to always return
non-nil *Rows to prevent a nil pointer deference when the QueryRow
caller calls Scan(). This commit fixes the few returns in QueryEx that
return nil on errors rather than *Rows with its err field set.
2017-08-31 11:37:20 -07:00
Jack Christensen
27ab289096 Use Go casing convention for OID 2017-06-03 11:53:49 -05:00
Jack Christensen
dd5e6a77dc Add QueryEx single round-trip mode 2017-05-29 11:27:44 -05:00
Jack Christensen
ee001a7cae Fix queries with more than 32 columns
fixes #270
2017-05-01 19:46:37 -05:00