pg 1.4.5 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.appveyor.yml +15 -9
  4. data/.github/workflows/binary-gems.yml +41 -10
  5. data/.github/workflows/source-gem.yml +23 -13
  6. data/.gitignore +11 -2
  7. data/.travis.yml +2 -2
  8. data/{History.rdoc → History.md} +248 -153
  9. data/README.ja.md +300 -0
  10. data/README.md +286 -0
  11. data/Rakefile +12 -3
  12. data/Rakefile.cross +7 -11
  13. data/certs/larskanis-2023.pem +24 -0
  14. data/ext/extconf.rb +4 -0
  15. data/ext/pg.c +11 -29
  16. data/ext/pg.h +10 -6
  17. data/ext/pg_binary_decoder.c +79 -0
  18. data/ext/pg_binary_encoder.c +224 -0
  19. data/ext/pg_coder.c +16 -7
  20. data/ext/pg_connection.c +172 -69
  21. data/ext/pg_copy_coder.c +306 -17
  22. data/ext/pg_record_coder.c +5 -4
  23. data/ext/pg_result.c +91 -17
  24. data/ext/pg_text_decoder.c +28 -10
  25. data/ext/pg_text_encoder.c +22 -9
  26. data/ext/pg_tuple.c +34 -31
  27. data/ext/pg_type_map.c +3 -2
  28. data/ext/pg_type_map_all_strings.c +2 -2
  29. data/ext/pg_type_map_by_class.c +5 -3
  30. data/ext/pg_type_map_by_column.c +7 -3
  31. data/ext/pg_type_map_by_oid.c +7 -4
  32. data/ext/pg_type_map_in_ruby.c +5 -2
  33. data/lib/pg/basic_type_map_based_on_result.rb +21 -1
  34. data/lib/pg/basic_type_map_for_queries.rb +13 -8
  35. data/lib/pg/basic_type_map_for_results.rb +26 -3
  36. data/lib/pg/basic_type_registry.rb +30 -32
  37. data/lib/pg/binary_decoder/date.rb +9 -0
  38. data/lib/pg/binary_decoder/timestamp.rb +26 -0
  39. data/lib/pg/binary_encoder/timestamp.rb +20 -0
  40. data/lib/pg/coder.rb +15 -13
  41. data/lib/pg/connection.rb +103 -30
  42. data/lib/pg/exceptions.rb +7 -0
  43. data/lib/pg/text_decoder/date.rb +18 -0
  44. data/lib/pg/text_decoder/inet.rb +9 -0
  45. data/lib/pg/text_decoder/json.rb +14 -0
  46. data/lib/pg/text_decoder/numeric.rb +9 -0
  47. data/lib/pg/text_decoder/timestamp.rb +30 -0
  48. data/lib/pg/text_encoder/date.rb +12 -0
  49. data/lib/pg/text_encoder/inet.rb +28 -0
  50. data/lib/pg/text_encoder/json.rb +14 -0
  51. data/lib/pg/text_encoder/numeric.rb +9 -0
  52. data/lib/pg/text_encoder/timestamp.rb +24 -0
  53. data/lib/pg/version.rb +1 -1
  54. data/lib/pg.rb +55 -15
  55. data/pg.gemspec +4 -2
  56. data/rakelib/task_extension.rb +1 -1
  57. data/translation/.po4a-version +7 -0
  58. data/translation/po/all.pot +936 -0
  59. data/translation/po/ja.po +1036 -0
  60. data/translation/po4a.cfg +12 -0
  61. data.tar.gz.sig +0 -0
  62. metadata +93 -22
  63. metadata.gz.sig +0 -0
  64. data/README.ja.rdoc +0 -13
  65. data/README.rdoc +0 -233
  66. data/lib/pg/binary_decoder.rb +0 -23
  67. data/lib/pg/constants.rb +0 -12
  68. data/lib/pg/text_decoder.rb +0 -46
  69. data/lib/pg/text_encoder.rb +0 -59
