pg 0.21.0 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/ChangeLog +0 -6595
  5. data/History.rdoc +184 -0
  6. data/Manifest.txt +8 -3
  7. data/README-Windows.rdoc +4 -4
  8. data/README.ja.rdoc +1 -2
  9. data/README.rdoc +58 -13
  10. data/Rakefile +10 -9
  11. data/Rakefile.cross +68 -71
  12. data/ext/errorcodes.def +76 -0
  13. data/ext/errorcodes.rb +1 -1
  14. data/ext/errorcodes.txt +21 -2
  15. data/ext/extconf.rb +18 -36
  16. data/ext/gvl_wrappers.c +4 -0
  17. data/ext/gvl_wrappers.h +23 -39
  18. data/ext/pg.c +154 -144
  19. data/ext/pg.h +68 -95
  20. data/ext/pg_binary_decoder.c +82 -15
  21. data/ext/pg_binary_encoder.c +13 -12
  22. data/ext/pg_coder.c +73 -12
  23. data/ext/pg_connection.c +699 -459
  24. data/ext/pg_copy_coder.c +16 -8
  25. data/ext/pg_record_coder.c +491 -0
  26. data/ext/pg_result.c +571 -195
  27. data/ext/pg_text_decoder.c +606 -40
  28. data/ext/pg_text_encoder.c +185 -54
  29. data/ext/pg_tuple.c +549 -0
  30. data/ext/pg_type_map.c +1 -1
  31. data/ext/pg_type_map_all_strings.c +4 -4
  32. data/ext/pg_type_map_by_class.c +9 -4
  33. data/ext/pg_type_map_by_column.c +7 -6
  34. data/ext/pg_type_map_by_mri_type.c +1 -1
  35. data/ext/pg_type_map_by_oid.c +3 -2
  36. data/ext/pg_type_map_in_ruby.c +1 -1
  37. data/ext/{util.c → pg_util.c} +10 -10
  38. data/ext/{util.h → pg_util.h} +2 -2
  39. data/lib/pg.rb +8 -10
  40. data/lib/pg/basic_type_mapping.rb +121 -25
  41. data/lib/pg/binary_decoder.rb +23 -0
  42. data/lib/pg/coder.rb +23 -2
  43. data/lib/pg/connection.rb +28 -4
  44. data/lib/pg/constants.rb +2 -1
  45. data/lib/pg/exceptions.rb +2 -1
  46. data/lib/pg/result.rb +14 -2
  47. data/lib/pg/text_decoder.rb +21 -26
  48. data/lib/pg/text_encoder.rb +32 -8
  49. data/lib/pg/tuple.rb +30 -0
  50. data/lib/pg/type_map_by_column.rb +3 -2
  51. data/spec/helpers.rb +61 -33
  52. data/spec/pg/basic_type_mapping_spec.rb +362 -37
  53. data/spec/pg/connection_spec.rb +602 -329
  54. data/spec/pg/connection_sync_spec.rb +41 -0
  55. data/spec/pg/result_spec.rb +242 -17
  56. data/spec/pg/tuple_spec.rb +333 -0
  57. data/spec/pg/type_map_by_class_spec.rb +2 -2
  58. data/spec/pg/type_map_by_column_spec.rb +6 -2
  59. data/spec/pg/type_map_by_mri_type_spec.rb +1 -1
  60. data/spec/pg/type_map_by_oid_spec.rb +3 -3
  61. data/spec/pg/type_map_in_ruby_spec.rb +1 -1
  62. data/spec/pg/type_map_spec.rb +1 -1
  63. data/spec/pg/type_spec.rb +364 -18
  64. data/spec/pg_spec.rb +2 -2
  65. metadata +48 -43
  66. metadata.gz.sig +0 -0
  67. data/lib/pg/deprecated_constants.rb +0 -21
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.1d'
33
+ self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '12.1'
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,27 @@ 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
+ ['x86-mingw32', 'mingw', 'i686-w64-mingw32'],
254
+ ['x64-mingw32', 'mingw64', 'x86_64-w64-mingw32'],
255
+ ].map do |platform, openssl_config, toolchain|
256
+ CrossLibrary.new platform, openssl_config, toolchain
262
257
  end
263
258
 
264
259
  desc 'cross compile pg for win32'
265
- task :cross => [ :mingw32, :libpq ]
260
+ task :cross => [ :mingw32 ]
266
261
 
267
262
  task :mingw32 do
268
263
  # Use Rake::ExtensionCompiler helpers to find the proper host
