pg 1.1.3 → 1.3.3

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 +4 -4
  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 +129 -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 +210 -6
  16. data/Manifest.txt +3 -3
  17. data/README-Windows.rdoc +4 -4
  18. data/README.ja.rdoc +1 -2
  19. data/README.rdoc +51 -15
  20. data/Rakefile +31 -140
  21. data/Rakefile.cross +60 -56
  22. data/certs/ged.pem +24 -0
  23. data/certs/larskanis-2022.pem +26 -0
  24. data/ext/errorcodes.def +76 -0
  25. data/ext/errorcodes.txt +21 -2
  26. data/ext/extconf.rb +101 -26
  27. data/ext/gvl_wrappers.c +4 -0
  28. data/ext/gvl_wrappers.h +23 -0
  29. data/ext/pg.c +190 -98
  30. data/ext/pg.h +42 -17
  31. data/ext/pg_binary_decoder.c +20 -16
  32. data/ext/pg_binary_encoder.c +13 -12
  33. data/ext/pg_coder.c +95 -29
  34. data/ext/pg_connection.c +1043 -769
  35. data/ext/pg_copy_coder.c +50 -18
  36. data/ext/pg_record_coder.c +519 -0
  37. data/ext/pg_result.c +326 -142
  38. data/ext/pg_text_decoder.c +15 -9
  39. data/ext/pg_text_encoder.c +185 -53
  40. data/ext/pg_tuple.c +61 -27
  41. data/ext/pg_type_map.c +42 -9
  42. data/ext/pg_type_map_all_strings.c +19 -5
  43. data/ext/pg_type_map_by_class.c +54 -24
  44. data/ext/pg_type_map_by_column.c +73 -34
  45. data/ext/pg_type_map_by_mri_type.c +48 -19
  46. data/ext/pg_type_map_by_oid.c +55 -25
  47. data/ext/pg_type_map_in_ruby.c +51 -20
  48. data/ext/{util.c → pg_util.c} +7 -7
  49. data/ext/{util.h → pg_util.h} +0 -0
  50. data/lib/pg/basic_type_map_based_on_result.rb +47 -0
  51. data/lib/pg/basic_type_map_for_queries.rb +193 -0
  52. data/lib/pg/basic_type_map_for_results.rb +81 -0
  53. data/lib/pg/basic_type_registry.rb +296 -0
  54. data/lib/pg/binary_decoder.rb +1 -0
  55. data/lib/pg/coder.rb +23 -2
  56. data/lib/pg/connection.rb +589 -59
  57. data/lib/pg/constants.rb +1 -0
  58. data/lib/pg/exceptions.rb +1 -0
  59. data/lib/pg/result.rb +13 -1
  60. data/lib/pg/text_decoder.rb +2 -3
  61. data/lib/pg/text_encoder.rb +8 -18
  62. data/lib/pg/type_map_by_column.rb +2 -1
  63. data/lib/pg/version.rb +4 -0
  64. data/lib/pg.rb +48 -33
  65. data/misc/openssl-pg-segfault.rb +31 -0
  66. data/misc/postgres/History.txt +9 -0
  67. data/misc/postgres/Manifest.txt +5 -0
  68. data/misc/postgres/README.txt +21 -0
  69. data/misc/postgres/Rakefile +21 -0
  70. data/misc/postgres/lib/postgres.rb +16 -0
  71. data/misc/ruby-pg/History.txt +9 -0
  72. data/misc/ruby-pg/Manifest.txt +5 -0
  73. data/misc/ruby-pg/README.txt +21 -0
  74. data/misc/ruby-pg/Rakefile +21 -0
  75. data/misc/ruby-pg/lib/ruby/pg.rb +16 -0
  76. data/pg.gemspec +32 -0
  77. data/rakelib/task_extension.rb +46 -0
  78. data/sample/array_insert.rb +20 -0
  79. data/sample/async_api.rb +106 -0
  80. data/sample/async_copyto.rb +39 -0
  81. data/sample/async_mixed.rb +56 -0
  82. data/sample/check_conn.rb +21 -0
  83. data/sample/copydata.rb +71 -0
  84. data/sample/copyfrom.rb +81 -0
  85. data/sample/copyto.rb +19 -0
  86. data/sample/cursor.rb +21 -0
  87. data/sample/disk_usage_report.rb +177 -0
  88. data/sample/issue-119.rb +94 -0
  89. data/sample/losample.rb +69 -0
  90. data/sample/minimal-testcase.rb +17 -0
  91. data/sample/notify_wait.rb +72 -0
  92. data/sample/pg_statistics.rb +285 -0
  93. data/sample/replication_monitor.rb +222 -0
  94. data/sample/test_binary_values.rb +33 -0
  95. data/sample/wal_shipper.rb +434 -0
  96. data/sample/warehouse_partitions.rb +311 -0
  97. data.tar.gz.sig +0 -0
  98. metadata +94 -237
  99. metadata.gz.sig +0 -0
  100. data/ChangeLog +0 -6595
  101. data/lib/pg/basic_type_mapping.rb +0 -459
  102. data/spec/data/expected_trace.out +0 -26
  103. data/spec/data/random_binary_data +0 -0
  104. data/spec/helpers.rb +0 -381
  105. data/spec/pg/basic_type_mapping_spec.rb +0 -508
  106. data/spec/pg/connection_spec.rb +0 -1849
  107. data/spec/pg/connection_sync_spec.rb +0 -41
  108. data/spec/pg/result_spec.rb +0 -491
  109. data/spec/pg/tuple_spec.rb +0 -280
  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 -949
  117. data/spec/pg_spec.rb +0 -50
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.0h'
33
- self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '10.4'
34
+ self.openssl_version = ENV['OPENSSL_VERSION'] || '1.1.1m'
35
+ self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '14.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
  #####################################################################
