pg 1.5.4 → 1.6.1

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 (78) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/{History.md → CHANGELOG.md} +106 -4
  4. data/Gemfile +12 -3
  5. data/README-Windows.rdoc +1 -1
  6. data/README.ja.md +4 -4
  7. data/README.md +58 -17
  8. data/Rakefile +95 -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 +161 -14
  14. data/ext/gvl_wrappers.c +13 -2
  15. data/ext/gvl_wrappers.h +33 -0
  16. data/ext/pg.c +17 -6
  17. data/ext/pg.h +9 -9
  18. data/ext/pg_binary_decoder.c +152 -0
  19. data/ext/pg_binary_encoder.c +211 -8
  20. data/ext/pg_cancel_connection.c +360 -0
  21. data/ext/pg_coder.c +54 -5
  22. data/ext/pg_connection.c +409 -167
  23. data/ext/pg_copy_coder.c +19 -15
  24. data/ext/pg_record_coder.c +7 -7
  25. data/ext/pg_result.c +11 -13
  26. data/ext/pg_text_decoder.c +4 -1
  27. data/ext/pg_text_encoder.c +37 -18
  28. data/ext/pg_tuple.c +2 -2
  29. data/ext/pg_type_map.c +1 -1
  30. data/ext/pg_type_map_all_strings.c +1 -1
  31. data/ext/pg_type_map_by_class.c +1 -1
  32. data/ext/pg_type_map_by_column.c +2 -1
  33. data/ext/pg_type_map_by_mri_type.c +1 -1
  34. data/ext/pg_type_map_by_oid.c +3 -1
  35. data/ext/pg_type_map_in_ruby.c +1 -1
  36. data/lib/pg/basic_type_map_for_queries.rb +15 -7
  37. data/lib/pg/basic_type_registry.rb +16 -4
  38. data/lib/pg/cancel_connection.rb +53 -0
  39. data/lib/pg/coder.rb +4 -2
  40. data/lib/pg/connection.rb +310 -167
  41. data/lib/pg/exceptions.rb +6 -0
  42. data/lib/pg/text_decoder/date.rb +3 -0
  43. data/lib/pg/text_decoder/json.rb +3 -0
  44. data/lib/pg/text_encoder/date.rb +1 -0
  45. data/lib/pg/text_encoder/inet.rb +3 -0
  46. data/lib/pg/text_encoder/json.rb +3 -0
  47. data/lib/pg/version.rb +1 -1
  48. data/lib/pg.rb +23 -8
  49. data/misc/yugabyte/Dockerfile +9 -0
  50. data/misc/yugabyte/docker-compose.yml +28 -0
  51. data/misc/yugabyte/pg-test.rb +45 -0
  52. data/pg.gemspec +8 -4
  53. data/ports/patches/krb5/1.21.3/0001-Allow-static-linking-krb5-library.patch +30 -0
  54. data/ports/patches/openssl/3.5.1/0001-aarch64-mingw.patch +21 -0
  55. data/ports/patches/postgresql/17.5/0001-Use-workaround-of-__builtin_setjmp-only-on-MINGW-on-.patch +42 -0
  56. data/ports/patches/postgresql/17.5/0001-libpq-Process-buffered-SSL-read-bytes-to-support-rec.patch +52 -0
  57. data/rakelib/pg_gem_helper.rb +64 -0
  58. data.tar.gz.sig +0 -0
  59. metadata +45 -47
  60. metadata.gz.sig +0 -0
  61. data/.appveyor.yml +0 -42
  62. data/.gems +0 -6
  63. data/.gemtest +0 -0
  64. data/.github/workflows/binary-gems.yml +0 -117
  65. data/.github/workflows/source-gem.yml +0 -141
  66. data/.gitignore +0 -22
  67. data/.hgsigs +0 -34
  68. data/.hgtags +0 -41
  69. data/.irbrc +0 -23
  70. data/.pryrc +0 -23
  71. data/.tm_properties +0 -21
  72. data/.travis.yml +0 -49
  73. data/Manifest.txt +0 -72
  74. data/Rakefile.cross +0 -298
  75. data/translation/.po4a-version +0 -7
  76. data/translation/po/all.pot +0 -936
  77. data/translation/po/ja.po +0 -1036
  78. data/translation/po4a.cfg +0 -12
@@ -127,8 +127,8 @@ class PG::BasicTypeRegistry
127
127
  @maps = [
128
128
  [0, :encoder, PG::TextEncoder::Array],
129
129
  [0, :decoder, PG::TextDecoder::Array],
130
- [1, :encoder, nil],
131
- [1, :decoder, nil],
130
+ [1, :encoder, PG::BinaryEncoder::Array],
131
+ [1, :decoder, PG::BinaryDecoder::Array],
132
132
  ].inject([]) do |h, (format, direction, arraycoder)|
133
133
  coders = registry.coders_for(format, direction) || {}
