pg 1.5.4 → 1.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e50a6829d4fe134af52d85429a3db06240fb6d228b96ef5b3fade98d38f4d199
4
- data.tar.gz: 281f5700e856a64a4a7c3157bbef4398345ac16698dbcdce54ed0408c0448457
3
+ metadata.gz: dabf91eb5c0f0871f693465f33fdd345e7b5fca07ffe35a0dad65f3b851d5292
4
+ data.tar.gz: ecfb93d8f10e6835b5c7b134d2861161faa9c13ecbd0fe7e5c2cc0d5257faf2b
5
5
  SHA512:
6
- metadata.gz: 4ca887b068f003b077c17fca5e8297368f5236ed74ae16888a64312fed269110c455e2cd58105b5a23fbb53a1841b081ae215d3a4c3473815914642fcdde75cc
7
- data.tar.gz: 86599add8d622097727be30a1a05259c69d8c83fa73e1dad0f46125e95685a752a5df24f235158ff0d62dbfe99034aa8512e89bc39f26edf81a2540c466a6541
6
+ metadata.gz: cbba19b5af6b7eeae29313fe028579c1f1c3005a4ae0244bafa7e2562279986cbbc851a089286bd40302bc8eb46b865e0b0baa7d80ee7b8797e50f12dd4f9633
7
+ data.tar.gz: 7e4a0c5fba7fb69a25297300c92f2a96599798390b77fb26c46056bb1557682c58f905006aacdf754a83880f2e01218b04ff32473be76eeb178161098a04ab39
checksums.yaml.gz.sig CHANGED
Binary file
@@ -9,7 +9,7 @@ on:
9
9
 
10
10
  jobs:
11
11
  job_build_x64:
12
- name: build
12
+ name: Build
13
13
  runs-on: ubuntu-latest
14
14
  strategy:
15
15
  fail-fast: false
@@ -23,7 +23,7 @@ jobs:
23
23
  - name: Set up Ruby
24
24
  uses: ruby/setup-ruby@v1
25
25
  with:
26
- ruby-version: "3.2"
26
+ ruby-version: "3.3"
27
27
  - run: bundle install
28
28
 
29
29
  - name: Create a dummy cert to satisfy the build