@@ -141,9 +134,9 @@ class CrossLibrary < OpenStruct
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,12 +146,12 @@ class CrossLibrary < OpenStruct
153
146
  end
154
147
 
155
148
  desc "compile static #{libssl}"
156
- file libssl => :compile_static_openssl do |t|
149
+ file libssl => "compile_static_openssl:#{for_platform}" do |t|
157
150
  rm t.name.gsub(/\.a$/, ".dll.a")
158
151
  end
159
152
 
160
153
  desc "compile static #{libcrypto}"
161
- file libcrypto => :compile_static_openssl do |t|
154
+ file libcrypto => "compile_static_openssl:#{for_platform}" do |t|
162
155
  rm t.name.gsub(/\.a$/, ".dll.a")
163
156
  end
164
157
 
@@ -189,7 +182,7 @@ class CrossLibrary < OpenStruct
189
182
  end
190
183
 
191
184
  # generate the makefile in a clean build location
192
- file postgresql_global_makefile => [ static_postgresql_builddir, :openssl_libs ] do |t|
185
+ file postgresql_global_makefile => [ static_postgresql_builddir, "openssl_libs:#{for_platform}" ] do |t|
193
186
  options = [
194
187
  "--target=#{host_platform}",
195
188
  "--host=#{host_platform}",
@@ -217,6 +210,9 @@ class CrossLibrary < OpenStruct
217
210
  chdir( static_postgresql_srcdir + "common" ) do
218
211
  sh 'make', "-j#{NUM_CPUS}"
219
212
  end
213
+ chdir( static_postgresql_srcdir + "port" ) do
214
+ sh 'make', "-j#{NUM_CPUS}"
215
+ end
220
216
 
221
217
  chdir( postgresql_lib.dirname ) do
222
218
  sh 'make',
@@ -228,10 +224,10 @@ class CrossLibrary < OpenStruct
228
224
 
229
225
 
230
226
  #desc 'compile libpg.a'
231
- task :libpq => postgresql_lib
227
+ task "native:#{for_platform}" => postgresql_lib
232
228
 
233
229
  # copy libpq.dll to lib dir
234
- dest_libpq = "lib/#{postgresql_lib.basename}"
230
+ dest_libpq = "lib/#{for_platform}/#{postgresql_lib.basename}"
235
231
  directory File.dirname(dest_libpq)
236
232
  file dest_libpq => [postgresql_lib, File.dirname(dest_libpq)] do
237
233
  cp postgresql_lib, dest_libpq
@@ -243,22 +239,28 @@ class CrossLibrary < OpenStruct
243
239
  cp postgresql_lib, stage_libpq
244
240
  end
245
241
  end
246
- end
247
242
 
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
243
+ def download(url, save_to)
244
+ part = save_to+".part"
245
+ sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
246
+ FileUtils.mv part, save_to
254
247
  end
255
- else
256
- $stderr.puts "Cross-compilation disabled -- rake-compiler not properly installed"
257
- CrossLibraries = []
248
+
249
+ def run(*args)
250
+ sh(*args)
251
+ end
252
+ end
253
+
254
+ CrossLibraries = [
255
+ ['x64-mingw-ucrt', 'mingw64', 'x86_64-w64-mingw32'],
256
+ ['x86-mingw32', 'mingw', 'i686-w64-mingw32'],
257
+ ['x64-mingw32', 'mingw64', 'x86_64-w64-mingw32'],
258
+ ].map do |platform, openssl_config, toolchain|
259
+ CrossLibrary.new platform, openssl_config, toolchain
258
260
  end
259
261
 
260
262
  desc 'cross compile pg for win32'
261
- task :cross => [ :mingw32, :libpq ]
263
+ task :cross => [ :mingw32 ]
262
264
 
263
265
  task :mingw32 do
264
266
  # Use Rake::ExtensionCompiler helpers to find the proper host
@@ -269,30 +271,32 @@ task :mingw32 do
269
271
  end
270
272
  end
271
273
 
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
274
+ task 'gem:windows:prepare' do
275
+ require 'io/console'
276
+ require 'rake_compiler_dock'
277
+
278
+ # Copy gem signing key and certs to be accessible from the docker container
279
+ mkdir_p 'build/gem'
280
+ sh "cp ~/.gem/gem-*.pem build/gem/ || true"
281
+ sh "bundle package"
282
+ begin
283
+ OpenSSL::PKey.read(File.read(File.expand_path("~/.gem/gem-private_key.pem")), ENV["GEM_PRIVATE_KEY_PASSPHRASE"] || "")
284
+ rescue OpenSSL::PKey::PKeyError
285
+ ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = STDIN.getpass("Enter passphrase of gem signature key: ")
286
+ retry
287
+ end
281
288
  end
282
289
 
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 RUBY_CC_VERSION=2.5.0:2.4.0:2.3.0:2.2.2:2.1.6:2.0.0 MAKE="make -j`nproc`"
297
- EOT
290
+ CrossLibraries.each do |xlib|
291
+ platform = xlib.for_platform
292
+ desc "Build fat binary gem for platform #{platform}"
293
+ task "gem:windows:#{platform}" => ['gem:windows:prepare', xlib.openssl_tarball, xlib.postgresql_tarball] do
294
+ RakeCompilerDock.sh <<-EOT, platform: platform
295
+ (cp build/gem/gem-*.pem ~/.gem/ || true) &&
296
+ bundle install --local &&
297
+ 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
298
+ EOT
299
+ end
300
+ desc "Build the windows binary gems"
301
+ multitask 'gem:windows' => "gem:windows:#{platform}"
298
302
  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+16A4aEe3XdZBRNmtOu/g81gvwA7fkJHKllJuaI
11
+ dXzdHqq+zbGZVSQ7pRYHYomD0IiDe1DbIouFnPWmagaBnGHwXkDT2bKKP+s2v21m
12
+ ozilJg4aar2okb/RA6VS87o+d7g6LpDDMMQjH4G9OPnJENLdhu8KnPw/ivSVvQw7
13
+ N2I4L/ZOIe2DIVuYH7aLHfjZDQv/mNgpAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYD
14
+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rsP/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 );
@@ -298,6 +302,70 @@
298
302
  VALUE klass = define_error_class( "InvalidXmlProcessingInstruction", "22" );
