Commit Graph

1084 Commits (82cd87d5026b8e7c85b010b3a5632708a3acbcaf)

Author SHA1 Message Date
Jack Christensen 82cd87d502 Support nil pointers to value implementing driver.Valuer
fixes #339
2017-10-26 21:37:06 -04:00
Jack Christensen 21ef449944 Merge pull request #340 from ligustah/patch-1
Use logrus.FieldLogger instead of *logrus.Logger
2017-10-17 20:31:45 -05:00
Jack Christensen ab9a1af65b Add support for array of enum
fixes #338
2017-10-17 20:31:11 -05: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
André Bierlein 4dea6c902e Use logrus.FieldLogger instead of *logrus.Logger
This allows supplying a logrus logger that already has fields configured
2017-10-10 16:58:24 +02:00
Jack Christensen 63f58fd32e Add UnmarshalJSON to a few types 2017-09-29 15:26:37 -05:00
Jack Christensen f71bf5db91 Merge pull request #336 from felixge/cratedb
Support CrateDB
2017-09-29 11:14:24 -05:00
Felix Geisendörfer 52bec9bec5 Support CrateDB 2017-09-27 18:32:18 +02:00
Jack Christensen e7924c7590 Merge branch 'plopik-master'
* plopik-master:
  Add doc for (*Tx) BeginBatch()
  New beginBatch on transaction object
2017-09-25 11:01:54 -05:00
Jack Christensen 5789af0b64 Add doc for (*Tx) BeginBatch() 2017-09-25 11:01:30 -05:00
Jack Christensen 3ed4e7488e Merge branch 'master' of https://github.com/plopik/pgx into plopik-master
* 'master' of https://github.com/plopik/pgx:
  New beginBatch on transaction object
2017-09-25 10:56:11 -05:00
Jack Christensen d51cb880e9 Add more required libs for testing 2017-09-25 10:26:55 -05:00
Jack Christensen c1e30c8e14 Merge pull request #330 from manniwood/add-errors-pkg-to-instructions
Adds `go get github.com/pkg/errors` to README.md
2017-09-25 10:25:17 -05:00
Jack Christensen 3ee7b5caa9 Merge pull request #332 from manniwood/remove-dup-ifs
Removes duplicate if statements in test
2017-09-25 10:13:48 -05:00
Gaspard Douady 554a4d08ec Merge branch 'master' into master 2017-09-25 10:41:52 +02:00
Gaspard Douady 38e2b9d449 New beginBatch on transaction object
A batch on a tx object does not open and close a transaction itself and
instead use the tx object to ensure the transactionality of the batch

remove unused boolean 'sent' in batch struct
2017-09-25 10:36:41 +02:00
Manni Wood 94cee0dce0 Removes duplicate if/else 2017-09-24 22:17:55 -04:00
Manni Wood 668eec13fc Adds `go get github.com/pkg/errors` to README.md 2017-09-23 12:07:24 -04:00
Jack Christensen 015b56a04f Merge branch 'wingedpig-master'
* wingedpig-master:
  Reverted breaking API change to CreateReplicationSlot. Instead, the new version that returns the consistent_point and snapshot_name values is called CreateReplicationSlotEx().
  Changed CreateReplicationSlot to return the consistent_point and snapshot_name.
2017-09-22 09:36:31 -05:00
Jack Christensen 89e8dad166 Merge branch 'master' of https://github.com/wingedpig/pgx into wingedpig-master
* 'master' of https://github.com/wingedpig/pgx:
  Reverted breaking API change to CreateReplicationSlot. Instead, the new version that returns the consistent_point and snapshot_name values is called CreateReplicationSlotEx().
  Changed CreateReplicationSlot to return the consistent_point and snapshot_name.
2017-09-22 09:34:19 -05:00
Mark Fletcher fd93b83433 Reverted breaking API change to CreateReplicationSlot. Instead, the new version that returns the consistent_point and snapshot_name values is
called CreateReplicationSlotEx().
2017-09-21 09:58:20 -07:00
Jack Christensen 66031d2435 Merge branch 'plopik-fixqueryrow'
* plopik-fixqueryrow:
  Fix incomplete selects during batch
  Fix queryRow leftover message on conn
2017-09-21 11:34:45 -05:00
Jack Christensen 53e5d8e341 Fix incomplete selects during batch
An incompletely read select followed by an insert would fail. This was
caused by query methods in the non-batch path always calling
ensureConnectionReadyForQuery. This ensures that connections interrupted
by context cancellation are still usable. However, in the batch case
query methods are not being called while reading the result. A
incompletely read select followed by another select would not manifest
this error due to it starting by reading until row description. But when
an incomplete select (which even a successful QueryRow would be
considered) is followed by an Exec, the CommandComplete message from the
select would be considered as the response to the subsequent Exec.