@@ -273,30 +268,32 @@ task :mingw32 do
273
268
  end
274
269
  end
275
270
 
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
271
+ task 'gem:windows:prepare' do
272
+ require 'io/console'
273
+ require 'rake_compiler_dock'
274
+
275
+ # Copy gem signing key and certs to be accessable from the docker container
276
+ mkdir_p 'build/gem'
277
+ sh "cp ~/.gem/gem-*.pem build/gem/ || true"
278
+ sh "bundle package"
279
+ begin
280
+ OpenSSL::PKey.read(File.read(File.expand_path("~/.gem/gem-private_key.pem")), ENV["GEM_PRIVATE_KEY_PASSPHRASE"] || "")
281
+ rescue OpenSSL::PKey::PKeyError
282
+ ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = STDIN.getpass("Enter passphrase of gem signature key: ")
283
+ retry
284
+ end
285
285
  end
286
286
 
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
287
+ CrossLibraries.each do |xlib|
288
+ platform = xlib.for_platform
289
+ desc "Build fat binary gem for platform #{platform}"
290
+ task "gem:windows:#{platform}" => ['ChangeLog', 'gem:windows:prepare', xlib.openssl_tarball, xlib.postgresql_tarball] do
291
+ RakeCompilerDock.sh <<-EOT, platform: platform
292
+ (cp build/gem/gem-*.pem ~/.gem/ || true) &&
293
+ bundle install --local &&
294
+ rake native:#{platform} pkg/#{$hoespec.spec.full_name}-#{platform}.gem MAKE="make -j`nproc`"
295
+ EOT
296
+ end
297
+ desc "Build the windows binary gems"
298
+ multitask 'gem:windows' => "gem:windows:#{platform}"
302
299
  end
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,66 @@
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( "InvalidJsonText", "22" );
311
+ register_error_class( "22032", klass );
312
+ }
313
+ {
314
+ VALUE klass = define_error_class( "InvalidSqlJsonSubscript", "22" );
315
+ register_error_class( "22033", klass );
316
+ }
317
+ {
318
+ VALUE klass = define_error_class( "MoreThanOneSqlJsonItem", "22" );
319
+ register_error_class( "22034", klass );
320
+ }
321
+ {
322
+ VALUE klass = define_error_class( "NoSqlJsonItem", "22" );
323
+ register_error_class( "22035", klass );
324
+ }
325
+ {
326
+ VALUE klass = define_error_class( "NonNumericSqlJsonItem", "22" );
327
+ register_error_class( "22036", klass );
328
+ }
329
+ {
330
+ VALUE klass = define_error_class( "NonUniqueKeysInAJsonObject", "22" );
331
+ register_error_class( "22037", klass );
332
+ }
333
+ {
334
+ VALUE klass = define_error_class( "SingletonSqlJsonItemRequired", "22" );
335
+ register_error_class( "22038", klass );
336
+ }
337
+ {
338
+ VALUE klass = define_error_class( "SqlJsonArrayNotFound", "22" );
339
+ register_error_class( "22039", klass );
340
+ }
341
+ {
342
+ VALUE klass = define_error_class( "SqlJsonMemberNotFound", "22" );
343
+ register_error_class( "2203A", klass );
344
+ }
345
+ {
346
+ VALUE klass = define_error_class( "SqlJsonNumberNotFound", "22" );
347
+ register_error_class( "2203B", klass );
348
+ }
349
+ {
350
+ VALUE klass = define_error_class( "SqlJsonObjectNotFound", "22" );
351
+ register_error_class( "2203C", klass );
352
+ }
353
+ {
354
+ VALUE klass = define_error_class( "TooManyJsonArrayElements", "22" );
355
+ register_error_class( "2203D", klass );
356
+ }
357
+ {
358
+ VALUE klass = define_error_class( "TooManyJsonObjectMembers", "22" );
359
+ register_error_class( "2203E", klass );
360
+ }
361
+ {
362
+ VALUE klass = define_error_class( "SqlJsonScalarRequired", "22" );
363
+ register_error_class( "2203F", klass );
364
+ }
297
365
  {
298
366
  VALUE klass = define_error_class( "IntegrityConstraintViolation", NULL );
299
367
  register_error_class( "23000", klass );
@@ -587,6 +655,10 @@
587
655
  VALUE klass = define_error_class( "WrongObjectType", "42" );
588
656
  register_error_class( "42809", klass );
589
657
  }
