pg 1.4.6 → 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 (92) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/{History.md → CHANGELOG.md} +185 -3
  4. data/Gemfile +12 -3
  5. data/README-Windows.rdoc +1 -1
  6. data/README.ja.md +75 -41
  7. data/README.md +86 -31
  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 +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 +70 -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 +18 -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
data/lib/pg/exceptions.rb CHANGED
@@ -21,5 +21,11 @@ module PG
21
21
  class NotInBlockingMode < PG::Error
22
22
  end
23
23
 
24
+ # PG::Connection#transaction uses this exception to distinguish a deliberate rollback from other exceptional situations.
25
+ # Normally, raising an exception will cause the .transaction method to rollback the database transaction and pass on the exception.
26
+ # But if you raise an PG::RollbackTransaction exception, then the database transaction will be rolled back, without passing on the exception.
27
+ class RollbackTransaction < StandardError
28
+ end
29
+
24
30
  end # module PG
25
31
 
@@ -0,0 +1,21 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ require 'date'
5
+
6
+ module PG
7
+ module TextDecoder
8
+ # This is a decoder class for conversion of PostgreSQL date type to Ruby Date values.
9
+ #
10
+ # As soon as this class is used, it requires the ruby standard library 'date'.
11
+ class Date < SimpleDecoder
12
+ def decode(string, tuple=nil, field=nil)
13
+ if string =~ /\A(\d{4})-(\d\d)-(\d\d)\z/
14
+ ::Date.new $1.to_i, $2.to_i, $3.to_i
15
+ else
16
+ string
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end # module PG
@@ -0,0 +1,9 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ module PG
5
+ module TextDecoder
6
+ # Init C part of the decoder
7
+ init_inet
8
+ end
9
+ end # module PG
@@ -0,0 +1,17 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ require 'json'
5
+
6
+ module PG
7
+ module TextDecoder
8
+ # This is a decoder class for conversion of PostgreSQL JSON/JSONB type to Ruby Hash, Array, String, Numeric, nil values.
9
+ #
10
+ # As soon as this class is used, it requires the ruby standard library 'json'.
11
+ class JSON < SimpleDecoder
12
+ def decode(string, tuple=nil, field=nil)
13
+ ::JSON.parse(string, quirks_mode: true)
14
+ end
15
+ end
16
+ end
17
+ end # module PG
@@ -0,0 +1,9 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ module PG
5
+ module TextDecoder
6
+ # Init C part of the decoder
7
+ init_numeric
8
+ end
9
+ end # module PG
@@ -0,0 +1,30 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ module PG
5
+ module TextDecoder
6
+ # Convenience classes for timezone options
7
+ class TimestampUtc < Timestamp
8
+ def initialize(hash={}, **kwargs)
9
+ warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) unless hash.empty?
10
+ super(**hash, **kwargs, flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_UTC)
11
+ end
12
+ end
13
+ class TimestampUtcToLocal < Timestamp
14
+ def initialize(hash={}, **kwargs)
15
+ warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) unless hash.empty?
16
+ super(**hash, **kwargs, flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_LOCAL)
17
+ end
18
+ end
19
+ class TimestampLocal < Timestamp
20
+ def initialize(hash={}, **kwargs)
21
+ warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) unless hash.empty?
22
+ super(**hash, **kwargs, flags: PG::Coder::TIMESTAMP_DB_LOCAL | PG::Coder::TIMESTAMP_APP_LOCAL)
23
+ end
24
+ end
25
+
26
+ # For backward compatibility:
27
+ TimestampWithoutTimeZone = TimestampLocal
28
+ TimestampWithTimeZone = Timestamp
29
+ end
30
+ end # module PG
@@ -0,0 +1,13 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ module PG
5
+ module TextEncoder
6
+ # This is a encoder class for conversion of Ruby Date values to PostgreSQL date type.
7
+ class Date < SimpleEncoder
8
+ def encode(value)
9
+ value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d") : value
10
+ end
11
+ end
12
+ end
13
+ end # module PG
@@ -0,0 +1,31 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ require 'ipaddr'
5
+
6
+ module PG
7
+ module TextEncoder
8
+ # This is a encoder class for conversion of Ruby IPAddr values to PostgreSQL inet type.
9
+ #
10
+ # As soon as this class is used, it requires the ruby standard library 'ipaddr'.
11
+ class Inet < SimpleEncoder
12
+ def encode(value)
13
+ case value
14
+ when IPAddr
15
+ default_prefix = (value.family == Socket::AF_INET ? 32 : 128)
16
+ s = value.to_s
17
+ if value.respond_to?(:prefix)
18
+ prefix = value.prefix
19
+ else
20
+ range = value.to_range
21
+ prefix = default_prefix - Math.log(((range.end.to_i - range.begin.to_i) + 1), 2).to_i
22
+ end
23
+ s << "/" << prefix.to_s if prefix != default_prefix
24
+ s
25
+ else
26
+ value
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end # module PG
@@ -0,0 +1,17 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ require 'json'
5
+
6
+ module PG
7
+ module TextEncoder
8
+ # This is a encoder class for conversion of Ruby Hash, Array, String, Numeric, nil values to PostgreSQL JSON/JSONB type.
9
+ #
10
+ # As soon as this class is used, it requires the ruby standard library 'json'.
11
+ class JSON < SimpleEncoder
12
+ def encode(value)
13
+ ::JSON.generate(value, quirks_mode: true)
14
+ end
15
+ end
16
+ end
17
+ end # module PG
@@ -0,0 +1,9 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ module PG
5
+ module TextEncoder
6
+ # Init C part of the decoder
7
+ init_numeric
8
+ end
9
+ end # module PG
@@ -0,0 +1,24 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ module PG
5
+ module TextEncoder
6
+ class TimestampWithoutTimeZone < SimpleEncoder
7
+ def encode(value)
8
+ value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d %H:%M:%S.%N") : value
9
+ end
10
+ end
11
+
12
+ class TimestampUtc < SimpleEncoder
13
+ def encode(value)
14
+ value.respond_to?(:utc) ? value.utc.strftime("%Y-%m-%d %H:%M:%S.%N") : value
15
+ end
16
+ end
17
+
18
+ class TimestampWithTimeZone < SimpleEncoder
19
+ def encode(value)
20
+ value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d %H:%M:%S.%N %:z") : value
21
+ end
22
+ end
23
+ end
24
+ end # module PG
data/lib/pg/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module PG
2
2
  # Library version
