pg 1.3.0.rc2-x64-mingw-ucrt

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 (111) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +3 -0
  3. data/.appveyor.yml +36 -0
  4. data/.gems +6 -0
  5. data/.gemtest +0 -0
  6. data/.github/workflows/binary-gems.yml +85 -0
  7. data/.github/workflows/source-gem.yml +130 -0
  8. data/.gitignore +13 -0
  9. data/.hgsigs +34 -0
  10. data/.hgtags +41 -0
  11. data/.irbrc +23 -0
  12. data/.pryrc +23 -0
  13. data/.tm_properties +21 -0
  14. data/.travis.yml +49 -0
  15. data/BSDL +22 -0
  16. data/Contributors.rdoc +46 -0
  17. data/Gemfile +14 -0
  18. data/History.rdoc +648 -0
  19. data/LICENSE +56 -0
  20. data/Manifest.txt +72 -0
  21. data/POSTGRES +23 -0
  22. data/README-OS_X.rdoc +68 -0
  23. data/README-Windows.rdoc +56 -0
  24. data/README.ja.rdoc +13 -0
  25. data/README.rdoc +214 -0
  26. data/Rakefile +106 -0
  27. data/Rakefile.cross +300 -0
  28. data/certs/ged.pem +24 -0
  29. data/ext/errorcodes.def +1040 -0
  30. data/ext/errorcodes.rb +45 -0
  31. data/ext/errorcodes.txt +496 -0
  32. data/ext/extconf.rb +165 -0
  33. data/ext/gvl_wrappers.c +21 -0
  34. data/ext/gvl_wrappers.h +264 -0
  35. data/ext/pg.c +732 -0
  36. data/ext/pg.h +385 -0
  37. data/ext/pg_binary_decoder.c +229 -0
  38. data/ext/pg_binary_encoder.c +163 -0
  39. data/ext/pg_coder.c +615 -0
  40. data/ext/pg_connection.c +4415 -0
  41. data/ext/pg_copy_coder.c +628 -0
  42. data/ext/pg_errors.c +95 -0
  43. data/ext/pg_record_coder.c +519 -0
  44. data/ext/pg_result.c +1683 -0
  45. data/ext/pg_text_decoder.c +987 -0
  46. data/ext/pg_text_encoder.c +814 -0
  47. data/ext/pg_tuple.c +575 -0
  48. data/ext/pg_type_map.c +199 -0
  49. data/ext/pg_type_map_all_strings.c +129 -0
  50. data/ext/pg_type_map_by_class.c +269 -0
  51. data/ext/pg_type_map_by_column.c +349 -0
  52. data/ext/pg_type_map_by_mri_type.c +313 -0
  53. data/ext/pg_type_map_by_oid.c +385 -0
  54. data/ext/pg_type_map_in_ruby.c +330 -0
  55. data/ext/pg_util.c +149 -0
  56. data/ext/pg_util.h +65 -0
  57. data/ext/vc/pg.sln +26 -0
  58. data/ext/vc/pg_18/pg.vcproj +216 -0
  59. data/ext/vc/pg_19/pg_19.vcproj +209 -0
  60. data/lib/3.1/pg_ext.so +0 -0
  61. data/lib/pg/basic_type_map_based_on_result.rb +47 -0
  62. data/lib/pg/basic_type_map_for_queries.rb +193 -0
  63. data/lib/pg/basic_type_map_for_results.rb +81 -0
  64. data/lib/pg/basic_type_registry.rb +296 -0
  65. data/lib/pg/binary_decoder.rb +23 -0
  66. data/lib/pg/coder.rb +104 -0
  67. data/lib/pg/connection.rb +813 -0
  68. data/lib/pg/constants.rb +12 -0
  69. data/lib/pg/exceptions.rb +12 -0
  70. data/lib/pg/result.rb +43 -0
  71. data/lib/pg/text_decoder.rb +46 -0
  72. data/lib/pg/text_encoder.rb +59 -0
  73. data/lib/pg/tuple.rb +30 -0
  74. data/lib/pg/type_map_by_column.rb +16 -0
  75. data/lib/pg/version.rb +4 -0
  76. data/lib/pg.rb +87 -0
  77. data/lib/x64-mingw-ucrt/libpq.dll +0 -0
  78. data/misc/openssl-pg-segfault.rb +31 -0
  79. data/misc/postgres/History.txt +9 -0
  80. data/misc/postgres/Manifest.txt +5 -0
  81. data/misc/postgres/README.txt +21 -0
  82. data/misc/postgres/Rakefile +21 -0
  83. data/misc/postgres/lib/postgres.rb +16 -0
  84. data/misc/ruby-pg/History.txt +9 -0
  85. data/misc/ruby-pg/Manifest.txt +5 -0
  86. data/misc/ruby-pg/README.txt +21 -0
  87. data/misc/ruby-pg/Rakefile +21 -0
  88. data/misc/ruby-pg/lib/ruby/pg.rb +16 -0
  89. data/pg.gemspec +32 -0
  90. data/sample/array_insert.rb +20 -0
  91. data/sample/async_api.rb +106 -0
  92. data/sample/async_copyto.rb +39 -0
  93. data/sample/async_mixed.rb +56 -0
  94. data/sample/check_conn.rb +21 -0
  95. data/sample/copydata.rb +71 -0
  96. data/sample/copyfrom.rb +81 -0
  97. data/sample/copyto.rb +19 -0
  98. data/sample/cursor.rb +21 -0
  99. data/sample/disk_usage_report.rb +177 -0
  100. data/sample/issue-119.rb +94 -0
  101. data/sample/losample.rb +69 -0
  102. data/sample/minimal-testcase.rb +17 -0
  103. data/sample/notify_wait.rb +72 -0
  104. data/sample/pg_statistics.rb +285 -0
  105. data/sample/replication_monitor.rb +222 -0
  106. data/sample/test_binary_values.rb +33 -0
  107. data/sample/wal_shipper.rb +434 -0
  108. data/sample/warehouse_partitions.rb +311 -0
  109. data.tar.gz.sig +0 -0
  110. metadata +188 -0
  111. metadata.gz.sig +0 -0
