pg 0.18.4 → 1.0.0

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 (58) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data/BSDL +2 -2
  4. data/ChangeLog +689 -5
  5. data/History.rdoc +84 -0
  6. data/Manifest.txt +0 -18
  7. data/README.rdoc +13 -10
  8. data/Rakefile +16 -19
  9. data/Rakefile.cross +21 -24
  10. data/ext/errorcodes.def +33 -0
  11. data/ext/errorcodes.txt +15 -1
  12. data/ext/extconf.rb +21 -33
  13. data/ext/gvl_wrappers.c +4 -0
  14. data/ext/gvl_wrappers.h +27 -39
  15. data/ext/pg.c +18 -50
  16. data/ext/pg.h +13 -80
  17. data/ext/pg_binary_encoder.c +8 -8
  18. data/ext/pg_coder.c +31 -10
  19. data/ext/pg_connection.c +340 -225
  20. data/ext/pg_copy_coder.c +34 -4
  21. data/ext/pg_result.c +24 -22
  22. data/ext/pg_text_encoder.c +62 -42
  23. data/ext/pg_type_map.c +14 -7
  24. data/lib/pg/basic_type_mapping.rb +35 -8
  25. data/lib/pg/connection.rb +53 -12
  26. data/lib/pg/result.rb +10 -5
  27. data/lib/pg/text_decoder.rb +7 -0
  28. data/lib/pg/text_encoder.rb +8 -0
  29. data/lib/pg.rb +18 -10
  30. data/spec/helpers.rb +8 -15
  31. data/spec/pg/basic_type_mapping_spec.rb +54 -0
  32. data/spec/pg/connection_spec.rb +384 -209
  33. data/spec/pg/result_spec.rb +14 -7
  34. data/spec/pg/type_map_by_class_spec.rb +2 -2
  35. data/spec/pg/type_map_by_mri_type_spec.rb +1 -1
  36. data/spec/pg/type_spec.rb +83 -3
  37. data/spec/pg_spec.rb +1 -1
  38. data.tar.gz.sig +0 -0
  39. metadata +55 -64
  40. metadata.gz.sig +0 -0
  41. data/sample/array_insert.rb +0 -20
  42. data/sample/async_api.rb +0 -106
  43. data/sample/async_copyto.rb +0 -39
  44. data/sample/async_mixed.rb +0 -56
  45. data/sample/check_conn.rb +0 -21
  46. data/sample/copyfrom.rb +0 -81
  47. data/sample/copyto.rb +0 -19
  48. data/sample/cursor.rb +0 -21
  49. data/sample/disk_usage_report.rb +0 -186
  50. data/sample/issue-119.rb +0 -94
  51. data/sample/losample.rb +0 -69
  52. data/sample/minimal-testcase.rb +0 -17
  53. data/sample/notify_wait.rb +0 -72
  54. data/sample/pg_statistics.rb +0 -294
  55. data/sample/replication_monitor.rb +0 -231
  56. data/sample/test_binary_values.rb +0 -33
  57. data/sample/wal_shipper.rb +0 -434
  58. data/sample/warehouse_partitions.rb +0 -320