@@ -0,0 +1,12 @@
1
+ [po_directory] po
2
+
3
+ [options] --master-charset UTF-8 \
4
+ --localized-charset UTF-8 \
5
+ --master-language en \
6
+ --option markdown \
7
+ --keep 0 \
8
+ --package-name Pg \
9
+ --package-version 1.4.6 \
10
+ --copyright-holder 'Pg authors'
11
+
12
+ [type:text] ../README.md ja:../README.ja.md
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.5
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -11,9 +11,9 @@ bindir: bin
11
11
  cert_chain:
12
12
  - |
13
13
  -----BEGIN CERTIFICATE-----
14
- MIIDLjCCAhagAwIBAgIBCjANBgkqhkiG9w0BAQsFADA9MQ4wDAYDVQQDDAVrYW5p
14
+ MIIDLjCCAhagAwIBAgIBCzANBgkqhkiG9w0BAQsFADA9MQ4wDAYDVQQDDAVrYW5p
15
15
  czEXMBUGCgmSJomT8ixkARkWB2NvbWNhcmQxEjAQBgoJkiaJk/IsZAEZFgJkZTAe
16
- Fw0yMjA0MTExMTMwNTNaFw0yMzA0MTExMTMwNTNaMD0xDjAMBgNVBAMMBWthbmlz
16
+ Fw0yMzA0MjgwOTI0NDhaFw0yNDA0MjcwOTI0NDhaMD0xDjAMBgNVBAMMBWthbmlz
17
17
  MRcwFQYKCZImiZPyLGQBGRYHY29tY2FyZDESMBAGCgmSJomT8ixkARkWAmRlMIIB
18
18
  IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApop+rNmg35bzRugZ21VMGqI6
19
19
  HGzPLO4VHYncWn/xmgPU/ZMcZdfj6MzIaZJ/czXyt4eHpBk1r8QOV3gBXnRXEjVW
@@ -22,15 +22,15 @@ cert_chain:
22
22
  Q53c63+VLGsOjODl1yPn/2ejyq8qWu6ahfTxiIlSar2UbwtaQGBDFdb2CXgEufXT
23
23
  L7oaPxlmj+Q2oLOfOnInd2Oxop59HoJCQPsg8f921J43NCQGA8VHK6paxIRDLQID
24
24
  AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUvgTdT7fe
25
- x17ugO3IOsjEJwW7KP4wDQYJKoZIhvcNAQELBQADggEBAILiaB/unSVBfX5n7uL8
26
- veGGCOHuGYhCGqspb6mYiCx0dmV3RPRiEfGDLfzcXbHNx/3AjygcxH4Slr+pmaxr
27
- 04Xli3WurocnjoANSWqCwpHH3OhSVxFgBNrCa3OMWcIr0xKH+I7PXA80SXe0pzfg
28
- ePjpzTY71j+rcyRJqWiU5/zwdUaCCelBJscxh/0IaNcz67ocCEMRj0n4m5HFEmZL
29
- 9zKkMZFoOjxRQjcL84QU7ZXnnFR5HG8nLw+NqWjo49W6MBQ9HGFda2tk3OpBhyWS
30
- sc3NyOkGUGdfiee5VRG31Sh3LLON3YGED+zZAS+ZF6598y4vhv8MBLa1Oy357byC
31
- tTg=
25
+ x17ugO3IOsjEJwW7KP4wDQYJKoZIhvcNAQELBQADggEBACAxNXwfMGG7paZjnG/c
26
+ smdi/ocW2GmCNtILaSzDZqlD5LoA68MiO7u5vwWyBaDJ6giUB330VJoGRbWMxvxN
27
+ JU6Bnwa4yYp9YtF91wYIi7FXwIrCPKd9bk3bf4M5wECdsv+zvVceq2zRXqD7fci8
28
+ 1LRG8ort/f4TgaT7B4aNwOaabA2UT6u0FGeglqxLkhir86MY3QQyBfJZUoTKWGkz
29
+ S9a7GXsYpe+8HMOaE4+SZp8SORKPgATND5m/4VdzuO59VXjE5UP7QpXigbxAt7H7
30
+ ciK5Du2ZDhowmWzZwNzR7VvVmfAK6RQJlRB03VkkQRWGld5yApOrYDne6WbD8kE0
31
+ uM8=
32
32
  -----END CERTIFICATE-----
33
- date: 2022-11-17 00:00:00.000000000 Z
33
+ date: 2023-09-01 00:00:00.000000000 Z
34
34
  dependencies: []
35
35
  description: Pg is the Ruby interface to the PostgreSQL RDBMS. It works with PostgreSQL
36
36
  9.3 and later.
@@ -40,7 +40,62 @@ email:
40
40
  executables: []
41
41
  extensions:
42
42
  - ext/extconf.rb
43
- extra_rdoc_files: []
43
+ extra_rdoc_files:
44
+ - Contributors.rdoc
45
+ - History.md
46
+ - README-OS_X.rdoc
47
+ - README-Windows.rdoc
48
+ - README.ja.md
49
+ - README.md
50
+ - ext/gvl_wrappers.c
51
+ - ext/gvl_wrappers.h
52
+ - ext/pg.c
53
+ - ext/pg.h
54
+ - ext/pg_binary_decoder.c
55
+ - ext/pg_binary_encoder.c
56
+ - ext/pg_coder.c
57
+ - ext/pg_connection.c
58
+ - ext/pg_copy_coder.c
59
+ - ext/pg_errors.c
60
+ - ext/pg_record_coder.c
61
+ - ext/pg_result.c
62
+ - ext/pg_text_decoder.c
63
+ - ext/pg_text_encoder.c
64
+ - ext/pg_tuple.c
65
+ - ext/pg_type_map.c
66
+ - ext/pg_type_map_all_strings.c
67
+ - ext/pg_type_map_by_class.c
68
+ - ext/pg_type_map_by_column.c
69
+ - ext/pg_type_map_by_mri_type.c
70
+ - ext/pg_type_map_by_oid.c
71
+ - ext/pg_type_map_in_ruby.c
72
+ - ext/pg_util.c
73
+ - ext/pg_util.h
74
+ - lib/pg.rb
75
+ - lib/pg/basic_type_map_based_on_result.rb
76
+ - lib/pg/basic_type_map_for_queries.rb
77
+ - lib/pg/basic_type_map_for_results.rb
78
+ - lib/pg/basic_type_registry.rb
79
+ - lib/pg/binary_decoder/date.rb
80
+ - lib/pg/binary_decoder/timestamp.rb
81
+ - lib/pg/binary_encoder/timestamp.rb
82
+ - lib/pg/coder.rb
83
+ - lib/pg/connection.rb
84
+ - lib/pg/exceptions.rb
85
+ - lib/pg/result.rb
86
+ - lib/pg/text_decoder/date.rb
87
+ - lib/pg/text_decoder/inet.rb
88
+ - lib/pg/text_decoder/json.rb
89
+ - lib/pg/text_decoder/numeric.rb
90
+ - lib/pg/text_decoder/timestamp.rb
91
+ - lib/pg/text_encoder/date.rb
92
+ - lib/pg/text_encoder/inet.rb
93
+ - lib/pg/text_encoder/json.rb
94
+ - lib/pg/text_encoder/numeric.rb
95
+ - lib/pg/text_encoder/timestamp.rb
96
+ - lib/pg/tuple.rb
97
+ - lib/pg/type_map_by_column.rb
98
+ - lib/pg/version.rb
44
99
  files:
45
100
  - ".appveyor.yml"
46
101
  - ".gems"
@@ -57,18 +112,19 @@ files:
57
112
  - BSDL
58
113
  - Contributors.rdoc
59
114
  - Gemfile
60
- - History.rdoc
115
+ - History.md
61
116
  - LICENSE
62
117
  - Manifest.txt
63
118
  - POSTGRES
64
119
  - README-OS_X.rdoc
65
120
  - README-Windows.rdoc
66
- - README.ja.rdoc
67
- - README.rdoc
121
+ - README.ja.md
122
+ - README.md
68
123
  - Rakefile
69
124
  - Rakefile.cross
70
125
  - certs/ged.pem
71
126
  - certs/larskanis-2022.pem
127
+ - certs/larskanis-2023.pem
72
128
  - ext/errorcodes.def
73
129
  - ext/errorcodes.rb
74
130
  - ext/errorcodes.txt
@@ -105,14 +161,23 @@ files:
105
161
  - lib/pg/basic_type_map_for_queries.rb
106
162
  - lib/pg/basic_type_map_for_results.rb
107
163
  - lib/pg/basic_type_registry.rb
108
- - lib/pg/binary_decoder.rb
164
+ - lib/pg/binary_decoder/date.rb
165
+ - lib/pg/binary_decoder/timestamp.rb
166
+ - lib/pg/binary_encoder/timestamp.rb
109
167
  - lib/pg/coder.rb
110
168
  - lib/pg/connection.rb
111
- - lib/pg/constants.rb
112
169
  - lib/pg/exceptions.rb
113
170
  - lib/pg/result.rb
114
- - lib/pg/text_decoder.rb
115
- - lib/pg/text_encoder.rb
171
+ - lib/pg/text_decoder/date.rb
172
+ - lib/pg/text_decoder/inet.rb
173
+ - lib/pg/text_decoder/json.rb
174
+ - lib/pg/text_decoder/numeric.rb
175
+ - lib/pg/text_decoder/timestamp.rb
176
+ - lib/pg/text_encoder/date.rb
177
+ - lib/pg/text_encoder/inet.rb
178
+ - lib/pg/text_encoder/json.rb
179
+ - lib/pg/text_encoder/numeric.rb
180
+ - lib/pg/text_encoder/timestamp.rb
116
181
  - lib/pg/tuple.rb
117
182
  - lib/pg/type_map_by_column.rb
118
183
  - lib/pg/version.rb
@@ -148,18 +213,24 @@ files:
148
213
  - sample/test_binary_values.rb
149
214
  - sample/wal_shipper.rb
150
215
  - sample/warehouse_partitions.rb
216
+ - translation/.po4a-version
217
+ - translation/po/all.pot
218
+ - translation/po/ja.po
219
+ - translation/po4a.cfg
151
220
  homepage: https://github.com/ged/ruby-pg
152
221
  licenses:
153
222
  - BSD-2-Clause
154
223
  metadata:
155
224
  homepage_uri: https://github.com/ged/ruby-pg
156
225
  source_code_uri: https://github.com/ged/ruby-pg
157
- changelog_uri: https://github.com/ged/ruby-pg/blob/master/History.rdoc
226
+ changelog_uri: https://github.com/ged/ruby-pg/blob/master/History.md
158
227
  documentation_uri: http://deveiate.org/code/pg
159
228
  post_install_message:
160
229
  rdoc_options:
161
230
  - "--main"
162
- - README.rdoc
231
+ - README.md
232
+ - "--title"
233
+ - 'PG: The Ruby PostgreSQL Driver'
163
234
  require_paths:
164
235
  - lib
165
236
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -173,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
244
  - !ruby/object:Gem::Version
174
245
  version: '0'
175
246
  requirements: []
176
- rubygems_version: 3.3.19
247
+ rubygems_version: 3.4.15
177
248
  signing_key:
178
249
  specification_version: 4
179
250
  summary: Pg is the Ruby interface to the PostgreSQL RDBMS