@@ -43,18 +43,18 @@ jobs:
43
43
  path: pkg/*.gem
44
44
 
45
45
  job_test_binary:
46
- name: Test on Windows
46
+ name: Test
47
47
  needs: job_build_x64
48
48
  strategy:
49
49
  fail-fast: false
50
50
  matrix:
51
51
  include:
52
52
  - os: windows-latest
53
- ruby: "3.2"
53
+ ruby: "3.3"
54
54
  platform: "x64-mingw-ucrt"
55
- PGVERSION: 15.1-1-windows-x64
55
+ PGVERSION: 16.0-1-windows-x64
56
56
  - os: windows-latest
57
- ruby: "3.1.3-1"
57
+ ruby: "3.1.4-1"
58
58
  platform: "x86-mingw32"
59
59
  PGVERSION: 10.20-1-windows
60
60
  - os: windows-latest
@@ -9,7 +9,7 @@ on:
9
9
 
10
10
  jobs:
11
11
  job_build_gem:
12
- name: build
12
+ name: Build
13
13
  runs-on: ubuntu-latest
14
14
  steps:
15
15
  - uses: actions/checkout@v3
@@ -28,7 +28,7 @@ jobs:
28
28
  path: "*.gem"
29
29
 
30
30
  job_test_gem:
31
- name: Test built gem
31
+ name: Test
32
32
  needs: job_build_gem
33
33
  strategy:
34
34
  fail-fast: false
@@ -36,19 +36,19 @@ jobs:
36
36
  include:
37
37
  - os: windows
38
38
  ruby: "head"
39
- PGVERSION: 15.1-1-windows-x64
40
- PGVER: "15"
39
+ PGVERSION: 16.0-1-windows-x64
40
+ PGVER: "16"
41
41
  - os: windows
42
42
  ruby: "2.5"
43
43
  PGVERSION: 9.4.26-1-windows-x64
44
44
  PGVER: "9.4"
45
45
  - os: windows
46
46
  ruby: "mswin"
47
- PGVERSION: 15.1-1-windows-x64
48
- PGVER: "15"
47
+ PGVERSION: 16.0-1-windows-x64
48
+ PGVER: "16"
49
49
  - os: ubuntu
50
50
  ruby: "head"
51
- PGVER: "15"
51
+ PGVER: "16"
52
52
  - os: ubuntu
53
53
  ruby: "3.2"
54
54
  PGVER: "12"
@@ -61,11 +61,11 @@ jobs:
61
61
  PGVER: "13"
62
62
  - os: ubuntu
63
63
  ruby: "truffleruby-head"
64
- PGVER: "15"
64
+ PGVER: "16"
65
65
  - os: macos
66
66
  ruby: "head"
67
- PGVERSION: 15.1-1-osx
68
- PGVER: "15"
67
+ PGVERSION: 16.0-1-osx
68
+ PGVER: "16"
69
69
 
70
70
  runs-on: ${{ matrix.os }}-${{ matrix.os_ver || 'latest' }}
71
71
  env:
data/Gemfile CHANGED
@@ -11,4 +11,7 @@ group :development, :test do
11
11
  gem "rake-compiler-dock", "~> 1.0"
12
12
  gem "rdoc", "~> 6.4"
13
13
  gem "rspec", "~> 3.5"
14
+ # "bigdecimal" is a gem on ruby-3.4+ and it's optional for ruby-pg.
15
+ # Specs should succeed without it, but 4 examples are then excluded.
16
+ # gem "bigdecimal", "~> 3.0"
14
17
  end
data/History.md CHANGED
@@ -1,9 +1,26 @@
1
+ ## v1.5.6 [2024-03-01] Lars Kanis <lars@greiz-reinsdorf.de>
2
+
3
+ - Renew address resolution (DNS) in conn.reset. [#558](https://github.com/ged/ruby-pg/pull/558)
4
+ This is important, if DNS is used for load balancing, etc.
5
+ - Make bigdecimal an optional dependency. [#556](https://github.com/ged/ruby-pg/pull/556)
6
+ It's a gem in ruby-3.4+, so that users shouldn't be forced to use it.
7
+
8
+
9
+ ## v1.5.5 [2024-02-15] Lars Kanis <lars@greiz-reinsdorf.de>
10
+
11
+ - Explicitly retype timespec fields to int64_t to fix compatibility with 32bit arches. [#547](https://github.com/ged/ruby-pg/pull/547)
12
+ - Fix possible buffer overflows in PG::BinaryDecoder::CopyRow on 32 bit systems. [#548](https://github.com/ged/ruby-pg/pull/548)
13
+ - Add binary Windows gems for Ruby 3.3.
14
+ - Update Windows fat binary gem to OpenSSL-3.2.1 and PostgreSQL-16.2.
15
+
16
+
1
17
  ## v1.5.4 [2023-09-01] Lars Kanis <lars@greiz-reinsdorf.de>
2
18
 
3
19
  - Fix compiling the pg extension with MSVC 2022. [#535](https://github.com/ged/ruby-pg/pull/535)
4
20
  - Set PG::Connection's encoding even if setting client_encoding on connection startup fails. [#541](https://github.com/ged/ruby-pg/pull/541)
5
21
  - Don't set the server's client_encoding if it's unnecessary. [#542](https://github.com/ged/ruby-pg/pull/542)
6
22
  This is important for connection proxies, who disallow configuration settings.
23
+ - Update Windows fat binary gem to OpenSSL-3.1.2 and PostgreSQL-15.4.
7
24
 
8
25
 
9
26
  ## v1.5.3 [2023-04-28] Lars Kanis <lars@greiz-reinsdorf.de>
data/Rakefile CHANGED
@@ -1,5 +1,8 @@
1
1
  # -*- rake -*-
2
2
 
3
+ # Enable english error messages, as some specs depend on them
4
+ ENV["LANG"] = "C"
5
+
3
6
  require 'rbconfig'
4
7
  require 'pathname'
5
8
  require 'tmpdir'
@@ -91,7 +94,7 @@ end
91
94
 
92
95
  desc "Update list of server error codes"
93
96
  task :update_error_codes do
94
- URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL_15_0"
97
+ URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL_16_0"
95
98
 
96
99
  ERRORCODES_TXT = "ext/errorcodes.txt"
97
100
  sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
data/Rakefile.cross CHANGED
@@ -31,8 +31,8 @@ class CrossLibrary < OpenStruct
31
31
  self.host_platform = toolchain
32
32
 
33
33
  # Cross-compilation constants
34
- self.openssl_version = ENV['OPENSSL_VERSION'] || '3.1.0'
35
- self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '15.2'
34
+ self.openssl_version = ENV['OPENSSL_VERSION'] || '3.2.1'
35
+ self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '16.2'
36
36
 
37
37
  # Check if symlinks work in the current working directory.
38
38
  # This fails, if rake-compiler-dock is running on a Windows box.
@@ -184,6 +184,7 @@ class CrossLibrary < OpenStruct
184
184
  "--host=#{host_platform}",
185
185
  '--with-openssl',
186
186
  '--without-zlib',
187
+ '--without-icu',
187
188
  ]
188
189
 
189
190
  chdir( static_postgresql_builddir ) do
@@ -290,7 +291,7 @@ CrossLibraries.each do |xlib|
290
291
  RakeCompilerDock.sh <<-EOT, platform: platform
291
292
  (cp build/gem/gem-*.pem ~/.gem/ || true) &&
292
293
  bundle install --local &&
293
- rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKE="make -j`nproc`" RUBY_CC_VERSION=3.2.0:3.1.0:3.0.0:2.7.0:2.6.0:2.5.0
294
+ rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKE="make -j`nproc`" RUBY_CC_VERSION=3.3.0:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0:2.5.0
294
295
  EOT
295
296
  end
296
297
  desc "Build the windows binary gems"
@@ -0,0 +1,20 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDLjCCAhagAwIBAgIBCzANBgkqhkiG9w0BAQsFADA9MQ4wDAYDVQQDDAVrYW5p
3
+ czEXMBUGCgmSJomT8ixkARkWB2NvbWNhcmQxEjAQBgoJkiaJk/IsZAEZFgJkZTAe
4
+ Fw0yMzA0MjgwOTI0NDhaFw0yNDA0MjcwOTI0NDhaMD0xDjAMBgNVBAMMBWthbmlz
5
+ MRcwFQYKCZImiZPyLGQBGRYHY29tY2FyZDESMBAGCgmSJomT8ixkARkWAmRlMIIB
6
+ IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApop+rNmg35bzRugZ21VMGqI6
7
+ HGzPLO4VHYncWn/xmgPU/ZMcZdfj6MzIaZJ/czXyt4eHpBk1r8QOV3gBXnRXEjVW
8
+ 9xi+EdVOkTV2/AVFKThcbTAQGiF/bT1n2M+B1GTybRzMg6hyhOJeGPqIhLfJEpxn
9
+ lJi4+ENAVT4MpqHEAGB8yFoPC0GqiOHQsdHxQV3P3c2OZqG+yJey74QtwA2tLcLn
10
+ Q53c63+VLGsOjODl1yPn/2ejyq8qWu6ahfTxiIlSar2UbwtaQGBDFdb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codes.txt CHANGED
@@ -2,7 +2,7 @@
2
2
  # errcodes.txt
3
3
  # PostgreSQL error codes
4
4
  #
5
- # Copyright (c) 2003-2022, PostgreSQL Global Development Group
5
+ # Copyright (c) 2003-2023, PostgreSQL Global Development Group
6
6
  #
7
7
  # This list serves as the basis for generating source files containing error
8
8
  # codes. It is kept in a common format to make sure all these source files have
@@ -185,7 +185,7 @@ pg_bin_enc_timestamp(t_pg_coder *this, VALUE value, char *out, VALUE *intermedia
185
185
  ts = rb_time_timespec(*intermediate);
186
186
  /* PostgreSQL's timestamp is based on year 2000 and Ruby's time is based on 1970.
187
187
  * Adjust the 30 years difference. */
