pg 0.21.0 → 1.3.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.
Files changed (117) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data/.appveyor.yml +36 -0
  4. data/.gems +6 -0
  5. data/.github/workflows/binary-gems.yml +86 -0
  6. data/.github/workflows/source-gem.yml +130 -0
  7. data/.gitignore +13 -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.rdoc +291 -4
  16. data/Manifest.txt +8 -4
  17. data/README-Windows.rdoc +4 -4
  18. data/README.ja.rdoc +1 -2
  19. data/README.rdoc +62 -16
  20. data/Rakefile +32 -142
  21. data/Rakefile.cross +69 -71
  22. data/certs/ged.pem +24 -0
  23. data/certs/larskanis-2022.pem +26 -0
  24. data/ext/errorcodes.def +84 -0
  25. data/ext/errorcodes.rb +1 -1
  26. data/ext/errorcodes.txt +23 -2
  27. data/ext/extconf.rb +109 -52
  28. data/ext/gvl_wrappers.c +8 -0
  29. data/ext/gvl_wrappers.h +40 -33
  30. data/ext/pg.c +211 -146
  31. data/ext/pg.h +85 -95
  32. data/ext/pg_binary_decoder.c +82 -15
  33. data/ext/pg_binary_encoder.c +13 -12
  34. data/ext/pg_coder.c +145 -30
  35. data/ext/pg_connection.c +1349 -929
  36. data/ext/pg_copy_coder.c +60 -23
  37. data/ext/pg_record_coder.c +519 -0
  38. data/ext/pg_result.c +613 -207
  39. data/ext/pg_text_decoder.c +606 -40
  40. data/ext/pg_text_encoder.c +190 -59
  41. data/ext/pg_tuple.c +575 -0
  42. data/ext/pg_type_map.c +42 -9
  43. data/ext/pg_type_map_all_strings.c +19 -5
  44. data/ext/pg_type_map_by_class.c +54 -24
  45. data/ext/pg_type_map_by_column.c +73 -34
  46. data/ext/pg_type_map_by_mri_type.c +48 -19
  47. data/ext/pg_type_map_by_oid.c +55 -25
  48. data/ext/pg_type_map_in_ruby.c +51 -20
  49. data/ext/{util.c → pg_util.c} +12 -12
  50. data/ext/{util.h → pg_util.h} +2 -2
  51. data/lib/pg/basic_type_map_based_on_result.rb +47 -0
  52. data/lib/pg/basic_type_map_for_queries.rb +193 -0
  53. data/lib/pg/basic_type_map_for_results.rb +81 -0
  54. data/lib/pg/basic_type_registry.rb +296 -0
  55. data/lib/pg/binary_decoder.rb +23 -0
  56. data/lib/pg/coder.rb +24 -3
  57. data/lib/pg/connection.rb +600 -46
  58. data/lib/pg/constants.rb +2 -1
  59. data/lib/pg/exceptions.rb +2 -1
  60. data/lib/pg/result.rb +14 -2
  61. data/lib/pg/text_decoder.rb +21 -26
  62. data/lib/pg/text_encoder.rb +32 -8
  63. data/lib/pg/tuple.rb +30 -0
  64. data/lib/pg/type_map_by_column.rb +3 -2
  65. data/lib/pg/version.rb +4 -0
  66. data/lib/pg.rb +51 -38
  67. data/misc/openssl-pg-segfault.rb +31 -0
  68. data/misc/postgres/History.txt +9 -0
  69. data/misc/postgres/Manifest.txt +5 -0
  70. data/misc/postgres/README.txt +21 -0
  71. data/misc/postgres/Rakefile +21 -0
  72. data/misc/postgres/lib/postgres.rb +16 -0
  73. data/misc/ruby-pg/History.txt +9 -0
  74. data/misc/ruby-pg/Manifest.txt +5 -0
  75. data/misc/ruby-pg/README.txt +21 -0
  76. data/misc/ruby-pg/Rakefile +21 -0
  77. data/misc/ruby-pg/lib/ruby/pg.rb +16 -0
  78. data/pg.gemspec +32 -0
  79. data/sample/array_insert.rb +20 -0
  80. data/sample/async_api.rb +106 -0
  81. data/sample/async_copyto.rb +39 -0
  82. data/sample/async_mixed.rb +56 -0
  83. data/sample/check_conn.rb +21 -0
  84. data/sample/copydata.rb +71 -0
  85. data/sample/copyfrom.rb +81 -0
  86. data/sample/copyto.rb +19 -0
  87. data/sample/cursor.rb +21 -0
  88. data/sample/disk_usage_report.rb +177 -0
  89. data/sample/issue-119.rb +94 -0
  90. data/sample/losample.rb +69 -0
  91. data/sample/minimal-testcase.rb +17 -0
  92. data/sample/notify_wait.rb +72 -0
  93. data/sample/pg_statistics.rb +285 -0
  94. data/sample/replication_monitor.rb +222 -0
  95. data/sample/test_binary_values.rb +33 -0
  96. data/sample/wal_shipper.rb +434 -0
  97. data/sample/warehouse_partitions.rb +311 -0
  98. data.tar.gz.sig +0 -0
  99. metadata +96 -229
  100. metadata.gz.sig +0 -0
  101. data/ChangeLog +0 -6595
  102. data/lib/pg/basic_type_mapping.rb +0 -426
  103. data/lib/pg/deprecated_constants.rb +0 -21
  104. data/spec/data/expected_trace.out +0 -26
  105. data/spec/data/random_binary_data +0 -0
  106. data/spec/helpers.rb +0 -352
  107. data/spec/pg/basic_type_mapping_spec.rb +0 -305
  108. data/spec/pg/connection_spec.rb +0 -1676
  109. data/spec/pg/result_spec.rb +0 -456
  110. data/spec/pg/type_map_by_class_spec.rb +0 -138
  111. data/spec/pg/type_map_by_column_spec.rb +0 -222
  112. data/spec/pg/type_map_by_mri_type_spec.rb +0 -136
  113. data/spec/pg/type_map_by_oid_spec.rb +0 -149
  114. data/spec/pg/type_map_in_ruby_spec.rb +0 -164
  115. data/spec/pg/type_map_spec.rb +0 -22
  116. data/spec/pg/type_spec.rb +0 -777
  117. data/spec/pg_spec.rb +0 -50
