pg 1.0.0 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/ChangeLog +0 -6595
- data/History.rdoc +156 -0
- data/Manifest.txt +8 -2
- data/README-Windows.rdoc +4 -4
- data/README.ja.rdoc +1 -2
- data/README.rdoc +55 -9
- data/Rakefile +9 -7
- data/Rakefile.cross +58 -57
- data/ext/errorcodes.def +68 -0
- data/ext/errorcodes.rb +1 -1
- data/ext/errorcodes.txt +19 -2
- data/ext/extconf.rb +7 -5
- data/ext/pg.c +141 -98
- data/ext/pg.h +64 -21
- data/ext/pg_binary_decoder.c +82 -15
- data/ext/pg_binary_encoder.c +13 -12
- data/ext/pg_coder.c +73 -12
- data/ext/pg_connection.c +625 -346
- data/ext/pg_copy_coder.c +16 -8
- data/ext/pg_record_coder.c +491 -0
- data/ext/pg_result.c +571 -191
- data/ext/pg_text_decoder.c +606 -40
- data/ext/pg_text_encoder.c +185 -54
- data/ext/pg_tuple.c +549 -0
- data/ext/pg_type_map.c +1 -1
- data/ext/pg_type_map_all_strings.c +4 -4
- data/ext/pg_type_map_by_class.c +9 -4
- data/ext/pg_type_map_by_column.c +7 -6
- data/ext/pg_type_map_by_mri_type.c +1 -1
- data/ext/pg_type_map_by_oid.c +3 -2
- data/ext/pg_type_map_in_ruby.c +1 -1
- data/ext/{util.c → pg_util.c} +10 -10
- data/ext/{util.h → pg_util.h} +2 -2
- data/lib/pg.rb +8 -6
- data/lib/pg/basic_type_mapping.rb +121 -25
- data/lib/pg/binary_decoder.rb +23 -0
- data/lib/pg/coder.rb +23 -2
- data/lib/pg/connection.rb +22 -3
- data/lib/pg/constants.rb +2 -1
- data/lib/pg/exceptions.rb +2 -1
- data/lib/pg/result.rb +14 -2
- data/lib/pg/text_decoder.rb +21 -26
- data/lib/pg/text_encoder.rb +32 -8
- data/lib/pg/tuple.rb +30 -0
- data/lib/pg/type_map_by_column.rb +3 -2
- data/spec/helpers.rb +52 -20
- data/spec/pg/basic_type_mapping_spec.rb +362 -37
- data/spec/pg/connection_spec.rb +376 -146
- data/spec/pg/connection_sync_spec.rb +41 -0
- data/spec/pg/result_spec.rb +240 -15
- data/spec/pg/tuple_spec.rb +333 -0
- data/spec/pg/type_map_by_class_spec.rb +2 -2
- data/spec/pg/type_map_by_column_spec.rb +6 -2
- data/spec/pg/type_map_by_mri_type_spec.rb +1 -1
- data/spec/pg/type_map_by_oid_spec.rb +3 -3
- data/spec/pg/type_map_in_ruby_spec.rb +1 -1
- data/spec/pg/type_map_spec.rb +1 -1
- data/spec/pg/type_spec.rb +363 -17
- data/spec/pg_spec.rb +1 -1
- metadata +47 -47
- metadata.gz.sig +0 -0
data/History.rdoc
CHANGED
@@ -1,3 +1,158 @@
|
|
1
|
+
== v1.2.3 [2020-03-18] Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
Bugfixes:
|
4
|
+
|
5
|
+
- Fix possible segfault at `PG::Coder#encode`, `decode` or their implicit calls through
|
6
|
+
a typemap after GC.compact. #327
|
7
|
+
- Fix possible segfault in `PG::TypeMapByClass` after GC.compact. #328
|
8
|
+
|
9
|
+
|
10
|
+
== v1.2.2 [2020-01-06] Michael Granger <ged@FaerieMUD.org>
|
11
|
+
|
12
|
+
Enhancements:
|
13
|
+
|
14
|
+
- Add a binary gem for Ruby 2.7.
|
15
|
+
|
16
|
+
|
17
|
+
== v1.2.1 [2020-01-02] Michael Granger <ged@FaerieMUD.org>
|
18
|
+
|
19
|
+
Enhancements:
|
20
|
+
|
21
|
+
- Added internal API for sequel_pg compatibility.
|
22
|
+
|
23
|
+
|
24
|
+
== v1.2.0 [2019-12-20] Michael Granger <ged@FaerieMUD.org>
|
25
|
+
|
26
|
+
Repository:
|
27
|
+
- Our primary repository has been moved to Github https://github.com/ged/ruby-pg .
|
28
|
+
Most of the issues from https://bitbucket.org/ged/ruby-pg have been migrated. #43
|
29
|
+
|
30
|
+
API enhancements:
|
31
|
+
- Add PG::Result#field_name_type= and siblings to allow symbols to be used as field names. #306
|
32
|
+
- Add new methods for error reporting:
|
33
|
+
- PG::Connection#set_error_context_visibility
|
34
|
+
- PG::Result#verbose_error_message
|
35
|
+
- PG::Result#result_verbose_error_message (alias)
|
36
|
+
- Update errorcodes and error classes to PostgreSQL-12.0.
|
37
|
+
- New constants: PG_DIAG_SEVERITY_NONLOCALIZED, PQERRORS_SQLSTATE, PQSHOW_CONTEXT_NEVER, PQSHOW_CONTEXT_ERRORS, PQSHOW_CONTEXT_ALWAYS
|
38
|
+
|
39
|
+
Type cast enhancements:
|
40
|
+
- Add PG::TextEncoder::Record and PG::TextDecoder::Record for en/decoding of Composite Types. #258, #36
|
41
|
+
- Add PG::BasicTypeRegistry.register_coder to register instances instead of classes.
|
42
|
+
This is useful to register parametrized en/decoders like PG::TextDecoder::Record .
|
43
|
+
- Add PG::BasicTypeMapForQueries#encode_array_as= to switch between various interpretations of ruby arrays.
|
44
|
+
- Add Time, Array<Time>, Array<BigDecimal> and Array<IPAddr> encoders to PG::BasicTypeMapForQueries
|
45
|
+
- Exchange sprintf based float encoder by very fast own implementation with more natural format. #301
|
46
|
+
- Define encode and decode methods only in en/decoders that implement it, so that they can be queried by respond_to? .
|
47
|
+
- Improve PG::TypeMapByColumn#inspect
|
48
|
+
- Accept Integer and Float as input to TextEncoder::Numeric . #310
|
49
|
+
|
50
|
+
Other enhancements:
|
51
|
+
- Allocate the data part and the ruby object of PG::Result in one step, so that we don't need to check for valid data.
|
52
|
+
This removes PG::Result.allocate and PG::Result.new, which were callable but without any practical use. #42
|
53
|
+
- Make use of PQresultMemorySize() of PostgreSQL-12 and fall back to our internal estimator.
|
54
|
+
- Improve performance of PG::Result#stream_each_tuple .
|
55
|
+
- Store client encoding in data part of PG::Connection and PG::Result objects, so that we no longer use ruby's internal encoding bits. #280
|
56
|
+
- Update Windows fat binary gem to OpenSSL-1.1.1d and PostgreSQL-12.1.
|
57
|
+
- Add support for TruffleRuby. It is regulary tested as part of our CI.
|
58
|
+
- Enable +frozen_string_literal+ in all pg's ruby files
|
59
|
+
|
60
|
+
Bugfixes:
|
61
|
+
- Update the license in gemspec to "BSD-2-Clause".
|
62
|
+
It was incorrectly labeled "BSD-3-Clause". #40
|
63
|
+
- Respect PG::Coder#flags in PG::Coder#to_h.
|
64
|
+
- Fix PG::Result memsize reporting after #clear.
|
65
|
+
- Release field names to GC on PG::Result#clear.
|
66
|
+
- Fix double free in PG::Result#stream_each_tuple when an exception is raised in the block.
|
67
|
+
- Fix PG::Result#stream_each_tuple to deliver typemapped values.
|
68
|
+
- Fix encoding of Array<unknown> with PG::BasicTypeMapForQueries
|
69
|
+
|
70
|
+
Deprecated:
|
71
|
+
- Add a deprecation warning to PG::Connection#socket .
|
72
|
+
|
73
|
+
Removed:
|
74
|
+
- Remove PG::Connection#guess_result_memsize= which was temporary added in pg-1.1.
|
75
|
+
- Remove PG::Result.allocate and PG::Result.new (see enhancements).
|
76
|
+
- Remove support of tainted objects. #307
|
77
|
+
- Remove support of ruby-2.0 and 2.1. Minimum is ruby-2.2 now.
|
78
|
+
|
79
|
+
Documentation:
|
80
|
+
- Update description of connection params. See PG::Connection.new
|
81
|
+
- Link many method descriptions to corresponding libpq's documentation.
|
82
|
+
- Update sync_* and async_* query method descriptions and document the aliases.
|
83
|
+
The primary documentation is now at the async_* methods which are the default since pg-1.1.
|
84
|
+
- Fix documentation of many constants
|
85
|
+
|
86
|
+
|
87
|
+
== v1.1.4 [2019-01-08] Michael Granger <ged@FaerieMUD.org>
|
88
|
+
|
89
|
+
- Fix PG::BinaryDecoder::Timestamp on 32 bit systems. # 284
|
90
|
+
- Add new error-codes of PostgreSQL-11.
|
91
|
+
- Add ruby-2.6 support for Windows fat binary gems and remove ruby-2.0 and 2.1.
|
92
|
+
|
93
|
+
|
94
|
+
== v1.1.3 [2018-09-06] Michael Granger <ged@FaerieMUD.org>
|
95
|
+
|
96
|
+
- Revert opimization that was sometimes causing EBADF in rb_wait_for_single_fd().
|
97
|
+
|
98
|
+
|
99
|
+
== v1.1.2 [2018-08-28] Michael Granger <ged@FaerieMUD.org>
|
100
|
+
|
101
|
+
- Don't generate aliases for JOHAB encoding.
|
102
|
+
This avoids linking to deprecated/private function rb_enc(db)_alias().
|
103
|
+
|
104
|
+
|
105
|
+
== v1.1.1 [2018-08-27] Michael Granger <ged@FaerieMUD.org>
|
106
|
+
|
107
|
+
- Reduce deprecation warnings to only one message per deprecation.
|
108
|
+
|
109
|
+
|
110
|
+
== v1.1.0 [2018-08-24] Michael Granger <ged@FaerieMUD.org>
|
111
|
+
|
112
|
+
Deprecated (disable warnings per PG_SKIP_DEPRECATION_WARNING=1):
|
113
|
+
- Forwarding conn.exec to conn.exec_params is deprecated.
|
114
|
+
- Forwarding conn.exec_params to conn.exec is deprecated.
|
115
|
+
- Forwarding conn.async_exec to conn.async_exec_params.
|
116
|
+
- Forwarding conn.send_query to conn.send_query_params is deprecated.
|
117
|
+
- Forwarding conn.async_exec_params to conn.async_exec is deprecated.
|
118
|
+
|
119
|
+
PG::Connection enhancements:
|
120
|
+
- Provide PG::Connection#sync_* and PG::Connection#async_* query methods for explicit calling syncronous or asynchronous libpq API.
|
121
|
+
- Make PG::Connection#exec and siblings switchable between sync and async API per PG::Connection.async_api= and change the default to async flavors.
|
122
|
+
- Add async flavors of exec_params, prepare, exec_prepared, describe_prepared and describe_portal.
|
123
|
+
They are identical to their syncronous counterpart, but make use of PostgreSQL's async API.
|
124
|
+
- Replace `rb_thread_fd_select()` by faster `rb_wait_for_single_fd()` in `conn.block` and `conn.async_exec` .
|
125
|
+
- Add PG::Connection#discard_results .
|
126
|
+
- Raise an ArgumentError for strings containing zero bytes by #escape, #escape_literal, #escape_identifier, #quote_ident and PG::TextEncoder::Identifier. These methods previously truncated strings.
|
127
|
+
|
128
|
+
Result retrieval enhancements:
|
129
|
+
- Add PG::Result#tuple_values to retrieve all field values of a row as array.
|
130
|
+
- Add PG::Tuple, PG::Result#tuple and PG::Result#stream_each_tuple .
|
131
|
+
PG::Tuple offers a way to lazy cast result values.
|
132
|
+
- Estimate PG::Result size allocated by libpq and notify the garbage collector about it when running on Ruby-2.4 or newer.
|
133
|
+
- Make the estimated PG::Result size available to ObjectSpace.memsize_of(result) .
|
134
|
+
|
135
|
+
Type cast enhancements:
|
136
|
+
- Replace Ruby code by a faster C implementation of the SimpleDecoder's timestamp decode functions. github #20
|
137
|
+
- Interpret years with up to 7 digists and BC dates by timestamp decoder.
|
138
|
+
- Add text timestamp decoders for UTC vs. local timezone variations.
|
139
|
+
- Add text timestamp encoders for UTC timezone.
|
140
|
+
- Add decoders for binary timestamps: PG::BinaryDecoder::Timestamp and variations.
|
141
|
+
- Add PG::Coder#flags accessor to allow modifications of de- respectively encoder behaviour.
|
142
|
+
- Add a flag to raise TypeError for invalid input values to PG::TextDecoder::Array .
|
143
|
+
- Add a text decoder for inet/cidr written in C.
|
144
|
+
- Add a numeric decoder written in C.
|
145
|
+
- Ensure input text is zero terminated for text format in PG::Coder#decode .
|
146
|
+
|
147
|
+
Source code enhancements:
|
148
|
+
- Fix headers and permission bits of various repository files.
|
149
|
+
|
150
|
+
Bugfixes:
|
151
|
+
- Properly decode array with prepended dimensions. #272
|
152
|
+
For now dimension decorations are ignored, but a correct Array is returned.
|
153
|
+
- Array-Decoder: Avoid leaking memory when an Exception is raised while parsing. Fixes #279
|
154
|
+
|
155
|
+
|
1
156
|
== v1.0.0 [2018-01-10] Michael Granger <ged@FaerieMUD.org>
|
2
157
|
|
3
158
|
Deprecated:
|
@@ -7,6 +162,7 @@ Deprecated:
|
|
7
162
|
Removed:
|
8
163
|
- Remove compatibility code for Ruby < 2.0 and PostgreSQL < 9.2.
|
9
164
|
- Remove partial compatibility with Rubinius.
|
165
|
+
- Remove top-level constants PGconn, PGresult, and PGError.
|
10
166
|
|
11
167
|
Enhancements:
|
12
168
|
- Update error codes to PostgreSQL-10
|
data/Manifest.txt
CHANGED
@@ -26,9 +26,11 @@ ext/pg_coder.c
|
|
26
26
|
ext/pg_connection.c
|
27
27
|
ext/pg_copy_coder.c
|
28
28
|
ext/pg_errors.c
|
29
|
+
ext/pg_record_coder.c
|
29
30
|
ext/pg_result.c
|
30
31
|
ext/pg_text_decoder.c
|
31
32
|
ext/pg_text_encoder.c
|
33
|
+
ext/pg_tuple.c
|
32
34
|
ext/pg_type_map.c
|
33
35
|
ext/pg_type_map_all_strings.c
|
34
36
|
ext/pg_type_map_by_class.c
|
@@ -36,13 +38,14 @@ ext/pg_type_map_by_column.c
|
|
36
38
|
ext/pg_type_map_by_mri_type.c
|
37
39
|
ext/pg_type_map_by_oid.c
|
38
40
|
ext/pg_type_map_in_ruby.c
|
39
|
-
ext/
|
40
|
-
ext/
|
41
|
+
ext/pg_util.c
|
42
|
+
ext/pg_util.h
|
41
43
|
ext/vc/pg.sln
|
42
44
|
ext/vc/pg_18/pg.vcproj
|
43
45
|
ext/vc/pg_19/pg_19.vcproj
|
44
46
|
lib/pg.rb
|
45
47
|
lib/pg/basic_type_mapping.rb
|
48
|
+
lib/pg/binary_decoder.rb
|
46
49
|
lib/pg/coder.rb
|
47
50
|
lib/pg/connection.rb
|
48
51
|
lib/pg/constants.rb
|
@@ -50,13 +53,16 @@ lib/pg/exceptions.rb
|
|
50
53
|
lib/pg/result.rb
|
51
54
|
lib/pg/text_decoder.rb
|
52
55
|
lib/pg/text_encoder.rb
|
56
|
+
lib/pg/tuple.rb
|
53
57
|
lib/pg/type_map_by_column.rb
|
54
58
|
spec/data/expected_trace.out
|
55
59
|
spec/data/random_binary_data
|
56
60
|
spec/helpers.rb
|
57
61
|
spec/pg/basic_type_mapping_spec.rb
|
58
62
|
spec/pg/connection_spec.rb
|
63
|
+
spec/pg/connection_sync_spec.rb
|
59
64
|
spec/pg/result_spec.rb
|
65
|
+
spec/pg/tuple_spec.rb
|
60
66
|
spec/pg/type_map_by_class_spec.rb
|
61
67
|
spec/pg/type_map_by_column_spec.rb
|
62
68
|
spec/pg/type_map_by_mri_type_spec.rb
|
data/README-Windows.rdoc
CHANGED
@@ -35,8 +35,8 @@ Binary gems for windows can be built on Linux, OS-X and even on Windows
|
|
35
35
|
with the help of docker. This is how regular windows gems are built for
|
36
36
|
rubygems.org .
|
37
37
|
|
38
|
-
To do this, install boot2docker
|
39
|
-
or
|
38
|
+
To do this, install boot2docker {on Windows}[https://github.com/boot2docker/windows-installer/releases]
|
39
|
+
or {on OS X}[https://github.com/boot2docker/osx-installer/releases] and make
|
40
40
|
sure it is started. A native Docker installation is best on Linux.
|
41
41
|
|
42
42
|
Then run:
|
@@ -50,7 +50,7 @@ containing binaries for all supported ruby versions.
|
|
50
50
|
|
51
51
|
== Reporting Problems
|
52
52
|
|
53
|
-
If you have any problems you can submit them via
|
54
|
-
|
53
|
+
If you have any problems you can submit them via {the project's
|
54
|
+
issue-tracker}[https://github.com/ged/ruby-pg/issues]. And submit questions, problems, or
|
55
55
|
solutions, so that it can be improved.
|
56
56
|
|
data/README.ja.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
= pg
|
2
2
|
|
3
|
-
home :: https://
|
4
|
-
mirror :: https://github.com/ged/ruby-pg
|
3
|
+
home :: https://github.com/ged/ruby-pg
|
5
4
|
docs :: http://deveiate.org/code/pg
|
6
5
|
|
7
6
|
{<img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/ged/ruby-pg">}[https://gitter.im/ged/ruby-pg?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge]
|
@@ -32,7 +31,7 @@ A small example usage:
|
|
32
31
|
== Build Status
|
33
32
|
|
34
33
|
{<img src="https://travis-ci.org/ged/ruby-pg.svg?branch=master" alt="Build Status Travis-CI" />}[https://travis-ci.org/ged/ruby-pg]
|
35
|
-
{<img src="https://ci.appveyor.com/api/projects/status/
|
34
|
+
{<img src="https://ci.appveyor.com/api/projects/status/gjx5axouf3b1wicp?svg=true" alt="Build Status Appveyor" />}[https://ci.appveyor.com/project/ged/ruby-pg-9j8l3]
|
36
35
|
|
37
36
|
|
38
37
|
== Requirements
|
@@ -40,10 +39,21 @@ A small example usage:
|
|
40
39
|
* Ruby 2.2 or newer
|
41
40
|
* PostgreSQL 9.2.x or later (with headers, -dev packages, etc).
|
42
41
|
|
43
|
-
It usually
|
42
|
+
It usually works with earlier versions of Ruby/PostgreSQL as well, but those are
|
44
43
|
not regularly tested.
|
45
44
|
|
46
45
|
|
46
|
+
== Versioning
|
47
|
+
|
48
|
+
We tag and release gems according to the {Semantic Versioning}[http://semver.org/] principle.
|
49
|
+
|
50
|
+
As a result of this policy, you can (and should) specify a dependency on this gem using the {Pessimistic Version Constraint}[http://guides.rubygems.org/patterns/#pessimistic-version-constraint] with two digits of precision.
|
51
|
+
|
52
|
+
For example:
|
53
|
+
|
54
|
+
spec.add_dependency 'pg', '~> 1.0'
|
55
|
+
|
56
|
+
|
47
57
|
== How To Install
|
48
58
|
|
49
59
|
Install via RubyGems:
|
@@ -67,7 +77,7 @@ There's also {a Google+ group}[http://goo.gl/TFy1U] and a
|
|
67
77
|
want to chat about something.
|
68
78
|
|
69
79
|
If you want to install as a signed gem, the public certs of the gem signers
|
70
|
-
can be found in {the `certs` directory}[https://
|
80
|
+
can be found in {the `certs` directory}[https://github.com/ged/ruby-pg/tree/master/certs]
|
71
81
|
of the repository.
|
72
82
|
|
73
83
|
|
@@ -107,6 +117,30 @@ to build composite types by assigning an element encoder/decoder.
|
|
107
117
|
PG::Coder objects can be used to set up a PG::TypeMap or alternatively
|
108
118
|
to convert single values to/from their string representation.
|
109
119
|
|
120
|
+
The following PostgreSQL column types are supported by ruby-pg (TE = Text Encoder, TD = Text Decoder, BE = Binary Encoder, BD = Binary Decoder):
|
121
|
+
* Integer: {TE}[rdoc-ref:PG::TextEncoder::Integer], {TD}[rdoc-ref:PG::TextDecoder::Integer], {BD}[rdoc-ref:PG::BinaryDecoder::Integer] 💡 No links? Switch to {here}[https://deveiate.org/code/pg/README_rdoc.html#label-Type+Casts] 💡
|
122
|
+
* BE: {Int2}[rdoc-ref:PG::BinaryEncoder::Int2], {Int4}[rdoc-ref:PG::BinaryEncoder::Int4], {Int8}[rdoc-ref:PG::BinaryEncoder::Int8]
|
123
|
+
* Float: {TE}[rdoc-ref:PG::TextEncoder::Float], {TD}[rdoc-ref:PG::TextDecoder::Float], {BD}[rdoc-ref:PG::BinaryDecoder::Float]
|
124
|
+
* Numeric: {TE}[rdoc-ref:PG::TextEncoder::Numeric], {TD}[rdoc-ref:PG::TextDecoder::Numeric]
|
125
|
+
* Boolean: {TE}[rdoc-ref:PG::TextEncoder::Boolean], {TD}[rdoc-ref:PG::TextDecoder::Boolean], {BE}[rdoc-ref:PG::BinaryEncoder::Boolean], {BD}[rdoc-ref:PG::BinaryDecoder::Boolean]
|
126
|
+
* String: {TE}[rdoc-ref:PG::TextEncoder::String], {TD}[rdoc-ref:PG::TextDecoder::String], {BE}[rdoc-ref:PG::BinaryEncoder::String], {BD}[rdoc-ref:PG::BinaryDecoder::String]
|
127
|
+
* Bytea: {TE}[rdoc-ref:PG::TextEncoder::Bytea], {TD}[rdoc-ref:PG::TextDecoder::Bytea], {BE}[rdoc-ref:PG::BinaryEncoder::Bytea], {BD}[rdoc-ref:PG::BinaryDecoder::Bytea]
|
128
|
+
* Base64: {TE}[rdoc-ref:PG::TextEncoder::ToBase64], {TD}[rdoc-ref:PG::TextDecoder::FromBase64], {BE}[rdoc-ref:PG::BinaryEncoder::FromBase64], {BD}[rdoc-ref:PG::BinaryDecoder::ToBase64]
|
129
|
+
* Timestamp:
|
130
|
+
* TE: {local}[rdoc-ref:PG::TextEncoder::TimestampWithoutTimeZone], {UTC}[rdoc-ref:PG::TextEncoder::TimestampUtc], {with-TZ}[rdoc-ref:PG::TextEncoder::TimestampWithTimeZone]
|
131
|
+
* TD: {local}[rdoc-ref:PG::TextDecoder::TimestampLocal], {UTC}[rdoc-ref:PG::TextDecoder::TimestampUtc], {UTC-to-local}[rdoc-ref:PG::TextDecoder::TimestampUtcToLocal]
|
132
|
+
* BD: {local}[rdoc-ref:PG::BinaryDecoder::TimestampLocal], {UTC}[rdoc-ref:PG::BinaryDecoder::TimestampUtc], {UTC-to-local}[rdoc-ref:PG::BinaryDecoder::TimestampUtcToLocal]
|
133
|
+
* Date: {TE}[rdoc-ref:PG::TextEncoder::Date], {TD}[rdoc-ref:PG::TextDecoder::Date]
|
134
|
+
* JSON and JSONB: {TE}[rdoc-ref:PG::TextEncoder::JSON], {TD}[rdoc-ref:PG::TextDecoder::JSON]
|
135
|
+
* Inet: {TE}[rdoc-ref:PG::TextEncoder::Inet], {TD}[rdoc-ref:PG::TextDecoder::Inet]
|
136
|
+
* Array: {TE}[rdoc-ref:PG::TextEncoder::Array], {TD}[rdoc-ref:PG::TextDecoder::Array]
|
137
|
+
* Composite Type (also called "Row" or "Record"): {TE}[rdoc-ref:PG::TextEncoder::Record], {TD}[rdoc-ref:PG::TextDecoder::Record]
|
138
|
+
|
139
|
+
The following text formats can also be encoded although they are not used as column type:
|
140
|
+
* COPY input and output data: {TE}[rdoc-ref:PG::TextEncoder::CopyRow], {TD}[rdoc-ref:PG::TextDecoder::CopyRow]
|
141
|
+
* Literal for insertion into SQL string: {TE}[rdoc-ref:PG::TextEncoder::QuotedLiteral]
|
142
|
+
* SQL-Identifier: {TE}[rdoc-ref:PG::TextEncoder::Identifier], {TD}[rdoc-ref:PG::TextDecoder::Identifier]
|
143
|
+
|
110
144
|
=== PG::TypeMap and derivations (ext/pg_type_map*.c, lib/pg/type_map*.rb)
|
111
145
|
|
112
146
|
A TypeMap defines which value will be converted by which encoder/decoder.
|
@@ -118,11 +152,23 @@ A type map can be assigned per connection or per query respectively per
|
|
118
152
|
result set. Type maps can also be used for COPY in and out data streaming.
|
119
153
|
See PG::Connection#copy_data .
|
120
154
|
|
155
|
+
The following base type maps are available:
|
156
|
+
* PG::TypeMapAllStrings - encodes and decodes all values to and from strings (default)
|
157
|
+
* PG::TypeMapByClass - selects encoder based on the class of the value to be sent
|
158
|
+
* PG::TypeMapByColumn - selects encoder and decoder by column order
|
159
|
+
* PG::TypeMapByOid - selects decoder by PostgreSQL type OID
|
160
|
+
* PG::TypeMapInRuby - define a custom type map in ruby
|
161
|
+
|
162
|
+
The following type maps are prefilled with type mappings from the PG::BasicTypeRegistry :
|
163
|
+
* PG::BasicTypeMapForResults - a PG::TypeMapByOid prefilled with decoders for common PostgreSQL column types
|
164
|
+
* PG::BasicTypeMapBasedOnResult - a PG::TypeMapByOid prefilled with encoders for common PostgreSQL column types
|
165
|
+
* PG::BasicTypeMapForQueries - a PG::TypeMapByClass prefilled with encoders for common Ruby value classes
|
166
|
+
|
167
|
+
|
121
168
|
== Contributing
|
122
169
|
|
123
|
-
To report bugs, suggest features, or check out the source with
|
124
|
-
{check out the project page}[
|
125
|
-
Git, there's also a {Github mirror}[https://github.com/ged/ruby-pg].
|
170
|
+
To report bugs, suggest features, or check out the source with Git,
|
171
|
+
{check out the project page}[https://github.com/ged/ruby-pg].
|
126
172
|
|
127
173
|
After checking out the source, run:
|
128
174
|
|
@@ -137,7 +183,7 @@ Lars Kanis <lars@greiz-reinsdorf.de>.
|
|
137
183
|
|
138
184
|
== Copying
|
139
185
|
|
140
|
-
Copyright (c) 1997-
|
186
|
+
Copyright (c) 1997-2019 by the authors.
|
141
187
|
|
142
188
|
* Jeff Davis <ruby-pg@j-davis.com>
|
143
189
|
* Guy Decoux (ts) <decoux@moulon.inra.fr>
|
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# -*- rake -*-
|
2
2
|
|
3
3
|
require 'rbconfig'
|
4
4
|
require 'pathname'
|
@@ -35,6 +35,8 @@ TEST_DIRECTORY = BASEDIR + "tmp_test_specs"
|
|
35
35
|
|
36
36
|
CLOBBER.include( TEST_DIRECTORY.to_s )
|
37
37
|
CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
|
38
|
+
CLEAN.include "lib/*/libpq.dll"
|
39
|
+
CLEAN.include "lib/pg_ext.*"
|
38
40
|
|
39
41
|
# Set up Hoe plugins
|
40
42
|
Hoe.plugin :mercurial
|
@@ -55,13 +57,13 @@ $hoespec = Hoe.spec 'pg' do
|
|
55
57
|
self.extra_rdoc_files = Rake::FileList[ '*.rdoc' ]
|
56
58
|
self.extra_rdoc_files.include( 'POSTGRES', 'LICENSE' )
|
57
59
|
self.extra_rdoc_files.include( 'ext/*.c' )
|
58
|
-
self.license 'BSD-
|
60
|
+
self.license 'BSD-2-Clause'
|
59
61
|
|
60
62
|
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
61
63
|
self.developer 'Lars Kanis', 'lars@greiz-reinsdorf.de'
|
62
64
|
|
63
65
|
self.dependency 'rake-compiler', '~> 1.0', :developer
|
64
|
-
self.dependency 'rake-compiler-dock', ['~>
|
66
|
+
self.dependency 'rake-compiler-dock', ['~> 1.0'], :developer
|
65
67
|
self.dependency 'hoe-deveiate', '~> 0.9', :developer
|
66
68
|
self.dependency 'hoe-bundler', '~> 1.0', :developer
|
67
69
|
self.dependency 'rspec', '~> 3.5', :developer
|
@@ -69,7 +71,7 @@ $hoespec = Hoe.spec 'pg' do
|
|
69
71
|
|
70
72
|
self.spec_extras[:extensions] = [ 'ext/extconf.rb' ]
|
71
73
|
|
72
|
-
self.require_ruby_version( '>= 2.
|
74
|
+
self.require_ruby_version( '>= 2.2' )
|
73
75
|
|
74
76
|
self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
|
75
77
|
self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
|
@@ -113,7 +115,7 @@ Rake::ExtensionTask.new do |ext|
|
|
113
115
|
ext.lib_dir = 'lib'
|
114
116
|
ext.source_pattern = "*.{c,h}"
|
115
117
|
ext.cross_compile = true
|
116
|
-
ext.cross_platform = CrossLibraries.map
|
118
|
+
ext.cross_platform = CrossLibraries.map(&:for_platform)
|
117
119
|
|
118
120
|
ext.cross_config_options += CrossLibraries.map do |lib|
|
119
121
|
{
|
@@ -129,7 +131,7 @@ Rake::ExtensionTask.new do |ext|
|
|
129
131
|
|
130
132
|
# Add libpq.dll to windows binary gemspec
|
131
133
|
ext.cross_compiling do |spec|
|
132
|
-
spec.files << "lib/libpq.dll"
|
134
|
+
spec.files << "lib/#{spec.platform}/libpq.dll"
|
133
135
|
end
|
134
136
|
end
|
135
137
|
|
@@ -184,7 +186,7 @@ end
|
|
184
186
|
|
185
187
|
desc "Update list of server error codes"
|
186
188
|
task :update_error_codes do
|
187
|
-
URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/
|
189
|
+
URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL_12_0"
|
188
190
|
|
189
191
|
ERRORCODES_TXT = "ext/errorcodes.txt"
|
190
192
|
sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
|
data/Rakefile.cross
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# -*- rake -*-
|
2
2
|
|
3
3
|
require 'uri'
|
4
4
|
require 'tempfile'
|
@@ -29,15 +29,15 @@ class CrossLibrary < OpenStruct
|
|
29
29
|
self.host_platform = toolchain
|
30
30
|
|
31
31
|
# Cross-compilation constants
|
32
|
-
self.openssl_version = ENV['OPENSSL_VERSION'] || '1.1.
|
33
|
-
self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '
|
32
|
+
self.openssl_version = ENV['OPENSSL_VERSION'] || '1.1.1d'
|
33
|
+
self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '12.1'
|
34
34
|
|
35
35
|
# Check if symlinks work in the current working directory.
|
36
36
|
# This fails, if rake-compiler-dock is running on a Windows box.
|
37
37
|
begin
|
38
38
|
FileUtils.rm_f '.test_symlink'
|
39
39
|
FileUtils.ln_s '/', '.test_symlink'
|
40
|
-
rescue SystemCallError
|
40
|
+
rescue NotImplementedError, SystemCallError
|
41
41
|
# Symlinks don't work -> use home directory instead
|
42
42
|
self.compile_home = Pathname( "~/.ruby-pg-build" ).expand_path
|
43
43
|
else
|
@@ -45,6 +45,8 @@ class CrossLibrary < OpenStruct
|
|
45
45
|
end
|
46
46
|
self.static_sourcesdir = compile_home + 'sources'
|
47
47
|
self.static_builddir = compile_home + 'builds' + for_platform
|
48
|
+
CLOBBER.include( static_sourcesdir )
|
49
|
+
CLEAN.include( static_builddir )
|
48
50
|
|
49
51
|
# Static OpenSSL build vars
|
50
52
|
self.static_openssl_builddir = static_builddir + "openssl-#{openssl_version}"
|
@@ -81,17 +83,6 @@ class CrossLibrary < OpenStruct
|
|
81
83
|
# clean intermediate files and folders
|
82
84
|
CLEAN.include( static_builddir.to_s )
|
83
85
|
|
84
|
-
|
85
|
-
def download(url, save_to)
|
86
|
-
part = save_to+".part"
|
87
|
-
sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
|
88
|
-
FileUtils.mv part, save_to
|
89
|
-
end
|
90
|
-
|
91
|
-
def run(*args)
|
92
|
-
sh *args
|
93
|
-
end
|
94
|
-
|
95
86
|
#####################################################################
|
96
87
|
### C R O S S - C O M P I L A T I O N - T A S K S
|
97
88
|
#####################################################################
|
@@ -141,9 +132,9 @@ class CrossLibrary < OpenStruct
|
|
141
132
|
end
|
142
133
|
|
143
134
|
desc "compile static openssl libraries"
|
144
|
-
task
|
135
|
+
task "openssl_libs:#{for_platform}" => [ libssl, libcrypto ]
|
145
136
|
|
146
|
-
task
|
137
|
+
task "compile_static_openssl:#{for_platform}" => openssl_makefile do |t|
|
147
138
|
chdir( static_openssl_builddir ) do
|
148
139
|
cmd = cmd_prelude.dup
|
149
140
|
cmd << 'make' << "-j#{NUM_CPUS}" << 'build_libs'
|
@@ -153,12 +144,12 @@ class CrossLibrary < OpenStruct
|
|
153
144
|
end
|
154
145
|
|
155
146
|
desc "compile static #{libssl}"
|
156
|
-
file libssl =>
|
147
|
+
file libssl => "compile_static_openssl:#{for_platform}" do |t|
|
157
148
|
rm t.name.gsub(/\.a$/, ".dll.a")
|
158
149
|
end
|
159
150
|
|
160
151
|
desc "compile static #{libcrypto}"
|
161
|
-
file libcrypto =>
|
152
|
+
file libcrypto => "compile_static_openssl:#{for_platform}" do |t|
|
162
153
|
rm t.name.gsub(/\.a$/, ".dll.a")
|
163
154
|
end
|
164
155
|
|
@@ -189,7 +180,7 @@ class CrossLibrary < OpenStruct
|
|
189
180
|
end
|
190
181
|
|
191
182
|
# generate the makefile in a clean build location
|
192
|
-
file postgresql_global_makefile => [ static_postgresql_builddir,
|
183
|
+
file postgresql_global_makefile => [ static_postgresql_builddir, "openssl_libs:#{for_platform}" ] do |t|
|
193
184
|
options = [
|
194
185
|
"--target=#{host_platform}",
|
195
186
|
"--host=#{host_platform}",
|
@@ -217,6 +208,9 @@ class CrossLibrary < OpenStruct
|
|
217
208
|
chdir( static_postgresql_srcdir + "common" ) do
|
218
209
|
sh 'make', "-j#{NUM_CPUS}"
|
219
210
|
end
|
211
|
+
chdir( static_postgresql_srcdir + "port" ) do
|
212
|
+
sh 'make', "-j#{NUM_CPUS}"
|
213
|
+
end
|
220
214
|
|
221
215
|
chdir( postgresql_lib.dirname ) do
|
222
216
|
sh 'make',
|
@@ -228,10 +222,10 @@ class CrossLibrary < OpenStruct
|
|
228
222
|
|
229
223
|
|
230
224
|
#desc 'compile libpg.a'
|
231
|
-
task
|
225
|
+
task "native:#{for_platform}" => postgresql_lib
|
232
226
|
|
233
227
|
# copy libpq.dll to lib dir
|
234
|
-
dest_libpq = "lib/#{postgresql_lib.basename}"
|
228
|
+
dest_libpq = "lib/#{for_platform}/#{postgresql_lib.basename}"
|
235
229
|
directory File.dirname(dest_libpq)
|
236
230
|
file dest_libpq => [postgresql_lib, File.dirname(dest_libpq)] do
|
237
231
|
cp postgresql_lib, dest_libpq
|
@@ -243,22 +237,27 @@ class CrossLibrary < OpenStruct
|
|
243
237
|
cp postgresql_lib, stage_libpq
|
244
238
|
end
|
245
239
|
end
|
246
|
-
end
|
247
240
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
].map do |platform, openssl_config, toolchain|
|
253
|
-
CrossLibrary.new platform, openssl_config, toolchain
|
241
|
+
def download(url, save_to)
|
242
|
+
part = save_to+".part"
|
243
|
+
sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
|
244
|
+
FileUtils.mv part, save_to
|
254
245
|
end
|
255
|
-
|
256
|
-
|
257
|
-
|
246
|
+
|
247
|
+
def run(*args)
|
248
|
+
sh(*args)
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
CrossLibraries = [
|
253
|
+
['x86-mingw32', 'mingw', 'i686-w64-mingw32'],
|
254
|
+
['x64-mingw32', 'mingw64', 'x86_64-w64-mingw32'],
|
255
|
+
].map do |platform, openssl_config, toolchain|
|
256
|
+
CrossLibrary.new platform, openssl_config, toolchain
|
258
257
|
end
|
259
258
|
|
260
259
|
desc 'cross compile pg for win32'
|
261
|
-
task :cross => [ :mingw32
|
260
|
+
task :cross => [ :mingw32 ]
|
262
261
|
|
263
262
|
task :mingw32 do
|
264
263
|
# Use Rake::ExtensionCompiler helpers to find the proper host
|
@@ -269,30 +268,32 @@ task :mingw32 do
|
|
269
268
|
end
|
270
269
|
end
|
271
270
|
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
271
|
+
task 'gem:windows:prepare' do
|
272
|
+
require 'io/console'
|
273
|
+
require 'rake_compiler_dock'
|
274
|
+
|
275
|
+
# Copy gem signing key and certs to be accessable from the docker container
|
276
|
+
mkdir_p 'build/gem'
|
277
|
+
sh "cp ~/.gem/gem-*.pem build/gem/ || true"
|
278
|
+
sh "bundle package"
|
279
|
+
begin
|
280
|
+
OpenSSL::PKey.read(File.read(File.expand_path("~/.gem/gem-private_key.pem")), ENV["GEM_PRIVATE_KEY_PASSPHRASE"] || "")
|
281
|
+
rescue OpenSSL::PKey::PKeyError
|
282
|
+
ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = STDIN.getpass("Enter passphrase of gem signature key: ")
|
283
|
+
retry
|
284
|
+
end
|
281
285
|
end
|
282
286
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
bundle install --local &&
|
296
|
-
rake cross native gem RUBY_CC_VERSION=2.5.0:2.4.0:2.3.0:2.2.2:2.1.6:2.0.0
|
297
|
-
EOT
|
287
|
+
CrossLibraries.each do |xlib|
|
288
|
+
platform = xlib.for_platform
|
289
|
+
desc "Build fat binary gem for platform #{platform}"
|
290
|
+
task "gem:windows:#{platform}" => ['ChangeLog', 'gem:windows:prepare', xlib.openssl_tarball, xlib.postgresql_tarball] do
|
291
|
+
RakeCompilerDock.sh <<-EOT, platform: platform
|
292
|
+
(cp build/gem/gem-*.pem ~/.gem/ || true) &&
|
293
|
+
bundle install --local &&
|
294
|
+
rake native:#{platform} pkg/#{$hoespec.spec.full_name}-#{platform}.gem MAKE="make -j`nproc`"
|
295
|
+
EOT
|
296
|
+
end
|
297
|
+
desc "Build the windows binary gems"
|
298
|
+
multitask 'gem:windows' => "gem:windows:#{platform}"
|
298
299
|
end
|