188
- timestamp = (ts.tv_sec - 10957L * 24L * 3600L) * 1000000 + (ts.tv_nsec / 1000);
188
+ timestamp = ((int64_t)ts.tv_sec - 10957L * 24L * 3600L) * 1000000 + ((int64_t)ts.tv_nsec / 1000);
189
189
 
190
190
  if( this->flags & PG_CODER_TIMESTAMP_DB_LOCAL ) {
191
191
  /* send as local time */
data/ext/pg_connection.c CHANGED
@@ -563,6 +563,27 @@ pgconn_sync_reset( VALUE self )
563
563
  return self;
564
564
  }
565
565
 
566
+ static VALUE
567
+ pgconn_reset_start2( VALUE self, VALUE conninfo )
568
+ {
569
+ t_pg_connection *this = pg_get_connection( self );
570
+
571
+ /* Close old connection */
572
+ pgconn_close_socket_io( self );
573
+ PQfinish( this->pgconn );
574
+
575
+ /* Start new connection */
576
+ this->pgconn = gvl_PQconnectStart( StringValueCStr(conninfo) );
577
+
578
+ if( this->pgconn == NULL )
579
+ rb_raise(rb_ePGerror, "PQconnectStart() unable to allocate PGconn structure");
580
+
581
+ if ( PQstatus(this->pgconn) == CONNECTION_BAD )
582
+ pg_raise_conn_error( rb_eConnectionBad, self, "%s", PQerrorMessage(this->pgconn));
583
+
584
+ return Qnil;
585
+ }
586
+
566
587
  /*
567
588
  * call-seq:
568
589
  * conn.reset_start() -> nil
@@ -4468,6 +4489,7 @@ init_pg_connection(void)
4468
4489
  rb_define_method(rb_cPGconn, "finished?", pgconn_finished_p, 0);
4469
4490
  rb_define_method(rb_cPGconn, "sync_reset", pgconn_sync_reset, 0);
4470
4491
  rb_define_method(rb_cPGconn, "reset_start", pgconn_reset_start, 0);
4492
+ rb_define_private_method(rb_cPGconn, "reset_start2", pgconn_reset_start2, 1);
4471
4493
  rb_define_method(rb_cPGconn, "reset_poll", pgconn_reset_poll, 0);
4472
4494
  rb_define_alias(rb_cPGconn, "close", "finish");
4473
4495
 
data/ext/pg_copy_coder.c CHANGED
@@ -795,26 +795,26 @@ pg_bin_dec_copy_row(t_pg_coder *conv, const char *input_line, int len, int _tupl
795
795
  cur_ptr = input_line;
796
796
  line_end_ptr = input_line + len;
797
797
 
798
- if (cur_ptr + 11 <= line_end_ptr && memcmp(cur_ptr, BinarySignature, 11) == 0){
798
+ if (line_end_ptr - cur_ptr >= 11 && memcmp(cur_ptr, BinarySignature, 11) == 0){
799
799
  /* binary COPY header signature detected -> just drop it */