data/Rakefile CHANGED
@@ -1,22 +1,13 @@
1
- #!/usr/bin/env rake
1
+ # -*- rake -*-
2
2
 
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,97 +16,38 @@ LIBDIR = BASEDIR + 'lib'
25
16
  EXTDIR = BASEDIR + 'ext'
26
17
  PKGDIR = BASEDIR + 'pkg'
27
18
  TMPDIR = BASEDIR + 'tmp'
19
+ TESTDIR = BASEDIR + "tmp_test_specs"
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
+ CLOBBER.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.6', :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
105
39
  ENV['MAINTAINER_MODE'] = 'yes'
106
40
  end
107
41
 
108
- ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.2:2.0.0'
109
-
110
42
  # Rake-compiler task
111
43
  Rake::ExtensionTask.new do |ext|
112
44
  ext.name = 'pg_ext'
113
- ext.gem_spec = $hoespec.spec
45
+ ext.gem_spec = $gem_spec
114
46
  ext.ext_dir = 'ext'
115
47
  ext.lib_dir = 'lib'
116
48
  ext.source_pattern = "*.{c,h}"
117
49
  ext.cross_compile = true
118
- ext.cross_platform = CrossLibraries.map &:for_platform
50
+ ext.cross_platform = CrossLibraries.map(&:for_platform)
119
51
 
120
52
  ext.cross_config_options += CrossLibraries.map do |lib|