data/Rakefile.cross ADDED
@@ -0,0 +1,300 @@
1
+ # -*- rake -*-
2
+
3
+ require 'uri'
4
+ require 'tempfile'
5
+ require 'rbconfig'
6
+ require 'rake/clean'
7
+ require 'rake/extensiontask'
8
+ require 'rake/extensioncompiler'
9
+ require 'ostruct'
10
+
11
+ MISCDIR = BASEDIR + 'misc'
12
+
13
+ NUM_CPUS = if File.exist?('/proc/cpuinfo')
14
+ File.read('/proc/cpuinfo').scan('processor').length
15
+ elsif RUBY_PLATFORM.include?( 'darwin' )
16
+ `system_profiler SPHardwareDataType | grep 'Cores' | awk '{print $5}'`.chomp
17
+ else
18
+ 1
19
+ end
20
+
21
+ class CrossLibrary < OpenStruct
22
+ include Rake::DSL
23
+
24
+ def initialize(for_platform, openssl_config, toolchain)
25
+ super()
26
+
27
+ self.for_platform = for_platform
28
+ self.openssl_config = openssl_config
29
+ self.host_platform = toolchain
30
+
31
+ # Cross-compilation constants
32
+ self.openssl_version = ENV['OPENSSL_VERSION'] || '1.1.1m'
33
+ self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '14.1'
34
+
35
+ # Check if symlinks work in the current working directory.
36
+ # This fails, if rake-compiler-dock is running on a Windows box.
37
+ begin
38
+ FileUtils.rm_f '.test_symlink'
39
+ FileUtils.ln_s '/', '.test_symlink'
40
+ rescue NotImplementedError, SystemCallError
41
+ # Symlinks don't work -> use home directory instead
42
+ self.compile_home = Pathname( "~/.ruby-pg-build" ).expand_path
43
+ else
44
+ self.compile_home = Pathname( "./build" ).expand_path
45
+ end
46
+ self.static_sourcesdir = compile_home + 'sources'
47
+ self.static_builddir = compile_home + 'builds' + for_platform
48
+ CLOBBER.include( static_sourcesdir )
49
+ CLEAN.include( static_builddir )
50
+
51
+ # Static OpenSSL build vars
52
+ self.static_openssl_builddir = static_builddir + "openssl-#{openssl_version}"
53
+
54
+ self.openssl_source_uri =
55
+ URI( "http://www.openssl.org/source/openssl-#{openssl_version}.tar.gz" )
56
+ self.openssl_tarball = static_sourcesdir + File.basename( openssl_source_uri.path )
57
+ self.openssl_makefile = static_openssl_builddir + 'Makefile'
58
+
59
+ self.libssl = static_openssl_builddir + 'libssl.a'
60
+ self.libcrypto = static_openssl_builddir + 'libcrypto.a'
61
+
62
+ self.openssl_patches = Rake::FileList[ (MISCDIR + "openssl-#{openssl_version}.*.patch").to_s ]
63
+
64
+ # Static PostgreSQL build vars
65
+ self.static_postgresql_builddir = static_builddir + "postgresql-#{postgresql_version}"
66
+ self.postgresql_source_uri = begin
67
+ uristring = "http://ftp.postgresql.org/pub/source/v%s/postgresql-%s.tar.bz2" %
68
+ [ postgresql_version, postgresql_version ]
69
+ URI( uristring )
70
+ end
71
+ self.postgresql_tarball = static_sourcesdir + File.basename( postgresql_source_uri.path )
72
+
73
+ self.static_postgresql_srcdir = static_postgresql_builddir + 'src'
74
+ self.static_postgresql_libdir = static_postgresql_srcdir + 'interfaces/libpq'
75
+ self.static_postgresql_incdir = static_postgresql_srcdir + 'include'
76
+
77
+ self.postgresql_global_makefile = static_postgresql_srcdir + 'Makefile.global'
78
+ self.postgresql_shlib_makefile = static_postgresql_srcdir + 'Makefile.shlib'
79
+ self.postgresql_shlib_mf_orig = static_postgresql_srcdir + 'Makefile.shlib.orig'
80
+ self.postgresql_lib = static_postgresql_libdir + 'libpq.dll'
81
+ self.postgresql_patches = Rake::FileList[ (MISCDIR + "postgresql-#{postgresql_version}.*.patch").to_s ]
82
+
83
+ # clean intermediate files and folders
84
+ CLEAN.include( static_builddir.to_s )
85
+
86
+ #####################################################################
87
+ ### C R O S S - C O M P I L A T I O N - T A S K S
88
+ #####################################################################
89
+
90
+
91
+ directory static_sourcesdir.to_s
92
+
93
+ #
94
+ # Static OpenSSL build tasks
95
+ #
96
+ directory static_openssl_builddir.to_s
97
+
98
+ # openssl source file should be stored there
99
+ file openssl_tarball => static_sourcesdir do |t|
100
+ download( openssl_source_uri, t.name )
101
+ end
102
+
103
+ # Extract the openssl builds
104
+ file static_openssl_builddir => openssl_tarball do |t|
105
+ puts "extracting %s to %s" % [ openssl_tarball, static_openssl_builddir.parent ]
106
+ static_openssl_builddir.mkpath
107
+ run 'tar', '-xzf', openssl_tarball.to_s, '-C', static_openssl_builddir.parent.to_s
108
+ openssl_makefile.unlink if openssl_makefile.exist?
109
+
110
+ openssl_patches.each do |patchfile|
111
+ puts " applying patch #{patchfile}..."
112
+ run 'patch', '-Np1', '-d', static_openssl_builddir.to_s,
113
+ '-i', File.expand_path( patchfile, BASEDIR )
114
+ end
115
+ end
116
+
117
+ self.cmd_prelude = [
118
+ "env",
119
+ "CROSS_COMPILE=#{host_platform}-",
120
+ "CFLAGS=-DDSO_WIN32",
121
+ ]
122
+
123
+
124
+ # generate the makefile in a clean build location
125
+ file openssl_makefile => static_openssl_builddir do |t|
126
+ chdir( static_openssl_builddir ) do
127
+ cmd = cmd_prelude.dup
128
+ cmd << "./Configure" << openssl_config
129
+
130
+ run( *cmd )
131
+ end
132
+ end
133
+
134
+ desc "compile static openssl libraries"
135
+ task "openssl_libs:#{for_platform}" => [ libssl, libcrypto ]
136
+
137
+ task "compile_static_openssl:#{for_platform}" => openssl_makefile do |t|
138
+ chdir( static_openssl_builddir ) do
139
+ cmd = cmd_prelude.dup
140
+ cmd << 'make' << "-j#{NUM_CPUS}" << 'build_libs'
141
+
142
+ run( *cmd )
143
+ end
144
+ end
145
+
146
+ desc "compile static #{libssl}"
147
+ file libssl => "compile_static_openssl:#{for_platform}" do |t|
148
+ rm t.name.gsub(/\.a$/, ".dll.a")
149
+ end
150
+
151
+ desc "compile static #{libcrypto}"
152
+ file libcrypto => "compile_static_openssl:#{for_platform}" do |t|
153
+ rm t.name.gsub(/\.a$/, ".dll.a")
154
+ end
155
+
156
+
157
+
158
+ #
159
+ # Static PostgreSQL build tasks
160
+ #
161
+ directory static_postgresql_builddir.to_s
162
+
163
+
164
+ # postgresql source file should be stored there
165
+ file postgresql_tarball => static_sourcesdir do |t|
166
+ download( postgresql_source_uri, t.name )
167
+ end
168
+
169
+ # Extract the postgresql sources
170
+ file static_postgresql_builddir => postgresql_tarball do |t|
171
+ puts "extracting %s to %s" % [ postgresql_tarball, static_postgresql_builddir.parent ]
172
+ static_postgresql_builddir.mkpath
173
+ run 'tar', '-xjf', postgresql_tarball.to_s, '-C', static_postgresql_builddir.parent.to_s
174
+
175
+ postgresql_patches.each do |patchfile|
176
+ puts " applying patch #{patchfile}..."
177
+ run 'patch', '-Np1', '-d', static_postgresql_builddir.to_s,
178
+ '-i', File.expand_path( patchfile, BASEDIR )
179
+ end
180
+ end
181
+
182
+ # generate the makefile in a clean build location
183
+ file postgresql_global_makefile => [ static_postgresql_builddir, "openssl_libs:#{for_platform}" ] do |t|
184
+ options = [
185
+ "--target=#{host_platform}",
186
+ "--host=#{host_platform}",
187
+ '--with-openssl',
188
+ '--without-zlib',
189
+ ]
190
+
191
+ chdir( static_postgresql_builddir ) do
192
+ configure_path = static_postgresql_builddir + 'configure'
193
+ cmd = [ configure_path.to_s, *options ]
194
+ cmd << "CFLAGS=-L#{static_openssl_builddir}"
195
+ cmd << "LDFLAGS=-L#{static_openssl_builddir}"
196
+ cmd << "LDFLAGS_SL=-L#{static_openssl_builddir}"
197
+ cmd << "LIBS=-lwsock32 -lgdi32 -lws2_32"
198
+ cmd << "CPPFLAGS=-I#{static_openssl_builddir}/include"
199
+
200
+ run( *cmd )
201
+ end
202
+ end
203
+
204
+
205
+ # make libpq.dll
206
+ task postgresql_lib => [ postgresql_global_makefile ] do |t|
207
+ # Work around missing dependency to libcommon in PostgreSQL-9.4.0
208
+ chdir( static_postgresql_srcdir + "common" ) do
209
+ sh 'make', "-j#{NUM_CPUS}"
210
+ end
211
+ chdir( static_postgresql_srcdir + "port" ) do
212
+ sh 'make', "-j#{NUM_CPUS}"
213
+ end
214
+
215
+ chdir( postgresql_lib.dirname ) do
216
+ sh 'make',
217
+ "-j#{NUM_CPUS}",
218
+ postgresql_lib.basename.to_s,
219
+ 'SHLIB_LINK=-lssl -lcrypto -lcrypt32 -lgdi32 -lsecur32 -lwsock32 -lws2_32'
220
+ end
221
+ end
222
+
223
+
224
+ #desc 'compile libpg.a'
225
+ task "native:#{for_platform}" => postgresql_lib
226
+
227
+ # copy libpq.dll to lib dir
228
+ dest_libpq = "lib/#{for_platform}/#{postgresql_lib.basename}"
229
+ directory File.dirname(dest_libpq)
230
+ file dest_libpq => [postgresql_lib, File.dirname(dest_libpq)] do
231
+ cp postgresql_lib, dest_libpq
232
+ end
233
+
234
+ stage_libpq = "tmp/#{for_platform}/stage/#{dest_libpq}"
235
+ directory File.dirname(stage_libpq)
236
+ file stage_libpq => [postgresql_lib, File.dirname(stage_libpq)] do |t|
237
+ cp postgresql_lib, stage_libpq
238
+ end
239
+ end
240
+
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
245
+ end
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
258
+ end
259
+
260
+ desc 'cross compile pg for win32'
261
+ task :cross => [ :mingw32 ]
262
+
263
+ task :mingw32 do
264
+ # Use Rake::ExtensionCompiler helpers to find the proper host
265
+ unless Rake::ExtensionCompiler.mingw_host then
266
+ warn "You need to install mingw32 cross compile functionality to be able to continue."
267
+ warn "Please refer to your distribution/package manager documentation about installation."
268
+ fail
269
+ end
270
+ end
271
+
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
286
+ end
287
+
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}"
300
+ end
data/certs/ged.pem ADDED
@@ -0,0 +1,24 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIID+DCCAmCgAwIBAgIBAzANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdnZWQv
3
+ REM9RmFlcmllTVVEL0RDPW9yZzAeFw0yMDEyMjQyMDU1MjlaFw0yMTEyMjQyMDU1
4
+ MjlaMCIxIDAeBgNVBAMMF2dlZC9EQz1GYWVyaWVNVUQvREM9b3JnMIIBojANBgkq
5
+ hkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAvyVhkRzvlEs0fe7145BYLfN6njX9ih5H
6
+ L60U0p0euIurpv84op9CNKF9tx+1WKwyQvQP7qFGuZxkSUuWcP/sFhDXL1lWUuIl
7
+ M4uHbGCRmOshDrF4dgnBeOvkHr1fIhPlJm5FO+Vew8tSQmlDsosxLUx+VB7DrVFO
8
+ 5PU2AEbf04GGSrmqADGWXeaslaoRdb1fu/0M5qfPTRn5V39sWD9umuDAF9qqil/x
9
+ Sl6phTvgBrG8GExHbNZpLARd3xrBYLEFsX7RvBn2UPfgsrtvpdXjsHGfpT3IPN+B
10
+ vQ66lts4alKC69TE5cuKasWBm+16A4aEe3XdZBRNmtOu/g81gvwA7fkJHKllJuaI
11
+ dXzdHqq+zbGZVSQ7pRYHYomD0IiDe1DbIouFnPWmagaBnGHwXkDT2bKKP+s2v21m
12
+ ozilJg4aar2okb/RA6VS87o+d7g6LpDDMMQjH4G9OPnJENLdhu8KnPw/ivSVvQw7
13
+ N2I4L/ZOIe2DIVuYH7aLHfjZDQv/mNgpAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYD
14
+ VR0PBAQDAgSwMB0GA1UdDgQWBBRyjf55EbrHagiRLqt5YAd3yb8k4DANBgkqhkiG
15
+ 9w0BAQsFAAOCAYEAMYegZanJi8zq7QKPT7wqXefX4C88I5JWeBHR3PvvWK0CwyMV
16
+ peyiu5I13w/lYX+HUZjE4qsSpJMJFXWl4WZCOo+AMprOcf0PxfuJpxCej5D4tavf
17
+ vRfhahSw7XJrcZih/3J+/UgoH7R05MJ+8LTcy3HGrB3a0vTafjm8OY7Xpa0LJDoN
18
+ JDqxK321VIHyTibbKeA1hWSE6ljlQDvFbTqiCj3Ulp1jTv3TOlvRl8fqcfhxUJI0
19
+ +5Q82jJODjEN+GaWs0V+NlrbU94cXwS2PH5dXogftB5YYA5Ex8A0ikZ73xns4Hdo
20
+ XxdLdd92F5ovxA23j/rKe/IDwqr6FpDkU3nPXH/Qp0TVGv9zZnVJc/Z6ChkuWj8z
21
+ pW7JAyyiiHZgKKDReDrA2LA7Zs3o/7KA6UtUH0FHf8LYhcK+pfHk6RtjRe65ffw+
22
+ MCh97sQ/Z/MOusb5+QddBmB+k8EicXyGNl4b5L4XpL7fIQu+Y96TB3JEJlShxFD9
23
+ k9FjI4d9EP54gS/4
24
+ -----END CERTIFICATE-----