800
800
  int ext_bytes;
801
801
  cur_ptr += 11;
802
802
 
803
803
  /* read flags */
804
- if (cur_ptr + 4 > line_end_ptr) goto length_error;
804
+ if (line_end_ptr - cur_ptr < 4 ) goto length_error;
805
805
  cur_ptr += 4;
806
806
 
807
807
  /* read header extensions */
808
- if (cur_ptr + 4 > line_end_ptr) goto length_error;
808
+ if (line_end_ptr - cur_ptr < 4 ) goto length_error;
809
809
  ext_bytes = read_nbo32(cur_ptr);
810
810
  if (ext_bytes < 0) goto length_error;
811
811
  cur_ptr += 4;
812
- if (cur_ptr + ext_bytes > line_end_ptr) goto length_error;
812
+ if (line_end_ptr - cur_ptr < ext_bytes ) goto length_error;
813
813
  cur_ptr += ext_bytes;
814
814
  }
815
815
 
816
816
  /* read row header */
817
- if (cur_ptr + 2 > line_end_ptr) goto length_error;
817
+ if (line_end_ptr - cur_ptr < 2 ) goto length_error;
818
818
  nfields = read_nbo16(cur_ptr);
819
819
  cur_ptr += 2;
820
820
 
@@ -830,7 +830,7 @@ pg_bin_dec_copy_row(t_pg_coder *conv, const char *input_line, int len, int _tupl
830
830
  VALUE field_value;
831
831
 
832
832
  /* read field size */
833
- if (cur_ptr + 4 > line_end_ptr) goto length_error;
833
+ if (line_end_ptr - cur_ptr < 4 ) goto length_error;
834
834
  input_len = read_nbo32(cur_ptr);
835
835
  cur_ptr += 4;
836
836
 
@@ -839,7 +839,7 @@ pg_bin_dec_copy_row(t_pg_coder *conv, const char *input_line, int len, int _tupl
839
839
  /* NULL indicator */
840
840
  rb_ary_push(array, Qnil);
841
841
  } else {
842
- if (cur_ptr + input_len > line_end_ptr) goto length_error;
842
+ if (line_end_ptr - cur_ptr < input_len ) goto length_error;
843
843
 
844
844
  /* copy input data to field_str */
845
845
  PG_RB_STR_ENSURE_CAPA( field_str, input_len, output_ptr, end_capa_ptr );
@@ -166,6 +166,12 @@ class PG::BasicTypeMapForQueries < PG::TypeMapByClass
166
166
  @textarray_encoder
167
167
  end
168
168
 
169
+ begin
170
+ require "bigdecimal"
171
+ has_bigdecimal = true
172
+ rescue LoadError
173
+ end
174
+
169
175
  DEFAULT_TYPE_MAP = PG.make_shareable({
170
176
  TrueClass => [1, 'bool', 'bool'],
171
177
  FalseClass => [1, 'bool', 'bool'],
@@ -173,7 +179,6 @@ class PG::BasicTypeMapForQueries < PG::TypeMapByClass
173
179
  # to unnecessary type conversions on server side.
174
180
  Integer => [0, 'int8'],
175
181
  Float => [0, 'float8'],
176
- BigDecimal => [0, 'numeric'],
177
182
  Time => [0, 'timestamptz'],
178
183
  # We use text format and no type OID for IPAddr, because setting the OID can lead
179
184
  # to unnecessary inet/cidr conversions on the server side.
@@ -181,7 +186,7 @@ class PG::BasicTypeMapForQueries < PG::TypeMapByClass
181
186
  Hash => [0, 'json'],
182
187
  Array => :get_array_type,
183
188
  BinaryData => [1, 'bytea'],
184
- })
189
+ }.merge(has_bigdecimal ? {BigDecimal => [0, 'numeric']} : {}))
185
190
  private_constant :DEFAULT_TYPE_MAP
