pg 1.4.6 → 1.6.0

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.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/{History.md → CHANGELOG.md} +177 -3
  4. data/Gemfile +12 -3
  5. data/README-Windows.rdoc +1 -1
  6. data/README.ja.md +75 -41
  7. data/README.md +34 -19
  8. data/Rakefile +84 -14
  9. data/certs/kanis@comcard.de.pem +20 -0
  10. data/certs/larskanis-2024.pem +24 -0
  11. data/ext/errorcodes.def +4 -5
  12. data/ext/errorcodes.txt +2 -5
  13. data/ext/extconf.rb +165 -14
  14. data/ext/gvl_wrappers.c +13 -2
  15. data/ext/gvl_wrappers.h +33 -0
  16. data/ext/pg.c +28 -35
  17. data/ext/pg.h +18 -14
  18. data/ext/pg_binary_decoder.c +231 -0
  19. data/ext/pg_binary_encoder.c +427 -0
  20. data/ext/pg_cancel_connection.c +360 -0
  21. data/ext/pg_coder.c +68 -12
  22. data/ext/pg_connection.c +473 -208
  23. data/ext/pg_copy_coder.c +316 -23
  24. data/ext/pg_record_coder.c +12 -11
  25. data/ext/pg_result.c +102 -30
  26. data/ext/pg_text_decoder.c +31 -10
  27. data/ext/pg_text_encoder.c +58 -26
  28. data/ext/pg_tuple.c +36 -33
  29. data/ext/pg_type_map.c +4 -3
  30. data/ext/pg_type_map_all_strings.c +3 -3
  31. data/ext/pg_type_map_by_class.c +6 -4
  32. data/ext/pg_type_map_by_column.c +9 -4
  33. data/ext/pg_type_map_by_mri_type.c +1 -1
  34. data/ext/pg_type_map_by_oid.c +10 -5
  35. data/ext/pg_type_map_in_ruby.c +6 -3
  36. data/lib/pg/basic_type_map_based_on_result.rb +21 -1
  37. data/lib/pg/basic_type_map_for_queries.rb +23 -10
  38. data/lib/pg/basic_type_map_for_results.rb +26 -3
  39. data/lib/pg/basic_type_registry.rb +46 -36
  40. data/lib/pg/binary_decoder/date.rb +9 -0
  41. data/lib/pg/binary_decoder/timestamp.rb +26 -0
  42. data/lib/pg/binary_encoder/timestamp.rb +20 -0
  43. data/lib/pg/cancel_connection.rb +53 -0
  44. data/lib/pg/coder.rb +17 -14
  45. data/lib/pg/connection.rb +387 -172
  46. data/lib/pg/exceptions.rb +6 -0
  47. data/lib/pg/text_decoder/date.rb +21 -0
  48. data/lib/pg/text_decoder/inet.rb +9 -0
  49. data/lib/pg/text_decoder/json.rb +17 -0
  50. data/lib/pg/text_decoder/numeric.rb +9 -0
  51. data/lib/pg/text_decoder/timestamp.rb +30 -0
  52. data/lib/pg/text_encoder/date.rb +13 -0
  53. data/lib/pg/text_encoder/inet.rb +31 -0
  54. data/lib/pg/text_encoder/json.rb +17 -0
  55. data/lib/pg/text_encoder/numeric.rb +9 -0
  56. data/lib/pg/text_encoder/timestamp.rb +24 -0
  57. data/lib/pg/version.rb +1 -1
  58. data/lib/pg.rb +78 -17
  59. data/misc/yugabyte/Dockerfile +9 -0
  60. data/misc/yugabyte/docker-compose.yml +28 -0
  61. data/misc/yugabyte/pg-test.rb +45 -0
  62. data/pg.gemspec +9 -5
  63. data/ports/patches/krb5/1.21.3/0001-Allow-static-linking-krb5-library.patch +30 -0
  64. data/ports/patches/openssl/3.5.1/0001-aarch64-mingw.patch +21 -0
  65. data/ports/patches/postgresql/17.5/0001-Use-workaround-of-__builtin_setjmp-only-on-MINGW-on-.patch +42 -0
  66. data/ports/patches/postgresql/17.5/0001-libpq-Process-buffered-SSL-read-bytes-to-support-rec.patch +52 -0
  67. data/rakelib/pg_gem_helper.rb +64 -0
  68. data.tar.gz.sig +0 -0
  69. metadata +61 -49
  70. metadata.gz.sig +0 -0
  71. data/.appveyor.yml +0 -42
  72. data/.gems +0 -6
  73. data/.gemtest +0 -0
  74. data/.github/workflows/binary-gems.yml +0 -117
  75. data/.github/workflows/source-gem.yml +0 -137
  76. data/.gitignore +0 -19
  77. data/.hgsigs +0 -34
  78. data/.hgtags +0 -41
  79. data/.irbrc +0 -23
  80. data/.pryrc +0 -23
  81. data/.tm_properties +0 -21
  82. data/.travis.yml +0 -49
  83. data/Manifest.txt +0 -72
  84. data/Rakefile.cross +0 -298
  85. data/lib/pg/binary_decoder.rb +0 -23
  86. data/lib/pg/constants.rb +0 -12
  87. data/lib/pg/text_decoder.rb +0 -46
  88. data/lib/pg/text_encoder.rb +0 -59
  89. data/translation/.po4a-version +0 -7
  90. data/translation/po/all.pot +0 -875
  91. data/translation/po/ja.po +0 -868
  92. data/translation/po4a.cfg +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c13f68e0e75751b8b4abc7981de62045998fdf4e8685fd90e74bcd609dc85a8
4
- data.tar.gz: 33c65915b3c04a9232bacbf39486738e7a3cd033fefd2f2947107fd9a3b70ebc
3
+ metadata.gz: 012dafe387d9f1fe9444dee7674ff5fdfcebce3b8ca61500b0ccbba847e28721
4
+ data.tar.gz: 2a3d537246a65cb6c86822296d723154abbab3be71ca772cfa71678535eb3369
5
5
  SHA512:
