264 Commits

Author SHA1 Message Date
Jacob Powers
25d18b98e5 fix regression 2020-06-10 09:26:59 -07:00
Jacob Powers
de77c70f48 enable hstore extension before running tests 2020-06-10 09:05:14 -07:00
Jacob Powers
97e4debcc0 disable test cases that require a binary sql snapshot 2020-06-10 08:27:56 -07:00
Jacob Powers
6d62aec6b1 remove irrelevant test from pgx 2020-06-09 18:31:49 -07:00
Jacob Powers
96f49eb89b copy travis configs over from pgx 2020-06-09 18:16:23 -07:00
Jacob Powers
3e586004db add travis config 2020-06-09 18:08:38 -07:00
Jack Christensen
9d847241cb
Merge pull request #29 from pmorelli92/master
Add the possibility of assigning a TID to a string
2020-05-21 09:46:10 -05:00
Pablo Morelli
afff6abc6c
TID AssignTo string 2020-05-20 15:01:21 +02:00
Jack Christensen
238967ec4e Improve accuracy of numeric to float
fixes #27
2020-05-13 08:05:19 -05:00
Jack Christensen
6a1a9d05bc Add pgxtype package for simpler type registration 2020-05-13 07:34:10 -05:00
Jack Christensen
f8471ebfa8 ArrayType requires element OID 2020-05-13 07:11:10 -05:00
Jack Christensen
ee0e207ee4 CompositeType fields contain name and oid 2020-05-13 07:09:52 -05:00
Jack Christensen
0e2bc3467a Fix ext/gofrs-uuid AssignTo *uuid.UUID 2020-05-12 21:01:06 -05:00
Jack Christensen
b3e1355a46 CompositeType can assign to struct via reflection 2020-05-12 16:58:16 -05:00
Jack Christensen
9a3923b6e0 EncodeRow is superceded by CompositeFields 2020-05-12 15:51:27 -05:00
Jack Christensen
506ea36835 Do not export quoteCompositeFieldIfNeeded 2020-05-12 15:47:44 -05:00
Jack Christensen
eebc6975de Add EncodeText support for CompositeType 2020-05-12 15:45:16 -05:00
Jack Christensen
e45ef46424 Refactor and add CompositeTextBuilder 2020-05-12 15:42:26 -05:00
Jack Christensen
fcb385dccb Add ScanDecoder and ScanValue to composite scanners.
Rename Scan to Next to disambiguate.
2020-05-12 15:04:14 -05:00
Jack Christensen
e51cb1ef09 Add CompositeBinaryBuilder 2020-05-12 14:04:11 -05:00
Jack Christensen
2186634638 Add CompositeFields encoders 2020-05-12 11:55:24 -05:00
Jack Christensen
e92ee69901 Expose EnumType directly instead of behind interface 2020-05-12 10:41:50 -05:00
Jack Christensen
9cdd928cb8 CompositeType implements TypeValue 2020-05-12 10:40:13 -05:00
Jack Christensen
e5992d0aed TypeValue should include Value 2020-05-12 10:28:13 -05:00
Jack Christensen
682201a4fc Rename CloneTypeValue to NewTypeValue 2020-05-12 10:26:51 -05:00
Jack Christensen
bff2829b0f Move ComposteType.Scan functionality into AssignTo
Also remove adapter functions that are no longer used.
2020-05-12 10:19:41 -05:00
Jack Christensen
247043b597 Merge SetFields functionality into Set 2020-05-12 08:35:45 -05:00
Jack Christensen
c41160bcbb Make CompositeType status private 2020-05-12 08:01:10 -05:00
Jack Christensen
4a6bd41a36 Rename Composite to CompositeType.
This harmonizes the naming with EnumType and ArrayType.
2020-05-12 07:58:10 -05:00
Jack Christensen
036101deb5 Allow scanning to nil as no-op 2020-05-11 17:41:20 -05:00
Jack Christensen
36dbbd983d Add CompositeFields type
This adds support for the text format and removes the need for the
ScanRowValue function.
2020-05-11 17:21:21 -05:00
Jack Christensen
1b3d694469 Add ArrayType 2020-05-10 19:37:25 -05:00
Jack Christensen
6cef4638ad Update pgx dependency for tests 2020-05-10 14:11:24 -05:00
Jack Christensen
8cd94a14c7 Allow types to specify preference format result and param formats
This will be useful for array and composite types that may have to
support elements that may not support binary encoding.

It also is slightly more convenient for text-ish types to have a default
format of text.
2020-05-10 14:05:16 -05:00
Jack Christensen
cc4d1eafe0 Doc tweaks and renames 2020-05-10 12:45:12 -05:00
Jack Christensen
a71c179ce3 Extract nullAssignmentError 2020-05-10 12:28:47 -05:00
Jack Christensen
52729c1b77 Back off some aggressive PlanScan optimizations
PlanScan used to require the exact same value be used every time. While
this was great for performance, on further consideration I think it is
too much of a potential foot-gun.

This moves back in the other direction. A plan tolerates a change in
destination. It even detects a change in destination type and falls
back to a new plan.

Perfectly matched hot scan paths (e.g. PG int4 to Go int32) are still
much faster than they were before this set of optimizations. The first
scan of a destination that uses a decoder is faster due to not
allocating. It's a little bit slower on subsequent runs than before
this set of optimizations. But it is preferable to optimize for the
most common scan targets (e.g. *int32, *int64, *string) over generic
decoder destinations.

In addition this fees pgx.connRows.Scan from having to check that
the destination is unchanged.
2020-05-10 09:37:15 -05:00
Jack Christensen
7e66ab1e14 Add scan plan system
This can improve performance now and will be useful for the future
transcoder system.
2020-05-09 23:52:48 -05:00
Jack Christensen
97bbe6ae20 Add RegisterDefaultPgType
This allows registering a mapping of a Go type to a PostgreSQL type
name. If the OID of a value to be encoded or decoded is unknown, this
additional mapping will be used to determine a suitable data type.
2020-05-08 16:13:15 -05:00
Jack Christensen
4a50a63f12 Refactor Scan optimization
Instead of hardcoding specific types and skipping type assertions based
on that, only check if a destination is a (sql.Scanner) after a failed
AssignTo.

This is slightly slower in the non-decoder case and *very* slightly
faster in the decoder. However, this approach is cleaner and has the
potential for further optimizations.
2020-05-07 19:48:48 -05:00
Jack Christensen
452511dfc5 Rename RecordFieldIter to CompositeBinaryScanner and adjust interface
Use interface similar to bufio.Scanner and pgx.Rows.
2020-05-07 13:38:19 -05:00
Jack Christensen
ff9bc5d68d Merge binary package into pgtype package 2020-05-07 10:15:23 -05:00
Jack Christensen
37e976192b ScanRowValue accepts interface{} dst 2020-05-06 14:56:25 -05:00
Jack Christensen
10838b39f6 Remove vscode settings 2020-05-06 14:45:55 -05:00
Jack Christensen
cce17427e1 Merge branch 'record-expect' of git://github.com/redbaron/pgtype into redbaron-record-expect 2020-05-06 14:43:10 -05:00
Jack Christensen
2938981516 Make EnumType implementation private 2020-05-06 10:30:43 -05:00
Jack Christensen
4d2b5a18c4 Clarify Value.Get() documentation
Specifying behavior for Status Null and Undefined is incorrect because
a Value is not required to have a Status. In addition, standard
behavior is to return nil, not pgtype.Null when the Status is
pgtype.Null.
2020-05-06 09:51:41 -05:00
Jack Christensen
3b7c47a2a7 Add EnumType 2020-05-05 13:23:14 -05:00
Jack Christensen
ab5e597826 Avoid type assertion in Scan
Before:
BenchmarkConnInfoScanInt4IntoBinaryDecoder-16           79859755                14.6 ns/op             0 B/op          0 allocs/op
BenchmarkConnInfoScanInt4IntoGoInt32-16                 38969991                30.0 ns/op             0 B/op          0 allocs/op

After:
BenchmarkConnInfoScanInt4IntoBinaryDecoder-16    	458046958	        13.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkConnInfoScanInt4IntoGoInt32-16          	275791776	        20.6 ns/op	       0 B/op	       0 allocs/op
2020-05-02 20:30:58 -05:00
Jack Christensen
18c64dceee ConnInfo Scan optimizes common native types
This comes at a small expense to scanning into a type that implements
TextDecoder or BinaryDecoder but I think it is a good trade.

Before:
BenchmarkConnInfoScanInt4IntoBinaryDecoder-16    	88181061	        12.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkConnInfoScanInt4IntoGoInt32-16          	30402768	        36.8 ns/op	       0 B/op	       0 allocs/op

After:
BenchmarkConnInfoScanInt4IntoBinaryDecoder-16    	79859755	        14.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkConnInfoScanInt4IntoGoInt32-16          	38969991	        30.0 ns/op	       0 B/op	       0 allocs/op
2020-05-02 20:18:51 -05:00