186
191
 
187
192
  DEFAULT_ARRAY_TYPE_MAP = PG.make_shareable({
@@ -190,9 +195,8 @@ class PG::BasicTypeMapForQueries < PG::TypeMapByClass
190
195
  Integer => [0, '_int8'],
191
196
  String => [0, '_text'],
192
197
  Float => [0, '_float8'],
193
- BigDecimal => [0, '_numeric'],
194
198
  Time => [0, '_timestamptz'],
195
199
  IPAddr => [0, '_inet'],
196
- })
200
+ }.merge(has_bigdecimal ? {BigDecimal => [0, '_numeric']} : {}))
197
201
  private_constant :DEFAULT_ARRAY_TYPE_MAP
198
202
  end
@@ -225,7 +225,11 @@ class PG::BasicTypeRegistry
225
225
  alias_type 0, 'int8', 'int2'
226
226
  alias_type 0, 'oid', 'int2'
227
227
 
228
- register_type 0, 'numeric', PG::TextEncoder::Numeric, PG::TextDecoder::Numeric
228
+ begin
229
+ require "bigdecimal"
230
+ register_type 0, 'numeric', PG::TextEncoder::Numeric, PG::TextDecoder::Numeric
231
+ rescue LoadError
232
+ end
229
233
  register_type 0, 'text', PG::TextEncoder::String, PG::TextDecoder::String