3
- VERSION = '1.4.6'
3
+ VERSION = '1.6.1'
4
4
  end
data/lib/pg.rb CHANGED
@@ -6,11 +6,12 @@
6
6
  module PG
7
7
 
8
8
  # Is this file part of a fat binary gem with bundled libpq?
9
- bundled_libpq_path = File.join(__dir__, RUBY_PLATFORM.gsub(/^i386-/, "x86-"))
10
- if File.exist?(bundled_libpq_path)
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
11
13
  POSTGRESQL_LIB_PATH = bundled_libpq_path
12
14
  else
13
- bundled_libpq_path = nil
14
15
  # Try to load libpq path as found by extconf.rb
15
16
  begin
16
17
  require "pg/postgresql_lib_path"
@@ -22,7 +23,8 @@ module PG
22
23
  end
23
24
 
24
25
  add_dll_path = proc do |path, &block|
25
- if RUBY_PLATFORM =~/(mswin|mingw)/i && path && File.exist?(path)
26
+ if RUBY_PLATFORM =~/(mswin|mingw)/i && path
27
+ BUNDLED_LIBPQ_WITH_UNIXSOCKET = false
26
28
  begin
27
29
  require 'ruby_installer/runtime'
28
30
  RubyInstaller::Runtime.add_dll_directory(path, &block)