metadata.gz.sig CHANGED
Binary file
data/README.ja.rdoc DELETED
@@ -1,13 +0,0 @@
1
- = pg
2
-
3
- home :: https://github.com/ged/ruby-pg
4
- docs :: http://deveiate.org/code/pg
5
-
6
-
7
- == Description
8
-
9
- This file needs a translation of the English README. Pull requests, patches, or
10
- volunteers gladly accepted.
11
-
12
- Until such time, please accept my sincere apologies for not knowing Japanese.
13
-
data/README.rdoc DELETED
@@ -1,233 +0,0 @@
1
- = pg
2
-
3
- home :: https://github.com/ged/ruby-pg
4
- docs :: http://deveiate.org/code/pg
5
- clog :: link:/History.rdoc
6
-
7
- {<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]
8
-
9
-
10
- == Description
11
-
12
- Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
13
-
14
- It works with {PostgreSQL 9.3 and later}[http://www.postgresql.org/support/versioning/].
15
-
16
- A small example usage:
17
-
18
- #!/usr/bin/env ruby
19
-
20
- require 'pg'
21
-
22
- # Output a table of current connections to the DB
23
- conn = PG.connect( dbname: 'sales' )
24
- conn.exec( "SELECT * FROM pg_stat_activity" ) do |result|
25
- puts " PID | User | Query"
26
- result.each do |row|
27
- puts " %7d | %-16s | %s " %
28
- row.values_at('pid', 'usename', 'query')
29
- end
30
- end
31
-
32
- == Build Status
33
-
34
- {<img src="https://github.com/ged/ruby-pg/actions/workflows/source-gem.yml/badge.svg?branch=master" alt="Build Status Github Actions" />}[https://github.com/ged/ruby-pg/actions/workflows/source-gem.yml]
35
- {<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
- {<img src="https://app.travis-ci.com/larskanis/ruby-pg.svg?branch=master" alt="Build Status" />}[https://app.travis-ci.com/larskanis/ruby-pg]
37
-
38
- == Requirements
39
-
40
- * Ruby 2.4 or newer
41
- * PostgreSQL 9.3.x or later (with headers, -dev packages, etc).
42
-
43
- It usually works with earlier versions of Ruby/PostgreSQL as well, but those are
44
- not regularly tested.
45
-
46
-
47
- == Versioning
48
-
49
- We tag and release gems according to the {Semantic Versioning}[http://semver.org/] principle.
50
-
51
- 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.
52
-
53
- For example:
54
-
55
- spec.add_dependency 'pg', '~> 1.0'
56
-
57
-
58
- == How To Install
59
-
60
- Install via RubyGems:
61
-
62
- gem install pg
63
-
64
- You may need to specify the path to the 'pg_config' program installed with
65
- Postgres:
66
-
67
- gem install pg -- --with-pg-config=<path to pg_config>
68
-
69
- If you're installing via Bundler, you can provide compile hints like so:
70
-
71
- bundle config build.pg --with-pg-config=<path to pg_config>
72
-
73
- See README-OS_X.rdoc for more information about installing under MacOS X, and
74
- README-Windows.rdoc for Windows build/installation instructions.
75
-
76
- There's also {a Google+ group}[http://goo.gl/TFy1U] and a
77
- {mailing list}[http://groups.google.com/group/ruby-pg] if you get stuck, or just
78
- want to chat about something.
79
-
80
- If you want to install as a signed gem, the public certs of the gem signers
81
- can be found in {the `certs` directory}[https://github.com/ged/ruby-pg/tree/master/certs]
82
- of the repository.
83
-
84
-
85
- == Type Casts
86
-
87
- Pg can optionally type cast result values and query parameters in Ruby or
88
- native C code. This can speed up data transfers to and from the database,
89
- because String allocations are reduced and conversions in (slower) Ruby code
90
- can be omitted.
91
-
92
- Very basic type casting can be enabled by:
93
-
94
- conn.type_map_for_results = PG::BasicTypeMapForResults.new conn
95
- # ... this works for result value mapping:
96
- conn.exec("select 1, now(), '{2,3}'::int[]").values
97
- # => [[1, 2014-09-21 20:51:56 +0200, [2, 3]]]
98
-
99
- conn.type_map_for_queries = PG::BasicTypeMapForQueries.new conn
100
- # ... and this for param value mapping:
101
- conn.exec_params("SELECT $1::text, $2::text, $3::text", [1, 1.23, [2,3]]).values
102
- # => [["1", "1.2300000000000000E+00", "{2,3}"]]
103
-
104
- But Pg's type casting is highly customizable. That's why it's divided into
105
- 2 layers:
106
-
107
- === Encoders / Decoders (ext/pg_*coder.c, lib/pg/*coder.rb)
108
-
109
- This is the lower layer, containing encoding classes that convert Ruby
110
- objects for transmission to the DBMS and decoding classes to convert
111
- received data back to Ruby objects. The classes are namespaced according
112
- to their format and direction in PG::TextEncoder, PG::TextDecoder,
113
- PG::BinaryEncoder and PG::BinaryDecoder.
114
-
115
- It is possible to assign a type OID, format code (text or binary) and
116
- optionally a name to an encoder or decoder object. It's also possible
117
- to build composite types by assigning an element encoder/decoder.
118
- PG::Coder objects can be used to set up a PG::TypeMap or alternatively
119
- to convert single values to/from their string representation.
120
-
121
- The following PostgreSQL column types are supported by ruby-pg (TE = Text Encoder, TD = Text Decoder, BE = Binary Encoder, BD = Binary Decoder):
122
- * 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] 💡
123
- * BE: {Int2}[rdoc-ref:PG::BinaryEncoder::Int2], {Int4}[rdoc-ref:PG::BinaryEncoder::Int4], {Int8}[rdoc-ref:PG::BinaryEncoder::Int8]
124
- * Float: {TE}[rdoc-ref:PG::TextEncoder::Float], {TD}[rdoc-ref:PG::TextDecoder::Float], {BD}[rdoc-ref:PG::BinaryDecoder::Float]
125
- * Numeric: {TE}[rdoc-ref:PG::TextEncoder::Numeric], {TD}[rdoc-ref:PG::TextDecoder::Numeric]
126
- * 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]
127
- * 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]
128
- * 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]
129
- * 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]
130
- * Timestamp:
131
- * TE: {local}[rdoc-ref:PG::TextEncoder::TimestampWithoutTimeZone], {UTC}[rdoc-ref:PG::TextEncoder::TimestampUtc], {with-TZ}[rdoc-ref:PG::TextEncoder::TimestampWithTimeZone]
132
- * TD: {local}[rdoc-ref:PG::TextDecoder::TimestampLocal], {UTC}[rdoc-ref:PG::TextDecoder::TimestampUtc], {UTC-to-local}[rdoc-ref:PG::TextDecoder::TimestampUtcToLocal]
133
- * BD: {local}[rdoc-ref:PG::BinaryDecoder::TimestampLocal], {UTC}[rdoc-ref:PG::BinaryDecoder::TimestampUtc], {UTC-to-local}[rdoc-ref:PG::BinaryDecoder::TimestampUtcToLocal]
134
- * Date: {TE}[rdoc-ref:PG::TextEncoder::Date], {TD}[rdoc-ref:PG::TextDecoder::Date]
135
- * JSON and JSONB: {TE}[rdoc-ref:PG::TextEncoder::JSON], {TD}[rdoc-ref:PG::TextDecoder::JSON]
136
- * Inet: {TE}[rdoc-ref:PG::TextEncoder::Inet], {TD}[rdoc-ref:PG::TextDecoder::Inet]
137
- * Array: {TE}[rdoc-ref:PG::TextEncoder::Array], {TD}[rdoc-ref:PG::TextDecoder::Array]
138
- * Composite Type (also called "Row" or "Record"): {TE}[rdoc-ref:PG::TextEncoder::Record], {TD}[rdoc-ref:PG::TextDecoder::Record]
139
-
140
- The following text formats can also be encoded although they are not used as column type:
141
- * COPY input and output data: {TE}[rdoc-ref:PG::TextEncoder::CopyRow], {TD}[rdoc-ref:PG::TextDecoder::CopyRow]
142
- * Literal for insertion into SQL string: {TE}[rdoc-ref:PG::TextEncoder::QuotedLiteral]
143
- * SQL-Identifier: {TE}[rdoc-ref:PG::TextEncoder::Identifier], {TD}[rdoc-ref:PG::TextDecoder::Identifier]
144
-
145
- === PG::TypeMap and derivations (ext/pg_type_map*.c, lib/pg/type_map*.rb)
146
-
147
- A TypeMap defines which value will be converted by which encoder/decoder.
148
- There are different type map strategies, implemented by several derivations
149
- of this class. They can be chosen and configured according to the particular
150
- needs for type casting. The default type map is PG::TypeMapAllStrings.
151
-
152
- A type map can be assigned per connection or per query respectively per
153
- result set. Type maps can also be used for COPY in and out data streaming.
154
- See PG::Connection#copy_data .
155
-
156
- The following base type maps are available:
157
- * PG::TypeMapAllStrings - encodes and decodes all values to and from strings (default)
158
- * PG::TypeMapByClass - selects encoder based on the class of the value to be sent
159
- * PG::TypeMapByColumn - selects encoder and decoder by column order
160
- * PG::TypeMapByOid - selects decoder by PostgreSQL type OID
161
- * PG::TypeMapInRuby - define a custom type map in ruby
162
-
163
- The following type maps are prefilled with type mappings from the PG::BasicTypeRegistry :
164
- * PG::BasicTypeMapForResults - a PG::TypeMapByOid prefilled with decoders for common PostgreSQL column types
165
- * PG::BasicTypeMapBasedOnResult - a PG::TypeMapByOid prefilled with encoders for common PostgreSQL column types
166
- * PG::BasicTypeMapForQueries - a PG::TypeMapByClass prefilled with encoders for common Ruby value classes
167
-
168
-
169
- == Contributing
170
-
171
- To report bugs, suggest features, or check out the source with Git,
172
- {check out the project page}[https://github.com/ged/ruby-pg].
173
-
174
- After checking out the source, install all dependencies:
175
-
176
- $ bundle install
177
-
178
- Cleanup extension files, packaging files, test databases:
179
-
180
- $ rake clean
181
-
182
- Compile extension:
183
-
184
- $ rake compile
185
-
186
- Run tests/specs with PostgreSQL tools like `initdb` in the path:
187
-
188
- $ PATH=$PATH:/usr/lib/postgresql/14/bin rake test
189
-
190
- Or run a specific test with the line number:
191
-
192
- $ PATH=$PATH:/usr/lib/postgresql/14/bin rspec -Ilib -fd spec/pg/connection_spec.rb:455
193
-
194
- Generate the API documentation:
195
-
196
- $ rake docs
197
-
198
- Make sure, that all bugs and new features are verified by tests.
199
-
200
- The current maintainers are Michael Granger <ged@FaerieMUD.org> and
201
- Lars Kanis <lars@greiz-reinsdorf.de>.
202
-
203
-
204
- == Copying
205
-
206
- Copyright (c) 1997-2022 by the authors.
207
-
208
- * Jeff Davis <ruby-pg@j-davis.com>
209
- * Guy Decoux (ts) <decoux@moulon.inra.fr>
210
- * Michael Granger <ged@FaerieMUD.org>
211
- * Lars Kanis <lars@greiz-reinsdorf.de>
212
- * Dave Lee
213
- * Eiji Matsumoto <usagi@ruby.club.or.jp>
214
- * Yukihiro Matsumoto <matz@ruby-lang.org>
215
- * Noboru Saitou <noborus@netlab.jp>
216
-
217
- You may redistribute this software under the same terms as Ruby itself; see
218
- https://www.ruby-lang.org/en/about/license.txt or the BSDL file in the source
219
- for details.
220
-
221
- Portions of the code are from the PostgreSQL project, and are distributed
222
- under the terms of the PostgreSQL license, included in the file POSTGRES.
223
-
224
- Portions copyright LAIKA, Inc.
225
-
226
-
227
- == Acknowledgments
228
-
229
- See Contributors.rdoc for the many additional fine people that have contributed
230
- to this library over the years.
231
-
232
- We are thankful to the people at the ruby-list and ruby-dev mailing lists.
233
- And to the people who developed PostgreSQL.
@@ -1,23 +0,0 @@
1
- # -*- ruby -*-
2
- # frozen_string_literal: true
3
-
4
- module PG
5
- module BinaryDecoder
6
- # Convenience classes for timezone options
7
- class TimestampUtc < Timestamp
8
- def initialize(params={})
9
- super(params.merge(flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_UTC))
10
- end
11
- end
12
- class TimestampUtcToLocal < Timestamp
13
- def initialize(params={})
14
- super(params.merge(flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_LOCAL))
15
- end
16
- end
17
- class TimestampLocal < Timestamp
18
- def initialize(params={})
19
- super(params.merge(flags: PG::Coder::TIMESTAMP_DB_LOCAL | PG::Coder::TIMESTAMP_APP_LOCAL))
20
- end
21
- end
22
- end
23
- end # module PG
data/lib/pg/constants.rb DELETED
@@ -1,12 +0,0 @@
1
- # -*- ruby -*-
2
- # frozen_string_literal: true
3
-
4
- require 'pg' unless defined?( PG )
5
-
6
-
7
- module PG::Constants
8
-
9
- # Most of these are defined in the extension.
10
-
11
- end # module PG::Constants
12
-
@@ -1,46 +0,0 @@
1
- # -*- ruby -*-
2
- # frozen_string_literal: true
3
-
4
- require 'date'
5
- require 'json'
6
-
7
- module PG
8
- module TextDecoder
9
- class Date < SimpleDecoder
10
- def decode(string, tuple=nil, field=nil)
11
- if string =~ /\A(\d{4})-(\d\d)-(\d\d)\z/
12
- ::Date.new $1.to_i, $2.to_i, $3.to_i
13
- else
14
- string
15
- end
16
- end
17
- end
18
-
19
- class JSON < SimpleDecoder
20
- def decode(string, tuple=nil, field=nil)
21
- ::JSON.parse(string, quirks_mode: true)
22
- end
23
- end
24
-
25
- # Convenience classes for timezone options
26
- class TimestampUtc < Timestamp
27
- def initialize(params={})
28
- super(params.merge(flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_UTC))
29
- end
30
- end
31
- class TimestampUtcToLocal < Timestamp
32
- def initialize(params={})
33
- super(params.merge(flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_LOCAL))
34
- end
35
- end
36
- class TimestampLocal < Timestamp
37
- def initialize(params={})
38
- super(params.merge(flags: PG::Coder::TIMESTAMP_DB_LOCAL | PG::Coder::TIMESTAMP_APP_LOCAL))
39
- end
40
- end
41
-
42
- # For backward compatibility:
43
- TimestampWithoutTimeZone = TimestampLocal
44
- TimestampWithTimeZone = Timestamp
45
- end
46
- end # module PG
@@ -1,59 +0,0 @@
1
- # -*- ruby -*-
2
- # frozen_string_literal: true
3
-
4
- require 'json'
5
- require 'ipaddr'
6
-
7
- module PG
8
- module TextEncoder
9
- class Date < SimpleEncoder
10
- def encode(value)
11
- value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d") : value
12
- end
13
- end
14
-
15
- class TimestampWithoutTimeZone < SimpleEncoder
16
- def encode(value)
17
- value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d %H:%M:%S.%N") : value
18
- end
19
- end
20
-
21
- class TimestampUtc < SimpleEncoder
22
- def encode(value)
23
- value.respond_to?(:utc) ? value.utc.strftime("%Y-%m-%d %H:%M:%S.%N") : value
24
- end
25
- end
26
-
27
- class TimestampWithTimeZone < SimpleEncoder
28
- def encode(value)
29
- value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d %H:%M:%S.%N %:z") : value
30
- end
31
- end
32
-
33
- class JSON < SimpleEncoder
34
- def encode(value)
35
- ::JSON.generate(value, quirks_mode: true)
36
- end
37
- end
38
-
39
- class Inet < SimpleEncoder
40
- def encode(value)
41
- case value
42
- when IPAddr
43
- default_prefix = (value.family == Socket::AF_INET ? 32 : 128)
44
- s = value.to_s
45
- if value.respond_to?(:prefix)
46
- prefix = value.prefix
47
- else
48
- range = value.to_range
49
- prefix = default_prefix - Math.log(((range.end.to_i - range.begin.to_i) + 1), 2).to_i
50
- end
51
- s << "/" << prefix.to_s if prefix != default_prefix
52
- s
53
- else
54
- value
55
- end
56
- end
57
- end
58
- end
59
- end # module PG