230
234
  alias_type 0, 'varchar', 'text'
231
235
  alias_type 0, 'char', 'text'
data/lib/pg/connection.rb CHANGED
@@ -565,7 +565,12 @@ class PG::Connection
565
565
  # Resets the backend connection. This method closes the
566
566
  # backend connection and tries to re-connect.
567
567
  def reset
568
- reset_start
568
+ iopts = conninfo_hash.compact
569
+ if iopts[:host] && !iopts[:host].empty? && PG.library_version >= 100000
570
+ iopts = self.class.send(:resolve_hosts, iopts)
571
+ end
572
+ conninfo = self.class.parse_connect_args( iopts );
573
+ reset_start2(conninfo)
569
574
  async_connect_or_reset(:reset_poll)
570
575
  self
571
576
  end
@@ -773,6 +778,40 @@ class PG::Connection
773
778
  alias setdb new
774
779
  alias setdblogin new
775
780
 
781
+ # Resolve DNS in Ruby to avoid blocking state while connecting.
782
+ # Multiple comma-separated values are generated, if the hostname resolves to both IPv4 and IPv6 addresses.
783
+ # This requires PostgreSQL-10+, so no DNS resolving is done on earlier versions.
784
+ private def resolve_hosts(iopts)
785
+ ihosts = iopts[:host].split(",", -1)
786
+ iports = iopts[:port].split(",", -1)
787
+ iports = [nil] if iports.size == 0
788
+ iports = iports * ihosts.size if iports.size == 1
789
+ raise PG::ConnectionBad, "could not match #{iports.size} port numbers to #{ihosts.size} hosts" if iports.size != ihosts.size
790
+
791
+ dests = ihosts.each_with_index.flat_map do |mhost, idx|
792
+ unless host_is_named_pipe?(mhost)
793
+ if Fiber.respond_to?(:scheduler) &&
794
+ Fiber.scheduler &&
795
+ RUBY_VERSION < '3.1.'
796
+
797
+ # Use a second thread to avoid blocking of the scheduler.
798
+ # `TCPSocket.gethostbyname` isn't fiber aware before ruby-3.1.
799
+ hostaddrs = Thread.new{ Addrinfo.getaddrinfo(mhost, nil, nil, :STREAM).map(&:ip_address) rescue [''] }.value
800
+ else
801
+ hostaddrs = Addrinfo.getaddrinfo(mhost, nil, nil, :STREAM).map(&:ip_address) rescue ['']
802
+ end
803
+ else
804
+ # No hostname to resolve (UnixSocket)
805
+ hostaddrs = [nil]
806
+ end
807
+ hostaddrs.map { |hostaddr| [hostaddr, mhost, iports[idx]] }
808
+ end
809
+ iopts.merge(
810
+ hostaddr: dests.map{|d| d[0] }.join(","),
811
+ host: dests.map{|d| d[1] }.join(","),
812
+ port: dests.map{|d| d[2] }.join(","))
813
+ end
814
+
776
815
  private def connect_to_hosts(*args)
777
816
  option_string = parse_connect_args(*args)
778
817
  iopts = PG::Connection.conninfo_parse(option_string).each_with_object({}){|h, o| o[h[:keyword].to_sym] = h[:val] if h[:val] }
@@ -782,37 +821,7 @@ class PG::Connection
782
821
  # hostaddr is provided -> no need to resolve hostnames
783
822
 
784
823
  elsif iopts[:host] && !iopts[:host].empty? && PG.library_version >= 100000