299
303
  register_error_class( "2200T", klass );
300
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
+ }
301
369
  {
302
370
  VALUE klass = define_error_class( "IntegrityConstraintViolation", NULL );
303
371
  register_error_class( "23000", klass );
@@ -763,6 +831,10 @@
763
831
  VALUE klass = define_error_class( "LockNotAvailable", "55" );
764
832
  register_error_class( "55P03", klass );
765
833
  }
834
+ {
835
+ VALUE klass = define_error_class( "UnsafeNewEnumValueUsage", "55" );
836
+ register_error_class( "55P04", klass );
837
+ }
766
838
  {
767
839
  VALUE klass = define_error_class( "OperatorIntervention", NULL );
768
840
  register_error_class( "57000", klass );
@@ -788,6 +860,10 @@
788
860
  VALUE klass = define_error_class( "DatabaseDropped", "57" );
789
861
  register_error_class( "57P04", klass );
790
862
  }
863
+ {
864
+ VALUE klass = define_error_class( "IdleSessionTimeout", "57" );
865
+ register_error_class( "57P05", klass );
866
+ }
791
867
  {
792
868
  VALUE klass = define_error_class( "SystemError", NULL );
793
869
  register_error_class( "58000", klass );
data/ext/errorcodes.txt CHANGED
@@ -2,7 +2,7 @@
2
2
  # errcodes.txt
3
3
  # PostgreSQL error codes
4
4
  #
5
- # Copyright (c) 2003-2017, PostgreSQL Global Development Group
5
+ # Copyright (c) 2003-2021, PostgreSQL Global Development Group
6
6
  #
7
7
  # This list serves as the basis for generating source files containing error
8
8
  # codes. It is kept in a common format to make sure all these source files have
@@ -18,7 +18,7 @@
18
18
  # src/pl/tcl/pltclerrcodes.h
19
19
  # the same, for PL/Tcl
20
20
  #
21
- # doc/src/sgml/errcodes-list.sgml
21
+ # doc/src/sgml/errcodes-table.sgml
22
22
  # a SGML table of error codes for inclusion in the documentation
23
23
  #
24
24
  # The format of this file is one error code per line, with the following
@@ -177,6 +177,7 @@ Section: Class 22 - Data Exception
177
177
  22P06 E ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER nonstandard_use_of_escape_character
178
178
  22010 E ERRCODE_INVALID_INDICATOR_PARAMETER_VALUE invalid_indicator_parameter_value
179
179
  22023 E ERRCODE_INVALID_PARAMETER_VALUE invalid_parameter_value
180
+ 22013 E ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE invalid_preceding_or_following_size
180
181
  2201B E ERRCODE_INVALID_REGULAR_EXPRESSION invalid_regular_expression
181
182
  2201W E ERRCODE_INVALID_ROW_COUNT_IN_LIMIT_CLAUSE invalid_row_count_in_limit_clause
182
183
  2201X E ERRCODE_INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE invalid_row_count_in_result_offset_clause
@@ -205,6 +206,22 @@ Section: Class 22 - Data Exception
205
206
  2200N E ERRCODE_INVALID_XML_CONTENT invalid_xml_content
206
207
  2200S E ERRCODE_INVALID_XML_COMMENT invalid_xml_comment
207
208
  2200T E ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION invalid_xml_processing_instruction
209
+ 22030 E ERRCODE_DUPLICATE_JSON_OBJECT_KEY_VALUE duplicate_json_object_key_value
210
+ 22031 E ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION invalid_argument_for_sql_json_datetime_function
211
+ 22032 E ERRCODE_INVALID_JSON_TEXT invalid_json_text
212
+ 22033 E ERRCODE_INVALID_SQL_JSON_SUBSCRIPT invalid_sql_json_subscript
213
+ 22034 E ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM more_than_one_sql_json_item
214
+ 22035 E ERRCODE_NO_SQL_JSON_ITEM no_sql_json_item
215
+ 22036 E ERRCODE_NON_NUMERIC_SQL_JSON_ITEM non_numeric_sql_json_item
216
+ 22037 E ERRCODE_NON_UNIQUE_KEYS_IN_A_JSON_OBJECT non_unique_keys_in_a_json_object
217
+ 22038 E ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED singleton_sql_json_item_required
218
+ 22039 E ERRCODE_SQL_JSON_ARRAY_NOT_FOUND sql_json_array_not_found
219
+ 2203A E ERRCODE_SQL_JSON_MEMBER_NOT_FOUND sql_json_member_not_found
220
+ 2203B E ERRCODE_SQL_JSON_NUMBER_NOT_FOUND sql_json_number_not_found
221
+ 2203C E ERRCODE_SQL_JSON_OBJECT_NOT_FOUND sql_json_object_not_found
222
+ 2203D E ERRCODE_TOO_MANY_JSON_ARRAY_ELEMENTS too_many_json_array_elements
223
+ 2203E E ERRCODE_TOO_MANY_JSON_OBJECT_MEMBERS too_many_json_object_members
224
+ 2203F E ERRCODE_SQL_JSON_SCALAR_REQUIRED sql_json_scalar_required
208
225
 
209
226
  Section: Class 23 - Integrity Constraint Violation
210
227
 
@@ -400,6 +417,7 @@ Section: Class 55 - Object Not In Prerequisite State
400
417
  55006 E ERRCODE_OBJECT_IN_USE object_in_use
401
418
  55P02 E ERRCODE_CANT_CHANGE_RUNTIME_PARAM cant_change_runtime_param
402
419
  55P03 E ERRCODE_LOCK_NOT_AVAILABLE lock_not_available
420
+ 55P04 E ERRCODE_UNSAFE_NEW_ENUM_VALUE_USAGE unsafe_new_enum_value_usage
403
421
 
404
422
  Section: Class 57 - Operator Intervention
405
423
 
@@ -410,6 +428,7 @@ Section: Class 57 - Operator Intervention
410
428
  57P02 E ERRCODE_CRASH_SHUTDOWN crash_shutdown
411
429
  57P03 E ERRCODE_CANNOT_CONNECT_NOW cannot_connect_now
412
430
  57P04 E ERRCODE_DATABASE_DROPPED database_dropped
431
+ 57P05 E ERRCODE_IDLE_SESSION_TIMEOUT idle_session_timeout
413
432
 
414
433
  Section: Class 58 - System Error (errors external to PostgreSQL itself)
415
434
 
data/ext/extconf.rb CHANGED
@@ -15,6 +15,13 @@ if pgdir = with_config( 'pg' )
15
15
  ENV['PATH'] = "#{pgdir}/bin" + File::PATH_SEPARATOR + ENV['PATH']
16
16
  end
17
17
 
18
+ if enable_config("gvl-unlock", true)
19
+ $defs.push( "-DENABLE_GVL_UNLOCK" )
20
+ $stderr.puts "Calling libpq with GVL unlocked"
21
+ else
22
+ $stderr.puts "Calling libpq with GVL locked"
23
+ end
24
+
18
25
  if enable_config("windows-cross")
19
26
  # Avoid dependency to external libgcc.dll on x86-mingw32
20
27
  $LDFLAGS << " -static-libgcc"
@@ -30,35 +37,97 @@ else
30
37
 
31
38
  if pgconfig && pgconfig != 'ignore'
32
39
  $stderr.puts "Using config values from %s" % [ pgconfig ]
33
- incdir = `"#{pgconfig}" --includedir`.chomp
34
- libdir = `"#{pgconfig}" --libdir`.chomp
40
+ incdir = IO.popen([pgconfig, "--includedir"], &:read).chomp
41
+ libdir = IO.popen([pgconfig, "--libdir"], &:read).chomp
35
42
  dir_config 'pg', incdir, libdir
36
43
 
37
- # Try to use runtime path linker option, even if RbConfig doesn't know about it.
38
- # The rpath option is usually set implicit by dir_config(), but so far not
39
- # on MacOS-X.
40
- if RbConfig::CONFIG["RPATHFLAG"].to_s.empty? && try_link('int main() {return 0;}', " -Wl,-rpath,#{libdir}")
41
- $LDFLAGS << " -Wl,-rpath,#{libdir}"
44
+ # Windows traditionally stores DLLs beside executables, not in libdir
45
+ dlldir = RUBY_PLATFORM=~/mingw|mswin/ ? IO.popen([pgconfig, "--bindir"], &:read).chomp : libdir
46
+
47
+ elsif checking_for "libpq per pkg-config" do
48
+ _cflags, ldflags, _libs = pkg_config("libpq")
49
+ dlldir = ldflags && ldflags[/-L([^ ]+)/] && $1
42
50
  end
51
+
43
52
  else
44
- $stderr.puts "No pg_config... trying anyway. If building fails, please try again with",
45
- " --with-pg-config=/path/to/pg_config"
46
- dir_config 'pg'
53
+ incdir, libdir = dir_config 'pg'
54
+ dlldir = libdir
55
+ end
56
+
57
+ # Try to use runtime path linker option, even if RbConfig doesn't know about it.
58
+ # The rpath option is usually set implicit by dir_config(), but so far not
59
+ # on MacOS-X.
60
+ if dlldir && RbConfig::CONFIG["RPATHFLAG"].to_s.empty?
61
+ append_ldflags "-Wl,-rpath,#{dlldir.quote}"
47
62
  end
48
63
  end
49
64
 
65
+ $stderr.puts "Using libpq from #{dlldir}"
66
+
67
+ File.write("postgresql_lib_path.rb", <<-EOT)
68
+ module PG
69
+ POSTGRESQL_LIB_PATH = #{dlldir.inspect}
70
+ end
71
+ EOT
72
+ $INSTALLFILES = {
73
+ "./postgresql_lib_path.rb" => "$(RUBYLIBDIR)/pg/"
74
+ }
75
+
50
76
  if RUBY_VERSION >= '2.3.0' && /solaris/ =~ RUBY_PLATFORM
51
77
  append_cppflags( '-D__EXTENSIONS__' )
52
78
  end
53
79
 
54
- find_header( 'libpq-fe.h' ) or abort "Can't find the 'libpq-fe.h header"
55
- find_header( 'libpq/libpq-fs.h' ) or abort "Can't find the 'libpq/libpq-fs.h header"
56
- find_header( 'pg_config_manual.h' ) or abort "Can't find the 'pg_config_manual.h' header"
80
+ begin
81
+ find_header( 'libpq-fe.h' ) or abort "Can't find the 'libpq-fe.h header"
82
+ find_header( 'libpq/libpq-fs.h' ) or abort "Can't find the 'libpq/libpq-fs.h header"
83
+ find_header( 'pg_config_manual.h' ) or abort "Can't find the 'pg_config_manual.h' header"
84
+
85
+ abort "Can't find the PostgreSQL client library (libpq)" unless
86
+ have_library( 'pq', 'PQconnectdb', ['libpq-fe.h'] ) ||
87
+ have_library( 'libpq', 'PQconnectdb', ['libpq-fe.h'] ) ||
88
+ have_library( 'ms/libpq', 'PQconnectdb', ['libpq-fe.h'] )
89
+
90
+ rescue SystemExit
91
+ install_text = case RUBY_PLATFORM
92
+ when /linux/
93
+ <<-EOT
94
+ Please install libpq or postgresql client package like so:
95
+ sudo apt install libpq-dev
96
+ sudo yum install postgresql-devel
97
+ sudo zypper in postgresql-devel
98
+ sudo pacman -S postgresql-libs
99
+ EOT
100
+ when /darwin/
101
+ <<-EOT
102
+ Please install libpq or postgresql client package like so:
103
+ brew install libpq
104
+ EOT
105
+ when /mingw/
106
+ <<-EOT
107
+ Please install libpq or postgresql client package like so:
108
+ ridk exec sh -c "pacman -S ${MINGW_PACKAGE_PREFIX}-postgresql"
109
+ EOT
110
+ else
111
+ <<-EOT
112
+ Please install libpq or postgresql client package.
113
+ EOT
114
+ end
115
+
116
+ $stderr.puts <<-EOT
117
+ *****************************************************************************
118
+
119
+ Unable to find PostgreSQL client library.
120
+
121
+ #{install_text}
122
+ or try again with:
123
+ gem install pg -- --with-pg-config=/path/to/pg_config
124
+
125
+ or set library paths manually with:
126
+ gem install pg -- --with-pg-include=/path/to/libpq-fe.h/ --with-pg-lib=/path/to/libpq.so/
57
127
 
58
- abort "Can't find the PostgreSQL client library (libpq)" unless
59
- have_library( 'pq', 'PQconnectdb', ['libpq-fe.h'] ) ||
60
- have_library( 'libpq', 'PQconnectdb', ['libpq-fe.h'] ) ||
61
- have_library( 'ms/libpq', 'PQconnectdb', ['libpq-fe.h'] )
128
+ EOT
129
+ raise
130
+ end
62
131
 
63
132
  if /mingw/ =~ RUBY_PLATFORM && RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
64
133
  # Work around: https://sourceware.org/bugzilla/show_bug.cgi?id=22504
@@ -69,21 +138,27 @@ if /mingw/ =~ RUBY_PLATFORM && RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
69
138
  end
70
139
  end
71
140
 
72
- # optional headers/functions
73
- have_func 'PQsetSingleRowMode' or
141
+ have_func 'PQconninfo', 'libpq-fe.h' or
74
142
  abort "Your PostgreSQL is too old. Either install an older version " +
75
- "of this gem or upgrade your database to at least PostgreSQL-9.2."
76
- have_func 'PQconninfo'
77
- have_func 'PQsslAttribute'
78
- have_func 'PQencryptPasswordConn'
143
+ "of this gem or upgrade your database to at least PostgreSQL-9.3."
144
+ # optional headers/functions
145
+ have_func 'PQsslAttribute', 'libpq-fe.h' # since PostgreSQL-9.5
146
+ have_func 'PQresultVerboseErrorMessage', 'libpq-fe.h' # since PostgreSQL-9.6
147
+ have_func 'PQencryptPasswordConn', 'libpq-fe.h' # since PostgreSQL-10
148
+ have_func 'PQresultMemorySize', 'libpq-fe.h' # since PostgreSQL-12
149
+ have_func 'PQenterPipelineMode', 'libpq-fe.h' do |src| # since PostgreSQL-14
150
+ # Ensure header files fit as well
151
+ src + " int con(){ return PGRES_PIPELINE_SYNC; }"
152
+ end
79
153
  have_func 'timegm'
80
- have_func 'rb_gc_adjust_memory_usage'
81
-
82
- have_const 'PG_DIAG_TABLE_NAME', 'libpq-fe.h'
154
+ have_func 'rb_gc_adjust_memory_usage' # since ruby-2.4
155
+ have_func 'rb_gc_mark_movable' # since ruby-2.7
156
+ have_func 'rb_io_wait' # since ruby-3.0
83
157
 
84
158
  # unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
85
159
  have_header 'unistd.h'
86
160
  have_header 'inttypes.h'
161
+ have_header('ruby/fiber/scheduler.h') if RUBY_PLATFORM=~/mingw|mswin/
87
162
 
88
163
  checking_for "C99 variable length arrays" do
89
164
  $defs.push( "-DHAVE_VARIABLE_LENGTH_ARRAYS" ) if try_compile('void test_vla(int l){ int vla[l]; }')
data/ext/gvl_wrappers.c CHANGED
@@ -9,9 +9,13 @@
9
9
  char *PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm){return NULL;}
10
10
  #endif
11
11
 
12
+ #ifdef ENABLE_GVL_UNLOCK
12
13
  FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_WRAPPER_STRUCT );
13
14
  FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_SKELETON );
15
+ #endif
14
16
  FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_STUB );
17
+ #ifdef ENABLE_GVL_UNLOCK
15
18
  FOR_EACH_CALLBACK_FUNCTION( DEFINE_GVL_WRAPPER_STRUCT );
16
19
  FOR_EACH_CALLBACK_FUNCTION( DEFINE_GVLCB_SKELETON );
20
+ #endif
17
21
  FOR_EACH_CALLBACK_FUNCTION( DEFINE_GVLCB_STUB );