@@ -33,19 +35,21 @@ module PG
33
35
  ENV['PATH'] = old_path
34
36
  end
35
37
  else
36
- # No need to set a load path manually - it's set as library rpath.
38
+ # libpq is found by a relative rpath in the cross compiled extension dll
39
+ # or by the system library loader
37
40
  block.call
41
+ BUNDLED_LIBPQ_WITH_UNIXSOCKET = RUBY_PLATFORM=~/linux/i && PG::IS_BINARY_GEM
38
42
  end
39
43
  end
40
44
 
41
45
  # Add a load path to the one retrieved from pg_config
42
46
  add_dll_path.call(POSTGRESQL_LIB_PATH) do
43
- if bundled_libpq_path
44
- # It's a Windows binary gem, try the <major>.<minor> subdirectory
47
+ begin
48
+ # Try the <major>.<minor> subdirectory for fat binary gems
45
49
  major_minor = RUBY_VERSION[ /^(\d+\.\d+)/ ] or
46
50
  raise "Oops, can't extract the major/minor version from #{RUBY_VERSION.dump}"
47
51
  require "#{major_minor}/pg_ext"
48
- else
52
+ rescue LoadError
49
53
  require 'pg_ext'
50
54
  end
51
55
  end
@@ -63,21 +67,78 @@ module PG
63
67
  Connection.new( *args, &block )
64
68
  end
65
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
66
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'
67
114
  require 'pg/exceptions'
68
- require 'pg/constants'
69
115
  require 'pg/coder'
70
- require 'pg/binary_decoder'
71
- require 'pg/text_encoder'
72
- require 'pg/text_decoder'
73
- require 'pg/basic_type_registry'
74
- require 'pg/basic_type_map_based_on_result'
75
- require 'pg/basic_type_map_for_queries'
76
- require 'pg/basic_type_map_for_results'
77
116
  require 'pg/type_map_by_column'
78
117
  require 'pg/connection'
118
+ require 'pg/cancel_connection'
79
119
  require 'pg/result'
80
120
  require 'pg/tuple'
81
- require 'pg/version'
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
82
143
 
83
144
  end # module PG