121
53
  {
@@ -131,61 +63,36 @@ Rake::ExtensionTask.new do |ext|
131
63
 
132
64
  # Add libpq.dll to windows binary gemspec
133
65
  ext.cross_compiling do |spec|
134
- spec.files << "lib/libpq.dll"
66
+ spec.files << "lib/#{spec.platform}/libpq.dll"
135
67
  end
136
68
  end
137
69
 
70
+ RSpec::Core::RakeTask.new(:spec).rspec_opts = "--profile -cfdoc"
71
+ task :test => :spec
138
72
 
139
73
  # Use the fivefish formatter for docs generated from development checkout
140
- if File.directory?( '.hg' )
141
- require 'rdoc/task'
142
-
143
- Rake::Task[ 'docs' ].clear
144
- RDoc::Task.new( 'docs' ) do |rdoc|
145
- rdoc.main = "README.rdoc"
146
- rdoc.rdoc_files.include( "*.rdoc", "ChangeLog", "lib/**/*.rb", 'ext/**/*.{c,h}' )
147
- rdoc.generator = :fivefish
148
- rdoc.title = "PG: The Ruby PostgreSQL Driver"
149
- rdoc.rdoc_dir = 'doc'
150
- end
74
+ require 'rdoc/task'
75
+
76
+ RDoc::Task.new( 'docs' ) do |rdoc|
77
+ rdoc.main = "README.rdoc"
78
+ rdoc.rdoc_files.include( "*.rdoc", "lib/**/*.rb", 'ext/**/*.{c,h}' )
79
+ rdoc.generator = :fivefish
80
+ rdoc.title = "PG: The Ruby PostgreSQL Driver"
81
+ rdoc.rdoc_dir = 'doc'
151
82
  end
152
83
 
84
+ desc "Build the source gem #{$gem_spec.full_name}.gem into the pkg directory"
85
+ task :gem => :build
153
86
 
154
- # Make the ChangeLog update if the repo has changed since it was last built
155
- file '.hg/branch' do
156
- warn "WARNING: You need the Mercurial repo to update the ChangeLog"
157
- end
158
- file 'ChangeLog' do |task|
159
- if File.exist?('.hg/branch')
160
- $stderr.puts "Updating the changelog..."
161
- begin
162
- include Hoe::MercurialHelpers
163
- content = make_changelog()
164
- rescue NameError
165
- abort "Packaging tasks require the hoe-mercurial plugin (gem install hoe-mercurial)"
166
- end
167
- File.open( task.name, 'w', 0644 ) do |fh|
168
- fh.print( content )
169
- end
170
- else
171
- touch 'ChangeLog'
172
- end
173
- end
174
-
175
- # Rebuild the ChangeLog immediately before release
176
- task :prerelease => 'ChangeLog'
177
-
178
-
179
- desc "Stop any Postmaster instances that remain after testing."
180
- task :cleanup_testing_dbs do
181
- require 'spec/lib/helpers'
182
- PgTestingHelpers.stop_existing_postmasters()
183
- Rake::Task[:clean].invoke
87
+ task :clobber do
88
+ puts "Stop any Postmaster instances that remain after testing."
89
+ require_relative 'spec/helpers'
90
+ PG::TestingHelpers.stop_existing_postmasters()
184
91
  end
185
92
 
186
93
  desc "Update list of server error codes"
187
94
  task :update_error_codes do
188
- URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL9_6_1"
95
+ URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL_14_0"
189
96
 
190
97
  ERRORCODES_TXT = "ext/errorcodes.txt"
191
98
  sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
@@ -197,20 +104,3 @@ file 'ext/pg_errors.c' => ['ext/errorcodes.def'] do
197
104
  # trigger compilation of changed errorcodes.def
198
105
  touch 'ext/pg_errors.c'
199
106
  end
200
-
201
- task :gemspec => GEMSPEC
202
- file GEMSPEC => __FILE__
203
- task GEMSPEC do |task|
204
- spec = $hoespec.spec
205
- spec.files.delete( '.gemtest' )
206
- spec.signing_key = nil
207
- spec.version = "#{spec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
208
- spec.cert_chain = [ 'certs/ged.pem' ]
209
- File.open( task.name, 'w' ) do |fh|
210
- fh.write( spec.to_ruby )
211
- end
212
- end
213
-
214
- CLOBBER.include( '*.gemspec' )
215
- task :default => :gemspec
216
-
data/Rakefile.cross CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env rake
1
+ # -*- rake -*-
2
2
 
3
3
  require 'uri'
4
4
  require 'tempfile'
@@ -29,15 +29,15 @@ class CrossLibrary < OpenStruct
29
29
  self.host_platform = toolchain
30
30
 
31
31
  # Cross-compilation constants
32
- self.openssl_version = ENV['OPENSSL_VERSION'] || '1.0.2j'
33
- self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '9.6.2'
32
+ self.openssl_version = ENV['OPENSSL_VERSION'] || '1.1.1m'
33
+ self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '14.2'
34
34
 
35
35
  # Check if symlinks work in the current working directory.
36
36
  # This fails, if rake-compiler-dock is running on a Windows box.
37
37
  begin
38
38
  FileUtils.rm_f '.test_symlink'
39
39
  FileUtils.ln_s '/', '.test_symlink'
40
- rescue SystemCallError
40
+ rescue NotImplementedError, SystemCallError
41
41
  # Symlinks don't work -> use home directory instead
42
42
  self.compile_home = Pathname( "~/.ruby-pg-build" ).expand_path
43
43
  else
@@ -45,6 +45,8 @@ class CrossLibrary < OpenStruct
45
45
  end
46
46
  self.static_sourcesdir = compile_home + 'sources'
47
47
  self.static_builddir = compile_home + 'builds' + for_platform
48
+ CLOBBER.include( static_sourcesdir )
49
+ CLEAN.include( static_builddir )
48
50
 
49
51
  # Static OpenSSL build vars
50
52
  self.static_openssl_builddir = static_builddir + "openssl-#{openssl_version}"
@@ -54,8 +56,8 @@ class CrossLibrary < OpenStruct
54
56
  self.openssl_tarball = static_sourcesdir + File.basename( openssl_source_uri.path )
55
57
  self.openssl_makefile = static_openssl_builddir + 'Makefile'
56
58
 
57
- self.libssleay32 = static_openssl_builddir + 'libssleay32.a'
58
- self.libeay32 = static_openssl_builddir + 'libeay32.a'
59
+ self.libssl = static_openssl_builddir + 'libssl.a'
60
+ self.libcrypto = static_openssl_builddir + 'libcrypto.a'
59
61
 
60
62
  self.openssl_patches = Rake::FileList[ (MISCDIR + "openssl-#{openssl_version}.*.patch").to_s ]
61
63
 
@@ -81,19 +83,6 @@ class CrossLibrary < OpenStruct
81
83
  # clean intermediate files and folders
82
84
  CLEAN.include( static_builddir.to_s )
83
85
 
84
-
85
- ENV['RUBY_CC_VERSION'] ||= '1.9.3:2.0.0'
86
-
87
- def download(url, save_to)
88
- part = save_to+".part"
89
- sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
90
- FileUtils.mv part, save_to
91
- end
92
-
93
- def run(*args)
94
- sh *args
95
- end
96
-
97
86
  #####################################################################
98
87
  ### C R O S S - C O M P I L A T I O N - T A S K S
99
88
  #####################################################################
@@ -126,11 +115,9 @@ class CrossLibrary < OpenStruct
126
115
  end
127
116
 
128
117
  self.cmd_prelude = [
129
- 'env',
130
- "CC=#{host_platform}-gcc",
118
+ "env",
119
+ "CROSS_COMPILE=#{host_platform}-",
131
120
  "CFLAGS=-DDSO_WIN32",
132
- "AR=#{host_platform}-ar",
133
- "RANLIB=#{host_platform}-ranlib"
134
121
  ]
135
122
 
136
123
 
@@ -145,9 +132,9 @@ class CrossLibrary < OpenStruct
145
132
  end
146
133
 
147
134
  desc "compile static openssl libraries"
148
- task :openssl_libs => [ libssleay32, libeay32 ]
135
+ task "openssl_libs:#{for_platform}" => [ libssl, libcrypto ]
149
136
 
150
- task :compile_static_openssl => openssl_makefile do |t|
137
+ task "compile_static_openssl:#{for_platform}" => openssl_makefile do |t|
151
138
  chdir( static_openssl_builddir ) do
152
139
  cmd = cmd_prelude.dup
153
140
  cmd << 'make' << "-j#{NUM_CPUS}" << 'build_libs'
@@ -156,14 +143,14 @@ class CrossLibrary < OpenStruct
156
143
  end
157
144
  end
158
145
 
159
- desc "compile static #{libeay32}"
160
- file libeay32 => :compile_static_openssl do |t|
161
- FileUtils.cp( static_openssl_builddir + 'libcrypto.a', libeay32.to_s )
146
+ desc "compile static #{libssl}"
147
+ file libssl => "compile_static_openssl:#{for_platform}" do |t|
148
+ rm t.name.gsub(/\.a$/, ".dll.a")
162
149
  end
163
150
 
164
- desc "compile static #{libssleay32}"
165
- file libssleay32 => :compile_static_openssl do |t|
166
- FileUtils.cp( static_openssl_builddir + 'libssl.a', libssleay32.to_s )
151
+ desc "compile static #{libcrypto}"
152
+ file libcrypto => "compile_static_openssl:#{for_platform}" do |t|
153
+ rm t.name.gsub(/\.a$/, ".dll.a")
167
154
  end
168
155
 
169
156
 
@@ -193,7 +180,7 @@ class CrossLibrary < OpenStruct
193
180
  end
194
181
 
195
182
  # generate the makefile in a clean build location
196
- file postgresql_global_makefile => [ static_postgresql_builddir, :openssl_libs ] do |t|
183
+ file postgresql_global_makefile => [ static_postgresql_builddir, "openssl_libs:#{for_platform}" ] do |t|
197
184
  options = [
198
185
  "--target=#{host_platform}",
199
186
  "--host=#{host_platform}",
@@ -207,7 +194,7 @@ class CrossLibrary < OpenStruct
207
194
  cmd << "CFLAGS=-L#{static_openssl_builddir}"
208
195
  cmd << "LDFLAGS=-L#{static_openssl_builddir}"
209
196
  cmd << "LDFLAGS_SL=-L#{static_openssl_builddir}"
210
- cmd << "LIBS=-lwsock32 -lgdi32"
197
+ cmd << "LIBS=-lwsock32 -lgdi32 -lws2_32"
211
198
  cmd << "CPPFLAGS=-I#{static_openssl_builddir}/include"
212
199
 
213
200
  run( *cmd )
@@ -221,21 +208,24 @@ class CrossLibrary < OpenStruct
221
208
  chdir( static_postgresql_srcdir + "common" ) do
222
209
  sh 'make', "-j#{NUM_CPUS}"
223
210
  end
211
+ chdir( static_postgresql_srcdir + "port" ) do
212
+ sh 'make', "-j#{NUM_CPUS}"
213
+ end
224
214
 
225
215
  chdir( postgresql_lib.dirname ) do
226
216
  sh 'make',
227
217
  "-j#{NUM_CPUS}",
228
218
  postgresql_lib.basename.to_s,
229
- 'SHLIB_LINK=-lssleay32 -leay32 -lcrypt32 -lgdi32 -lsecur32 -lwsock32 -lws2_32'
219
+ 'SHLIB_LINK=-lssl -lcrypto -lcrypt32 -lgdi32 -lsecur32 -lwsock32 -lws2_32'
230
220
  end
231
221
  end
232
222
 
233
223
 
234
224
  #desc 'compile libpg.a'
235
- task :libpq => postgresql_lib
225
+ task "native:#{for_platform}" => postgresql_lib
236
226
 
237
227
  # copy libpq.dll to lib dir
238
- dest_libpq = "lib/#{postgresql_lib.basename}"
228
+ dest_libpq = "lib/#{for_platform}/#{postgresql_lib.basename}"
239
229
  directory File.dirname(dest_libpq)
240
230
  file dest_libpq => [postgresql_lib, File.dirname(dest_libpq)] do
241
231
  cp postgresql_lib, dest_libpq
@@ -247,22 +237,28 @@ class CrossLibrary < OpenStruct
247
237
  cp postgresql_lib, stage_libpq
248
238
  end
249
239
  end
250
- end
251
240
 
252
- if File.exist?(File.expand_path("~/.rake-compiler/config.yml"))
253
- CrossLibraries = [
254
- ['i386-mingw32', 'mingw', 'i686-w64-mingw32'],
255
- ['x64-mingw32', 'mingw64', 'x86_64-w64-mingw32'],
256
- ].map do |platform, openssl_config, toolchain|
257
- CrossLibrary.new platform, openssl_config, toolchain
241
+ def download(url, save_to)
242
+ part = save_to+".part"
243
+ sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
244
+ FileUtils.mv part, save_to
258
245
  end
259
- else
260
- $stderr.puts "Cross-compilation disabled -- rake-compiler not properly installed"
261
- CrossLibraries = []
246
+
247
+ def run(*args)
248
+ sh(*args)
249
+ end
250
+ end
251
+
252
+ CrossLibraries = [
253
+ ['x64-mingw-ucrt', 'mingw64', 'x86_64-w64-mingw32'],
254
+ ['x86-mingw32', 'mingw', 'i686-w64-mingw32'],
255
+ ['x64-mingw32', 'mingw64', 'x86_64-w64-mingw32'],
256
+ ].map do |platform, openssl_config, toolchain|
257
+ CrossLibrary.new platform, openssl_config, toolchain
262
258
  end
263
259
 
264
260
  desc 'cross compile pg for win32'
265
- task :cross => [ :mingw32, :libpq ]
261
+ task :cross => [ :mingw32 ]
266
262
 
267
263
  task :mingw32 do
268
264
  # Use Rake::ExtensionCompiler helpers to find the proper host
@@ -273,30 +269,32 @@ task :mingw32 do
273
269
  end
274
270
  end
275
271
 
276
- # To reduce the gem file size strip mingw32 dlls before packaging
277
- ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
278
- task "tmp/i386-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/pg_ext.so" do |t|
279
- sh "i686-w64-mingw32-strip -S tmp/i386-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/pg_ext.so"
280
- end
281
-
282
- task "tmp/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/pg_ext.so" do |t|
283
- sh "x86_64-w64-mingw32-strip -S tmp/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/pg_ext.so"
284
- end
272
+ task 'gem:windows:prepare' do
273
+ require 'io/console'
274
+ require 'rake_compiler_dock'
275
+
276
+ # Copy gem signing key and certs to be accessible from the docker container
277
+ mkdir_p 'build/gem'
278
+ sh "cp ~/.gem/gem-*.pem build/gem/ || true"
279
+ sh "bundle package"
280
+ begin
281
+ OpenSSL::PKey.read(File.read(File.expand_path("~/.gem/gem-private_key.pem")), ENV["GEM_PRIVATE_KEY_PASSPHRASE"] || "")
282
+ rescue OpenSSL::PKey::PKeyError
283
+ ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = STDIN.getpass("Enter passphrase of gem signature key: ")
284
+ retry
285
+ end
285
286
  end
286
287
 
287
- desc "Build the windows binary gems"
288
- task 'gem:windows' => ['ChangeLog'] do
289
- require 'rake_compiler_dock'
290
-
291
- # Copy gem signing key and certs to be accessable from the docker container
292
- mkdir_p 'build/gem'
293
- sh "cp ~/.gem/gem-*.pem build/gem/ || true"
294
- sh "bundle package"
295
-
296
- RakeCompilerDock.sh <<-EOT
297
- mkdir ~/.gem &&
298
- (cp build/gem/gem-*.pem ~/.gem/ || true) &&
299
- bundle install --local &&
300
- rake cross native gem RUBY_CC_VERSION=2.4.0:2.3.0:2.2.2:2.1.6:2.0.0
301
- EOT
288
+ CrossLibraries.each do |xlib|
289
+ platform = xlib.for_platform
290
+ desc "Build fat binary gem for platform #{platform}"
291
+ task "gem:windows:#{platform}" => ['gem:windows:prepare', xlib.openssl_tarball, xlib.postgresql_tarball] do
292
+ RakeCompilerDock.sh <<-EOT, platform: platform
293
+ (cp build/gem/gem-*.pem ~/.gem/ || true) &&
294
+ bundle install --local &&
295
+ rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKE="make -j`nproc`" RUBY_CC_VERSION=3.1.0:3.0.0:2.7.0:2.6.0:2.5.0
296
+ EOT
297
+ end
298
+ desc "Build the windows binary gems"
299
+ multitask 'gem:windows' => "gem:windows:#{platform}"
302
300
  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
+ Sl6phTvgBrG8GExHbNZpLARd3xrBYLEFsX7Rv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Hemf/fJy1wPyu+fNdp5SEEUwEo+2toRFlzTe4u4LdS
19
+ QC636nPPTMt8H3xz2wf/lUIUeo2Qc95Qt2BQM465ibbG9kmA3c7Sopx6yOabYOAl
20
+ KPRbOSEPiWYcF9Suuz8Gdf8jxEtPlnZiwRvnYJ+IHMq3XQCJWPpMzdDMbtlgHbXE
21
+ vq1zOTLMSYAS0UB3uionR4yo1hLz60odwkCm7qf0o2Ci/5OjtB0a89VuyqRU2vUJ
22
+ QH95WBjDJ6lCCW7J0mrMPnJQSUFTmufsU6jOChvPaCeAzW1YwrsP/YKnvwueG7ip
23
+ VOdW6RitjtFxhS7evRL0201+KUvLz12zZWWjOcujlQs64QprxOtiv/MiisKb1Ng+
24
+ oL1mUdzB8KrZL4/WbG5YNX6UTtJbIOu9qEFbBAy4/jtIkJX+dlNoFwd4GXQW1YNO
25
+ nA==
26
+ -----END CERTIFICATE-----
data/ext/errorcodes.def CHANGED
@@ -186,6 +186,10 @@
186
186
  VALUE klass = define_error_class( "InvalidParameterValue", "22" );
187
187
  register_error_class( "22023", klass );
188
188
  }
189
+ {
190
+ VALUE klass = define_error_class( "InvalidPrecedingOrFollowingSize", "22" );
191
+ register_error_class( "22013", klass );
192
+ }
189
193
  {
190
194
  VALUE klass = define_error_class( "InvalidRegularExpression", "22" );
191
195
  register_error_class( "2201B", klass );
@@ -230,6 +234,10 @@
230
234
  VALUE klass = define_error_class( "NumericValueOutOfRange", "22" );
231
235
  register_error_class( "22003", klass );
232
236
  }
237
+ {
238
+ VALUE klass = define_error_class( "SequenceGeneratorLimitExceeded", "22" );
239
+ register_error_class( "2200H", klass );
240
+ }
233
241
  {
234
242
  VALUE klass = define_error_class( "StringDataLengthMismatch", "22" );
235
243
  register_error_class( "22026", klass );
@@ -294,6 +302,70 @@
294
302
  VALUE klass = define_error_class( "InvalidXmlProcessingInstruction", "22" );
295
303
  register_error_class( "2200T", klass );
296
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
+ }
297
369
  {
298
370
  VALUE klass = define_error_class( "IntegrityConstraintViolation", NULL );
299
371
  register_error_class( "23000", klass );
@@ -587,6 +659,10 @@
587
659
  VALUE klass = define_error_class( "WrongObjectType", "42" );
588
660
  register_error_class( "42809", klass );
589
661
  }
662
+ {
663
+ VALUE klass = define_error_class( "GeneratedAlways", "42" );
664
+ register_error_class( "428C9", klass );
665
+ }
590
666
  {
591
667
  VALUE klass = define_error_class( "UndefinedColumn", "42" );
592
668
  register_error_class( "42703", klass );
@@ -755,6 +831,10 @@
755
831
  VALUE klass = define_error_class( "LockNotAvailable", "55" );
756
832
  register_error_class( "55P03", klass );
757
833
  }
834
+ {
835
+ VALUE klass = define_error_class( "UnsafeNewEnumValueUsage", "55" );
836
+ register_error_class( "55P04", klass );
837
+ }
758
838
  {
759
839
  VALUE klass = define_error_class( "OperatorIntervention", NULL );
760
840
  register_error_class( "57000", klass );
@@ -780,6 +860,10 @@
780
860
  VALUE klass = define_error_class( "DatabaseDropped", "57" );
781
861
  register_error_class( "57P04", klass );
782
862
  }
863
+ {
864
+ VALUE klass = define_error_class( "IdleSessionTimeout", "57" );
865
+ register_error_class( "57P05", klass );
866
+ }
783
867
  {
784
868
  VALUE klass = define_error_class( "SystemError", NULL );
785
869
  register_error_class( "58000", klass );
data/ext/errorcodes.rb CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
2
 
3
3
  def camelize(lower_case_and_underscored_word)
4
4
  lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }