pg 1.1.4 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.appveyor.yml +42 -0
  4. data/.gems +6 -0
  5. data/.github/workflows/binary-gems.yml +117 -0
  6. data/.github/workflows/source-gem.yml +137 -0
  7. data/.gitignore +22 -0
  8. data/.hgsigs +34 -0
  9. data/.hgtags +41 -0
  10. data/.irbrc +23 -0
  11. data/.pryrc +23 -0
  12. data/.tm_properties +21 -0
  13. data/.travis.yml +49 -0
  14. data/Gemfile +14 -0
  15. data/History.md +876 -0
  16. data/Manifest.txt +3 -3
  17. data/README-Windows.rdoc +4 -4
  18. data/README.ja.md +276 -0
  19. data/README.md +286 -0
  20. data/Rakefile +37 -137
  21. data/Rakefile.cross +62 -62
  22. data/certs/ged.pem +24 -0
  23. data/certs/larskanis-2022.pem +26 -0
  24. data/certs/larskanis-2023.pem +24 -0
  25. data/ext/errorcodes.def +76 -0
  26. data/ext/errorcodes.rb +0 -0
  27. data/ext/errorcodes.txt +21 -2
  28. data/ext/extconf.rb +101 -26
  29. data/ext/gvl_wrappers.c +4 -0
  30. data/ext/gvl_wrappers.h +23 -0
  31. data/ext/pg.c +203 -151
  32. data/ext/pg.h +48 -21
  33. data/ext/pg_binary_decoder.c +89 -10
  34. data/ext/pg_binary_encoder.c +238 -13
  35. data/ext/pg_coder.c +109 -34
  36. data/ext/pg_connection.c +1365 -976
  37. data/ext/pg_copy_coder.c +356 -35
  38. data/ext/pg_errors.c +1 -1
  39. data/ext/pg_record_coder.c +522 -0
  40. data/ext/pg_result.c +436 -171
  41. data/ext/pg_text_decoder.c +42 -18
  42. data/ext/pg_text_encoder.c +201 -56
  43. data/ext/pg_tuple.c +97 -66
  44. data/ext/pg_type_map.c +45 -11
  45. data/ext/pg_type_map_all_strings.c +21 -7
  46. data/ext/pg_type_map_by_class.c +59 -27
  47. data/ext/pg_type_map_by_column.c +80 -37
  48. data/ext/pg_type_map_by_mri_type.c +49 -20
  49. data/ext/pg_type_map_by_oid.c +62 -29
  50. data/ext/pg_type_map_in_ruby.c +56 -22
  51. data/ext/{util.c → pg_util.c} +7 -7
  52. data/lib/pg/basic_type_map_based_on_result.rb +67 -0
  53. data/lib/pg/basic_type_map_for_queries.rb +198 -0
  54. data/lib/pg/basic_type_map_for_results.rb +104 -0
  55. data/lib/pg/basic_type_registry.rb +299 -0
  56. data/lib/pg/binary_decoder/date.rb +9 -0
  57. data/lib/pg/binary_decoder/timestamp.rb +26 -0
  58. data/lib/pg/binary_encoder/timestamp.rb +20 -0
  59. data/lib/pg/coder.rb +35 -12
  60. data/lib/pg/connection.rb +744 -84
  61. data/lib/pg/exceptions.rb +15 -1
  62. data/lib/pg/result.rb +13 -1
  63. data/lib/pg/text_decoder/date.rb +18 -0
  64. data/lib/pg/text_decoder/inet.rb +9 -0
  65. data/lib/pg/text_decoder/json.rb +14 -0
  66. data/lib/pg/text_decoder/numeric.rb +9 -0
  67. data/lib/pg/text_decoder/timestamp.rb +30 -0
  68. data/lib/pg/text_encoder/date.rb +12 -0
  69. data/lib/pg/text_encoder/inet.rb +28 -0
  70. data/lib/pg/text_encoder/json.rb +14 -0
  71. data/lib/pg/text_encoder/numeric.rb +9 -0
  72. data/lib/pg/text_encoder/timestamp.rb +24 -0
  73. data/lib/pg/type_map_by_column.rb +2 -1
  74. data/lib/pg/version.rb +4 -0
  75. data/lib/pg.rb +94 -39
  76. data/misc/openssl-pg-segfault.rb +31 -0
  77. data/misc/postgres/History.txt +9 -0
  78. data/misc/postgres/Manifest.txt +5 -0
  79. data/misc/postgres/README.txt +21 -0
  80. data/misc/postgres/Rakefile +21 -0
  81. data/misc/postgres/lib/postgres.rb +16 -0
  82. data/misc/ruby-pg/History.txt +9 -0
  83. data/misc/ruby-pg/Manifest.txt +5 -0
  84. data/misc/ruby-pg/README.txt +21 -0
  85. data/misc/ruby-pg/Rakefile +21 -0
  86. data/misc/ruby-pg/lib/ruby/pg.rb +16 -0
  87. data/pg.gemspec +34 -0
  88. data/rakelib/task_extension.rb +46 -0
  89. data/sample/array_insert.rb +20 -0
  90. data/sample/async_api.rb +102 -0
  91. data/sample/async_copyto.rb +39 -0
  92. data/sample/async_mixed.rb +56 -0
  93. data/sample/check_conn.rb +21 -0
  94. data/sample/copydata.rb +71 -0
  95. data/sample/copyfrom.rb +81 -0
  96. data/sample/copyto.rb +19 -0
  97. data/sample/cursor.rb +21 -0
  98. data/sample/disk_usage_report.rb +177 -0
  99. data/sample/issue-119.rb +94 -0
  100. data/sample/losample.rb +69 -0
  101. data/sample/minimal-testcase.rb +17 -0
  102. data/sample/notify_wait.rb +72 -0
  103. data/sample/pg_statistics.rb +285 -0
  104. data/sample/replication_monitor.rb +222 -0
  105. data/sample/test_binary_values.rb +33 -0
  106. data/sample/wal_shipper.rb +434 -0
  107. data/sample/warehouse_partitions.rb +311 -0
  108. data/translation/.po4a-version +7 -0
  109. data/translation/po/all.pot +910 -0
  110. data/translation/po/ja.po +1047 -0
  111. data/translation/po4a.cfg +12 -0
  112. data.tar.gz.sig +0 -0
  113. metadata +151 -218
  114. metadata.gz.sig +0 -0
  115. data/ChangeLog +0 -6595
  116. data/History.rdoc +0 -492
  117. data/README.ja.rdoc +0 -14
  118. data/README.rdoc +0 -178
  119. data/lib/pg/basic_type_mapping.rb +0 -459
  120. data/lib/pg/binary_decoder.rb +0 -22
  121. data/lib/pg/constants.rb +0 -11
  122. data/lib/pg/text_decoder.rb +0 -47
  123. data/lib/pg/text_encoder.rb +0 -69
  124. data/spec/data/expected_trace.out +0 -26
  125. data/spec/data/random_binary_data +0 -0
  126. data/spec/helpers.rb +0 -380
  127. data/spec/pg/basic_type_mapping_spec.rb +0 -508
  128. data/spec/pg/connection_spec.rb +0 -1872
  129. data/spec/pg/connection_sync_spec.rb +0 -41
  130. data/spec/pg/result_spec.rb +0 -491
  131. data/spec/pg/tuple_spec.rb +0 -280
  132. data/spec/pg/type_map_by_class_spec.rb +0 -138
  133. data/spec/pg/type_map_by_column_spec.rb +0 -222
  134. data/spec/pg/type_map_by_mri_type_spec.rb +0 -136
  135. data/spec/pg/type_map_by_oid_spec.rb +0 -149
  136. data/spec/pg/type_map_in_ruby_spec.rb +0 -164
  137. data/spec/pg/type_map_spec.rb +0 -22
  138. data/spec/pg/type_spec.rb +0 -949
  139. data/spec/pg_spec.rb +0 -50
  140. /data/ext/{util.h → pg_util.h} +0 -0
data/Rakefile CHANGED
@@ -3,20 +3,11 @@
3
3
  require 'rbconfig'
4
4
  require 'pathname'
5
5
  require 'tmpdir'
6
-
7
- begin
8
- require 'rake/extensiontask'
9
- rescue LoadError
10
- abort "This Rakefile requires rake-compiler (gem install rake-compiler)"
11
- end
12
-
13
- begin
14
- require 'hoe'
15
- rescue LoadError
16
- abort "This Rakefile requires hoe (gem install hoe)"
17
- end
18
-
6
+ require 'rake/extensiontask'
19
7
  require 'rake/clean'
8
+ require 'rspec/core/rake_task'
9
+ require 'bundler'
10
+ require 'bundler/gem_helper'
20
11
 
21
12
  # Build directory constants
22
13
  BASEDIR = Pathname( __FILE__ ).dirname
@@ -25,80 +16,23 @@ LIBDIR = BASEDIR + 'lib'
25
16
  EXTDIR = BASEDIR + 'ext'
26
17
  PKGDIR = BASEDIR + 'pkg'
27
18
  TMPDIR = BASEDIR + 'tmp'
19
+ TESTDIR = BASEDIR + "tmp_test_*"
28
20
 
29
21
  DLEXT = RbConfig::CONFIG['DLEXT']