The fix is the batch tracking whether a CommandComplete is pending and
reading it before advancing to the next result. This is similar in
principle to ensureConnectionReadyForQuery, just specific to Batch.
2017-09-21 11:19:52 -05:00
Gaspard Douady b4f9d149c1 Fix queryRow leftover message on conn
those leftover messages are tossed by ensureConnectionReadyForQuery but
in the batch use case this is not called between each query.
2017-09-21 11:12:50 +02:00
Mark Fletcher a1e4b1b9b5 Changed CreateReplicationSlot to return the consistent_point and snapshot_name. 2017-09-19 21:12:15 -07:00
Jack Christensen fd7b776540 Merge pull request #323 from kelseyfrancis/namespace-oids
Prefix types in namespaces other than pg_catalog or public
2017-09-14 13:59:51 -05:00
Kelsey Francis 953e08df99 Prefix types in namespaces other than pg_catalog or public
It's possible to define a type (e.g., an enum) with the same name in two
different schemas. When initializing data types after connecting, types
defined within schemas other than pg_catalog or public should be
qualified with their schema name to disambiguate them and ensure all
types with the same base name get added to the map of OID to type.

Prior to this commit, the last type scanned would "win", and all others
with the same name would be missing from the ConnInfo type maps, which
would subsequently cause any PREPARE involving columns of those missing
types to return the error "unknown oid".
2017-09-11 11:29:42 -07:00
Jack Christensen 3e49ad8dec Merge branch 'johanbrandhorst-patch-1' 2017-09-09 11:06:16 -05:00
Jack Christensen 9eb21591ee Update sslmode docs 2017-09-09 11:05:39 -05:00
Jack Christensen a1e4d17e58 Fix sslmode require test 2017-09-09 11:05:27 -05:00
Johan Brandhorst 30fa7cc37f Skip certificate verification for sslmode "require"
This more appropriately aligns the behaviour of the library with
that advertised by the postgres documentation.

According to the table on the official documentation page
https://www.postgresql.org/docs/current/static/libpq-ssl.html,
the "require" mode should be used when:

"I want my data to be encrypted, and I accept the overhead. I trust that the network will make sure I always connect to the server I want."

This maps reasonably well to a TLS config that skips certificate verification.
2017-09-08 20:44:10 +01:00
Jack Christensen b70fb1c7cf Merge pull request #318 from kelseyfrancis/zap-logger-adapter
Add zap log adapter
2017-09-08 09:16:17 -05:00
Jack Christensen 6047f4a56e Merge pull request #317 from miktwon/master
Fix doc: Import stdlib
2017-09-08 08:52:56 -05:00
Kelsey Francis 8cb78d376a Add zap log adapter 2017-09-07 11:07:55 -07:00
miktwon 9fafa4ebf3 Fix doc: Import stdlib 2017-09-07 11:48:56 +03: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
Jack Christensen e2695be13b Update examples to use PG envvars 2017-09-01 14:25:03 -05:00
Jack Christensen d0d4002ecf Merge pull request #315 from kelseyfrancis/fix-query-row-nil-return-value
Always return non-nil *Rows from Query to fix QueryRow
2017-08-31 14:00:19 -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 47c0e9cbac Fix decoding row with same type values
Row decoding was reusing and returning connection owned values for
decoding. Instead allocate new value each time.

fixes #313
2017-08-29 15:38:45 -05:00
Jack Christensen ef9e5159bf Merge branch 'MaerF0x0-master' 2017-08-29 14:54:20 -05:00
Jack Christensen 23c3724fb3 Fix comment on ErrClosedPool 2017-08-29 14:53:31 -05:00
Jack Christensen 8a4681db4a Merge branch 'master' of https://github.com/MaerF0x0/pgx into MaerF0x0-master 2017-08-29 14:53:07 -05:00
Jack Christensen a669dfccfc Merge pull request #311 from kelseyfrancis/fix-one-round-trip-exec-bug
Fix some invalid one round trip execs failing to return non-nil error
2017-08-29 14:49:39 -05:00
Jack Christensen 016888130a Merge branch 'kelseyfrancis-uuid-array' 2017-08-29 14:34:38 -05:00
Jack Christensen 4e26b04d6e Generate UUIDArray from template
- Fix error in Set
- Specifically handle untyped nil
2017-08-29 14:33:25 -05:00
Mike Graf 30896744c8 Return ErrClosedPool when Acquire() with closed pool 2017-08-28 22:30:42 -07:00
Kelsey Francis ea740fb316 Fix some invalid one round trip execs failing to return non-nil error
Prior to this commit, execEx() would write the one round trip exec to
the connection before first calling ensureConnectionReadyForQuery, which
ultimately caused any errors to be suppressed if the exec followed a
valid query, because the receive message processing would finish
successfully as soon as it received the ReadyForQuery that actually
belonged to the preceding query. So, the exec would never actually
receive the error message that it caused, leaving it to be incorrectly
received by the first subsequent query sent.
2017-08-28 18:51:35 -07:00
Kelsey Francis 1e36edf4b0 Add UUIDArray type
Also change UUID.Set() to convert nil to NULL in order for
UUIDArray.Set() to support converting [][]byte slices that contain nil.
2017-08-27 19:36:53 -07:00
Jack Christensen f65776f084 Fix typo 2017-08-25 13:31:50 -05:00