6
- metadata.gz: 3d7144fb8feaa713aae83a12f90890d82c554cb26b81e76f245f47f0f99bac8f2a290bdfbf27deb069f6e4852ff692203799f1a9bf5914e616abb4d3037e6b7a
7
- data.tar.gz: 06fb1dbe5e4ff3626c4c1fb24ef2862f32c97baa983400585379ffbbde55079fd449c1ae895296947c29a9316bacfa1f8c173059c426aa8659bccdb676c461f7
6
+ metadata.gz: 9d395a1d05e7bafda559f0a5041579b5d15c7f8b5c50b8ff0e37ae0b577a21e20b0f3471fb874ed23f6101e0fe21591f22efd60c230b59106029d7f1713b3023
7
+ data.tar.gz: 2456f8130e18b84aebd95aa08254fb79747024ce1e4747237aa36909e3031039fdfede8b315a2ad4b7ab03daf79f067e634336abeb675151e5d9a2950cb7ec13
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,3 +1,177 @@
1
+ ## v1.6.0 [2025-07-27] Lars Kanis <lars@greiz-reinsdorf.de>
2
+
3
+ Added:
4
+
5
+ - Add binary gems for Ruby 3.4.
6
+ - Add fat binary gem for platform `aarch64-mingw-ucrt` aka Windows on ARM [#626](https://github.com/ged/ruby-pg/pull/626), for platform Macos on Intel and ARM [#643](https://github.com/ged/ruby-pg/pull/643), for platform `aarch64-linux` [#646](https://github.com/ged/ruby-pg/pull/646) and for platform `x86_64-linux` [#551](https://github.com/ged/ruby-pg/pull/551#issuecomment-2504715762).
7
+ - Update fat binary gem to OpenSSL-3.5.1 and PostgreSQL-17.5.
8
+ - Add a patch to libpq to avoid starvation on bigger SSL records, which some database engines other than vanilla PostgreSQL use.
9
+ This patch applies to platform specific binary gems only.
10
+ [#616](https://github.com/ged/ruby-pg/pull/616)
11
+ - Add support for new query cancel functions of PostgreSQL-17.
12
+ This adds the new class `PG::CancelConnection` which provides the ability to cancel a query per blocking or per non-blocking functions.
13
+ If the new functions are available they are used and the older are no longer compiled in.
14
+ This way we can get rid of reading out the internal `PGcancel` struct by `Connection#backend_key`.
15
+ [#614](https://github.com/ged/ruby-pg/pull/614)
16
+ - Add PG::BinaryDecoder::Array and PG::BinaryEncoder::Array to parse and encode PostgreSQL arrays in binary format.
17
+ [#603](https://github.com/ged/ruby-pg/pull/603)
18
+ - Add possibility to define the number of array dimensions to be encoded.
19
+ Setting dimensions is especially useful, when a Record shall be encoded into an Array, since the Array encoder can not distinguish if the array shall be encoded as a higher dimension or as a record otherwise.
20
+ [#622](https://github.com/ged/ruby-pg/pull/622)
21
+ - Add Connection#set_chunked_rows_mode [#610](https://github.com/ged/ruby-pg/pull/610)
22
+ - Add PG::Connection#close_prepared, PG::Connection#close_portal, PG::Connection#send_close_prepared and PG::Connection#send_close_portal which are new in PostgreSQL-17.
23
+ [#611](https://github.com/ged/ruby-pg/pull/611)
24
+ - Add Connection#send_pipeline_sync, async_pipeline_sync and release GVL at PQ(sendP|P)ipelineSync.
25
+ [#612](https://github.com/ged/ruby-pg/pull/612)
26
+ - Add MINGW package dependency which is resolved by RubyInstaller.
27
+ [#617](https://github.com/ged/ruby-pg/pull/617)
28
+ - Change `conn.server_version` and `conn.protocol_version` to raise instead of return 0 on error.
29
+ [#632](https://github.com/ged/ruby-pg/pull/632)
30
+ - Fix connecting to multiple hosts after `connnect_timeout`.
31
+ [#637](https://github.com/ged/ruby-pg/pull/637)
32
+ - Fix making PG::BasicTypeMapForQueries shareable for Ractor in ruby-3.5.
33
+ [#636](https://github.com/ged/ruby-pg/pull/636)
34
+ - Fix missing array input verification in PG::TypeMapByColumn.
35
+ This could cause a segfault.
36
+ [#620](https://github.com/ged/ruby-pg/pull/620)
37
+ - Rename `History.md` to `CHANGELOG.md`, which is more common.
38
+ [#642](https://github.com/ged/ruby-pg/pull/642)
39
+
40
+ Removed:
41
+
42
+ - Drop support of Ruby < 2.7 [#606](https://github.com/ged/ruby-pg/pull/606)
43
+ - Drop support of PostgreSQL < 10 [#606](https://github.com/ged/ruby-pg/pull/606)
44
+ - Remove workaround for Truffleruby < 21.3.0 [#613](https://github.com/ged/ruby-pg/pull/613)
45
+
46
+
47
+ ## v1.5.9 [2024-10-24] Lars Kanis <lars@greiz-reinsdorf.de>
48
+
49
+ - Enable thread safety in static OpenSSL build for Windows. [#595](https://github.com/ged/ruby-pg/pull/595)
50
+ - Remove raising `conect_timeout` from 1 to 2 seconds. [#590](https://github.com/ged/ruby-pg/pull/590)
51
+ - Fix binary copy_data in Ractor context. [#594](https://github.com/ged/ruby-pg/pull/594)
52
+ - Exclude CI files and hidden files from built gem. [#591](https://github.com/ged/ruby-pg/pull/591)
53
+ This is to simplify security inspection.
54
+ - Update error classes to PostgreSQL-17.
55
+ - Update Windows fat binary gem to OpenSSL-3.4.0 and PostgreSQL-17.0.
56
+
57
+
58
+ ## v1.5.8 [2024-09-06] Lars Kanis <lars@greiz-reinsdorf.de>
59
+
60
+ - Fix host list duplication every time conn.reset is used. [#586](https://github.com/ged/ruby-pg/pull/586)
61
+ - Add default decoder for anonymous record types to BasicTypeRegistry [#579](https://github.com/ged/ruby-pg/pull/579)
62
+ - Update Windows fat binary gem to OpenSSL-3.3.2 and PostgreSQL-16.4.
63
+
64
+
65
+ ## v1.5.7 [2024-07-28] Lars Kanis <lars@greiz-reinsdorf.de>
66
+
67
+ - Remove deprecated use of fptr->fd.[#562](https://github.com/ged/ruby-pg/pull/562)
68
+ Direct access is disallowed since ruby-3.4.
69
+ - Make `pgconn_connect_poll` close the socket prior to calling `PQconnectPoll`. [#564](https://github.com/ged/ruby-pg/pull/564)
70
+ This could result in an exception while connecting when used multi threaded.
71
+ - Fix several typos and improve spelling in documentation and code. [#566](https://github.com/ged/ruby-pg/pull/566)
72
+ - Add missing PG::RollbackTransaction as an option to exit conn.transaction. [#560](https://github.com/ged/ruby-pg/pull/560)
73
+ Usage like in rails: https://api.rubyonrails.org/classes/ActiveRecord/Rollback.html
74
+ - Don't print a warning when bigdecimal is required on ruby-3.4+ [#574](https://github.com/ged/ruby-pg/pull/574)
75
+ - Update Windows fat binary gem to OpenSSL-3.3.1 and PostgreSQL-16.3.
76
+
77
+
78
+ ## v1.5.6 [2024-03-01] Lars Kanis <lars@greiz-reinsdorf.de>
79
+
80
+ - Renew address resolution (DNS) in conn.reset. [#558](https://github.com/ged/ruby-pg/pull/558)
81
+ This is important, if DNS is used for load balancing, etc.
82
+ - Make bigdecimal an optional dependency. [#556](https://github.com/ged/ruby-pg/pull/556)
83
+ It's a gem in ruby-3.4+, so that users shouldn't be forced to use it.
84
+
85
+
86
+ ## v1.5.5 [2024-02-15] Lars Kanis <lars@greiz-reinsdorf.de>
87
+
88
+ - Explicitly retype timespec fields to int64_t to fix compatibility with 32bit arches. [#547](https://github.com/ged/ruby-pg/pull/547)
89
+ - Fix possible buffer overflows in PG::BinaryDecoder::CopyRow on 32 bit systems. [#548](https://github.com/ged/ruby-pg/pull/548)
90
+ - Add binary Windows gems for Ruby 3.3.
91
+ - Update Windows fat binary gem to OpenSSL-3.2.1 and PostgreSQL-16.2.
92
+
93
+
94
+ ## v1.5.4 [2023-09-01] Lars Kanis <lars@greiz-reinsdorf.de>
95
+
96
+ - Fix compiling the pg extension with MSVC 2022. [#535](https://github.com/ged/ruby-pg/pull/535)
97
+ - Set PG::Connection's encoding even if setting client_encoding on connection startup fails. [#541](https://github.com/ged/ruby-pg/pull/541)
98
+ - Don't set the server's client_encoding if it's unnecessary. [#542](https://github.com/ged/ruby-pg/pull/542)
99
+ This is important for connection proxies, who disallow configuration settings.
100
+ - Update Windows fat binary gem to OpenSSL-3.1.2 and PostgreSQL-15.4.
101
+
102
+
103
+ ## v1.5.3 [2023-04-28] Lars Kanis <lars@greiz-reinsdorf.de>
104
+
105
+ - Fix possible segfault when creating a new PG::Result with type map. [#530](https://github.com/ged/ruby-pg/pull/530)
106
+ - Add category to deprecation warnings of Coder.new, so that they are suppressed for most users. [#528](https://github.com/ged/ruby-pg/pull/528)
107
+
108
+
109
+ ## v1.5.2 [2023-04-26] Lars Kanis <lars@greiz-reinsdorf.de>
110
+
111
+ - Fix regression in copy_data regarding binary format when using no coder. [#527](https://github.com/ged/ruby-pg/pull/527)
112
+
113
+
114
+ ## v1.5.1 [2023-04-24] Lars Kanis <lars@greiz-reinsdorf.de>
115
+
116
+ - Don't overwrite flags of timestamp coders. [#524](https://github.com/ged/ruby-pg/pull/524)
117
+ Fixes a regression in rails: https://github.com/rails/rails/issues/48049
118
+
119
+
120
+ ## v1.5.0 [2023-04-24] Lars Kanis <lars@greiz-reinsdorf.de>
121
+
122
+ Enhancements:
123
+
124
+ - Better support for binary format:
125
+ - Extend PG::Connection#copy_data to better support binary transfers [#511](https://github.com/ged/ruby-pg/pull/511)
126
+ - Add binary COPY encoder and decoder:
127
+ * PG::BinaryEncoder::CopyRow
128
+ * PG::BinaryDecoder::CopyRow
129
+ - Add binary timestamp encoders:
130
+ * PG::BinaryEncoder::TimestampUtc
131
+ * PG::BinaryEncoder::TimestampLocal
132
+ * PG::BinaryEncoder::Timestamp
133
+ - Add PG::BinaryEncoder::Float4 and Float8
134
+ - Add binary date type: [#515](https://github.com/ged/ruby-pg/pull/515)
135
+ * PG::BinaryEncoder::Date
136
+ * PG::BinaryDecoder::Date
137
+ - Add PG::Result#binary_tuples [#511](https://github.com/ged/ruby-pg/pull/511)
138
+ It is useful for COPY and not deprecated in that context.
139
+ - Add PG::TextEncoder::Bytea to BasicTypeRegistry [#506](https://github.com/ged/ruby-pg/pull/506)
140
+ - Ractor support: [#519](https://github.com/ged/ruby-pg/pull/519)
141
+ - Pg is now fully compatible with Ractor introduced in Ruby-3.0 and doesn't use any global mutable state.
142
+ - All type en/decoders and type maps are shareable between ractors if they are made frozen by `Ractor.make_shareable`.
143
+ - Also frozen PG::Result and PG::Tuple objects can be shared.
144
+ - All frozen objects (except PG::Connection) can still be used to do communication with the PostgreSQL server or to read retrieved data.
145
+ - PG::Connection is not shareable and must be created within each Ractor to establish a dedicated connection.
146
+ - Use keyword arguments instead of hashes for Coder initialization and #to_h. [#511](https://github.com/ged/ruby-pg/pull/511)
147
+ - Add PG::Result.res_status as a class method and extend Result#res_status to return the status of self. [#508](https://github.com/ged/ruby-pg/pull/508)
148
+ - Reduce the number of files loaded at `require 'pg'` by using autoload. [#513](https://github.com/ged/ruby-pg/pull/513)
149
+ Previously stdlib libraries `date`, `json`, `ipaddr` and `bigdecimal` were static dependencies, but now only `socket` is mandatory.
150
+ - Improve garbage collector performance by adding write barriers to all PG classes. [#518](https://github.com/ged/ruby-pg/pull/518)
151
+ Now they can be promoted to the old generation, which means they only get marked on major GC.
152
+ - New method PG::Connection#check_socket to check the socket state. [#521](https://github.com/ged/ruby-pg/pull/521)
153
+ - Mark many internal constants as private. [#522](https://github.com/ged/ruby-pg/pull/522)
154
+ - Update Windows fat binary gem to OpenSSL-3.1.0.
155
+
156
+ Bugfixes:
157
+
158
+ - Move nfields-check of stream-methods after result status check [#507](https://github.com/ged/ruby-pg/pull/507)
159
+ This ensures that the nfield-check doesn't hide errors like statement timeout.
160
+
161
+ Removed:
162
+
163
+ - Remove deprecated PG::BasicTypeRegistry.register_type and co. [Part of #519](https://github.com/ged/ruby-pg/commit/2919ee1a0c6b216e18e1d06c95c2616ef69d2f97)
164
+ - Add deprecation warning about PG::Coder initialization per Hash argument. [#514](https://github.com/ged/ruby-pg/pull/514)
165
+ It is recommended to use keyword arguments instead.
166
+ - The internal encoding cache was removed. [#516](https://github.com/ged/ruby-pg/pull/516)
167
+ It shouldn't have a practical performance impact.
168
+
169
+ Repository:
170
+
171
+ - `rake test` tries to find PostgreSQL server commands by pg_config [#503](https://github.com/ged/ruby-pg/pull/503)
172
+ So there's no need to set the PATH manually any longer.
173
+
174
+
1
175
  ## v1.4.6 [2023-02-26] Lars Kanis <lars@greiz-reinsdorf.de>
2
176
 
3
177
  - Add japanese README file. [#502](https://github.com/ged/ruby-pg/pull/502)
@@ -64,7 +238,7 @@ Added:
64
238
  Bugfixes:
65
239
 
66
240
  - Try IPv6 and IPv4 addresses, if DNS resolves to both. [#452](https://github.com/ged/ruby-pg/pull/452)
67
- - Re-add block-call semantics to PG::Connection.new accidently removed in pg-1.3.0. [#454](https://github.com/ged/ruby-pg/pull/454)
241
+ - Re-add block-call semantics to PG::Connection.new accidentally removed in pg-1.3.0. [#454](https://github.com/ged/ruby-pg/pull/454)
68
242
  - Handle client error after all data consumed in #copy_data for output. [#455](https://github.com/ged/ruby-pg/pull/455)
69
243
  - Avoid spurious keyword argument warning on Ruby 2.7. [#456](https://github.com/ged/ruby-pg/pull/456)
70
244
  - Change connection setup to respect connect_timeout parameter. [#459](https://github.com/ged/ruby-pg/pull/459)
@@ -103,7 +277,7 @@ Bugfixes:
103
277
 
104
278
  - Don't leak IO in case of connection errors. [#439](https://github.com/ged/ruby-pg/pull/439)
105
279
  Previously it was kept open until the PG::Connection was garbage collected.
106
- - Fix a performance regession in conn.get_result noticed in single row mode. [#442](https://github.com/ged/ruby-pg/pull/442)
280
+ - Fix a performance regression in conn.get_result noticed in single row mode. [#442](https://github.com/ged/ruby-pg/pull/442)
107
281
  - Fix occasional error Errno::EBADF (Bad file descriptor) while connecting. [#444](https://github.com/ged/ruby-pg/pull/444)
108
282
  - Fix compatibility of res.stream_each* methods with Fiber.scheduler. [#446](https://github.com/ged/ruby-pg/pull/446)
109
283
  - Remove FL_TEST and FL_SET, which are MRI-internal. [#437](https://github.com/ged/ruby-pg/pull/437)
@@ -189,7 +363,7 @@ Type cast enhancements:
189
363
  - Add PG::BasicTypeMapForQueries::BinaryData for encoding of bytea columns. [#348](https://github.com/ged/ruby-pg/pull/348)
190
364
  - Reduce time to build coder maps and permit to reuse them for several type maps per PG::BasicTypeRegistry::CoderMapsBundle.new(conn) . [#376](https://github.com/ged/ruby-pg/pull/376)
191
365
  - Make BasicTypeRegistry a class and use a global default instance of it.
192
- Now a local type registry can be instanciated and given to the type map, to avoid changing shared global states.
366
+ Now a local type registry can be instantiated and given to the type map, to avoid changing shared global states.
193
367
  - Allow PG::BasicTypeMapForQueries to take a Proc as callback for undefined types.
194
368
 
195
369
  Other Enhancements:
data/Gemfile CHANGED
@@ -5,10 +5,19 @@ gemspec
5
5
 
6
6
  source "https://rubygems.org/"
7
7
 
8
- group :development, :test do
8
+ group :development do
9
+ gem "rdoc", "~> 6.4"
10
+ gem "mini_portile2", "~> 2.1"
11
+ end
12
+
13
+ group :test do
9
14
  gem "bundler", ">= 1.16", "< 3.0"
10
15
  gem "rake-compiler", "~> 1.0"
11
- gem "rake-compiler-dock", "~> 1.0"
12
- gem "rdoc", "~> 6.4"
16
+ gem "rake-compiler-dock", "~> 1.9.1"
13
17
  gem "rspec", "~> 3.5"
18
+ # "bigdecimal" is a gem on ruby-3.4+ and it's optional for ruby-pg.
19
+ # Specs should succeed without it, but 4 examples are then excluded.
20
+ # With bigdecimal commented out here, corresponding tests are omitted on ruby-3.4+ but are executed on ruby < 3.4.
21
+ # That way we can check both situations in CI.
22
+ # gem "bigdecimal", "~> 3.0"
14
23
  end
data/README-Windows.rdoc CHANGED
@@ -41,7 +41,7 @@ sure it is started. A native Docker installation is best on Linux.
41
41
 
42
42
  Then run:
43
43
 
44
- rake gem:windows
44
+ rake gem:native
45
45
 
46
46
  This will download a docker image suited for building windows gems, and it
47
47
  will download and build OpenSSL and PostgreSQL. Finally the gem is built
data/README.ja.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # pg
2
2
 
3
- * home :: https://github.com/ged/ruby-pg
4
- * docs :: http://deveiate.org/code/pg
5
- * clog :: link:/History.md
3
+ * ホーム :: https://github.com/ged/ruby-pg
4
+ * ドキュメント :: http://deveiate.org/code/pg (英語)、 https://deveiate.org/code/pg/README_ja_md.html (日本語)
5
+ * 変更履歴 :: link:/CHANGELOG.md
6
6
 
7
7
  [![https://gitter.im/ged/ruby-pg
8
8
  でチャットに参加](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ged/ruby-pg?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -12,7 +12,7 @@
12
12
 
13
13
  Pgは[PostgreSQL
14
14
  RDBMS](http://www.postgresql.org/)へのRubyのインターフェースです。[PostgreSQL
15
- 9.3以降](http://www.postgresql.org/support/versioning/)で動作します。
15
+ 10以降](http://www.postgresql.org/support/versioning/)で動作します。
16
16
 
17
17
  簡単な使用例は次の通りです。
18
18
  ```ruby
@@ -41,8 +41,8 @@ Actionsのビルド状況](https://github.com/ged/ruby-pg/actions/workflows/sour
41
41
 
42
42
  ## 要件
43
43
 
44
- * Ruby 2.4かそれより新しいバージョン
45
- * PostgreSQL 9.3.xかそれ以降のバージョン(ヘッダー付属のもの、例えば-devの名前のパッケージ)。
44
+ * Ruby 2.7かそれより新しいバージョン
45
+ * PostgreSQL 10.xかそれ以降のバージョン(ヘッダー付属のもの、例えば-devの名前のパッケージ)。
46
46
 
47
47
  それより前のバージョンのRubyやPostgreSQLでも通常は同様に動作しますが、定期的なテストはされていません。
48
48
 
@@ -83,8 +83,9 @@ README-Windows.rdoc を参照してください。
83
83
 
84
84
  ## 型変換
85
85
 
86
- PgにはおまけとしてRubyとネイティブCコードにある結果の値やクエリ引数の型変換ができます。
87
- こうすることでデータベースとのデータの往来を加速させられますが、それは文字列のアロケーションが減り、(より遅い)Rubyのコードでの変換部分が除かれるからです。
86
+ Pgでは任意でRubyと素のCコードにある結果の値やクエリ引数の型変換ができます。
87
+ こうすることでデータベースとのデータの往来を加速させられます。
88
+ なぜなら文字列のアロケーションが減り、(比較的遅い)Rubyのコードでの変換部分が省かれるからです。
88
89
 
89
90
  とても基本的な型変換は次のようにできます。
90
91
  ```ruby
@@ -103,9 +104,13 @@ PgにはおまけとしてRubyとネイティブCコードにある結果の値
103
104
 
104
105
  ### エンコーダーとデコーダー (ext/pg_*coder.c, lib/pg/*coder.rb)
105
106
 
106
- こちらはより低層で、DBMSへ転送するためにRubyのオブジェクトを変換するエンコーディングクラスと取得してきたデータをRubyのオブジェクトに変換し戻すデコーディングクラスが含まれています。クラスはそれぞれの形式によって名前空間PG::TextEncoder、PG::TextDecoder、PG::BinaryEncoder、そしてPG::BinaryDecoderに分かれています。
107
+ こちらはより低層で、DBMSへ転送するためにRubyのオブジェクトを変換するエンコーディングクラスと、取得してきたデータをRubyのオブジェクトに変換し戻すデコーディングクラスが含まれています。
108
+ クラスはそれぞれの形式によって名前空間 PG::TextEncoder, PG::TextDecoder, PG::BinaryEncoder, そして
109
+ PG::BinaryDecoder に分かれています。
107
110
 
108
- エンコーダーないしデコーダーオブジェクトにOIDデータ型や形式コード(テキストないしバイナリ)や任意で名前を割り当てることができます。要素のエンコーダーないしデコーダーを割り当てることによって複合型を構築することもできます。PG::CoderオブジェクトはPG::TypeMapをセットアップしたりその代わりに単一の値と文字列表現とを相互に変換したりするのに使えます。
111
+ エンコーダーないしデコーダーオブジェクトにOIDデータ型や形式コード(テキストないしバイナリ)や任意で名前を割り当てることができます。
112
+ 要素のエンコーダーないしデコーダーを割り当てることによって複合型を構築することもできます。
113
+ PG::Coder オブジェクトは PG::TypeMap をセットアップしたり、その代わりに単一の値と文字列表現とを相互に変換したりするのに使えます。
109
114
 
110
115
  ruby-pgでは以下のPostgreSQLカラム型に対応しています(TE = Text Encoder、TD = Text Decoder、BE =
111
116
  Binary Encoder、BD = Binary Decoder)。
@@ -115,10 +120,12 @@ Binary Encoder、BD = Binary Decoder)。
115
120
  💡
116
121
  リンクがないでしょうか。[こちら](https://deveiate.org/code/pg/README_ja_md.html#label-E5-9E-8B-E5-A4-89-E6-8F-9B)を代わりに見てください
117
122
  💡
118
- * BE:
119
- [Int2](rdoc-ref:PG::BinaryEncoder::Int2)、[Int4](rdoc-ref:PG::BinaryEncoder::Int4)、[Int8](rdoc-ref:PG::BinaryEncoder::Int8)
123
+ * BE:
124
+ [Int2](rdoc-ref:PG::BinaryEncoder::Int2)、[Int4](rdoc-ref:PG::BinaryEncoder::Int4)、[Int8](rdoc-ref:PG::BinaryEncoder::Int8)
120
125
  * Float:
121
126
  [TE](rdoc-ref:PG::TextEncoder::Float)、[TD](rdoc-ref:PG::TextDecoder::Float)、[BD](rdoc-ref:PG::BinaryDecoder::Float)
127
+ * BE: [Float4](rdoc-ref:PG::BinaryEncoder::Float4),
128
+ [Float8](rdoc-ref:PG::BinaryEncoder::Float8)
122
129
  * Numeric:
123
130
  [TE](rdoc-ref:PG::TextEncoder::Numeric)、[TD](rdoc-ref:PG::TextDecoder::Numeric)
124
131
  * Boolean:
@@ -130,14 +137,15 @@ Binary Encoder、BD = Binary Decoder)。
130
137
  * Base64:
131
138
  [TE](rdoc-ref:PG::TextEncoder::ToBase64)、[TD](rdoc-ref:PG::TextDecoder::FromBase64)、[BE](rdoc-ref:PG::BinaryEncoder::FromBase64)、[BD](rdoc-ref:PG::BinaryDecoder::ToBase64)
132
139
  * Timestamp:
133
- * TE:
134
- [現地時間](rdoc-ref:PG::TextEncoder::TimestampWithoutTimeZone)、[UTC](rdoc-ref:PG::TextEncoder::TimestampUtc)、[タイムゾーン付き](rdoc-ref:PG::TextEncoder::TimestampWithTimeZone)
135
- * TD:
136
- [現地時間](rdoc-ref:PG::TextDecoder::TimestampLocal)、[UTC](rdoc-ref:PG::TextDecoder::TimestampUtc)、[UTCから現地時間へ](rdoc-ref:PG::TextDecoder::TimestampUtcToLocal)
137
- * BD:
138
- [現地時間](rdoc-ref:PG::BinaryDecoder::TimestampLocal)、[UTC](rdoc-ref:PG::BinaryDecoder::TimestampUtc)、[UTCから現地時間へ](rdoc-ref:PG::BinaryDecoder::TimestampUtcToLocal)
139
- * Date:
140
- [TE](rdoc-ref:PG::TextEncoder::Date)、[TD](rdoc-ref:PG::TextDecoder::Date)
140
+ * TE:
141
+ [現地時間](rdoc-ref:PG::TextEncoder::TimestampWithoutTimeZone)、[UTC](rdoc-ref:PG::TextEncoder::TimestampUtc)、[タイムゾーン付き](rdoc-ref:PG::TextEncoder::TimestampWithTimeZone)
142
+ * TD:
143
+ [現地時間](rdoc-ref:PG::TextDecoder::TimestampLocal)、[UTC](rdoc-ref:PG::TextDecoder::TimestampUtc)、[UTCから現地時間へ](rdoc-ref:PG::TextDecoder::TimestampUtcToLocal)
144
+ * BE:
145
+ [現地時間](rdoc-ref:PG::BinaryEncoder::TimestampLocal)、[UTC](rdoc-ref:PG::BinaryEncoder::TimestampUtc)
146
+ * BD:
147
+ [現地時間](rdoc-ref:PG::BinaryDecoder::TimestampLocal)、[UTC](rdoc-ref:PG::BinaryDecoder::TimestampUtc)、[UTCから現地時間へ](rdoc-ref:PG::BinaryDecoder::TimestampUtcToLocal)
148
+ * 日付:[TE](rdoc-ref:PG::TextEncoder::Date)、[TD](rdoc-ref:PG::TextDecoder::Date)、[BE](rdoc-ref:PG::BinaryEncoder::Date)、[BD](rdoc-ref:PG::BinaryDecoder::Date)
141
149
  * JSONとJSONB:
142
150
  [TE](rdoc-ref:PG::TextEncoder::JSON)、[TD](rdoc-ref:PG::TextDecoder::JSON)
143
151
  * Inet:
@@ -146,18 +154,25 @@ Binary Encoder、BD = Binary Decoder)。
146
154
  [TE](rdoc-ref:PG::TextEncoder::Array)、[TD](rdoc-ref:PG::TextDecoder::Array)
147
155
  * 複合型(「行」や「レコード」などとも言います):[TE](rdoc-ref:PG::TextEncoder::Record)、[TD](rdoc-ref:PG::TextDecoder::Record)
148
156
 
149
- カラム型として使われていませんが以下のテキスト形式もエンコードできます。
157
+ カラム型として使われていませんが、以下のテキスト形式とバイナリ形式もエンコードできます。
150
158
 
151
- * COPYの入出力データ:[TE](rdoc-ref:PG::TextEncoder::CopyRow)、[TD](rdoc-ref:PG::TextDecoder::CopyRow)
159
+ * COPYの入出力データ:[TE](rdoc-ref:PG::TextEncoder::CopyRow)、[TD](rdoc-ref:PG::TextDecoder::CopyRow),
160
+ [BE](rdoc-ref:PG::BinaryEncoder::CopyRow),
161
+ [BD](rdoc-ref:PG::BinaryDecoder::CopyRow)
152
162
  * SQL文字列に挿入するリテラル:[TE](rdoc-ref:PG::TextEncoder::QuotedLiteral)
153
163
  * SQLの識別子:
154
164
  [TE](rdoc-ref:PG::TextEncoder::Identifier)、[TD](rdoc-ref:PG::TextDecoder::Identifier)
155
165
 
156
- ### PG::TypeMapとその派生 (ext/pg_type_map*.c, lib/pg/type_map*.rb)
166
+ ### PG::TypeMap とその派生 (ext/pg_type_map*.c, lib/pg/type_map*.rb)
157
167
 
158
- TypeMapはエンコーダーまたはデコーダーのどちらによってどの値を変換するかを定義します。様々な型の対応付け戦略があるので、このクラスにはいくつかの派生が実装されています。型変換の特有の需要に合わせてそれらの派生から選んで調整を加えることができます。既定の型の対応付けはPG::TypeMapAllStringsです。
168
+ TypeMapはエンコーダーまたはデコーダーのどちらによってどの値を変換するかを定義します。
169
+ 様々な型の対応付け戦略があるので、このクラスにはいくつかの派生が実装されています。
170
+ 型変換の特有の需要に合わせてそれらの派生から選んで調整を加えることができます。
171
+ 既定の型の対応付けは PG::TypeMapAllStrings です。
159
172
 
160
- 型の対応付けは、結果の集合それぞれに対し、接続毎ないしクエリ毎に割り当てることができます。型の対応付けはCOPYの入出力データストリーミングでも使うことができます。PG::Connection#copy_dataを参照してください。
173
+ 型の対応付けは、結果の集合それぞれに対し、接続毎ないしクエリ毎に割り当てることができます。
174
+ 型の対応付けはCOPYの入出力データストリーミングでも使うことができます。
175
+ PG::Connection#copy_data を参照してください。
161
176
 
162
177
  以下の基底となる型の対応付けが使えます。
163
178
 
@@ -167,19 +182,21 @@ TypeMapはエンコーダーまたはデコーダーのどちらによってど
167
182
  * PG::TypeMapByOid - PostgreSQLのOIDデータ型によってデコーダーを選択します
168
183
  * PG::TypeMapInRuby - Rubyで独自の型の対応付けを定義します
169
184
 
170
- 以下の型の対応付けはPG::BasicTypeRegistry由来の型の対応付けが入った状態になっています。
185
+ 以下の型の対応付けは PG::BasicTypeRegistry 由来の型の対応付けが入った状態になっています。
171
186
 
172
- * PG::BasicTypeMapForResults -
173
- PG::TypeMapByOidによくあるPostgreSQLカラム型用にデコーダーが入った状態になっています
174
- * PG::BasicTypeMapBasedOnResult -
175
- PG::TypeMapByOidによくあるPostgreSQLカラム型用のエンコーダーが入った状態になっています
176
- * PG::BasicTypeMapForQueries -
177
- PG::TypeMapByClassによくあるRubyの値クラス用にエンコーダーが入った状態になっています
187
+ * PG::BasicTypeMapForResults - PG::TypeMapByOid
188
+ によくあるPostgreSQLカラム型用にデコーダーが入った状態になっています
189
+ * PG::BasicTypeMapBasedOnResult - PG::TypeMapByOid
190
+ によくあるPostgreSQLカラム型用のエンコーダーが入った状態になっています
191
+ * PG::BasicTypeMapForQueries - PG::TypeMapByClass
192
+ によくあるRubyの値クラス用にエンコーダーが入った状態になっています
178
193
 
179
194
 
180
195
  ## スレッド対応
181
196
 
182
- PGには個々のスレッドが別々のPG::Connectionオブジェクトを同時に使えるという点でスレッド安全性があります。しかし1つ以上のスレッドから同時にPgのオブジェクトにアクセスすると安全ではありません。そのため必ず、毎回新しいスレッドを作るときに新しいデータベースサーバー接続を開くか、スレッド安全性のある方法で接続を管理するActiveRecordのようなラッパーライブラリを使うようにしてください。
197
+ PGには個々のスレッドが別々の PG::Connection オブジェクトを同時に使えるという点でスレッド安全性があります。
198
+ しかし1つ以上のスレッドから同時にPgのオブジェクトにアクセスすると安全ではありません。
199
+ そのため必ず、毎回新しいスレッドを作るときに新しいデータベースサーバー接続を開くか、スレッド安全性のある方法で接続を管理するActiveRecordのようなラッパーライブラリを使うようにしてください。
183
200
 
184
201
  以下のようなメッセージが標準エラー出力に表示された場合、恐らく複数のスレッドが1つの接続を使っています。
185
202
 
@@ -192,13 +209,30 @@ PGには個々のスレッドが別々のPG::Connectionオブジェクトを同
192
209
 
193
210
  ## Fiber IOスケジューラー対応
194
211
 
195
- PgはRuby-3.0で導入された`Fiber.scheduler`に完全に対応しています。`Fiber.scheduler`のWindows対応についてはRuby-3.1以降で使えます。`Fiber.scheduler`が走らせているスレッドに登録されている場合、起こりうる全てのブロッキングIO操作はそのスケジューラーを経由します。同期的であったりブロックしたりするメソッド呼び出しについてもpgが内部的に非同期のlibpqインターフェースを使っているのはそれが理由です。またlibpqの組み込み関数に代えてRubyのDNS解決を使っています。
212
+ pg-1.3.0以降で、PgはRuby-3.0で導入された`Fiber.scheduler`に完全に対応しています。
213
+ Windowsでは、`Fiber.scheduler`対応はRuby-3.1以降で使えます。
214
+ `Fiber.scheduler`が走らせているスレッドに登録されている場合、起こりうる全てのブロッキングIO操作はそのスケジューラーを経由します。
215
+ 同期的であったりブロックしたりするメソッド呼び出しについてもpgが内部的に非同期のlibpqインターフェースを使っているのはそれが理由です。
216
+ またlibpqの組み込み関数に代えてRubyのDNS解決を使っています。
196
217
 
197
- 内部的にPgは常にlibpqのノンブロッキング接続モードを使います。それからブロッキングモードで走っているように振舞いますが、もし`Fiber.scheduler`が登録されていれば全てのブロッキングIOはそのスケジューラーを通じてRubyで制御されます。`PG::Connection.setnonblocking(true)`が呼ばれたらノンブロッキング状態が有効になったままになりますが、それ以降のブロッキング状態の制御が無効になるので、呼び出しているプログラムはブロッキング状態を自力で制御しなければなりません。
218
+ 内部的にPgは常にlibpqのノンブロッキング接続モードを使います。
219
+ それからブロッキングモードで走っているように振舞いますが、もし`Fiber.scheduler`が登録されていれば全てのブロッキングIOはそのスケジューラーを通じてRubyで制御されます。
220
+ `PG::Connection.setnonblocking(true)`が呼ばれたらノンブロッキング状態が有効になったままになりますが、それ以降のブロッキング状態の制御が無効になるので、呼び出しているプログラムはブロッキング状態を自力で制御しなければなりません。
198
221
 
199
222
  この規則の1つの例外には、`PG::Connection#lo_create`や外部ライブラリを使う認証メソッド(GSSAPI認証など)のような、大きめのオブジェクト用のメソッドがあります。これらは`Fiber.scheduler`と互換性がないため、ブロッキング状態は登録されたIOスケジューラに渡されません。つまり操作は適切に実行されますが、IO待ち状態に別のIOを扱うFiberから使用を切り替えてくることができなくなります。
200
223
 
201
224
 
225
+ ## Ractor対応
226
+
227
+ pg-1.5.0以降で、PgはRuby-3.0で導入されたRactorと完全な互換性があります。
228
+ 型エンコーダーないしデコーダー、及び型の対応付けが`Ractor.make_shareable`により凍結されている場合、これらをractor間で共有できます。
229
+ また凍結された PG::Result と PG::Tuple オブジェクトも共有できます。
230
+ 少なくとも全ての凍結されたオブジェクト(ただし PG::Connection
231
+ を除く)はPostgreSQLサーバーとのやり取りをしたり取得されたデータを読むのに使えます。
232
+
233
+ PG::Connection は共有できません。個々の接続を確立するために、それぞれのRactor内で作られなければなりません。
234
+
235
+
202
236
  ## 貢献
203
237
 
204
238
  バグを報告したり機能を提案したりGitでソースをチェックアウトしたりするには[プロジェクトページをご確認ください](https://github.com/ged/ruby-pg)。
@@ -207,7 +241,7 @@ PgはRuby-3.0で導入された`Fiber.scheduler`に完全に対応していま
207
241
 
208
242
  $ bundle install
209
243
 
210
- 拡張ファイル、パッケージファイル、テストデータベースを一掃するには次のようにします。
244
+ 拡張ファイル、パッケージファイル、テストデータベースを一掃するには、このコマンドを走らせてください。PostgreSQLのバージョンも切り替わります。
211
245
 
212
246
  $ rake clean
213
247
 
@@ -215,13 +249,13 @@ PgはRuby-3.0で導入された`Fiber.scheduler`に完全に対応していま
215
249
 
216
250
  $ rake compile
217
251
 
218
- パスにある`initdb`といったPostgreSQLのツールを使ってテストやスペックを走らせるには次のようにします。
252
+ `pg_config --bindir`が指すPostgreSQLのバージョンでテストやスペックを走らせるには次のようにします。
219
253
 
220
- $ PATH=$PATH:/usr/lib/postgresql/14/bin rake test
254
+ $ rake test
221
255
 
222
- あるいは行番号を使って特定のテストを走らせるには次のようにします。
256
+ あるいは特定のPostgreSQLのバージョンで、ファイル中の行番号を使って特定のテストを走らせるには次のようにします。
223
257
 
224
- $ PATH=$PATH:/usr/lib/postgresql/14/bin rspec -Ilib -fd spec/pg/connection_spec.rb:455
258
+ $ PATH=/usr/lib/postgresql/14/bin:$PATH rspec -Ilib -fd spec/pg/connection_spec.rb:455
225
259
 
226
260
  APIドキュメントを生成するには次のようにします。
227
261
 
@@ -261,6 +295,6 @@ Portions copyright LAIKA, Inc.
261
295
 
262
296
  ## 謝辞
263
297
 
264
- 長年にわたって貢献してくださった方々についてはContributors.rdocを参照してください。
298
+ 長年にわたって貢献してくださった方々については Contributors.rdoc を参照してください。
265
299
 
266
300
  ruby-listとruby-devメーリングリストの方々に感謝します。またPostgreSQLを開発された方々へも謝意を表します。
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # pg
2
2
 
3
3
  * home :: https://github.com/ged/ruby-pg
4
- * docs :: http://deveiate.org/code/pg
5
- * clog :: link:/History.md
4
+ * docs :: http://deveiate.org/code/pg (English) ,
5
+ https://deveiate.org/code/pg/README_ja_md.html (Japanese)
6
+ * clog :: link:/CHANGELOG.md
6
7
 
7
8
  [![Join the chat at https://gitter.im/ged/ruby-pg](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ged/ruby-pg?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8
9
 
@@ -10,7 +11,7 @@
10
11
  ## Description
11
12
 
12
13
  Pg is the Ruby interface to the [PostgreSQL RDBMS](http://www.postgresql.org/).
13
- It works with [PostgreSQL 9.3 and later](http://www.postgresql.org/support/versioning/).
14
+ It works with [PostgreSQL 10 and later](http://www.postgresql.org/support/versioning/).
14
15
 
15
16
  A small example usage:
16
17
  ```ruby
@@ -38,8 +39,8 @@ A small example usage:
38
39
 
39
40
  ## Requirements
40
41
 
41
- * Ruby 2.4 or newer
42
- * PostgreSQL 9.3.x or later (with headers, -dev packages, etc).
42
+ * Ruby 2.7 or newer
43
+ * PostgreSQL 10.x or later (with headers, -dev packages, etc).
43
44
 
44
45
  It usually works with earlier versions of Ruby/PostgreSQL as well, but those are
45
46
  not regularly tested.
@@ -124,26 +125,28 @@ to convert single values to/from their string representation.
124
125
  The following PostgreSQL column types are supported by ruby-pg (TE = Text Encoder, TD = Text Decoder, BE = Binary Encoder, BD = Binary Decoder):
125
126
 
126
127
  * 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_md.html#label-Type+Casts) 💡
127
- * BE: [Int2](rdoc-ref:PG::BinaryEncoder::Int2), [Int4](rdoc-ref:PG::BinaryEncoder::Int4), [Int8](rdoc-ref:PG::BinaryEncoder::Int8)
128
+ * BE: [Int2](rdoc-ref:PG::BinaryEncoder::Int2), [Int4](rdoc-ref:PG::BinaryEncoder::Int4), [Int8](rdoc-ref:PG::BinaryEncoder::Int8)
128
129
  * Float: [TE](rdoc-ref:PG::TextEncoder::Float), [TD](rdoc-ref:PG::TextDecoder::Float), [BD](rdoc-ref:PG::BinaryDecoder::Float)
130
+ * BE: [Float4](rdoc-ref:PG::BinaryEncoder::Float4), [Float8](rdoc-ref:PG::BinaryEncoder::Float8)
129
131
  * Numeric: [TE](rdoc-ref:PG::TextEncoder::Numeric), [TD](rdoc-ref:PG::TextDecoder::Numeric)
130
132
  * 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)
131
133
  * 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)
132
134
  * 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)
133
135
  * 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)
134
136
  * Timestamp:
135
- * TE: [local](rdoc-ref:PG::TextEncoder::TimestampWithoutTimeZone), [UTC](rdoc-ref:PG::TextEncoder::TimestampUtc), [with-TZ](rdoc-ref:PG::TextEncoder::TimestampWithTimeZone)
136
- * TD: [local](rdoc-ref:PG::TextDecoder::TimestampLocal), [UTC](rdoc-ref:PG::TextDecoder::TimestampUtc), [UTC-to-local](rdoc-ref:PG::TextDecoder::TimestampUtcToLocal)
137
- * BD: [local](rdoc-ref:PG::BinaryDecoder::TimestampLocal), [UTC](rdoc-ref:PG::BinaryDecoder::TimestampUtc), [UTC-to-local](rdoc-ref:PG::BinaryDecoder::TimestampUtcToLocal)
138
- * Date: [TE](rdoc-ref:PG::TextEncoder::Date), [TD](rdoc-ref:PG::TextDecoder::Date)
137
+ * TE: [local](rdoc-ref:PG::TextEncoder::TimestampWithoutTimeZone), [UTC](rdoc-ref:PG::TextEncoder::TimestampUtc), [with-TZ](rdoc-ref:PG::TextEncoder::TimestampWithTimeZone)
138
+ * TD: [local](rdoc-ref:PG::TextDecoder::TimestampLocal), [UTC](rdoc-ref:PG::TextDecoder::TimestampUtc), [UTC-to-local](rdoc-ref:PG::TextDecoder::TimestampUtcToLocal)
139
+ * BE: [local](rdoc-ref:PG::BinaryEncoder::TimestampLocal), [UTC](rdoc-ref:PG::BinaryEncoder::TimestampUtc)
140
+ * BD: [local](rdoc-ref:PG::BinaryDecoder::TimestampLocal), [UTC](rdoc-ref:PG::BinaryDecoder::TimestampUtc), [UTC-to-local](rdoc-ref:PG::BinaryDecoder::TimestampUtcToLocal)
141
+ * Date: [TE](rdoc-ref:PG::TextEncoder::Date), [TD](rdoc-ref:PG::TextDecoder::Date), [BE](rdoc-ref:PG::BinaryEncoder::Date), [BD](rdoc-ref:PG::BinaryDecoder::Date)
139
142
  * JSON and JSONB: [TE](rdoc-ref:PG::TextEncoder::JSON), [TD](rdoc-ref:PG::TextDecoder::JSON)
140
143
  * Inet: [TE](rdoc-ref:PG::TextEncoder::Inet), [TD](rdoc-ref:PG::TextDecoder::Inet)
141
- * Array: [TE](rdoc-ref:PG::TextEncoder::Array), [TD](rdoc-ref:PG::TextDecoder::Array)
144
+ * Array: [TE](rdoc-ref:PG::TextEncoder::Array), [TD](rdoc-ref:PG::TextDecoder::Array), [BE](rdoc-ref:PG::BinaryEncoder::Array), [BD](rdoc-ref:PG::BinaryDecoder::Array)
142
145
  * Composite Type (also called "Row" or "Record"): [TE](rdoc-ref:PG::TextEncoder::Record), [TD](rdoc-ref:PG::TextDecoder::Record)
143
146
 
144
- The following text formats can also be encoded although they are not used as column type:
147
+ The following text and binary formats can also be encoded although they are not used as column type:
145
148
 
146
- * COPY input and output data: [TE](rdoc-ref:PG::TextEncoder::CopyRow), [TD](rdoc-ref:PG::TextDecoder::CopyRow)
149
+ * COPY input and output data: [TE](rdoc-ref:PG::TextEncoder::CopyRow), [TD](rdoc-ref:PG::TextDecoder::CopyRow), [BE](rdoc-ref:PG::BinaryEncoder::CopyRow), [BD](rdoc-ref:PG::BinaryDecoder::CopyRow)
147
150
  * Literal for insertion into SQL string: [TE](rdoc-ref:PG::TextEncoder::QuotedLiteral)
148
151
  * SQL-Identifier: [TE](rdoc-ref:PG::TextEncoder::Identifier), [TD](rdoc-ref:PG::TextDecoder::Identifier)
149
152
 
@@ -172,6 +175,7 @@ The following type maps are prefilled with type mappings from the PG::BasicTypeR
172
175
  * PG::BasicTypeMapBasedOnResult - a PG::TypeMapByOid prefilled with encoders for common PostgreSQL column types
173
176
  * PG::BasicTypeMapForQueries - a PG::TypeMapByClass prefilled with encoders for common Ruby value classes
174
177
 
178
+ Several type maps can be chained by setting PG::TypeMap::DefaultTypeMappable#default_type_map .
175
179
 
176
180
  ## Thread support
177
181
 
@@ -190,7 +194,7 @@ If messages like the following are printed to stderr, you're probably using one
190
194
 
191
195
  ## Fiber IO scheduler support
192
196
 
193
- Pg is fully compatible with `Fiber.scheduler` introduced in Ruby-3.0.
197
+ Pg is fully compatible with `Fiber.scheduler` introduced in Ruby-3.0 since pg-1.3.0.
194
198
  On Windows support for `Fiber.scheduler` is available on Ruby-3.1 or newer.
195
199
  All possibly blocking IO operations are routed through the `Fiber.scheduler` if one is registered for the running thread.
196
200
  That is why pg internally uses the asynchronous libpq interface even for synchronous/blocking method calls.
@@ -205,6 +209,16 @@ They are not compatible with `Fiber.scheduler`, so that blocking states are not
205
209
  That means the operation will work properly, but IO waiting states can not be used to switch to another Fiber doing IO.
206
210
 
207
211
 
212
+ ## Ractor support
213
+
214
+ Pg is fully compatible with Ractor introduced in Ruby-3.0 since pg-1.5.0.
215
+ All type en/decoders and type maps are shareable between ractors if they are made frozen by `Ractor.make_shareable`.
216
+ Also frozen PG::Result and PG::Tuple objects can be shared.
217
+ All frozen objects (except PG::Connection) can still be used to do communication with the PostgreSQL server or to read retrieved data.
218
+
219
+ PG::Connection is not shareable and must be created within each Ractor to establish a dedicated connection.
220
+
221
+
208
222
  ## Contributing
209
223
 
210
224
  To report bugs, suggest features, or check out the source with Git,
@@ -214,7 +228,8 @@ After checking out the source, install all dependencies:
214
228
 
215
229
  $ bundle install
216
230
 
217
- Cleanup extension files, packaging files, test databases:
231
+ Cleanup extension files, packaging files, test databases.
232
+ Run this to change between PostgreSQL versions:
218
233
 
219
234
  $ rake clean
220
235
 
@@ -222,13 +237,13 @@ Compile extension:
222
237
 
223
238
  $ rake compile
224
239
 
225
- Run tests/specs with PostgreSQL tools like `initdb` in the path:
240
+ Run tests/specs on the PostgreSQL version that `pg_config --bindir` points to:
226
241
 
227
- $ PATH=$PATH:/usr/lib/postgresql/14/bin rake test
242
+ $ rake test
228
243
 
229
- Or run a specific test with the line number:
244
+ Or run a specific test per file and line number on a specific PostgreSQL version:
230
245
 
231
- $ PATH=$PATH:/usr/lib/postgresql/14/bin rspec -Ilib -fd spec/pg/connection_spec.rb:455
246
+ $ PATH=/usr/lib/postgresql/14/bin:$PATH rspec -Ilib -fd spec/pg/connection_spec.rb:455
232
247
 
233
248
  Generate the API documentation:
234
249