785
- # Resolve DNS in Ruby to avoid blocking state while connecting.
786
- # Multiple comma-separated values are generated, if the hostname resolves to both IPv4 and IPv6 addresses.
787
- # This requires PostgreSQL-10+, so no DNS resolving is done on earlier versions.
788
- ihosts = iopts[:host].split(",", -1)
789
- iports = iopts[:port].split(",", -1)
790
- iports = [nil] if iports.size == 0
791
- iports = iports * ihosts.size if iports.size == 1
792
- raise PG::ConnectionBad, "could not match #{iports.size} port numbers to #{ihosts.size} hosts" if iports.size != ihosts.size
793
-
794
- dests = ihosts.each_with_index.flat_map do |mhost, idx|
795
- unless host_is_named_pipe?(mhost)
796
- if Fiber.respond_to?(:scheduler) &&
797
- Fiber.scheduler &&
798
- RUBY_VERSION < '3.1.'
799
-
800
- # Use a second thread to avoid blocking of the scheduler.
801
- # `TCPSocket.gethostbyname` isn't fiber aware before ruby-3.1.
802
- hostaddrs = Thread.new{ Addrinfo.getaddrinfo(mhost, nil, nil, :STREAM).map(&:ip_address) rescue [''] }.value
803
- else
804
- hostaddrs = Addrinfo.getaddrinfo(mhost, nil, nil, :STREAM).map(&:ip_address) rescue ['']
805
- end
806
- else
807
- # No hostname to resolve (UnixSocket)
808
- hostaddrs = [nil]
809
- end
810
- hostaddrs.map { |hostaddr| [hostaddr, mhost, iports[idx]] }
811
- end
812
- iopts.merge!(
813
- hostaddr: dests.map{|d| d[0] }.join(","),
814
- host: dests.map{|d| d[1] }.join(","),
815
- port: dests.map{|d| d[2] }.join(","))
824
+ iopts = resolve_hosts(iopts)
816
825
  else
817
826
  # No host given
818
827
  end
data/lib/pg/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module PG
2
2
  # Library version
3
- VERSION = '1.5.4'
3
+ VERSION = '1.5.6'
4
4
  end
data/pg.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  # Specify which files should be added to the gem when it is released.
24
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
25
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features|translation)/}) }
27
27
  end
28
28
  spec.extensions = ["ext/extconf.rb"]
29
29
  spec.require_paths = ["lib"]
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,36 +1,39 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
8
8
  - Lars Kanis
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain:
12
11
  - |
13
12
  -----BEGIN CERTIFICATE-----
14
- MIIDLjCCAhagAwIBAgIBCzANBgkqhkiG9w0BAQsFADA9MQ4wDAYDVQQDDAVrYW5p
15
- czEXMBUGCgmSJomT8ixkARkWB2NvbWNhcmQxEjAQBgoJkiaJk/IsZAEZFgJkZTAe
16
- Fw0yMzA0MjgwOTI0NDhaFw0yNDA0MjcwOTI0NDhaMD0xDjAMBgNVBAMMBWthbmlz
17
- MRcwFQYKCZImiZPyLGQBGRYHY29tY2FyZDESMBAGCgmSJomT8ixkARkWAmRlMIIB
18
- IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApop+rNmg35bzRugZ21VMGqI6
19
- HGzPLO4VHYncWn/xmgPU/ZMcZdfj6MzIaZJ/czXyt4eHpBk1r8QOV3gBXnRXEjVW
20
- 9xi+EdVOkTV2/AVFKThcbTAQGiF/bT1n2M+B1GTybRzMg6hyhOJeGPqIhLfJEpxn
21
- lJi4+ENAVT4MpqHEAGB8yFoPC0GqiOHQsdHxQV3P3c2OZqG+yJey74QtwA2tLcLn
22
- Q53c63+VLGsOjODl1yPn/2ejyq8qWu6ahfTxiIlSar2UbwtaQGBDFdb2CXgEufXT
23
- L7oaPxlmj+Q2oLOfOnInd2Oxop59HoJCQPsg8f921J43NCQGA8VHK6paxIRDLQID
24
- AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUvgTdT7fe
25
- x17ugO3IOsjEJwW7KP4wDQYJKoZIhvcNAQELBQADggEBACAxNXwfMG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dwT7Mj3pv1VHa+aNUbqSPpvJeDyxRIuo9hvzDaBHb/Cg
24
+ 9qRVcm8a96n4t7y2lrX1oookY6bkBaxWOMtWlqIprq8JZXM9AgMBAAGjOTA3MAkG
25
+ A1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQ4h1tIyvdUWtMI739xMzTR
26
+ 7EfMFzANBgkqhkiG9w0BAQsFAAOCAYEArBmHSfnUyNWf3R1Fx0mMHloWGdcKn2D2
27
+ BsqTApXU2nADiyppIqRq4b9e7hw342uzadSLkoQcEFOxThLRhAcijoWfQVBcsbV/
28
+ ZsCY1qlUTIJuSWxaSyS4efUX+N4eMNyPM9oW/sphlWFo0DgI34Y9WB6HDzH+O71y
29
+ R7PARke3f4kYnRJf5yRQLPDrH9UYt9KlBQm6l7XMtr5EMnQt0EfcmZEi9H4t/vS2
30
+ haxvpFMdAKo4H46GBYNO96r6b74t++vgQSBTg/AFVwvRZwNSrPPcBfb4xxeEAhRR
31
+ x+LU7feIH7lZ//3buiyD03gLAEtHXai0Y+/VfuWIpwYJAl2BO/tU7FS/dtbJq9oc
32
+ dI36Yyzy+BrCM0WT4oCsagePNb97FaNhl4F6sM5JEPT0ZPxRx0i3G4TNNIYziVos
33
+ 5wFER6XhvvLDFAMh/jMg+s7Wd5SbSHgHNSUaUGVtdWkVPOer6oF0aLdZUR3CETkn
34
+ 5nWXZma/BUd3YgYA/Xumc6QQqIS4p7mr
32
35
  -----END CERTIFICATE-----