@@ -0,0 +1,9 @@
1
+ FROM yugabytedb/yugabyte:2024.1.0.0-b129
2
+
3
+ WORKDIR /app
4
+
5
+ RUN yugabyted cert generate_server_certs --hostnames=127.0.0.1 --base_dir=.
6
+
7
+ ENTRYPOINT ["yugabyted"]
8
+ CMD ["start", "--background", "false", "--ui", "false", "--tserver_flags", "use_client_to_server_encryption=true,cert_node_filename=127.0.0.1,certs_dir=/app/generated_certs/127.0.0.1"]
9
+ VOLUME /app
@@ -0,0 +1,28 @@
1
+ services:
2
+ yb:
3
+ build: .
4
+ container_name: yb
5
+ ports:
6
+ - "127.0.0.1:5433:5433"
7
+ volumes:
8
+ - certs:/app/generated_certs
9
+ healthcheck:
10
+ test: 'ysqlsh -h $$(hostname) -c \\conninfo || exit 1;'
11
+ interval: 2s
12
+ timeout: 30s
13
+ retries: 20
14
+ start_period: 10s
15
+
16
+ pg:
17
+ image: ruby:3.0
18
+ working_dir: /app
19
+ volumes:
20
+ - .:/app
21
+ - certs:/generated_certs
22
+ command: bash -c "gem inst pg-*.gem && ruby pg-test.rb"
23
+ depends_on:
24
+ yb:
25
+ condition: service_healthy
26
+
27
+ volumes:
28
+ certs:
@@ -0,0 +1,45 @@
1
+ require 'pg'
2
+
3
+ conn = PG.connect(
4
+ host: 'yb',
5
+ port: 5433,
6
+ user: 'yugabyte',
7
+ dbname: 'yugabyte',
8
+ sslmode: 'require',
9
+ sslrootcert: 'app/generated_certs/127.0.0.1/ca.crt',
10
+ sslcert: 'app/generated_certs/127.0.0.1/node.127.0.0.1.crt',
11
+ sslkey: 'app/generated_certs/127.0.0.1/node.127.0.0.1.key'
12
+ )
13
+
14
+ $stdout.sync = true
15
+ # fd = File.open("pg_trace.log", "a+")
16
+ # conn.trace(fd)
17
+
18
+ begin
19
+ # Validate connection is working
20
+ res = conn.exec("SELECT version();")
21
+ res.each_row do |row|
22
+ puts "You are connected to: #{row[0]}"
23
+ end
24
+ # 53*511
25
+ # 53*767
26
+ # 53*1023
27
+ # 53*1279
28
+ # 7*1817
29
+ # 11*1487
30
+ # 13*1363
31
+ # 16*1211
32
+ # 18*1128
33
+ # 22*1984
34
+ # 27*1723
35
+
36
+ (22..53).each do |m|
37
+ (1..2048).each do |l|
38
+ hanging_query = "SELECT lpad(''::text, #{m}, '0') FROM generate_series(1, #{l});"
39
+ puts "Executing hanging query: #{hanging_query}"
40
+ conn.exec(hanging_query)
41
+ end
42
+ end
43
+ ensure
44
+ conn.close if conn
45
+ end
data/pg.gemspec CHANGED
@@ -10,25 +10,29 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["ged@FaerieMUD.org", "lars@greiz-reinsdorf.de"]
11
11
 
12
12
  spec.summary = "Pg is the Ruby interface to the PostgreSQL RDBMS"
13
- spec.description = "Pg is the Ruby interface to the PostgreSQL RDBMS. It works with PostgreSQL 9.3 and later."
13
+ spec.description = "Pg is the Ruby interface to the PostgreSQL RDBMS. It works with PostgreSQL 10 and later."
14
14
  spec.homepage = "https://github.com/ged/ruby-pg"
15
15
  spec.license = "BSD-2-Clause"
16
- spec.required_ruby_version = ">= 2.5"
16
+ spec.required_ruby_version = ">= 2.7"
17
17
 
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
19
  spec.metadata["source_code_uri"] = "https://github.com/ged/ruby-pg"
20
- spec.metadata["changelog_uri"] = "https://github.com/ged/ruby-pg/blob/master/History.md"
20
+ spec.metadata["changelog_uri"] = "https://github.com/ged/ruby-pg/blob/master/CHANGELOG.md"
21
21
  spec.metadata["documentation_uri"] = "http://deveiate.org/code/pg"
22
+ # https://github.com/oneclick/rubyinstaller2/wiki/For-gem-developers#msys2-library-dependency
23
+ spec.metadata["msys2_mingw_dependencies"] = "postgresql"
22
24
 
23
25
  # Specify which files should be added to the gem when it is released.
24
26
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
27
  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)/}) }
28
+ `git ls-files -z`.split("\x0").reject do |f|
29
+ f.match(%r{\A(?:test|spec|features|translation|\.)})
30
+ end
27
31
  end
28
32
  spec.extensions = ["ext/extconf.rb"]
29
33
  spec.require_paths = ["lib"]
30
34
  spec.cert_chain = ["certs/ged.pem"]
31
35
  spec.rdoc_options = ["--main", "README.md",
32
36
  "--title", "PG: The Ruby PostgreSQL Driver"]
33
- spec.extra_rdoc_files = `git ls-files -z *.rdoc *.md lib/*.rb lib/*/*.rb ext/*.c ext/*.h`.split("\x0")
37
+ spec.extra_rdoc_files = `git ls-files -z *.rdoc *.md lib/*.rb lib/*/*.rb lib/*/*/*.rb ext/*.c ext/*.h`.split("\x0")
34
38
  end