30
22
  EXT = LIBDIR + "pg_ext.#{DLEXT}"
31
23
 
32
24
  GEMSPEC = 'pg.gemspec'
33
25
 
34
- TEST_DIRECTORY = BASEDIR + "tmp_test_specs"
35
-
36
- CLOBBER.include( TEST_DIRECTORY.to_s )
26
+ CLEAN.include( TESTDIR.to_s )
37
27
  CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
38
-
39
- # Set up Hoe plugins
40
- Hoe.plugin :mercurial
41
- Hoe.plugin :signing
42
- Hoe.plugin :deveiate
43
- Hoe.plugin :bundler
44
-
45
- Hoe.plugins.delete :rubyforge
46
- Hoe.plugins.delete :compiler
28
+ CLEAN.include "lib/*/libpq.dll"
29
+ CLEAN.include "lib/pg_ext.*"
30
+ CLEAN.include "lib/pg/postgresql_lib_path.rb"
47
31
 
48
32
  load 'Rakefile.cross'
49
33
 
50
-
51
- # Hoe specification
52
- $hoespec = Hoe.spec 'pg' do
53
- self.readme_file = 'README.rdoc'
54
- self.history_file = 'History.rdoc'
55
- self.extra_rdoc_files = Rake::FileList[ '*.rdoc' ]
56
- self.extra_rdoc_files.include( 'POSTGRES', 'LICENSE' )
57
- self.extra_rdoc_files.include( 'ext/*.c' )
58
- self.license 'BSD-3-Clause'
59
-
60
- self.developer 'Michael Granger', 'ged@FaerieMUD.org'
61
- self.developer 'Lars Kanis', 'lars@greiz-reinsdorf.de'
62
-
63
- self.dependency 'rake-compiler', '~> 1.0', :developer
64
- self.dependency 'rake-compiler-dock', ['~> 0.7.0'], :developer
65
- self.dependency 'hoe-deveiate', '~> 0.9', :developer
66
- self.dependency 'hoe-bundler', '~> 1.0', :developer
67
- self.dependency 'rspec', '~> 3.5', :developer
68
- self.dependency 'rdoc', '~> 5.1', :developer
69
-
70
- self.spec_extras[:extensions] = [ 'ext/extconf.rb' ]
71
-
72
- self.require_ruby_version( '>= 2.0.0' )
73
-
74
- self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
75
- self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
76
-
77
- self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
78
- end
79
-
80
- ENV['VERSION'] ||= $hoespec.spec.version.to_s
81
-
82
- # Tests should pass before checking in
83
- task 'hg:precheckin' => [ :check_history, :check_manifest, :spec, :gemspec ]
84
-
85
- # Support for 'rvm specs'
86
- task :specs => :spec
87
-
88
- # Compile before testing
89
- task :spec => :compile
90
-
91
- # gem-testers support
92
- task :test do
93
- # rake-compiler always wants to copy the compiled extension into lib/, but
94
- # we don't want testers to have to re-compile, especially since that
95
- # often fails because they can't (and shouldn't have to) write to tmp/ in
96
- # the installed gem dir. So we clear the task rake-compiler set up
97
- # to break the dependency between :spec and :compile when running under
98
- # rubygems-test, and then run :spec.
99
- Rake::Task[ EXT.to_s ].clear if File.exist?(EXT.to_s)
100
- Rake::Task[ :spec ].execute
101
- end
34
+ Bundler::GemHelper.install_tasks
35
+ $gem_spec = Bundler.load_gemspec(GEMSPEC)
102
36
 
103
37
  desc "Turn on warnings and debugging in the build."
104
38
  task :maint do
@@ -108,12 +42,12 @@ end
108
42
  # Rake-compiler task
109
43
  Rake::ExtensionTask.new do |ext|
110
44
  ext.name = 'pg_ext'
111
- ext.gem_spec = $hoespec.spec
45
+ ext.gem_spec = $gem_spec
112
46
  ext.ext_dir = 'ext'
113
47
  ext.lib_dir = 'lib'
114
48
  ext.source_pattern = "*.{c,h}"
115
49
  ext.cross_compile = true
116
- ext.cross_platform = CrossLibraries.map &:for_platform
50
+ ext.cross_platform = CrossLibraries.map(&:for_platform)
117
51
 
118
52
  ext.cross_config_options += CrossLibraries.map do |lib|
