pg 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c220f1cc5cfd8e07690949fcf30a96abd8f710bc64f0c358eb6452288966a5b4
4
- data.tar.gz: cd5f28d3098e2537e04dc218c8809b83308cb541e6b17891220559d33e2ada82
3
+ metadata.gz: 40f704970acf17f5fc3514de1e25454441776d1a5ae7b267c791d2bc59bfdb82
4
+ data.tar.gz: f727c84142cc8d5a576b974c4cbf866e3d69d15004815c088461fef5c1f76190
5
5
  SHA512:
6
- metadata.gz: f5de3fb30c6da95937d6c8913c9e172a348fa376edc6f06cc9333669c908a25cb2af85853aafbdc6839407f6b4aea93ca97e3b5b53f7182732664ecd6cd81e33
7
- data.tar.gz: 00f5c6e8c359e81bf7c9145b7322583e511d440f681d32192430d9ce96772f1d71f8abce35e12ccf126d96a552205e799efee2533c54a84c623fa0aeee5c1c3c
6
+ metadata.gz: 2d3df7542a3b3b001709d59b9e75a0ed3bf734db3b3b5cc2fa293278920720a4443fa4e13365926cfca3df08862137bc89f6bc5b13167607c935c1d95f55c848
7
+ data.tar.gz: fb5d5d62930e3dba1ef983c0201fcd86b2c46eacd920f22372372b34b5e628333d0090d2b10f75f0075eba189df24e964a8cdf27b8bf2ff396d7d9bae7adf5dd
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## v1.6.2 [2025-09-02] Lars Kanis <lars@greiz-reinsdorf.de>
2
+
3
+ - Remove several absolute paths from native binaries which pointed to build directories. [#668](https://github.com/ged/ruby-pg/pull/668)
4
+ - Fix bad fallback path to `pg_service.conf`. [#666](https://github.com/ged/ruby-pg/pull/666)
5
+ - Use `rbpg_` prefix for `base64_*` functions to avoid name clashes with functions provided by other libraries like Heimdal on Macos. [#667](https://github.com/ged/ruby-pg/pull/667)
6
+ - Raise a more descriptive error message in case of `pg_ext` LoadError. [#664](https://github.com/ged/ruby-pg/pull/664)
7
+ - Freeze some constants to make them available in a Ractor context. [#660](https://github.com/ged/ruby-pg/pull/660)
8
+ - Several documentation improvements.
9
+ - Update native binary gems to OpenSSL-3.5.2, krb5-1.22.1 and PostgreSQL-17.6.
10
+
11
+
1
12
  ## v1.6.1 [2025-08-03] Lars Kanis <lars@greiz-reinsdorf.de>
2
13
 
3
14
  - Add binary gems for platforms `aarch64-linux-musl` and `x86_64-linux-musl` without the need to install package `gcompat`. [#657](https://github.com/ged/ruby-pg/pull/657).
data/Gemfile CHANGED
@@ -13,7 +13,7 @@ end
13
13
  group :test do
14
14
  gem "bundler", ">= 1.16", "< 3.0"
15
15
  gem "rake-compiler", "~> 1.0"
16
- gem "rake-compiler-dock", "~> 1.9.1"
16
+ gem "rake-compiler-dock", "~> 1.9.1", git: "https://github.com/rake-compiler/rake-compiler-dock"
17
17
  gem "rspec", "~> 3.5"
18
18
  # "bigdecimal" is a gem on ruby-3.4+ and it's optional for ruby-pg.
19
19
  # Specs should succeed without it, but 4 examples are then excluded.
data/README.md CHANGED
@@ -57,9 +57,7 @@ This installs the binary gem, specific to the running platform by default.
57
57
  The binary gems don't depend on the libpq package on the running system.
58
58
  They have libpq builtin.
59
59
 
60
- The gems for platform `x86_64-linux` and `aarch64-linux` run on Alpine Linux, but require the package `gcompat` there as long as we don't provide a native gem for platform `x86_64-linux-musl`. Install this package like so:
61
-
62
- apk add gcompat
60
+ The gems for platform `x86_64-linux` and `aarch64-linux` run on Alpine Linux, but require the package `gcompat`, while the native gems for platform `*-linux-musl` work without that dependency.
63
61
 
64
62
  There is one use case the binary gems don't support: Retrieval of connection [options from LDAP](https://www.postgresql.org/docs/current/libpq-ldap.html). To support this `libldap` would be necessary, but it has a lot of dependencies. It doesn't seem to be a widely used feature and that it's worth to support it. If it's necessary, the source gem can be forced.
65
63
 
@@ -67,6 +65,7 @@ There is one use case the binary gems don't support: Retrieval of connection [op
67
65
 
68
66
  The source gem can be forced by:
69
67
 
68
+ gem uninstall pg --all
70
69
  gem install pg --platform ruby
71
70
 
72
71
  You may need to specify the path to the 'pg_config' program installed with
@@ -148,7 +147,7 @@ Very basic type casting can be enabled by:
148
147
  But Pg's type casting is highly customizable. That's why it's divided into
149
148
  2 layers:
150
149
 
151
- ### Encoders / Decoders (ext/pg_*coder.c, lib/pg/*coder.rb)
150
+ ### Encoders / Decoders (ext/pg_\*coder.c, lib/pg/\*coder.rb)
152
151
 
153
152
  This is the lower layer, containing encoding classes that convert Ruby
154
153
  objects for transmission to the DBMS and decoding classes to convert
@@ -190,9 +189,9 @@ The following text and binary formats can also be encoded although they are not
190
189
  * Literal for insertion into SQL string: [TE](rdoc-ref:PG::TextEncoder::QuotedLiteral)
191
190
  * SQL-Identifier: [TE](rdoc-ref:PG::TextEncoder::Identifier), [TD](rdoc-ref:PG::TextDecoder::Identifier)
192
191
 
193
- ### PG::TypeMap and derivations (ext/pg_type_map*.c, lib/pg/type_map*.rb)
192
+ ### TypeMap and derivations (ext/pg_type_map\*.c, lib/pg/type_map\*.rb)
194
193
 
195
- A TypeMap defines which value will be converted by which encoder/decoder.
194
+ A PG::TypeMap defines which value will be converted by which encoder/decoder.
196
195
  There are different type map strategies, implemented by several derivations
197
196
  of this class. They can be chosen and configured according to the particular
198
197
  needs for type casting. The default type map is PG::TypeMapAllStrings.
data/Rakefile CHANGED
@@ -74,7 +74,7 @@ Rake::ExtensionTask.new do |ext|
74
74
  # Activate current cross compiled platform only.
75
75
  # This is to work around the issue that `linux` platform is selected in `linux-musl` image.
76
76
  ext.cross_platform = CrossLibraries.map(&:platform).select do |pl|
77
- m = ENV["RCD_IMAGE"]&.match(/:(?<ruby_ver>[\d\.]+)-mri-(?<platform>[-\w]+)$/)
77
+ m = ENV["RCD_IMAGE"]&.match(/:(?<ruby_ver>[\w\.]+)-mri-(?<platform>[-\w]+)$/)
78
78
  m && m[:platform] == pl
79
79
  end
80
80
 
@@ -106,7 +106,7 @@ task 'gem:native:prepare' do
106
106
  # Copy gem signing key and certs to be accessible from the docker container
107
107
  mkdir_p 'build/gem'
108
108
  sh "cp ~/.gem/gem-*.pem build/gem/ || true"
109
- sh "bundle package"
109
+ sh "bundle package --all"
110
110
  begin
111
111
  OpenSSL::PKey.read(File.read(File.expand_path("~/.gem/gem-private_key.pem")), ENV["GEM_PRIVATE_KEY_PASSPHRASE"] || "")
112
112
  rescue OpenSSL::PKey::PKeyError
@@ -141,7 +141,7 @@ CrossLibraries.each do |xlib|
141
141
  bundle install --local &&
142
142
  #{ "rake install_darwin_mig[__arm64__]" if platform =~ /arm64-darwin/ }
143
143
  #{ "rake install_darwin_mig[__x86_64__]" if platform =~ /x86_64-darwin/ }
144
- rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKEOPTS=-j`nproc` RUBY_CC_VERSION=#{RakeCompilerDock.ruby_cc_version("~>2.7", "~>3.0")}
144
+ rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKEFLAGS="-j`nproc` V=1" RUBY_CC_VERSION=#{RakeCompilerDock.ruby_cc_version("~>2.7", "~>3.0")}
145
145
  EOT
146
146
  end
147
147
  desc "Build the native binary gems"
data/ext/extconf.rb CHANGED
@@ -27,13 +27,13 @@ if gem_platform=with_config("cross-build")
27
27
  gem 'mini_portile2', '~>2.1'
28
28
  require 'mini_portile2'
29
29
 
30
- OPENSSL_VERSION = ENV['OPENSSL_VERSION'] || '3.5.1'
30
+ OPENSSL_VERSION = ENV['OPENSSL_VERSION'] || '3.5.2'
31
31
  OPENSSL_SOURCE_URI = "http://www.openssl.org/source/openssl-#{OPENSSL_VERSION}.tar.gz"
32
32
 
33
- KRB5_VERSION = ENV['KRB5_VERSION'] || '1.21.3'
33
+ KRB5_VERSION = ENV['KRB5_VERSION'] || '1.22.1'
34
34
  KRB5_SOURCE_URI = "http://kerberos.org/dist/krb5/#{KRB5_VERSION[/^(\d+\.\d+)/]}/krb5-#{KRB5_VERSION}.tar.gz"
35
35
 
36
- POSTGRESQL_VERSION = ENV['POSTGRESQL_VERSION'] || '17.5'
36
+ POSTGRESQL_VERSION = ENV['POSTGRESQL_VERSION'] || '17.6'
37
37
  POSTGRESQL_SOURCE_URI = "http://ftp.postgresql.org/pub/source/v#{POSTGRESQL_VERSION}/postgresql-#{POSTGRESQL_VERSION}.tar.bz2"
38
38
 
39
39
  class BuildRecipe < MiniPortile
@@ -49,6 +49,12 @@ if gem_platform=with_config("cross-build")
49
49
  "#{target}/#{RUBY_PLATFORM}"
50
50
  end
51
51
 
52
+ # Add "--prefix=/", to avoid our actual build install path compiled into the binary.
53
+ # Instead use DESTDIR variable of make to set our install path.
54
+ def configure_prefix
55
+ "--prefix="
56
+ end
57
+
52
58
  def cook_and_activate
53
59
  checkpoint = File.join(self.target, "#{self.name}-#{self.version}-#{RUBY_PLATFORM}.installed")
54
60
  unless File.exist?(checkpoint)
@@ -70,13 +76,13 @@ if gem_platform=with_config("cross-build")
70
76
  envs = []
71
77
  envs << "CFLAGS=-DDSO_WIN32 -DOPENSSL_THREADS" if RUBY_PLATFORM =~ /mingw|mswin/
72
78
  envs << "CFLAGS=-fPIC -DOPENSSL_THREADS" if RUBY_PLATFORM =~ /linux|darwin/
73
- execute('configure', ['env', *envs, "./Configure", openssl_platform, "threads", "-static", "CROSS_COMPILE=#{host}-", configure_prefix], altlog: "config.log")
79
+ execute('configure', ['env', *envs, "./Configure", openssl_platform, "threads", "-static", "CROSS_COMPILE=#{host}-", "--prefix=/"], altlog: "config.log")
74
80
  end
75
81
  def compile
76
82
  execute('compile', "#{make_cmd} build_libs")
77
83
  end
78
84
  def install
79
- execute('install', "#{make_cmd} install_dev")
85
+ execute('install', "#{make_cmd} install_dev DESTDIR=#{path}")
80
86
  end
81
87
  end
82
88
 
@@ -104,6 +110,9 @@ if gem_platform=with_config("cross-build")
104
110
  end
105
111
  super
106
112
  end
113
+ def install
114
+ execute('install', "#{make_cmd} install DESTDIR=#{path}")
115
+ end
107
116
  end
108
117
  # We specify -fcommon to get around duplicate definition errors in recent gcc.
109
118
  # See https://github.com/cockroachdb/cockroach/issues/49734
@@ -112,6 +121,7 @@ if gem_platform=with_config("cross-build")
112
121
  recipe.configure_options << "--without-keyutils"
113
122
  recipe.configure_options << "--disable-nls"
114
123
  recipe.configure_options << "--disable-silent-rules"
124
+ recipe.configure_options << "--disable-rpath"
115
125
  recipe.configure_options << "--without-system-verto"
116
126
  recipe.configure_options << "krb5_cv_attr_constructor_destructor=yes"
117
127
  recipe.configure_options << "ac_cv_func_regcomp=yes"
@@ -146,12 +156,13 @@ if gem_platform=with_config("cross-build")
146
156
  '--without-zlib',
147
157
  '--without-icu',
148
158
  '--without-readline',
159
+ '--disable-rpath',
149
160
  'ac_cv_search_gss_store_cred_into=',
150
161
  ]
151
162
  end
152
163
  def compile
153
- execute 'compile include', "#{make_cmd} -C src/include install"
154
- execute 'compile interfaces', "#{make_cmd} -C src/interfaces install"
164
+ execute 'compile include', "#{make_cmd} -C src/include install DESTDIR=#{path}"
165
+ execute 'compile interfaces', "#{make_cmd} -C src/interfaces install DESTDIR=#{path}"
155
166
  end
156
167
  def install
157
168
  end
@@ -169,6 +180,9 @@ if gem_platform=with_config("cross-build")
169
180
  # Use our own library name for libpq to avoid loading of system libpq by accident.
170
181
  FileUtils.ln_sf File.join(postgresql_recipe.port_path, "lib/#{libpq_orig}"),
171
182
  File.join(postgresql_recipe.port_path, "lib/#{libpq_rubypg}")
183
+ # Link to libpq_rubypg in our ports directory without adding it as rpath (like dir_config does)
184
+ $CFLAGS << " -I#{postgresql_recipe.path}/include"
185
+ $LDFLAGS << " -L#{postgresql_recipe.path}/lib"
172
186
  # Avoid dependency to external libgcc.dll on x86-mingw32
173
187
  $LDFLAGS << " -static-libgcc" if RUBY_PLATFORM =~ /mingw|mswin/
174
188
  # Avoid: "libpq.so: undefined reference to `dlopen'" in cross-ruby-2.7.8
@@ -176,8 +190,6 @@ if gem_platform=with_config("cross-build")
176
190
  # Find libpq in the ports directory coming from lib/3.x
177
191
  # It is shared between all compiled ruby versions.
178
192
  $LDFLAGS << " '-Wl,-rpath=$$ORIGIN/../../ports/#{gem_platform}/lib'" if RUBY_PLATFORM =~ /linux/
179
- # Don't use pg_config for cross build, but --with-pg-* path options
180
- dir_config('pg', "#{postgresql_recipe.path}/include", "#{postgresql_recipe.path}/lib")
181
193
 
182
194
  $defs.push( "-DPG_IS_BINARY_GEM")
183
195
  else
@@ -318,3 +330,20 @@ end
318
330
  create_header()
319
331
  create_makefile( "pg_ext" )
320
332
 
333
+ if gem_platform
334
+ # exercise the strip command on native binary gems
335
+ # This approach borrowed from
336
+ # https://github.com/rake-compiler/rake-compiler-dock/blob/38066d479050f4fdb3956469255b35a05e5949ef/test/rcd_test/ext/mri/extconf.rb#L97C1-L110C42
337
+ strip_tool = RbConfig::CONFIG['STRIP']
338
+ strip_tool += ' -x' if RUBY_PLATFORM =~ /darwin/
339
+ File.open('Makefile.new', 'w') do |o|
340
+ o.puts 'hijack: all strip'
341
+ o.puts
342
+ o.write(File.read('Makefile'))
343
+ o.puts
344
+ o.puts 'strip: $(DLLIB)'
345
+ o.puts "\t$(ECHO) Stripping $(DLLIB)"
346
+ o.puts "\t$(Q) #{strip_tool} $(DLLIB)"
347
+ end
348
+ File.rename('Makefile.new', 'Makefile')
349
+ end
@@ -117,7 +117,7 @@ pg_bin_dec_to_base64(t_pg_coder *conv, const char *val, int len, int tuple, int
117
117
  /* create a buffer of the encoded length */
118
118
  VALUE out_value = rb_str_new(NULL, encoded_len);
119
119
 
120
- base64_encode( RSTRING_PTR(out_value), val, len );
120
+ rbpg_base64_encode( RSTRING_PTR(out_value), val, len );
121
121
 
122
122
  /* Is it a pure String conversion? Then we can directly send out_value to the user. */
123
123
  if( this->comp.format == 0 && dec_func == pg_text_dec_string ){
@@ -524,7 +524,7 @@ pg_bin_enc_from_base64(t_pg_coder *conv, VALUE value, char *out, VALUE *intermed
524
524
  if(out){
525
525
  /* Second encoder pass, if required */
526
526
  strlen = enc_func(this->elem, value, out, intermediate, enc_idx);
527
- strlen = base64_decode( out, out, strlen );
527
+ strlen = rbpg_base64_decode( out, out, strlen );
528
528
 
529
529
  return strlen;
530
530
  } else {
@@ -538,7 +538,7 @@ pg_bin_enc_from_base64(t_pg_coder *conv, VALUE value, char *out, VALUE *intermed
538
538
  strlen = RSTRING_LENINT(subint);
539
539
  out_str = rb_str_new(NULL, BASE64_DECODED_SIZE(strlen));
540
540
 
541
- strlen = base64_decode( RSTRING_PTR(out_str), RSTRING_PTR(subint), strlen);
541
+ strlen = rbpg_base64_decode( RSTRING_PTR(out_str), RSTRING_PTR(subint), strlen);
542
542
  rb_str_set_len( out_str, strlen );
543
543
  *intermediate = out_str;
544
544
 
data/ext/pg_result.c CHANGED
@@ -617,7 +617,7 @@ pgresult_error_message(VALUE self)
617
617
  * call-seq:
618
618
  * res.verbose_error_message( verbosity, show_context ) -> String
619
619
  *
620
- * Returns a reformatted version of the error message associated with a PGresult object.
620
+ * Returns a reformatted version of the error message associated with the PG::Result object.
621
621
  *
622
622
  */
623
623
  static VALUE
@@ -734,9 +734,9 @@ pgresult_nfields(VALUE self)
734
734
  * call-seq:
735
735
  * res.binary_tuples() -> Integer
736
736
  *
737
- * Returns 1 if the PGresult contains binary data and 0 if it contains text data.
737
+ * Returns 1 if the PG::Result contains binary data and 0 if it contains text data.
738
738
  *
739
- * This function is deprecated (except for its use in connection with COPY), because it is possible for a single PGresult to contain text data in some columns and binary data in others.
739
+ * This function is deprecated (except for its use in connection with COPY), because it is possible for a single PG::Result to contain text data in some columns and binary data in others.
740
740
  * Result#fformat is preferred. binary_tuples returns 1 only if all columns of the result are binary (format 1).
741
741
  */
742
742
  static VALUE
@@ -1402,7 +1402,7 @@ pgresult_fields(VALUE self)
1402
1402
  * call-seq:
1403
1403
  * res.type_map = typemap
1404
1404
  *
1405
- * Set the TypeMap that is used for type casts of result values to ruby objects.
1405
+ * Set the PG::TypeMap that is used for type casts of result values to ruby objects.
1406
1406
  *
1407
1407
  * All value retrieval methods will respect the type map and will do the
1408
1408
  * type casts from PostgreSQL's wire format to Ruby objects on the fly,
@@ -1432,7 +1432,7 @@ pgresult_type_map_set(VALUE self, VALUE typemap)
1432
1432
  * call-seq:
1433
1433
  * res.type_map -> value
1434
1434
  *
1435
- * Returns the TypeMap that is currently set for type casts of result values to ruby objects.
1435
+ * Returns the PG::TypeMap that is currently set for type casts of result values to ruby objects.
1436
1436
  *
1437
1437
  */
1438
1438
  static VALUE
@@ -1572,8 +1572,8 @@ pgresult_stream_any(VALUE self, int (*yielder)(VALUE, int, int, void*), void* da
1572
1572
  * wrapping each row into a dedicated result object, it delivers data in nearly
1573
1573
  * the same speed as with ordinary results.
1574
1574
  *
1575
- * The base result must be in status PGRES_SINGLE_TUPLE or PGRES_TUPLES_CHUNK.
1576
- * It iterates over all tuples until the status changes to PGRES_TUPLES_OK.
1575
+ * The base result must be in status +PGRES_SINGLE_TUPLE+ or +PGRES_TUPLES_CHUNK+.
1576
+ * It iterates over all tuples until the status changes to +PGRES_TUPLES_OK+.
1577
1577
  * A PG::Error is raised for any errors from the server.
1578
1578
  *
1579
1579
  * Row description data does not change while the iteration. All value retrieval
@@ -579,7 +579,7 @@ pg_text_dec_from_base64(t_pg_coder *conv, const char *val, int len, int tuple, i
579
579
  /* create a buffer of the expected decoded length */
580
580
  VALUE out_value = rb_str_new(NULL, BASE64_DECODED_SIZE(len));
581
581
 
582
- decoded_len = base64_decode( RSTRING_PTR(out_value), val, len );
582
+ decoded_len = rbpg_base64_decode( RSTRING_PTR(out_value), val, len );
583
583
  rb_str_set_len(out_value, decoded_len);
584
584
 
585
585
  /* Is it a pure String conversion? Then we can directly send out_value to the user. */
@@ -784,7 +784,7 @@ pg_text_enc_to_base64(t_pg_coder *conv, VALUE value, char *out, VALUE *intermedi
784
784
  if(out){
785
785
  /* Second encoder pass, if required */
786
786
  strlen = enc_func(this->elem, value, out, intermediate, enc_idx);
787
- base64_encode( out, out, strlen );
787
+ rbpg_base64_encode( out, out, strlen );
788
788
 
789
789
  return BASE64_ENCODED_SIZE(strlen);
790
790
  } else {
@@ -799,7 +799,7 @@ pg_text_enc_to_base64(t_pg_coder *conv, VALUE value, char *out, VALUE *intermedi
799
799
  out_str = rb_str_new(NULL, BASE64_ENCODED_SIZE(strlen));
800
800
  PG_ENCODING_SET_NOCHECK(out_str, enc_idx);
801
801
 
802
- base64_encode( RSTRING_PTR(out_str), RSTRING_PTR(subint), strlen);
802
+ rbpg_base64_encode( RSTRING_PTR(out_str), RSTRING_PTR(subint), strlen);
803
803
  *intermediate = out_str;
804
804
 
805
805
  return -1;
data/ext/pg_tuple.c CHANGED
@@ -242,10 +242,10 @@ pg_tuple_materialize(VALUE self)
242
242
  * An integer +key+ is interpreted as column index.
243
243
  * Negative values of index count from the end of the array.
244
244
  *
245
- * Depending on Result#field_name_type= a string or symbol +key+ is interpreted as column name.
245
+ * Depending on PG::Result#field_name_type= a string or symbol +key+ is interpreted as column name.
246
246
  *
247
247
  * If the key can't be found, there are several options:
248
- * With no other arguments, it will raise a IndexError exception;
248
+ * With no other arguments, it will raise a +IndexError+ exception;
249
249
  * if default is given, then that will be returned;
250
250
  * if the optional code block is specified, then that will be run and its result returned.
251
251
  */
@@ -302,7 +302,7 @@ pg_tuple_fetch(int argc, VALUE *argv, VALUE self)
302
302
  * An integer +key+ is interpreted as column index.
303
303
  * Negative values of index count from the end of the array.
304
304
  *
305
- * Depending on Result#field_name_type= a string or symbol +key+ is interpreted as column name.
305
+ * Depending on PG::Result#field_name_type= a string or symbol +key+ is interpreted as column name.
306
306
  *
307
307
  * If the key can't be found, it returns +nil+ .
308
308
  */
@@ -405,7 +405,7 @@ pg_tuple_each_value(VALUE self)
405
405
  * tup.values -> Array
406
406
  *
407
407
  * Returns the values of this tuple as Array.
408
- * +res.tuple(i).values+ is equal to +res.tuple_values(i)+ .
408
+ * <tt>res.tuple(i).values</tt> is equal to <tt>res.tuple_values(i)</tt> .
409
409
  */
410
410
  static VALUE
411
411
  pg_tuple_values(VALUE self)
@@ -474,7 +474,7 @@ pg_tuple_dump(VALUE self)
474
474
  values = rb_ary_new4(this->num_fields, &this->values[0]);
475
475
  a = rb_ary_new3(2, field_names, values);
476
476
 
477
- rb_copy_generic_ivar(a, self);
477
+ rb_copy_generic_ivar(a, self);
478
478
 
479
479
  return a;
480
480
  }
data/ext/pg_type_map.c CHANGED
@@ -187,7 +187,9 @@ init_pg_type_map(void)
187
187
  *
188
188
  * This is the base class for type maps.
189
189
  * See derived classes for implementations of different type cast strategies
190
- * ( PG::TypeMapByColumn, PG::TypeMapByOid ).
190
+ * ( PG::TypeMapByColumn, PG::TypeMapByOid, etc.).
191
+ *
192
+ * Find more type maps in the {README}[rdoc-ref:README.md@Type+Casts].
191
193
  *
192
194
  */
193
195
  rb_cTypeMap = rb_define_class_under( rb_mPG, "TypeMap", rb_cObject );
data/ext/pg_util.c CHANGED
@@ -15,7 +15,7 @@ static const char base64_encode_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijk
15
15
  * in-place (with _out_ == _in_).
16
16
  */
17
17
  void
18
- base64_encode( char *out, const char *in, int len)
18
+ rbpg_base64_encode( char *out, const char *in, int len)
19
19
  {
20
20
  const unsigned char *in_ptr = (const unsigned char *)in + len;
21
21
  char *out_ptr = out + BASE64_ENCODED_SIZE(len);
@@ -72,7 +72,7 @@ static const unsigned char base64_decode_table[] =
72
72
  * It is possible to decode a string in-place (with _out_ == _in_).
73
73
  */
74
74
  int
75
- base64_decode( char *out, const char *in, unsigned int len)
75
+ rbpg_base64_decode( char *out, const char *in, unsigned int len)
76
76
  {
77
77
  unsigned char a, b, c, d;
78
78
  const unsigned char *in_ptr = (const unsigned char *)in;
data/ext/pg_util.h CHANGED
@@ -57,8 +57,8 @@
57
57
  #define BASE64_ENCODED_SIZE(strlen) (((strlen) + 2) / 3 * 4)
58
58
  #define BASE64_DECODED_SIZE(base64len) (((base64len) + 3) / 4 * 3)
59
59
 
60
- void base64_encode( char *out, const char *in, int len);
61
- int base64_decode( char *out, const char *in, unsigned int len);
60
+ void rbpg_base64_encode( char *out, const char *in, int len);
61
+ int rbpg_base64_decode( char *out, const char *in, unsigned int len);
62
62
 
63
63
  int rbpg_strncasecmp(const char *s1, const char *s2, size_t n);
64
64
 
data/lib/pg/version.rb CHANGED
@@ -1,4 +1,5 @@
1
+ # frozen_string_literal: true
1
2
  module PG
2
3
  # Library version
3
- VERSION = '1.6.1'
4
+ VERSION = '1.6.2'
4
5
  end
data/lib/pg.rb CHANGED
@@ -5,140 +5,161 @@
5
5
  # The top-level PG namespace.
6
6
  module PG
7
7
 
8
- # Is this file part of a fat binary gem with bundled libpq?
9
- # This path must be enabled by add_dll_directory on Windows.
10
- gplat = Gem::Platform.local
11
- bundled_libpq_path = Dir[File.expand_path("../ports/#{gplat.cpu}-#{gplat.os}*/lib", __dir__)].first
12
- if bundled_libpq_path
13
- POSTGRESQL_LIB_PATH = bundled_libpq_path
14
- else
15
- # Try to load libpq path as found by extconf.rb
16
- begin
17
- require "pg/postgresql_lib_path"
18
- rescue LoadError
19
- # rake-compiler doesn't use regular "make install", but uses it's own install tasks.
20
- # It therefore doesn't copy pg/postgresql_lib_path.rb in case of "rake compile".
21
- POSTGRESQL_LIB_PATH = false
22
- end
23
- end
24
-
25
- add_dll_path = proc do |path, &block|
26
- if RUBY_PLATFORM =~/(mswin|mingw)/i && path
27
- BUNDLED_LIBPQ_WITH_UNIXSOCKET = false
28
- begin
29
- require 'ruby_installer/runtime'
30
- RubyInstaller::Runtime.add_dll_directory(path, &block)
31
- rescue LoadError
32
- old_path = ENV['PATH']
33
- ENV['PATH'] = "#{path};#{old_path}"
34
- block.call
35
- ENV['PATH'] = old_path
36
- end
37
- else
38
- # libpq is found by a relative rpath in the cross compiled extension dll
39
- # or by the system library loader
40
- block.call
41
- BUNDLED_LIBPQ_WITH_UNIXSOCKET = RUBY_PLATFORM=~/linux/i && PG::IS_BINARY_GEM
42
- end
43
- end
44
-
45
- # Add a load path to the one retrieved from pg_config
46
- add_dll_path.call(POSTGRESQL_LIB_PATH) do
47
- begin
48
- # Try the <major>.<minor> subdirectory for fat binary gems
49
- major_minor = RUBY_VERSION[ /^(\d+\.\d+)/ ] or
50
- raise "Oops, can't extract the major/minor version from #{RUBY_VERSION.dump}"
51
- require "#{major_minor}/pg_ext"
52
- rescue LoadError
53
- require 'pg_ext'
54
- end
55
- end
56
-
57
- # Get the PG library version.
58
- #
59
- # +include_buildnum+ is no longer used and any value passed will be ignored.
60
- def self.version_string( include_buildnum=nil )
61
- "%s %s" % [ self.name, VERSION ]
62
- end
63
-
64
-
65
- ### Convenience alias for PG::Connection.new.
66
- def self.connect( *args, &block )
67
- Connection.new( *args, &block )
68
- end
69
-
70
- if defined?(Ractor.make_shareable)
71
- def self.make_shareable(obj)
72
- Ractor.make_shareable(obj)
73
- end
74
- else
75
- def self.make_shareable(obj)
76
- obj.freeze
77
- end
78
- end
79
-
80
- module BinaryDecoder
81
- %i[ TimestampUtc TimestampUtcToLocal TimestampLocal ].each do |klass|
82
- autoload klass, 'pg/binary_decoder/timestamp'
83
- end
84
- autoload :Date, 'pg/binary_decoder/date'
85
- end
86
- module BinaryEncoder
87
- %i[ TimestampUtc TimestampLocal ].each do |klass|
88
- autoload klass, 'pg/binary_encoder/timestamp'
89
- end
90
- end
91
- module TextDecoder
92
- %i[ TimestampUtc TimestampUtcToLocal TimestampLocal TimestampWithoutTimeZone TimestampWithTimeZone ].each do |klass|
93
- autoload klass, 'pg/text_decoder/timestamp'
94
- end
95
- autoload :Date, 'pg/text_decoder/date'
96
- autoload :Inet, 'pg/text_decoder/inet'
97
- autoload :JSON, 'pg/text_decoder/json'
98
- autoload :Numeric, 'pg/text_decoder/numeric'
99
- end
100
- module TextEncoder
101
- %i[ TimestampUtc TimestampWithoutTimeZone TimestampWithTimeZone ].each do |klass|
102
- autoload klass, 'pg/text_encoder/timestamp'
103
- end
104
- autoload :Date, 'pg/text_encoder/date'
105
- autoload :Inet, 'pg/text_encoder/inet'
106
- autoload :JSON, 'pg/text_encoder/json'
107
- autoload :Numeric, 'pg/text_encoder/numeric'
108
- end
109
-
110
- autoload :BasicTypeMapBasedOnResult, 'pg/basic_type_map_based_on_result'
111
- autoload :BasicTypeMapForQueries, 'pg/basic_type_map_for_queries'
112
- autoload :BasicTypeMapForResults, 'pg/basic_type_map_for_results'
113
- autoload :BasicTypeRegistry, 'pg/basic_type_registry'
114
- require 'pg/exceptions'
115
- require 'pg/coder'
116
- require 'pg/type_map_by_column'
117
- require 'pg/connection'
118
- require 'pg/cancel_connection'
119
- require 'pg/result'
120
- require 'pg/tuple'
121
- autoload :VERSION, 'pg/version'
122
-
123
-
124
- # Avoid "uninitialized constant Truffle::WarningOperations" on Truffleruby up to 22.3.1
125
- if RUBY_ENGINE=="truffleruby" && !defined?(Truffle::WarningOperations)
126
- module TruffleFixWarn
127
- def warn(str, category=nil)
128
- super(str)
129
- end
130
- end
131
- Warning.extend(TruffleFixWarn)
132
- end
133
-
134
- # Ruby-3.4+ prints a warning, if bigdecimal is required but not in the Gemfile.
135
- # But it's a false positive, since we enable bigdecimal depending features only if it's available.
136
- # And most people don't need these features.
137
- def self.require_bigdecimal_without_warning
138
- oldverb, $VERBOSE = $VERBOSE, nil
139
- require "bigdecimal"
140
- ensure
141
- $VERBOSE = oldverb
142
- end
8
+ # Is this file part of a fat binary gem with bundled libpq?
9
+ # This path must be enabled by add_dll_directory on Windows.
10
+ gplat = Gem::Platform.local
11
+ bundled_libpq_path = Dir[File.expand_path("../ports/#{gplat.cpu}-#{gplat.os}*/lib", __dir__)].first
12
+ if bundled_libpq_path
13
+ POSTGRESQL_LIB_PATH = bundled_libpq_path
14
+ else
15
+ # Try to load libpq path as found by extconf.rb
16
+ begin
17
+ require "pg/postgresql_lib_path"
18
+ rescue LoadError
19
+ # rake-compiler doesn't use regular "make install", but uses it's own install tasks.
20
+ # It therefore doesn't copy pg/postgresql_lib_path.rb in case of "rake compile".
21
+ POSTGRESQL_LIB_PATH = false
22
+ end
23
+ end
24
+ POSTGRESQL_LIB_PATH.freeze
25
+
26
+ add_dll_path = proc do |path, &block|
27
+ if RUBY_PLATFORM =~/(mswin|mingw)/i && path
28
+ BUNDLED_LIBPQ_WITH_UNIXSOCKET = false
29
+ begin
30
+ require 'ruby_installer/runtime'
31
+ RubyInstaller::Runtime.add_dll_directory(path, &block)
32
+ rescue LoadError
33
+ old_path = ENV['PATH']
34
+ ENV['PATH'] = "#{path};#{old_path}"
35
+ block.call
36
+ ENV['PATH'] = old_path
37
+ end
38
+ else
39
+ # libpq is found by a relative rpath in the cross compiled extension dll
40
+ # or by the system library loader
41
+ block.call
42
+ BUNDLED_LIBPQ_WITH_UNIXSOCKET = RUBY_PLATFORM=~/linux/i && PG::IS_BINARY_GEM
43
+ end
44
+ end
45
+
46
+ # Add a load path to the one retrieved from pg_config
47
+ add_dll_path.call(POSTGRESQL_LIB_PATH) do
48
+ begin
49
+ # Try the <major>.<minor> subdirectory for fat binary gems
50
+ major_minor = RUBY_VERSION[ /^(\d+\.\d+)/ ] or
51
+ raise "Oops, can't extract the major/minor version from #{RUBY_VERSION.dump}"
52
+ require "#{major_minor}/pg_ext"
53
+ rescue LoadError => error1
54
+ begin
55
+ require 'pg_ext'
56
+ rescue LoadError => error2
57
+ msg = <<~EOT
58
+ pg's C extension failed to load:
59
+ #{error1}
60
+ #{error2}
61
+ EOT
62
+ if msg =~ /GLIBC/
63
+ msg += <<~EOT
64
+
65
+ The GLIBC version of this system seems too old. Please use the source version of pg:
66
+ gem uninstall pg --all
67
+ gem install pg --platform ruby
68
+ or in your Gemfile:
69
+ gem "pg", force_ruby_platform: true
70
+ See also: https://deveiate.org/code/pg/README_md.html#label-Source+gem
71
+ EOT
72
+ end
73
+ raise error2, msg
74
+ end
75
+ end
76
+ end
77
+
78
+ # Get the PG library version.
79
+ #
80
+ # +include_buildnum+ is no longer used and any value passed will be ignored.
81
+ def self.version_string( include_buildnum=nil )
82
+ "%s %s" % [ self.name, VERSION ]
83
+ end
84
+
85
+
86
+ ### Convenience alias for PG::Connection.new.
87
+ def self.connect( *args, &block )
88
+ Connection.new( *args, &block )
89
+ end
90
+
91
+ if defined?(Ractor.make_shareable)
92
+ def self.make_shareable(obj)
93
+ Ractor.make_shareable(obj)
94
+ end
95
+ else
96
+ def self.make_shareable(obj)
97
+ obj.freeze
98
+ end
99
+ end
100
+
101
+ module BinaryDecoder
102
+ %i[ TimestampUtc TimestampUtcToLocal TimestampLocal ].each do |klass|
103
+ autoload klass, 'pg/binary_decoder/timestamp'
104
+ end
105
+ autoload :Date, 'pg/binary_decoder/date'
106
+ end
107
+ module BinaryEncoder
108
+ %i[ TimestampUtc TimestampLocal ].each do |klass|
109
+ autoload klass, 'pg/binary_encoder/timestamp'
110
+ end
111
+ end
112
+ module TextDecoder
113
+ %i[ TimestampUtc TimestampUtcToLocal TimestampLocal TimestampWithoutTimeZone TimestampWithTimeZone ].each do |klass|
114
+ autoload klass, 'pg/text_decoder/timestamp'
115
+ end
116
+ autoload :Date, 'pg/text_decoder/date'
117
+ autoload :Inet, 'pg/text_decoder/inet'
118
+ autoload :JSON, 'pg/text_decoder/json'
119
+ autoload :Numeric, 'pg/text_decoder/numeric'
120
+ end
121
+ module TextEncoder
122
+ %i[ TimestampUtc TimestampWithoutTimeZone TimestampWithTimeZone ].each do |klass|
123
+ autoload klass, 'pg/text_encoder/timestamp'
124
+ end
125
+ autoload :Date, 'pg/text_encoder/date'
126
+ autoload :Inet, 'pg/text_encoder/inet'
127
+ autoload :JSON, 'pg/text_encoder/json'
128
+ autoload :Numeric, 'pg/text_encoder/numeric'
129
+ end
130
+
131
+ autoload :BasicTypeMapBasedOnResult, 'pg/basic_type_map_based_on_result'
132
+ autoload :BasicTypeMapForQueries, 'pg/basic_type_map_for_queries'
133
+ autoload :BasicTypeMapForResults, 'pg/basic_type_map_for_results'
134
+ autoload :BasicTypeRegistry, 'pg/basic_type_registry'
135
+ require 'pg/exceptions'
136
+ require 'pg/coder'
137
+ require 'pg/type_map_by_column'
138
+ require 'pg/connection'
139
+ require 'pg/cancel_connection'
140
+ require 'pg/result'
141
+ require 'pg/tuple'
142
+ autoload :VERSION, 'pg/version'
143
+
144
+
145
+ # Avoid "uninitialized constant Truffle::WarningOperations" on Truffleruby up to 22.3.1
146
+ if RUBY_ENGINE=="truffleruby" && !defined?(Truffle::WarningOperations)
147
+ module TruffleFixWarn
148
+ def warn(str, category=nil)
149
+ super(str)
150
+ end
151
+ end
152
+ Warning.extend(TruffleFixWarn)
153
+ end
154
+
155
+ # Ruby-3.4+ prints a warning, if bigdecimal is required but not in the Gemfile.
156
+ # But it's a false positive, since we enable bigdecimal depending features only if it's available.
157
+ # And most people don't need these features.
158
+ def self.require_bigdecimal_without_warning
159
+ oldverb, $VERBOSE = $VERBOSE, nil
160
+ require "bigdecimal"
161
+ ensure
162
+ $VERBOSE = oldverb
163
+ end
143
164
 
144
165
  end # module PG
@@ -0,0 +1,20 @@
1
+ FROM debian:10.13
2
+
3
+ WORKDIR /pg
4
+
5
+ # Debian 10.13 is EOL now:
6
+ RUN sed -i s/deb.debian.org/archive.debian.org/g /etc/apt/sources.list
7
+
8
+ RUN apt-get update && apt-get install ruby git wget gcc make libz-dev libffi-dev libreadline-dev libyaml-dev libssl-dev -y
9
+
10
+ ENV RBENV_ROOT=/usr/local/rbenv
11
+
12
+ RUN git clone https://github.com/rbenv/rbenv.git ${RBENV_ROOT} && \
13
+ git clone https://github.com/rbenv/ruby-build.git ${RBENV_ROOT}/plugins/ruby-build && \
14
+ $RBENV_ROOT/bin/rbenv init
15
+
16
+ RUN $RBENV_ROOT/bin/rbenv install 3.3.9 -- --disable-install-doc
17
+ RUN /usr/local/rbenv/versions/3.3.9/bin/gem inst rspec
18
+
19
+ CMD /usr/local/rbenv/versions/3.3.9/bin/gem inst --local pg-*.gem && \
20
+ /usr/local/rbenv/versions/3.3.9/bin/rspec glibc_spec.rb
@@ -0,0 +1,9 @@
1
+ services:
2
+ pg:
3
+ build:
4
+ context: .
5
+ args:
6
+ - http_proxy
7
+ - https_proxy
8
+ volumes:
9
+ - .:/pg
@@ -0,0 +1,5 @@
1
+ RSpec.describe "require 'pg'" do
2
+ it "gives a descriptive error message when GLIBC is too old" do
3
+ expect { require "pg" }.to raise_error(/GLIBC.*gem install pg --platform ruby/m)
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ diff --git a/src/lib/krb5/krb/deltat.c b/src/lib/krb5/krb/deltat.c
2
+ index 03145c854..34cdf969e 100644
3
+ --- a/lib/krb5/krb/deltat.c
4
+ +++ b/lib/krb5/krb/deltat.c
5
+ @@ -44,7 +44,6 @@
6
+ #ifdef __GNUC__
7
+ #pragma GCC diagnostic push
8
+ #pragma GCC diagnostic ignored "-Wuninitialized"
9
+ -#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
10
+ #endif
11
+
12
+ #include "k5-int.h"
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.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -176,6 +176,9 @@ files:
176
176
  - lib/pg/tuple.rb
177
177
  - lib/pg/type_map_by_column.rb
178
178
  - lib/pg/version.rb
179
+ - misc/glibc/Dockerfile
180
+ - misc/glibc/docker-compose.yml
181
+ - misc/glibc/glibc_spec.rb
179
182
  - misc/openssl-pg-segfault.rb
180
183
  - misc/postgres/History.txt
181
184
  - misc/postgres/Manifest.txt
@@ -191,10 +194,11 @@ files:
191
194
  - misc/yugabyte/docker-compose.yml
192
195
  - misc/yugabyte/pg-test.rb
193
196
  - pg.gemspec
194
- - ports/patches/krb5/1.21.3/0001-Allow-static-linking-krb5-library.patch
195
- - ports/patches/openssl/3.5.1/0001-aarch64-mingw.patch
196
- - ports/patches/postgresql/17.5/0001-Use-workaround-of-__builtin_setjmp-only-on-MINGW-on-.patch
197
- - ports/patches/postgresql/17.5/0001-libpq-Process-buffered-SSL-read-bytes-to-support-rec.patch
197
+ - ports/patches/krb5/1.22.1/0001-Allow-static-linking-krb5-library.patch
198
+ - ports/patches/krb5/1.22.1/0002-unknown-command-line-option-on-clang.patch
199
+ - ports/patches/openssl/3.5.2/0001-aarch64-mingw.patch
200
+ - ports/patches/postgresql/17.6/0001-Use-workaround-of-__builtin_setjmp-only-on-MINGW-on-.patch
201
+ - ports/patches/postgresql/17.6/0001-libpq-Process-buffered-SSL-read-bytes-to-support-rec.patch
198
202
  - rakelib/pg_gem_helper.rb
199
203
  - rakelib/task_extension.rb
200
204
  - sample/array_insert.rb
@@ -243,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
247
  - !ruby/object:Gem::Version
244
248
  version: '0'
245
249
  requirements: []
246
- rubygems_version: 3.7.1
250
+ rubygems_version: 3.6.9
247
251
  specification_version: 4
248
252
  summary: Pg is the Ruby interface to the PostgreSQL RDBMS
249
253
  test_files: []
metadata.gz.sig CHANGED
Binary file