134
134
  h[format] ||= {}
@@ -171,7 +171,14 @@ class PG::BasicTypeRegistry
171
171
  include Checker
172
172
 
173
173
  def initialize
174
- # The key of these hashs maps to the `typname` column from the table pg_type.
174
+ # @coders_by_name has a content of
175
+ # Array< Hash< Symbol: Hash< String: Coder > > >
176
+ #
177
+ # The layers are:
178
+ # * index of Array is 0 (text) and 1 (binary)
179
+ # * Symbol key in the middle Hash is :encoder and :decoder
180
+ # * String key in the inner Hash corresponds to the `typname` column in the table pg_type
181
+ # * Coder value in the inner Hash is the associated coder object
175
182
  @coders_by_name = []
176
183
  end
177
184
 
@@ -225,7 +232,11 @@ class PG::BasicTypeRegistry
225
232
  alias_type 0, 'int8', 'int2'
226
233
  alias_type 0, 'oid', 'int2'
227
234
 
228
- register_type 0, 'numeric', PG::TextEncoder::Numeric, PG::TextDecoder::Numeric
235
+ begin
236
+ PG.require_bigdecimal_without_warning
237
+ register_type 0, 'numeric', PG::TextEncoder::Numeric, PG::TextDecoder::Numeric
238
+ rescue LoadError
239
+ end
229
240
  register_type 0, 'text', PG::TextEncoder::String, PG::TextDecoder::String
230
241
  alias_type 0, 'varchar', 'text'
231
242
  alias_type 0, 'char', 'text'
@@ -267,6 +278,7 @@ class PG::BasicTypeRegistry
267
278
  register_type 0, 'inet', PG::TextEncoder::Inet, PG::TextDecoder::Inet
268
279
  alias_type 0, 'cidr', 'inet'
269
280
 
281
+ register_type 0, 'record', PG::TextEncoder::Record, PG::TextDecoder::Record
270
282
 
271
283
 
272
284
  register_type 1, 'int2', PG::BinaryEncoder::Int2, PG::BinaryDecoder::Integer
@@ -0,0 +1,53 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ require 'pg' unless defined?( PG )
5
+
6
+ if defined?(PG::CancelConnection)
7
+ class PG::CancelConnection
8
+ include PG::Connection::Pollable
9
+
10
+ alias c_initialize initialize
11
+
12
+ def initialize(conn)
13
+ c_initialize(conn)
14
+
15
+ # A cancel connection is always to one destination server only.
16
+ # Prepare conninfo_hash with just enough information to allow a shared polling_loop.
17
+ @host = conn.host
18
+ @hostaddr = conn.hostaddr
19
+ @port = conn.port
20
+
21
+ @conninfo_hash = {
22
+ host: @host,
23
+ hostaddr: @hostaddr,
24
+ port: @port.to_s,
25
+ connect_timeout: conn.conninfo_hash[:connect_timeout],
26
+ }
27
+ end
28
+
29
+ # call-seq:
30
+ # conn.cancel
31
+ #
32
+ # Requests that the server abandons processing of the current command in a blocking manner.
33
+ #
34
+ # If the cancel request wasn't successfully dispatched an error message is raised.
35
+ #
36
+ # Successful dispatch of the cancellation is no guarantee that the request will have any effect, however.
37
+ # If the cancellation is effective, the command being canceled will terminate early and raises an error.
38
+ # If the cancellation fails (say, because the server was already done processing the command), then there will be no visible result at all.
39
+ #
40
+ def cancel
41
+ start
42
+ polling_loop(:poll)
43
+ end
44
+ alias async_cancel cancel
45
+
46
+ # These private methods are there to allow a shared polling_loop.
47
+ private
48
+ attr_reader :host
49
+ attr_reader :hostaddr
50
+ attr_reader :port
51
+ attr_reader :conninfo_hash
52
+ end
53
+ end
data/lib/pg/coder.rb CHANGED
@@ -72,16 +72,18 @@ module PG
72
72
 
73
73
  class CompositeCoder < Coder
74
74
  def to_h
75
- { **super,
75
+ h = { **super,
76
76
  elements_type: elements_type,
77
77
  needs_quotation: needs_quotation?,
78
78
  delimiter: delimiter,
79
79
  }
80
+ h[:dimensions] = dimensions if dimensions # Write only when set, for Marshal compat with pg<1.6
81
+ h
80
82
  end
81
83
 
82
84
  def inspect
83
85
  str = super
84
- str[-1,0] = " elements_type=#{elements_type.inspect} #{needs_quotation? ? 'needs' : 'no'} quotation"
86
+ str[-1,0] = " elements_type=#{elements_type.inspect} #{needs_quotation? ? 'needs' : 'no'} quotation#{dimensions && " #{dimensions} dimensions"}"
85
87
  str
86
88
  end
87
89
  end