119
53
  {
@@ -129,62 +63,35 @@ Rake::ExtensionTask.new do |ext|
129
63
 
130
64
  # Add libpq.dll to windows binary gemspec
131
65
  ext.cross_compiling do |spec|
132
- spec.files << "lib/libpq.dll"
66
+ spec.files << "lib/#{spec.platform}/libpq.dll"
133
67
  end
134
68
  end
135
69
 
70
+ RSpec::Core::RakeTask.new(:spec).rspec_opts = "--profile -cfdoc"
71
+ task :test => :spec
136
72
 
137
73
  # Use the fivefish formatter for docs generated from development checkout
138
- if File.directory?( '.hg' )
139
- require 'rdoc/task'
140
-
141
- Rake::Task[ 'docs' ].clear
142
- RDoc::Task.new( 'docs' ) do |rdoc|
143
- rdoc.main = "README.rdoc"
144
- rdoc.rdoc_files.include( "*.rdoc", "ChangeLog", "lib/**/*.rb", 'ext/**/*.{c,h}' )
145
- rdoc.generator = :fivefish
146
- rdoc.title = "PG: The Ruby PostgreSQL Driver"
147
- rdoc.rdoc_dir = 'doc'
148
- end
149
- end
74
+ require 'rdoc/task'
150
75
 
151
-
152
- # Make the ChangeLog update if the repo has changed since it was last built
153
- file '.hg/branch' do
154
- warn "WARNING: You need the Mercurial repo to update the ChangeLog"
155
- end
156
- Rake::Task["ChangeLog"].clear
157
- file 'ChangeLog' do |task|
158
- if File.exist?('.hg/branch')
159
- $stderr.puts "Updating the changelog..."
160
- begin
161
- include Hoe::MercurialHelpers
162
- content = make_changelog()
163
- rescue NameError
164
- abort "Packaging tasks require the hoe-mercurial plugin (gem install hoe-mercurial)"
165
- end
166
- File.open( task.name, 'w', 0644 ) do |fh|
167
- fh.print( content )
168
- end
169
- else
170
- touch 'ChangeLog'
171
- end
76
+ RDoc::Task.new( 'docs' ) do |rdoc|
77
+ rdoc.options = $gem_spec.rdoc_options
78
+ rdoc.rdoc_files = $gem_spec.extra_rdoc_files
79
+ rdoc.generator = :fivefish
80
+ rdoc.rdoc_dir = 'doc'
172
81
  end
173
82
 
174
- # Rebuild the ChangeLog immediately before release
175
- task :prerelease => 'ChangeLog'
176
-
83
+ desc "Build the source gem #{$gem_spec.full_name}.gem into the pkg directory"
84
+ task :gem => :build
177
85
 
178
- desc "Stop any Postmaster instances that remain after testing."
179
- task :cleanup_testing_dbs do
180
- require 'spec/lib/helpers'
181
- PgTestingHelpers.stop_existing_postmasters()
182
- Rake::Task[:clean].invoke
86
+ task :clobber do
87
+ puts "Stop any Postmaster instances that remain after testing."
88
+ require_relative 'spec/helpers'
89
+ PG::TestingHelpers.stop_existing_postmasters()
183
90
  end
184
91
 
185
92
  desc "Update list of server error codes"
186
93
  task :update_error_codes do
187
- URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL_11_1"
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"
188
95
 
189
96
  ERRORCODES_TXT = "ext/errorcodes.txt"
190
97
  sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
@@ -197,19 +104,12 @@ file 'ext/pg_errors.c' => ['ext/errorcodes.def'] do
197
104
  touch 'ext/pg_errors.c'
198
105
  end
199
106
 
200
- task :gemspec => GEMSPEC
201
- file GEMSPEC => __FILE__
202
- task GEMSPEC do |task|
203
- spec = $hoespec.spec
204
- spec.files.delete( '.gemtest' )
205
- spec.signing_key = nil
206
- spec.version = "#{spec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
207
- spec.cert_chain = [ 'certs/ged.pem' ]
208
- File.open( task.name, 'w' ) do |fh|
209
- fh.write( spec.to_ruby )
210
- end
211
- end
212
-
213
- CLOBBER.include( '*.gemspec' )
214
- task :default => :gemspec
107
+ desc "Translate readme"
108
+ task :translate do
109
+ cd "translation" do
110
+ # po4a's lexer might change, so record its version for reference
111
+ sh "LANG=C po4a --version > .po4a-version"
215
112
 
113
+ sh "po4a po4a.cfg"
114
+ end
115
+ end
data/Rakefile.cross CHANGED
@@ -7,6 +7,7 @@ require 'rake/clean'
7
7
  require 'rake/extensiontask'
8
8
  require 'rake/extensioncompiler'
9
9
  require 'ostruct'
10
+ require_relative 'rakelib/task_extension'
10
11
 
11
12
  MISCDIR = BASEDIR + 'misc'
12
13
 
@@ -20,6 +21,7 @@ end
20
21
 
21
22
  class CrossLibrary < OpenStruct
22
23
  include Rake::DSL
24
+ prepend TaskExtension
23
25
 
24
26
  def initialize(for_platform, openssl_config, toolchain)
25
27
  super()
@@ -29,15 +31,15 @@ class CrossLibrary < OpenStruct
29
31
  self.host_platform = toolchain
30
32
 
31
33
  # Cross-compilation constants
32
- self.openssl_version = ENV['OPENSSL_VERSION'] || '1.1.1a'
33
- self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '11.1'
34
+ self.openssl_version = ENV['OPENSSL_VERSION'] || '3.1.0'
35
+ self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '15.2'
34
36
 
35
37
  # Check if symlinks work in the current working directory.
36
38
  # This fails, if rake-compiler-dock is running on a Windows box.
37
39
  begin
38
40
  FileUtils.rm_f '.test_symlink'
39
41
  FileUtils.ln_s '/', '.test_symlink'
40
- rescue SystemCallError
42
+ rescue NotImplementedError, SystemCallError
41
43
  # Symlinks don't work -> use home directory instead
42
44
  self.compile_home = Pathname( "~/.ruby-pg-build" ).expand_path
43
45
  else
@@ -45,6 +47,8 @@ class CrossLibrary < OpenStruct
45
47
  end
46
48
  self.static_sourcesdir = compile_home + 'sources'
47
49
  self.static_builddir = compile_home + 'builds' + for_platform
50
+ CLOBBER.include( static_sourcesdir )
51
+ CLEAN.include( static_builddir )
48
52
 
49
53
  # Static OpenSSL build vars
50
54
  self.static_openssl_builddir = static_builddir + "openssl-#{openssl_version}"
@@ -81,17 +85,6 @@ class CrossLibrary < OpenStruct
81
85
  # clean intermediate files and folders
82
86
  CLEAN.include( static_builddir.to_s )
83
87
 
84
-
85
- def download(url, save_to)
86
- part = save_to+".part"
87
- sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
88
- FileUtils.mv part, save_to
89
- end
90
-
91
- def run(*args)
92
- sh *args
93
- end
94
-
95
88
  #####################################################################
96
89
  ### C R O S S - C O M P I L A T I O N - T A S K S
97
90
  #####################################################################
@@ -134,16 +127,16 @@ class CrossLibrary < OpenStruct
134
127
  file openssl_makefile => static_openssl_builddir do |t|
135
128
  chdir( static_openssl_builddir ) do
136
129
  cmd = cmd_prelude.dup
137
- cmd << "./Configure" << openssl_config
130
+ cmd << "./Configure" << "-static" << openssl_config
138
131
 
139
132
  run( *cmd )
140
133
  end
141
134
  end
142
135
 
143
136
  desc "compile static openssl libraries"
144
- task :openssl_libs => [ libssl, libcrypto ]
137
+ task "openssl_libs:#{for_platform}" => [ libssl, libcrypto ]
145
138
 
146
- task :compile_static_openssl => openssl_makefile do |t|
139
+ task "compile_static_openssl:#{for_platform}" => openssl_makefile do |t|
147
140
  chdir( static_openssl_builddir ) do
148
141
  cmd = cmd_prelude.dup
149
142
  cmd << 'make' << "-j#{NUM_CPUS}" << 'build_libs'
@@ -153,14 +146,10 @@ class CrossLibrary < OpenStruct
153
146
  end
154
147
 
155
148
  desc "compile static #{libssl}"
156
- file libssl => :compile_static_openssl do |t|
157
- rm t.name.gsub(/\.a$/, ".dll.a")
158
- end
149
+ file libssl => "compile_static_openssl:#{for_platform}"
159
150
 
160
151
  desc "compile static #{libcrypto}"
161
- file libcrypto => :compile_static_openssl do |t|
162
- rm t.name.gsub(/\.a$/, ".dll.a")
163
- end
152
+ file libcrypto => "compile_static_openssl:#{for_platform}"
164
153
 
165
154
 
166
155
 
@@ -189,7 +178,7 @@ class CrossLibrary < OpenStruct
189
178
  end
190
179
 
191
180
  # generate the makefile in a clean build location
192
- file postgresql_global_makefile => [ static_postgresql_builddir, :openssl_libs ] do |t|
181
+ file postgresql_global_makefile => [ static_postgresql_builddir, "openssl_libs:#{for_platform}" ] do |t|
193
182
  options = [
194
183
  "--target=#{host_platform}",
195
184
  "--host=#{host_platform}",
@@ -203,7 +192,7 @@ class CrossLibrary < OpenStruct
203
192
  cmd << "CFLAGS=-L#{static_openssl_builddir}"
204
193
  cmd << "LDFLAGS=-L#{static_openssl_builddir}"
205
194
  cmd << "LDFLAGS_SL=-L#{static_openssl_builddir}"
206
- cmd << "LIBS=-lwsock32 -lgdi32 -lws2_32"
195
+ cmd << "LIBS=-lwsock32 -lgdi32 -lws2_32 -lcrypt32"
207
196
  cmd << "CPPFLAGS=-I#{static_openssl_builddir}/include"
208
197
 
209
198
  run( *cmd )
@@ -217,6 +206,9 @@ class CrossLibrary < OpenStruct
217
206
  chdir( static_postgresql_srcdir + "common" ) do
218
207
  sh 'make', "-j#{NUM_CPUS}"
219
208
  end
209
+ chdir( static_postgresql_srcdir + "port" ) do
210
+ sh 'make', "-j#{NUM_CPUS}"
211
+ end
220
212
 
221
213
  chdir( postgresql_lib.dirname ) do
222
214
  sh 'make',
@@ -228,10 +220,10 @@ class CrossLibrary < OpenStruct
228
220
 
229
221
 
230
222
  #desc 'compile libpg.a'
231
- task :libpq => postgresql_lib
223
+ task "native:#{for_platform}" => postgresql_lib
232
224
 
233
225
  # copy libpq.dll to lib dir
234
- dest_libpq = "lib/#{postgresql_lib.basename}"
226
+ dest_libpq = "lib/#{for_platform}/#{postgresql_lib.basename}"
235
227
  directory File.dirname(dest_libpq)
236
228
  file dest_libpq => [postgresql_lib, File.dirname(dest_libpq)] do
237
229
  cp postgresql_lib, dest_libpq
@@ -243,22 +235,28 @@ class CrossLibrary < OpenStruct
243
235
  cp postgresql_lib, stage_libpq
244
236
  end
245
237
  end
246
- end
247
238
 
248
- if File.exist?(File.expand_path("~/.rake-compiler/config.yml"))
249
- CrossLibraries = [
250
- ['i386-mingw32', 'mingw', 'i686-w64-mingw32'],
251
- ['x64-mingw32', 'mingw64', 'x86_64-w64-mingw32'],
252
- ].map do |platform, openssl_config, toolchain|
253
- CrossLibrary.new platform, openssl_config, toolchain
239
+ def download(url, save_to)
240
+ part = save_to+".part"
241
+ sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
242
+ FileUtils.mv part, save_to
243
+ end
244
+
245
+ def run(*args)
246
+ sh(*args)
254
247
  end
255
- else
256
- $stderr.puts "Cross-compilation disabled -- rake-compiler not properly installed"
257
- CrossLibraries = []
248
+ end
249
+
250
+ CrossLibraries = [
251
+ ['x64-mingw-ucrt', 'mingw64', 'x86_64-w64-mingw32'],
252
+ ['x86-mingw32', 'mingw', 'i686-w64-mingw32'],
253
+ ['x64-mingw32', 'mingw64', 'x86_64-w64-mingw32'],
254
+ ].map do |platform, openssl_config, toolchain|
255
+ CrossLibrary.new platform, openssl_config, toolchain
258
256
  end
259
257
 
260
258
  desc 'cross compile pg for win32'
261
- task :cross => [ :mingw32, :libpq ]
259
+ task :cross => [ :mingw32 ]
262
260
 
263
261
  task :mingw32 do
264
262
  # Use Rake::ExtensionCompiler helpers to find the proper host
@@ -269,30 +267,32 @@ task :mingw32 do
269
267
  end
270
268
  end
271
269
 
272
- # To reduce the gem file size strip mingw32 dlls before packaging
273
- ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
274
- task "tmp/i386-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/pg_ext.so" do |t|
275
- sh "i686-w64-mingw32-strip -S tmp/i386-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/pg_ext.so"
276
- end
277
-
278
- task "tmp/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/pg_ext.so" do |t|
279
- sh "x86_64-w64-mingw32-strip -S tmp/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/pg_ext.so"
280
- end
270
+ task 'gem:windows:prepare' do
271
+ require 'io/console'
272
+ require 'rake_compiler_dock'
273
+
274
+ # Copy gem signing key and certs to be accessible from the docker container
275
+ mkdir_p 'build/gem'
276
+ sh "cp ~/.gem/gem-*.pem build/gem/ || true"
277
+ sh "bundle package"
278
+ begin
279
+ OpenSSL::PKey.read(File.read(File.expand_path("~/.gem/gem-private_key.pem")), ENV["GEM_PRIVATE_KEY_PASSPHRASE"] || "")
280
+ rescue OpenSSL::PKey::PKeyError
281
+ ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = STDIN.getpass("Enter passphrase of gem signature key: ")
282
+ retry
283
+ end
281
284
  end
282
285
 
283
- desc "Build the windows binary gems"
284
- task 'gem:windows' => ['ChangeLog'] do
285
- require 'rake_compiler_dock'
286
-
287
- # Copy gem signing key and certs to be accessable from the docker container
288
- mkdir_p 'build/gem'
289
- sh "cp ~/.gem/gem-*.pem build/gem/ || true"
290
- sh "bundle package"
291
-
292
- RakeCompilerDock.sh <<-EOT
293
- mkdir ~/.gem &&
294
- (cp build/gem/gem-*.pem ~/.gem/ || true) &&
295
- bundle install --local &&
296
- rake cross native gem MAKE="make -j`nproc`"
297
- EOT
286
+ CrossLibraries.each do |xlib|
287
+ platform = xlib.for_platform
288
+ desc "Build fat binary gem for platform #{platform}"
289
+ task "gem:windows:#{platform}" => ['gem:windows:prepare', xlib.openssl_tarball, xlib.postgresql_tarball] do
290
+ RakeCompilerDock.sh <<-EOT, platform: platform
291
+ (cp build/gem/gem-*.pem ~/.gem/ || true) &&
292
+ 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
+ EOT
295
+ end
296
+ desc "Build the windows binary gems"
297
+ multitask 'gem:windows' => "gem:windows:#{platform}"
298
298
  end
data/certs/ged.pem ADDED
@@ -0,0 +1,24 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIID+DCCAmCgAwIBAgIBBDANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdnZWQv
3
+ REM9RmFlcmllTVVEL0RDPW9yZzAeFw0yMjAxMDcyMzU4MTRaFw0yMzAxMDcyMzU4
4
+ MTRaMCIxIDAeBgNVBAMMF2dlZC9EQz1GYWVyaWVNVUQvREM9b3JnMIIBojANBgkq
5
+ hkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAvyVhkRzvlEs0fe7145BYLfN6njX9ih5H
6
+ L60U0p0euIurpv84op9CNKF9tx+1WKwyQvQP7qFGuZxkSUuWcP/sFhDXL1lWUuIl
7
+ M4uHbGCRmOshDrF4dgnBeOvkHr1fIhPlJm5FO+Vew8tSQmlDsosxLUx+VB7DrVFO
8
+ 5PU2AEbf04GGSrmqADGWXeaslaoRdb1fu/0M5qfPTRn5V39sWD9umuDAF9qqil/x
9
+ Sl6phTvgBrG8GExHbNZpLARd3xrBYLEFsX7RvBn2UPfgsrtvpdXjsHGfpT3IPN+B
10
+ vQ66lts4alKC69TE5cuKasWBm+16A4a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dj7GhmbF5gBzkV5uepd
11
+ eJQPgWGwrQW/Z2oPjRuJrRofzWfrMWqbOahj9uth6WSxhNexUtbjk6P8emmXOJi5
12
+ chQPnWX+N3Gj+jjYxqTFdwT7Mj3pv1VHa+aNUbqSPpvJeDyxRIuo9hvzDaBHb/Cg
13
+ 9qRVcm8a96n4t7y2lrX1oookY6bkBaxWOMtWlqIprq8JZXM9AgMBAAGjOTA3MAkG
14
+ A1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQ4h1tIyvdUWtMI739xMzTR
15
+ 7EfMFzANBgkqhkiG9w0BAQsFAAOCAYEAQAcuTARfiiVUVx5KURICfdTM2Kd7LhOn
16
+ qt3Vs4ANGvT226LEp3RnQ+kWGQYMRb3cw3LY2TNQRPlnZxE994mgjBscN4fbjXqO
17
+ T0JbVpeszRZa5k1goggbnWT7CO7yU7WcHh13DaSubY7HUpAJn2xz9w2stxQfN/EE
18
+ VMlnDJ1P7mUHAvpK8X9j9h7Xlc1niViT18MYwux8mboVTryrLr+clATUkkM3yBF0
19
+ RV+c34ReW5eXO9Tr6aKTxh/pFC9ggDT6jOxuJgSvG8HWJzVf4NDvMavIas4KYjiI
20
+ BU6CpWaG5NxicqL3BERi52U43HV08br+LNVpb7Rekgve/PJuSFnAR015bhSRXe5U
21
+ vBioD1qW2ZW9tXg8Ww2IfDaO5a1So5Xby51rhNlyo6ATj2NkuLWZUKPKHhAz0TKm
22
+ Dzx/gFSOrRoCt2mXNgrmcAfr386AfaMvCh7cXqdxZwmVo7ILZCYXck0pajvubsDd
23
+ NUIIFkVXvd1odFyK9LF1RFAtxn/iAmpx
24
+ -----END CERTIFICATE-----
data/ext/errorcodes.def CHANGED
@@ -302,6 +302,74 @@
302
302
  VALUE klass = define_error_class( "InvalidXmlProcessingInstruction", "22" );
303
303
  register_error_class( "2200T", klass );
304
304
  }
305
+ {
306
+ VALUE klass = define_error_class( "DuplicateJsonObjectKeyValue", "22" );
307
+ register_error_class( "22030", klass );
308
+ }
309
+ {
310
+ VALUE klass = define_error_class( "InvalidArgumentForSqlJsonDatetimeFunction", "22" );
311
+ register_error_class( "22031", klass );
312
+ }
313
+ {
314
+ VALUE klass = define_error_class( "InvalidJsonText", "22" );
315
+ register_error_class( "22032", klass );
316
+ }
317
+ {
318
+ VALUE klass = define_error_class( "InvalidSqlJsonSubscript", "22" );
319
+ register_error_class( "22033", klass );
320
+ }
321
+ {
322
+ VALUE klass = define_error_class( "MoreThanOneSqlJsonItem", "22" );
323
+ register_error_class( "22034", klass );
324
+ }
325
+ {
326
+ VALUE klass = define_error_class( "NoSqlJsonItem", "22" );
327
+ register_error_class( "22035", klass );
328
+ }
329
+ {
330
+ VALUE klass = define_error_class( "NonNumericSqlJsonItem", "22" );
331
+ register_error_class( "22036", klass );
332
+ }
333
+ {
334
+ VALUE klass = define_error_class( "NonUniqueKeysInAJsonObject", "22" );
335
+ register_error_class( "22037", klass );
336
+ }
337
+ {
338
+ VALUE klass = define_error_class( "SingletonSqlJsonItemRequired", "22" );
339
+ register_error_class( "22038", klass );
340
+ }
341
+ {
342
+ VALUE klass = define_error_class( "SqlJsonArrayNotFound", "22" );
343
+ register_error_class( "22039", klass );
344
+ }
345
+ {
346
+ VALUE klass = define_error_class( "SqlJsonMemberNotFound", "22" );
347
+ register_error_class( "2203A", klass );
348
+ }
349
+ {
350
+ VALUE klass = define_error_class( "SqlJsonNumberNotFound", "22" );
351
+ register_error_class( "2203B", klass );
352
+ }
353
+ {
354
+ VALUE klass = define_error_class( "SqlJsonObjectNotFound", "22" );
355
+ register_error_class( "2203C", klass );
356
+ }
357
+ {
358
+ VALUE klass = define_error_class( "TooManyJsonArrayElements", "22" );
359
+ register_error_class( "2203D", klass );
360
+ }
361
+ {
362
+ VALUE klass = define_error_class( "TooManyJsonObjectMembers", "22" );
363
+ register_error_class( "2203E", klass );
364
+ }
365
+ {
366
+ VALUE klass = define_error_class( "SqlJsonScalarRequired", "22" );
367
+ register_error_class( "2203F", klass );
368
+ }
369
+ {
370
+ VALUE klass = define_error_class( "SqlJsonItemCannotBeCastToTargetType", "22" );
371
+ register_error_class( "2203G", klass );
372
+ }
305
373
  {
306
374
  VALUE klass = define_error_class( "IntegrityConstraintViolation", NULL );
307
375
  register_error_class( "23000", klass );
@@ -767,6 +835,10 @@
767
835
  VALUE klass = define_error_class( "LockNotAvailable", "55" );
768
836
  register_error_class( "55P03", klass );
769
837
  }
838
+ {
839
+ VALUE klass = define_error_class( "UnsafeNewEnumValueUsage", "55" );
840
+ register_error_class( "55P04", klass );
841
+ }
770
842
  {
771
843
  VALUE klass = define_error_class( "OperatorIntervention", NULL );
772
844
  register_error_class( "57000", klass );
@@ -792,6 +864,10 @@
792
864
  VALUE klass = define_error_class( "DatabaseDropped", "57" );
793
865
  register_error_class( "57P04", klass );
794
866
  }
867
+ {
868
+ VALUE klass = define_error_class( "IdleSessionTimeout", "57" );
869
+ register_error_class( "57P05", klass );
870
+ }
795
871
  {
796
872
  VALUE klass = define_error_class( "SystemError", NULL );
797
873
  register_error_class( "58000", klass );
data/ext/errorcodes.rb CHANGED
File without changes