658
+ {
659
+ VALUE klass = define_error_class( "GeneratedAlways", "42" );
660
+ register_error_class( "428C9", klass );
661
+ }
590
662
  {
591
663
  VALUE klass = define_error_class( "UndefinedColumn", "42" );
592
664
  register_error_class( "42703", klass );
@@ -755,6 +827,10 @@
755
827
  VALUE klass = define_error_class( "LockNotAvailable", "55" );
756
828
  register_error_class( "55P03", klass );
757
829
  }
830
+ {
831
+ VALUE klass = define_error_class( "UnsafeNewEnumValueUsage", "55" );
832
+ register_error_class( "55P04", klass );
833
+ }
758
834
  {
759
835
  VALUE klass = define_error_class( "OperatorIntervention", NULL );
760
836
  register_error_class( "57000", 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 }
data/ext/errorcodes.txt CHANGED
@@ -2,7 +2,7 @@
2
2
  # errcodes.txt
3
3
  # PostgreSQL error codes
4
4
  #
5
- # Copyright (c) 2003-2016, PostgreSQL Global Development Group
5
+ # Copyright (c) 2003-2019, 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
@@ -188,6 +189,7 @@ Section: Class 22 - Data Exception
188
189
  22004 E ERRCODE_NULL_VALUE_NOT_ALLOWED null_value_not_allowed
189
190
  22002 E ERRCODE_NULL_VALUE_NO_INDICATOR_PARAMETER null_value_no_indicator_parameter
190
191
  22003 E ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE numeric_value_out_of_range
192
+ 2200H E ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED sequence_generator_limit_exceeded
191
193
  22026 E ERRCODE_STRING_DATA_LENGTH_MISMATCH string_data_length_mismatch
192
194
  22001 E ERRCODE_STRING_DATA_RIGHT_TRUNCATION string_data_right_truncation
193
195
  22011 E ERRCODE_SUBSTRING_ERROR substring_error
@@ -204,6 +206,21 @@ Section: Class 22 - Data Exception
204
206
  2200N E ERRCODE_INVALID_XML_CONTENT invalid_xml_content
205
207
  2200S E ERRCODE_INVALID_XML_COMMENT invalid_xml_comment
206
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
+ 22032 E ERRCODE_INVALID_JSON_TEXT invalid_json_text
211
+ 22033 E ERRCODE_INVALID_SQL_JSON_SUBSCRIPT invalid_sql_json_subscript
212
+ 22034 E ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM more_than_one_sql_json_item
213
+ 22035 E ERRCODE_NO_SQL_JSON_ITEM no_sql_json_item
214
+ 22036 E ERRCODE_NON_NUMERIC_SQL_JSON_ITEM non_numeric_sql_json_item
215
+ 22037 E ERRCODE_NON_UNIQUE_KEYS_IN_A_JSON_OBJECT non_unique_keys_in_a_json_object
216
+ 22038 E ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED singleton_sql_json_item_required
217
+ 22039 E ERRCODE_SQL_JSON_ARRAY_NOT_FOUND sql_json_array_not_found
218
+ 2203A E ERRCODE_SQL_JSON_MEMBER_NOT_FOUND sql_json_member_not_found
219
+ 2203B E ERRCODE_SQL_JSON_NUMBER_NOT_FOUND sql_json_number_not_found
220
+ 2203C E ERRCODE_SQL_JSON_OBJECT_NOT_FOUND sql_json_object_not_found
221
+ 2203D E ERRCODE_TOO_MANY_JSON_ARRAY_ELEMENTS too_many_json_array_elements
222
+ 2203E E ERRCODE_TOO_MANY_JSON_OBJECT_MEMBERS too_many_json_object_members
223
+ 2203F E ERRCODE_SQL_JSON_SCALAR_REQUIRED sql_json_scalar_required
207
224
 
208
225
  Section: Class 23 - Integrity Constraint Violation
209
226
 
@@ -326,6 +343,7 @@ Section: Class 42 - Syntax Error or Access Rule Violation
326
343
  42P21 E ERRCODE_COLLATION_MISMATCH collation_mismatch
327
344
  42P22 E ERRCODE_INDETERMINATE_COLLATION indeterminate_collation
328
345
  42809 E ERRCODE_WRONG_OBJECT_TYPE wrong_object_type
346
+ 428C9 E ERRCODE_GENERATED_ALWAYS generated_always
329
347
 
330
348
  # Note: for ERRCODE purposes, we divide namable objects into these categories:
331
349
  # databases, schemas, prepared statements, cursors, tables, columns,
@@ -398,6 +416,7 @@ Section: Class 55 - Object Not In Prerequisite State
398
416
  55006 E ERRCODE_OBJECT_IN_USE object_in_use
399
417
  55P02 E ERRCODE_CANT_CHANGE_RUNTIME_PARAM cant_change_runtime_param
400
418
  55P03 E ERRCODE_LOCK_NOT_AVAILABLE lock_not_available
419
+ 55P04 E ERRCODE_UNSAFE_NEW_ENUM_VALUE_USAGE unsafe_new_enum_value_usage
401
420
 
402
421
  Section: Class 57 - Operator Intervention
403
422
 
data/ext/extconf.rb CHANGED
@@ -60,48 +60,30 @@ abort "Can't find the PostgreSQL client library (libpq)" unless
60
60
  have_library( 'libpq', 'PQconnectdb', ['libpq-fe.h'] ) ||
61
61
  have_library( 'ms/libpq', 'PQconnectdb', ['libpq-fe.h'] )
62
62
 
63
+ if /mingw/ =~ RUBY_PLATFORM && RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
64
+ # Work around: https://sourceware.org/bugzilla/show_bug.cgi?id=22504
65
+ checking_for "workaround gcc version with link issue" do
66
+ `#{RbConfig::MAKEFILE_CONFIG['CC']} --version`.chomp =~ /\s(\d+)\.\d+\.\d+(\s|$)/ &&
67
+ $1.to_i >= 6 &&
68
+ have_library(':libpq.lib') # Prefer linking to libpq.lib over libpq.dll if available
69
+ end
70
+ end
71
+
63
72
  # optional headers/functions
64
- have_func 'PQconnectionUsedPassword' or
73
+ have_func 'PQsetSingleRowMode' or
65
74
  abort "Your PostgreSQL is too old. Either install an older version " +
66
- "of this gem or upgrade your database."
67
- have_func 'PQisthreadsafe'
68
- have_func 'PQprepare'
69
- have_func 'PQexecParams'
70
- have_func 'PQescapeString'
71
- have_func 'PQescapeStringConn'
72
- have_func 'PQescapeLiteral'
73
- have_func 'PQescapeIdentifier'
74
- have_func 'PQgetCancel'
75
- have_func 'lo_create'
76
- have_func 'pg_encoding_to_char'
77
- have_func 'pg_char_to_encoding'
78
- have_func 'PQsetClientEncoding'
79
- have_func 'PQlibVersion'
80
- have_func 'PQping'
81
- have_func 'PQsetSingleRowMode'
82
- have_func 'PQconninfo'
83
- have_func 'PQsslAttribute'
84
-
85
- have_func 'rb_encdb_alias'
86
- have_func 'rb_enc_alias'
87
- have_func 'rb_thread_call_without_gvl'
88
- have_func 'rb_thread_call_with_gvl'
89
- have_func 'rb_thread_fd_select'
90
- have_func 'rb_w32_wrap_io_handle'
91
- have_func 'rb_str_modify_expand'
92
- have_func 'rb_hash_dup'
93
-
94
- have_const 'PGRES_COPY_BOTH', 'libpq-fe.h'
95
- have_const 'PGRES_SINGLE_TUPLE', 'libpq-fe.h'
96
- have_const 'PG_DIAG_TABLE_NAME', 'libpq-fe.h'
97
-
98
- $defs.push( "-DHAVE_ST_NOTIFY_EXTRA" ) if
99
- have_struct_member 'struct pgNotify', 'extra', 'libpq-fe.h'
75
+ "of this gem or upgrade your database to at least PostgreSQL-9.2."
76
+ have_func 'PQconninfo' # since PostgreSQL-9.3
77
+ have_func 'PQsslAttribute' # since PostgreSQL-9.5
78
+ have_func 'PQresultVerboseErrorMessage' # since PostgreSQL-9.6
79
+ have_func 'PQencryptPasswordConn' # since PostgreSQL-10
80
+ have_func 'PQresultMemorySize' # since PostgreSQL-12
81
+ have_func 'timegm'
82
+ have_func 'rb_gc_adjust_memory_usage' # since ruby-2.4
100
83
 
101
84
  # unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
102
85
  have_header 'unistd.h'
103
86
  have_header 'inttypes.h'
104
- have_header 'ruby/st.h' or have_header 'st.h' or abort "pg currently requires the ruby/st.h header"
105
87
 
106
88
  checking_for "C99 variable length arrays" do
107
89
  $defs.push( "-DHAVE_VARIABLE_LENGTH_ARRAYS" ) if try_compile('void test_vla(int l){ int vla[l]; }')