@@ -0,0 +1,30 @@
1
+ From e82c1b395162ea71279ea2170259383082e41ab0 Mon Sep 17 00:00:00 2001
2
+ From: Lars Kanis <lars@greiz-reinsdorf.de>
3
+ Date: Sat, 12 Jul 2025 10:55:17 +0200
4
+ Subject: [PATCH] Allow static linking krb5 library
5
+
6
+ Otherwise it fails with:
7
+ Undefined symbols for architecture arm64:
8
+ "_krb5int_c_mit_des_zeroblock", referenced from:
9
+ _krb5int_des3_cbc_encrypt in libk5crypto.a(d3_aead.o)
10
+ _krb5int_des3_cbc_decrypt in libk5crypto.a(d3_aead.o)
11
+ ---
12
+ src/lib/crypto/builtin/des/des_int.h | 2 +-
13
+ 1 file changed, 1 insertion(+), 1 deletion(-)
14
+
15
+ diff --git a/src/lib/crypto/builtin/des/des_int.h b/src/lib/crypto/builtin/des/des_int.h
16
+ index 46fed7dbd..114e48ebd 100644
17
+ --- a/lib/crypto/builtin/des/des_int.h
18
+ +++ b/lib/crypto/builtin/des/des_int.h
19
+ @@ -159,7 +159,7 @@ mit_des_cbc_encrypt(const mit_des_cblock *in, mit_des_cblock *out,
20
+ const mit_des_cblock ivec, int enc);
21
+
22
+ #define mit_des_zeroblock krb5int_c_mit_des_zeroblock
23
+ -extern const mit_des_cblock mit_des_zeroblock;
24
+ +const mit_des_cblock mit_des_zeroblock;
25
+
26
+ /* fin_rndkey.c */
27
+ krb5_error_code mit_des_finish_random_key(const krb5_encrypt_block *,
28
+ --
29
+ 2.43.0
30
+
@@ -0,0 +1,21 @@
1
+ --- a/Configurations/10-main.conf
2
+ +++ b/Configurations/10-main.conf
3
+ @@ -1603,6 +1603,18 @@
4
+ multilib => "64",
5
+ },
6
+
7
+ + "mingwarm64" => {
8
+ + inherit_from => [ "mingw-common" ],
9
+ + cflags => "",
10
+ + sys_id => "MINGWARM64",
11
+ + bn_ops => add("SIXTY_FOUR_BIT"),
12
+ + asm_arch => 'aarch64',
13
+ + uplink_arch => 'armv8',
14
+ + perlasm_scheme => "win64",
15
+ + shared_rcflag => "",
16
+ + multilib => "-arm64",
17
+ + },
18
+ +
19
+ #### UEFI
20
+ "UEFI" => {
21
+ inherit_from => [ "BASE_unix" ],
@@ -0,0 +1,42 @@
1
+ From 746e8e250b265c40d9706f26560e02e8623f123f Mon Sep 17 00:00:00 2001
2
+ From: Lars Kanis <lars@greiz-reinsdorf.de>
3
+ Date: Fri, 31 Jan 2025 21:58:00 +0100
4
+ Subject: [PATCH] Use workaround of __builtin_setjmp only on MINGW on MSVCRT
5
+
6
+ Because it is not present on ARM64 on Windows and not necessary on any UCRT based toolchain.
7
+ ---
8
+ src/include/c.h | 10 +++++-----
9
+ 1 file changed, 5 insertions(+), 5 deletions(-)
10
+
11
+ diff --git a/src/include/c.h b/src/include/c.h
12
+ index a14c631516..33792c860c 100644
13
+ --- a/src/include/c.h
14
+ +++ b/src/include/c.h
15
+ @@ -1312,19 +1312,19 @@ extern int fdatasync(int fildes);
16
+ /*
17
+ * When there is no sigsetjmp, its functionality is provided by plain
18
+ * setjmp. We now support the case only on Windows. However, it seems
19
+ - * that MinGW-64 has some longstanding issues in its setjmp support,
20
+ - * so on that toolchain we cheat and use gcc's builtins.
21
+ + * that MinGW-64 on x86_64 has some longstanding issues in its setjmp
22
+ + * support, so on that toolchain we cheat and use gcc's builtins.
23
+ */
24
+ #ifdef WIN32
25
+ -#ifdef __MINGW64__
26
+ +#if defined(__MINGW64__) && !defined(_UCRT)
27
+ typedef intptr_t sigjmp_buf[5];
28
+ #define sigsetjmp(x,y) __builtin_setjmp(x)
29
+ #define siglongjmp __builtin_longjmp
30
+ -#else /* !__MINGW64__ */
31
+ +#else /* !defined(__MINGW64__) || defined(_UCRT) */
32
+ #define sigjmp_buf jmp_buf
33
+ #define sigsetjmp(x,y) setjmp(x)
34
+ #define siglongjmp longjmp
35
+ -#endif /* __MINGW64__ */
36
+ +#endif /* defined(__MINGW64__) && !defined(_UCRT) */
37
+ #endif /* WIN32 */
38
+
39
+ /* /port compatibility functions */
40
+ --
41
+ 2.43.0
42
+
@@ -0,0 +1,52 @@
1
+ From ab793829a4ce473f1cc2bbc0e2a6f6753553255d Mon Sep 17 00:00:00 2001
2
+ From: Lars Kanis <lars@greiz-reinsdorf.de>
3
+ Date: Sun, 8 Sep 2024 13:59:05 +0200
4
+ Subject: [PATCH] libpq: Process buffered SSL read bytes to support records
5
+ >8kB on async API
6
+
7
+ The async API of libpq doesn't support SSL record sizes >8kB so far.
8
+ This size isn't exceeded by vanilla PostgreSQL, but by other products using
9
+ the postgres wire protocol 3.
10
+ PQconsumeInput() reads all data readable from the socket, so that the read
11
+ condition is cleared.
12
+ But it doesn't process all the data that is pending on the SSL layer.
13
+ Also a subsequent call to PQisBusy() doesn't process it, so that the client
14
+ is triggered to wait for more readable data on the socket.
15
+ But this never arrives, so that the connection blocks infinitely.
16
+
17
+ To fix this issue call pqReadData() repeatedly until there is no buffered
18
+ SSL data left to be read.
19
+
20
+ The synchronous libpq API isn't affected, since it supports arbitrary SSL
21
+ record sizes already.
22
+ ---
23
+ src/interfaces/libpq/fe-exec.c | 13 +++++++++++++
24
+ 1 file changed, 13 insertions(+)
25
+
26
+ diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
27
+ index 0d224a852..637894ee1 100644
28
+ --- a/src/interfaces/libpq/fe-exec.c
29
+ +++ b/src/interfaces/libpq/fe-exec.c
30
+ @@ -2006,6 +2006,19 @@ PQconsumeInput(PGconn *conn)
31
+ if (pqReadData(conn) < 0)
32
+ return 0;
33
+
34
+ + #ifdef USE_SSL
35
+ + /*
36
+ + * Ensure all buffered read bytes in the SSL library are processed,
37
+ + * which might be not the case, if the SSL record size exceeds 8k.
38
+ + * Otherwise parseInput can't process the data.
39
+ + */
40
+ + while (conn->ssl_in_use && pgtls_read_pending(conn))
41
+ + {
42
+ + if (pqReadData(conn) < 0)
43
+ + return 0;
44
+ + }
45
+ + #endif
46
+ +
47
+ /* Parsing of the data waits till later. */
48
+ return 1;
49
+ }
50
+ --
51
+ 2.43.0
52
+