33
- date: 2023-09-01 00:00:00.000000000 Z
36
+ date: 2024-03-01 00:00:00.000000000 Z
34
37
  dependencies: []
35
38
  description: Pg is the Ruby interface to the PostgreSQL RDBMS. It works with PostgreSQL
36
39
  9.3 and later.
@@ -123,8 +126,10 @@ files:
123
126
  - Rakefile
124
127
  - Rakefile.cross
125
128
  - certs/ged.pem
129
+ - certs/kanis@comcard.de.pem
126
130
  - certs/larskanis-2022.pem
127
131
  - certs/larskanis-2023.pem
132
+ - certs/larskanis-2024.pem
128
133
  - ext/errorcodes.def
129
134
  - ext/errorcodes.rb
130
135
  - ext/errorcodes.txt
@@ -213,10 +218,6 @@ files:
213
218
  - sample/test_binary_values.rb
214
219
  - sample/wal_shipper.rb
215
220
  - sample/warehouse_partitions.rb
216
- - translation/.po4a-version
217
- - translation/po/all.pot
218
- - translation/po/ja.po
219
- - translation/po4a.cfg
220
221
  homepage: https://github.com/ged/ruby-pg
221
222
  licenses:
222
223
  - BSD-2-Clause
@@ -225,7 +226,6 @@ metadata:
225
226
  source_code_uri: https://github.com/ged/ruby-pg
226
227
  changelog_uri: https://github.com/ged/ruby-pg/blob/master/History.md
227
228
  documentation_uri: http://deveiate.org/code/pg
228
- post_install_message:
229
229
  rdoc_options:
230
230
  - "--main"
231
231
  - README.md
@@ -244,8 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  - !ruby/object:Gem::Version
245
245
  version: '0'
246
246
  requirements: []
247
- rubygems_version: 3.4.15
248
- signing_key:
247
+ rubygems_version: 3.6.0.dev
249
248
  specification_version: 4
250
249
  summary: Pg is the Ruby interface to the PostgreSQL RDBMS
251
250
  test_files: []
metadata.gz.sig CHANGED
Binary file
@@ -1,7 +0,0 @@
1
- po4a version 0.68.
2
- Written by Martin Quinson and Denis Barbier.
3
-
4
- Copyright © 2002-2022 Software in the Public Interest, Inc.
5
- This is free software; see source code for copying
6
- conditions. There is NO warranty; not even for
7
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.