data/History.rdoc CHANGED
@@ -1,3 +1,87 @@
1
+ == v1.0.0 [2018-01-10] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Deprecated:
4
+ - Deprecate Ruby older than 2.2.
5
+ - Deprecate Connection#socket in favor of #socket_io.
6
+
7
+ Removed:
8
+ - Remove compatibility code for Ruby < 2.0 and PostgreSQL < 9.2.
9
+ - Remove partial compatibility with Rubinius.
10
+
11
+ Enhancements:
12
+ - Update error codes to PostgreSQL-10
13
+ - Update Windows binary gems to Ruby-2.5, PostgreSQL 10.1 and
14
+ OpenSSL 1.1.0g.
15
+
16
+ Bugfixes:
17
+ - Fix URI detection for connection strings. #265 (thanks to jjoos)
18
+ - MINGW: Workaround segfault due to GCC linker error in conjunction with MSVC.
19
+ This happens when linking to PostgreSQL-10.0-x64 from EnterpriseDB.
20
+
21
+ Documentation fixes:
22
+ - Add PostgreSQL version since when the given function is supported. #263
23
+ - Better documentation to `encoder` and `decoder` arguments of COPY related methods.
24
+
25
+
26
+ == v0.21.0 [2017-06-12] Michael Granger <ged@FaerieMUD.org>
27
+
28
+ Enhancements:
29
+ - Move add_dll_directory to the Runtime namespace for newest versions
30
+ of RubyInstaller.
31
+ - Deprecate PGconn, PGresult, and PGError top-level constants; a warning
32
+ will be output the first time one of them is used. They will be
33
+ removed in the upcoming 1.0 release.
34
+
35
+ Documentation fixes:
36
+ - Update the docs for PG::Result#cmd_tuples
37
+
38
+ New Samples:
39
+ - Add an example of the nicer #copy_data way of doing `COPY`.
40
+
41
+
42
+ == v0.20.0 [2017-03-10] Michael Granger <ged@FaerieMUD.org>
43
+
44
+ Enhancements:
45
+ - Update error codes to PostgreSQL-9.6
46
+ - Update Windows binary gems to Ruby-2.4, PostgreSQL 9.6.1 and
47
+ OpenSSL 1.0.2j.
48
+ - Add support for RubyInstaller2 to Windows binary gems.
49
+
50
+ Bugfixes:
51
+ - Use secure JSON methods for JSON (de)serialisation. #248
52
+ - Fix Result#inspect on a cleared result.
53
+ - Fix test case that failed on Ruby-2.4. #255
54
+
55
+ Documentation fixes:
56
+ - Talk about Integer instead of Fixnum.
57
+ - Fix method signature of Coder#encode.
58
+
59
+
60
+ == v0.19.0 [2016-09-21] Michael Granger <ged@FaerieMUD.org>
61
+
62
+ - Deprecate Ruby 1.9
63
+
64
+ Enhancements:
65
+ - Respect and convert character encoding of all strings sent
66
+ to the server. #231
67
+ - Add PostgreSQL-9.5 functions PQsslInUse(), PQsslAttribute()
68
+ and PQsslAttributeNames().
69
+ - Various documentation fixes and improvements.
70
+ - Add mechanism to build without pg_config:
71
+ gem install pg -- --with-pg-config=ignore
72
+ - Update Windows binary gems to Ruby-2.3, PostgreSQL 9.5.4 and
73
+ OpenSSL 1.0.2f.
74
+ - Add JSON coders and add them to BasicTypeMapForResults and
75
+ BasicTypeMapBasedOnResult
76
+ - Allow build from git per bundler.
77
+
78
+ Bugfixes:
79
+ - Release GVL while calling PQsetClientEncoding(). #245
80
+ - Add __EXTENSIONS__ to Solaris/SmartOS for Ruby >= 2.3.x. #236
81
+ - Fix wrong exception when running SQL while in Connection#copy_data
82
+ block for output
83
+
84
+
1
85
  == v0.18.4 [2015-11-13] Michael Granger <ged@FaerieMUD.org>
2
86
 
3
87
  Enhancements:
data/Manifest.txt CHANGED
@@ -51,24 +51,6 @@ lib/pg/result.rb
51
51
  lib/pg/text_decoder.rb
52
52
  lib/pg/text_encoder.rb
53
53
  lib/pg/type_map_by_column.rb
54
- sample/array_insert.rb
55
- sample/async_api.rb
56
- sample/async_copyto.rb
57
- sample/async_mixed.rb
58
- sample/check_conn.rb
59
- sample/copyfrom.rb
60
- sample/copyto.rb
61
- sample/cursor.rb
62
- sample/disk_usage_report.rb
63
- sample/issue-119.rb
64
- sample/losample.rb
65
- sample/minimal-testcase.rb
66
- sample/notify_wait.rb
67
- sample/pg_statistics.rb
68
- sample/replication_monitor.rb
69
- sample/test_binary_values.rb
70
- sample/wal_shipper.rb
71
- sample/warehouse_partitions.rb
72
54
  spec/data/expected_trace.out
73
55
  spec/data/random_binary_data
74
56
  spec/helpers.rb
data/README.rdoc CHANGED
@@ -11,7 +11,7 @@ docs :: http://deveiate.org/code/pg
11
11
 
12
12
  Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
13
13
 
14
- It works with {PostgreSQL 8.4 and later}[http://www.postgresql.org/support/versioning/].
14
+ It works with {PostgreSQL 9.2 and later}[http://www.postgresql.org/support/versioning/].
15
15
 
16
16
  A small example usage:
17
17
 
@@ -23,7 +23,7 @@ A small example usage:
23
23
  conn = PG.connect( dbname: 'sales' )
24
24
  conn.exec( "SELECT * FROM pg_stat_activity" ) do |result|
25
25
  puts " PID | User | Query"
26
- result.each do |row|
26
+ result.each do |row|
27
27
  puts " %7d | %-16s | %s " %
28
28
  row.values_at('procpid', 'usename', 'current_query')
29
29
  end
@@ -31,16 +31,16 @@ A small example usage:
31
31
 
32
32
  == Build Status
33
33
 
34
- {<img src="https://travis-ci.org/ged/ruby-pg.png?branch=master" alt="Build Status Travis-CI" />}[https://travis-ci.org/ged/ruby-pg]
34
+ {<img src="https://travis-ci.org/ged/ruby-pg.svg?branch=master" alt="Build Status Travis-CI" />}[https://travis-ci.org/ged/ruby-pg]
35
35
  {<img src="https://ci.appveyor.com/api/projects/status/at4g4swb2cd4xji7/branch/master?svg=true" alt="Build Status Appveyor" />}[https://ci.appveyor.com/project/ged/ruby-pg]
36
36
 
37
37
 
38
38
  == Requirements
39
39
 
40
- * Ruby 1.9.3-p392, or 2.0.0-p0.
41
- * PostgreSQL 8.4.x or later (with headers, -dev packages, etc).
40
+ * Ruby 2.2 or newer
41
+ * PostgreSQL 9.2.x or later (with headers, -dev packages, etc).
42
42
 
43
- It may work with earlier versions of Ruby/PostgreSQL as well, but those are
43
+ It usually work with earlier versions of Ruby/PostgreSQL as well, but those are
44
44
  not regularly tested.
45
45
 
46
46
 
@@ -66,6 +66,10 @@ There's also {a Google+ group}[http://goo.gl/TFy1U] and a
66
66
  {mailing list}[http://groups.google.com/group/ruby-pg] if you get stuck, or just
67
67
  want to chat about something.
68
68
 
69
+ If you want to install as a signed gem, the public certs of the gem signers
70
+ can be found in {the `certs` directory}[https://bitbucket.org/ged/ruby-pg/src/tip/certs/]
71
+ of the repository.
72
+
69
73
 
70
74
  == Type Casts
71
75
 
@@ -112,7 +116,7 @@ needs for type casting. The default type map is PG::TypeMapAllStrings.
112
116
 
113
117
  A type map can be assigned per connection or per query respectively per
114
118
  result set. Type maps can also be used for COPY in and out data streaming.
115
-
119
+ See PG::Connection#copy_data .
116
120
 
117
121
  == Contributing
118
122
 
@@ -133,7 +137,7 @@ Lars Kanis <lars@greiz-reinsdorf.de>.
133
137
 
134
138
  == Copying
135
139
 
136
- Copyright (c) 1997-2015 by the authors.
140
+ Copyright (c) 1997-2016 by the authors.
137
141
 
138
142
  * Jeff Davis <ruby-pg@j-davis.com>
139
143
  * Guy Decoux (ts) <decoux@moulon.inra.fr>
@@ -145,7 +149,7 @@ Copyright (c) 1997-2015 by the authors.
145
149
  * Noboru Saitou <noborus@netlab.jp>
146
150
 
147
151
  You may redistribute this software under the same terms as Ruby itself; see
148
- http://www.ruby-lang.org/en/LICENSE.txt or the LICENSE file in the source
152
+ https://www.ruby-lang.org/en/about/license.txt or the BSDL file in the source
149
153
  for details.
150
154
 
151
155
  Portions of the code are from the PostgreSQL project, and are distributed
@@ -161,4 +165,3 @@ to this library over the years.
161
165
 
162
166
  We are thankful to the people at the ruby-list and ruby-dev mailing lists.
163
167
  And to the people who developed PostgreSQL.
164
-
data/Rakefile CHANGED
@@ -55,22 +55,21 @@ $hoespec = Hoe.spec 'pg' do
55
55
  self.extra_rdoc_files = Rake::FileList[ '*.rdoc' ]
56
56
  self.extra_rdoc_files.include( 'POSTGRES', 'LICENSE' )
57
57
  self.extra_rdoc_files.include( 'ext/*.c' )
58
- self.license :BSD
58
+ self.license 'BSD-3-Clause'
59
59
 
60
60
  self.developer 'Michael Granger', 'ged@FaerieMUD.org'
61
61
  self.developer 'Lars Kanis', 'lars@greiz-reinsdorf.de'
62
62
 
63
- self.dependency 'rake-compiler', '~> 0.9', :developer
64
- self.dependency 'rake-compiler-dock', '~> 0.3', :developer
65
- self.dependency 'hoe', '~> 3.12', :developer
66
- self.dependency 'hoe-deveiate', '~> 0.6', :developer
63
+ self.dependency 'rake-compiler', '~> 1.0', :developer
64
+ self.dependency 'rake-compiler-dock', ['~> 0.6', '>= 0.6.2'], :developer
65
+ self.dependency 'hoe-deveiate', '~> 0.9', :developer
67
66
  self.dependency 'hoe-bundler', '~> 1.0', :developer
68
- self.dependency 'rspec', '~> 3.0', :developer
67
+ self.dependency 'rspec', '~> 3.5', :developer
68
+ self.dependency 'rdoc', '~> 5.1', :developer
69
69
 
70
- self.spec_extras[:licenses] = ['BSD', 'Ruby', 'GPL']
71
70
  self.spec_extras[:extensions] = [ 'ext/extconf.rb' ]
72
71
 
73
- self.require_ruby_version( '>= 1.9.3' )
72
+ self.require_ruby_version( '>= 2.0.0' )
74
73
 
75
74
  self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
76
75
  self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
@@ -81,7 +80,7 @@ end
81
80
  ENV['VERSION'] ||= $hoespec.spec.version.to_s
82
81
 
83
82
  # Tests should pass before checking in
84
- task 'hg:precheckin' => [ :check_history, :check_manifest, :spec ]
83
+ task 'hg:precheckin' => [ :check_history, :check_manifest, :spec, :gemspec ]
85
84
 
86
85
  # Support for 'rvm specs'
87
86
  task :specs => :spec
@@ -97,7 +96,7 @@ task :test do
97
96
  # the installed gem dir. So we clear the task rake-compiler set up
98
97
  # to break the dependency between :spec and :compile when running under
99
98
  # rubygems-test, and then run :spec.
100
- Rake::Task[ EXT.to_s ].clear
99
+ Rake::Task[ EXT.to_s ].clear if File.exist?(EXT.to_s)
101
100
  Rake::Task[ :spec ].execute
102
101
  end
103
102
 
@@ -106,8 +105,6 @@ task :maint do
106
105
  ENV['MAINTAINER_MODE'] = 'yes'
107
106
  end
108
107
 
109
- ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.2:2.0.0'
110
-
111
108
  # Rake-compiler task
112
109
  Rake::ExtensionTask.new do |ext|
113
110
  ext.name = 'pg_ext'
@@ -132,8 +129,7 @@ Rake::ExtensionTask.new do |ext|
132
129
 
133
130
  # Add libpq.dll to windows binary gemspec
134
131
  ext.cross_compiling do |spec|
135
- # mingw32-platform strings differ (RUBY_PLATFORM=i386-mingw32 vs. x86-mingw32 for rubygems)
136
- spec.files << "lib/#{spec.platform.to_s.gsub(/^x86-/, "i386-")}/libpq.dll"
132
+ spec.files << "lib/libpq.dll"
137
133
  end
138
134
  end
139
135
 
@@ -157,6 +153,7 @@ end
157
153
  file '.hg/branch' do
158
154
  warn "WARNING: You need the Mercurial repo to update the ChangeLog"
159
155
  end
156
+ Rake::Task["ChangeLog"].clear
160
157
  file 'ChangeLog' do |task|
161
158
  if File.exist?('.hg/branch')
162
159
  $stderr.puts "Updating the changelog..."
@@ -187,13 +184,11 @@ end
187
184
 
188
185
  desc "Update list of server error codes"
189
186
  task :update_error_codes do
190
- URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=HEAD"
187
+ URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL_10_1"
191
188
 
192
189
  ERRORCODES_TXT = "ext/errorcodes.txt"
193
190
  sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
194
- end
195
191
 
196
- file 'ext/errorcodes.def' => ['ext/errorcodes.rb', 'ext/errorcodes.txt'] do
197
192
  ruby 'ext/errorcodes.rb', 'ext/errorcodes.txt', 'ext/errorcodes.def'
198
193
  end
199
194
 
@@ -207,12 +202,14 @@ file GEMSPEC => __FILE__
207
202
  task GEMSPEC do |task|
208
203
  spec = $hoespec.spec
209
204
  spec.files.delete( '.gemtest' )
210
- spec.version = "#{spec.version}.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
205
+ spec.signing_key = nil
206
+ spec.version = "#{spec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
207
+ spec.cert_chain = [ 'certs/ged.pem' ]
211
208
  File.open( task.name, 'w' ) do |fh|
212
209
  fh.write( spec.to_ruby )
213
210
  end
214
211
  end
215
212
 
216
- CLOBBER.include( GEMSPEC.to_s )
213
+ CLOBBER.include( '*.gemspec' )
217
214
  task :default => :gemspec
218
215
 
data/Rakefile.cross CHANGED
@@ -29,8 +29,8 @@ 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.2d'
33
- self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '9.4.4'
32
+ self.openssl_version = ENV['OPENSSL_VERSION'] || '1.1.0g'
33
+ self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '10.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.
@@ -54,8 +54,8 @@ class CrossLibrary < OpenStruct
54
54
  self.openssl_tarball = static_sourcesdir + File.basename( openssl_source_uri.path )
55
55
  self.openssl_makefile = static_openssl_builddir + 'Makefile'
56
56
 
57
- self.libssleay32 = static_openssl_builddir + 'libssleay32.a'
58
- self.libeay32 = static_openssl_builddir + 'libeay32.a'
57
+ self.libssl = static_openssl_builddir + 'libssl.a'
58
+ self.libcrypto = static_openssl_builddir + 'libcrypto.a'
59
59
 
60
60
  self.openssl_patches = Rake::FileList[ (MISCDIR + "openssl-#{openssl_version}.*.patch").to_s ]
61
61
 
@@ -82,8 +82,6 @@ class CrossLibrary < OpenStruct
82
82
  CLEAN.include( static_builddir.to_s )
83
83
 
84
84
 
85
- ENV['RUBY_CC_VERSION'] ||= '1.9.3:2.0.0'
86
-
87
85
  def download(url, save_to)
88
86
  part = save_to+".part"
89
87
  sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
@@ -126,11 +124,9 @@ class CrossLibrary < OpenStruct
126
124
  end
127
125
 
128
126
  self.cmd_prelude = [
129
- 'env',
130
- "CC=#{host_platform}-gcc",
127
+ "env",
128
+ "CROSS_COMPILE=#{host_platform}-",
131
129
  "CFLAGS=-DDSO_WIN32",
132
- "AR=#{host_platform}-ar",
133
- "RANLIB=#{host_platform}-ranlib"
134
130
  ]
135
131
 
136
132
 
@@ -145,7 +141,7 @@ class CrossLibrary < OpenStruct
145
141
  end
146
142
 
147
143
  desc "compile static openssl libraries"
148
- task :openssl_libs => [ libssleay32, libeay32 ]
144
+ task :openssl_libs => [ libssl, libcrypto ]
149
145
 
150
146
  task :compile_static_openssl => openssl_makefile do |t|
151
147
  chdir( static_openssl_builddir ) do
@@ -156,14 +152,14 @@ class CrossLibrary < OpenStruct
156
152
  end
157
153
  end
158
154
 
159
- desc "compile static #{libeay32}"
160
- file libeay32 => :compile_static_openssl do |t|
161
- FileUtils.cp( static_openssl_builddir + 'libcrypto.a', libeay32.to_s )
155
+ desc "compile static #{libssl}"
156
+ file libssl => :compile_static_openssl do |t|
157
+ rm t.name.gsub(/\.a$/, ".dll.a")
162
158
  end
163
159
 
164
- desc "compile static #{libssleay32}"
165
- file libssleay32 => :compile_static_openssl do |t|
166
- FileUtils.cp( static_openssl_builddir + 'libssl.a', libssleay32.to_s )
160
+ desc "compile static #{libcrypto}"
161
+ file libcrypto => :compile_static_openssl do |t|
162
+ rm t.name.gsub(/\.a$/, ".dll.a")
167
163
  end
168
164
 
169
165
 
@@ -207,7 +203,7 @@ class CrossLibrary < OpenStruct
207
203
  cmd << "CFLAGS=-L#{static_openssl_builddir}"
208
204
  cmd << "LDFLAGS=-L#{static_openssl_builddir}"
209
205
  cmd << "LDFLAGS_SL=-L#{static_openssl_builddir}"
210
- cmd << "LIBS=-lwsock32 -lgdi32"
206
+ cmd << "LIBS=-lwsock32 -lgdi32 -lws2_32"
211
207
  cmd << "CPPFLAGS=-I#{static_openssl_builddir}/include"
212
208
 
213
209
  run( *cmd )
@@ -226,7 +222,7 @@ class CrossLibrary < OpenStruct
226
222
  sh 'make',
227
223
  "-j#{NUM_CPUS}",
228
224
  postgresql_lib.basename.to_s,
229
- 'SHLIB_LINK=-lssleay32 -leay32 -lcrypt32 -lgdi32 -lsecur32 -lwsock32 -lws2_32'
225
+ 'SHLIB_LINK=-lssl -lcrypto -lcrypt32 -lgdi32 -lsecur32 -lwsock32 -lws2_32'
230
226
  end
231
227
  end
232
228
 
@@ -235,7 +231,7 @@ class CrossLibrary < OpenStruct
235
231
  task :libpq => postgresql_lib
236
232
 
237
233
  # copy libpq.dll to lib dir
238
- dest_libpq = "lib/#{for_platform}/#{postgresql_lib.basename}"
234
+ dest_libpq = "lib/#{postgresql_lib.basename}"
239
235
  directory File.dirname(dest_libpq)
240
236
  file dest_libpq => [postgresql_lib, File.dirname(dest_libpq)] do
241
237
  cp postgresql_lib, dest_libpq
@@ -290,12 +286,13 @@ task 'gem:windows' => ['ChangeLog'] do
290
286
 
291
287
  # Copy gem signing key and certs to be accessable from the docker container
292
288
  mkdir_p 'build/gem'
293
- sh "cp ~/.gem/gem-*.pem build/gem/"
289
+ sh "cp ~/.gem/gem-*.pem build/gem/ || true"
290
+ sh "bundle package"
294
291
 
295
292
  RakeCompilerDock.sh <<-EOT
296
293
  mkdir ~/.gem &&
297
- cp build/gem/gem-*.pem ~/.gem/ &&
298
- bundle install &&
299
- rake cross native gem RUBYOPT=--disable-rubygems RUBY_CC_VERSION=1.9.3:2.0.0:2.1.6:2.2.2
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
300
297
  EOT
301
298
  end
data/ext/errorcodes.def CHANGED
@@ -198,6 +198,14 @@
198
198
  VALUE klass = define_error_class( "InvalidRowCountInResultOffsetClause", "22" );
199
199
  register_error_class( "2201X", klass );
200
200
  }
201
+ {
202
+ VALUE klass = define_error_class( "InvalidTablesampleArgument", "22" );
203
+ register_error_class( "2202H", klass );
204
+ }
205
+ {
206
+ VALUE klass = define_error_class( "InvalidTablesampleRepeat", "22" );
207
+ register_error_class( "2202G", klass );
208
+ }
201
209
  {
202
210
  VALUE klass = define_error_class( "InvalidTimeZoneDisplacementValue", "22" );
203
211
  register_error_class( "22009", klass );
@@ -222,6 +230,10 @@
222
230
  VALUE klass = define_error_class( "NumericValueOutOfRange", "22" );
223
231
  register_error_class( "22003", klass );
224
232
  }
233
+ {
234
+ VALUE klass = define_error_class( "SequenceGeneratorLimitExceeded", "22" );
235
+ register_error_class( "2200H", klass );
236
+ }
225
237
  {
226
238
  VALUE klass = define_error_class( "StringDataLengthMismatch", "22" );
227
239
  register_error_class( "22026", klass );
@@ -365,6 +377,10 @@
365
377
  VALUE klass = define_error_class( "InFailedSqlTransaction", "25" );
366
378
  register_error_class( "25P02", klass );
367
379
  }
380
+ {
381
+ VALUE klass = define_error_class( "IdleInTransactionSessionTimeout", "25" );
382
+ register_error_class( "25P03", klass );
383
+ }
368
384
  {
369
385
  VALUE klass = define_error_class( "InvalidSqlStatementName", NULL );
370
386
  register_error_class( "26000", klass );
@@ -466,6 +482,10 @@
466
482
  VALUE klass = define_error_class( "ERIESrfProtocolViolated", "39" );
467
483
  register_error_class( "39P02", klass );
468
484
  }
485
+ {
486
+ VALUE klass = define_error_class( "ERIEEventTriggerProtocolViolated", "39" );
487
+ register_error_class( "39P03", klass );
488
+ }
469
489
  {
470
490
  VALUE klass = define_error_class( "SavepointException", NULL );
471
491
  register_error_class( "3B000", klass );
@@ -571,6 +591,10 @@
571
591
  VALUE klass = define_error_class( "WrongObjectType", "42" );
572
592
  register_error_class( "42809", klass );
573
593
  }
594
+ {
595
+ VALUE klass = define_error_class( "GeneratedAlways", "42" );
596
+ register_error_class( "428C9", klass );
597
+ }
574
598
  {
575
599
  VALUE klass = define_error_class( "UndefinedColumn", "42" );
576
600
  register_error_class( "42703", klass );
@@ -781,6 +805,11 @@
781
805
  VALUE klass = define_error_class( "DuplicateFile", "58" );
782
806
  register_error_class( "58P02", klass );
783
807
  }
808
+ {
809
+ VALUE klass = define_error_class( "SnapshotTooOld", NULL );
810
+ register_error_class( "72000", klass );
811
+ register_error_class( "72", klass );
812
+ }
784
813
  {
785
814
  VALUE klass = define_error_class( "ConfigFileError", NULL );
786
815
  register_error_class( "F0000", klass );
@@ -916,6 +945,10 @@
916
945
  VALUE klass = define_error_class( "TooManyRows", "P0" );
917
946
  register_error_class( "P0003", klass );
918
947
  }
948
+ {
949
+ VALUE klass = define_error_class( "AssertFailure", "P0" );
950
+ register_error_class( "P0004", klass );
951
+ }
919
952
  {
920
953
  VALUE klass = define_error_class( "InternalError", NULL );
921
954
  register_error_class( "XX000", 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-2013, PostgreSQL Global Development Group
5
+ # Copyright (c) 2003-2017, 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
@@ -15,6 +15,9 @@
15
15
  # src/pl/plpgsql/src/plerrcodes.h
16
16
  # a list of PL/pgSQL condition names and their SQLSTATE codes
17
17
  #
18
+ # src/pl/tcl/pltclerrcodes.h
19
+ # the same, for PL/Tcl
20
+ #
18
21
  # doc/src/sgml/errcodes-list.sgml
19
22
  # a SGML table of error codes for inclusion in the documentation
20
23
  #
@@ -177,12 +180,15 @@ Section: Class 22 - Data Exception
177
180
  2201B E ERRCODE_INVALID_REGULAR_EXPRESSION invalid_regular_expression
178
181
  2201W E ERRCODE_INVALID_ROW_COUNT_IN_LIMIT_CLAUSE invalid_row_count_in_limit_clause
179
182
  2201X E ERRCODE_INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE invalid_row_count_in_result_offset_clause
183
+ 2202H E ERRCODE_INVALID_TABLESAMPLE_ARGUMENT invalid_tablesample_argument
184
+ 2202G E ERRCODE_INVALID_TABLESAMPLE_REPEAT invalid_tablesample_repeat
180
185
  22009 E ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE invalid_time_zone_displacement_value
181
186
  2200C E ERRCODE_INVALID_USE_OF_ESCAPE_CHARACTER invalid_use_of_escape_character
182
187
  2200G E ERRCODE_MOST_SPECIFIC_TYPE_MISMATCH most_specific_type_mismatch
183
188
  22004 E ERRCODE_NULL_VALUE_NOT_ALLOWED null_value_not_allowed
184
189
  22002 E ERRCODE_NULL_VALUE_NO_INDICATOR_PARAMETER null_value_no_indicator_parameter
185
190
  22003 E ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE numeric_value_out_of_range
191
+ 2200H E ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED sequence_generator_limit_exceeded
186
192
  22026 E ERRCODE_STRING_DATA_LENGTH_MISMATCH string_data_length_mismatch
187
193
  22001 E ERRCODE_STRING_DATA_RIGHT_TRUNCATION string_data_right_truncation
188
194
  22011 E ERRCODE_SUBSTRING_ERROR substring_error
@@ -227,6 +233,7 @@ Section: Class 25 - Invalid Transaction State
227
233
  25007 E ERRCODE_SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED schema_and_data_statement_mixing_not_supported
228
234
  25P01 E ERRCODE_NO_ACTIVE_SQL_TRANSACTION no_active_sql_transaction
229
235
  25P02 E ERRCODE_IN_FAILED_SQL_TRANSACTION in_failed_sql_transaction
236
+ 25P03 E ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT idle_in_transaction_session_timeout
230
237
 
231
238
  Section: Class 26 - Invalid SQL Statement Name
232
239
 
@@ -278,6 +285,7 @@ Section: Class 39 - External Routine Invocation Exception
278
285
  39004 E ERRCODE_E_R_I_E_NULL_VALUE_NOT_ALLOWED null_value_not_allowed
279
286
  39P01 E ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED trigger_protocol_violated
280
287
  39P02 E ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED srf_protocol_violated
288
+ 39P03 E ERRCODE_E_R_I_E_EVENT_TRIGGER_PROTOCOL_VIOLATED event_trigger_protocol_violated
281
289
 
282
290
  Section: Class 3B - Savepoint Exception
283
291
 
@@ -319,6 +327,7 @@ Section: Class 42 - Syntax Error or Access Rule Violation
319
327
  42P21 E ERRCODE_COLLATION_MISMATCH collation_mismatch
320
328
  42P22 E ERRCODE_INDETERMINATE_COLLATION indeterminate_collation
321
329
  42809 E ERRCODE_WRONG_OBJECT_TYPE wrong_object_type
330
+ 428C9 E ERRCODE_GENERATED_ALWAYS generated_always
322
331
 
323
332
  # Note: for ERRCODE purposes, we divide namable objects into these categories:
324
333
  # databases, schemas, prepared statements, cursors, tables, columns,
@@ -410,6 +419,10 @@ Section: Class 58 - System Error (errors external to PostgreSQL itself)
410
419
  58P01 E ERRCODE_UNDEFINED_FILE undefined_file
411
420
  58P02 E ERRCODE_DUPLICATE_FILE duplicate_file
412
421
 
422
+ Section: Class 72 - Snapshot Failure
423
+ # (class borrowed from Oracle)
424
+ 72000 E ERRCODE_SNAPSHOT_TOO_OLD snapshot_too_old
425
+
413
426
  Section: Class F0 - Configuration File Error
414
427
 
415
428
  # (PostgreSQL-specific error class)
@@ -454,6 +467,7 @@ P0000 E ERRCODE_PLPGSQL_ERROR plp
454
467
  P0001 E ERRCODE_RAISE_EXCEPTION raise_exception
455
468
  P0002 E ERRCODE_NO_DATA_FOUND no_data_found
456
469
  P0003 E ERRCODE_TOO_MANY_ROWS too_many_rows
470
+ P0004 E ERRCODE_ASSERT_FAILURE assert_failure
457
471
 
458
472
  Section: Class XX - Internal Error
459
473
 
data/ext/extconf.rb CHANGED
@@ -24,7 +24,11 @@ if enable_config("windows-cross")
24
24
  else
25
25
  # Native build
26
26
 
27
- if pgconfig = ( with_config('pg-config') || with_config('pg_config') || find_executable('pg_config') )
27
+ pgconfig = with_config('pg-config') ||
28
+ with_config('pg_config') ||
29
+ find_executable('pg_config')
30
+
31
+ if pgconfig && pgconfig != 'ignore'
28
32
  $stderr.puts "Using config values from %s" % [ pgconfig ]
29
33
  incdir = `"#{pgconfig}" --includedir`.chomp
30
34
  libdir = `"#{pgconfig}" --libdir`.chomp
@@ -43,6 +47,9 @@ else
43
47
  end
44
48
  end
45
49
 
50
+ if RUBY_VERSION >= '2.3.0' && /solaris/ =~ RUBY_PLATFORM
51
+ append_cppflags( '-D__EXTENSIONS__' )
52
+ end
46
53
 
47
54
  find_header( 'libpq-fe.h' ) or abort "Can't find the 'libpq-fe.h header"
48
55
  find_header( 'libpq/libpq-fs.h' ) or abort "Can't find the 'libpq/libpq-fs.h header"
@@ -53,47 +60,28 @@ abort "Can't find the PostgreSQL client library (libpq)" unless
53
60
  have_library( 'libpq', 'PQconnectdb', ['libpq-fe.h'] ) ||
54
61
  have_library( 'ms/libpq', 'PQconnectdb', ['libpq-fe.h'] )
55
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
+
56
72
  # optional headers/functions
57
- have_func 'PQconnectionUsedPassword' or
73
+ have_func 'PQsetSingleRowMode' or
58
74
  abort "Your PostgreSQL is too old. Either install an older version " +
59
- "of this gem or upgrade your database."
60
- have_func 'PQisthreadsafe'
61
- have_func 'PQprepare'
62
- have_func 'PQexecParams'
63
- have_func 'PQescapeString'
64
- have_func 'PQescapeStringConn'
65
- have_func 'PQescapeLiteral'
66
- have_func 'PQescapeIdentifier'
67
- have_func 'PQgetCancel'
68
- have_func 'lo_create'
69
- have_func 'pg_encoding_to_char'
70
- have_func 'pg_char_to_encoding'
71
- have_func 'PQsetClientEncoding'
72
- have_func 'PQlibVersion'
73
- have_func 'PQping'
74
- have_func 'PQsetSingleRowMode'
75
+ "of this gem or upgrade your database to at least PostgreSQL-9.2."
75
76
  have_func 'PQconninfo'
77
+ have_func 'PQsslAttribute'
78
+ have_func 'PQencryptPasswordConn'
76
79
 
77
- have_func 'rb_encdb_alias'
78
- have_func 'rb_enc_alias'
79
- have_func 'rb_thread_call_without_gvl'
80
- have_func 'rb_thread_call_with_gvl'
81
- have_func 'rb_thread_fd_select'
82
- have_func 'rb_w32_wrap_io_handle'
83
- have_func 'rb_str_modify_expand'
84
- have_func 'rb_hash_dup'
85
-
86
- have_const 'PGRES_COPY_BOTH', 'libpq-fe.h'
87
- have_const 'PGRES_SINGLE_TUPLE', 'libpq-fe.h'
88
80
  have_const 'PG_DIAG_TABLE_NAME', 'libpq-fe.h'
89
81
 
90
- $defs.push( "-DHAVE_ST_NOTIFY_EXTRA" ) if
91
- have_struct_member 'struct pgNotify', 'extra', 'libpq-fe.h'
92
-
93
82
  # unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
94
83
  have_header 'unistd.h'
95
84
  have_header 'inttypes.h'
96
- have_header 'ruby/st.h' or have_header 'st.h' or abort "pg currently requires the ruby/st.h header"
97
85
 
98
86
  checking_for "C99 variable length arrays" do
99
87
  $defs.push( "-DHAVE_VARIABLE_LENGTH_ARRAYS" ) if try_compile('void test_vla(int l){ int vla[l]; }')
data/ext/gvl_wrappers.c CHANGED
@@ -5,6 +5,10 @@
5
5
 
6
6
  #include "pg.h"
7
7
 
8
+ #ifndef HAVE_PQENCRYPTPASSWORDCONN
9
+ char *PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm){return NULL;}
10
+ #endif
11
+
8
12
  FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_WRAPPER_STRUCT );
9
13
  FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_SKELETON );
10
14
  FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_STUB );