pg 0.18.1 → 0.19.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.
data/History.rdoc CHANGED
@@ -1,3 +1,68 @@
1
+ == v0.19.0 [2016-09-21] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ - Deprecate Ruby 1.9
4
+
5
+ Enhancements:
6
+ - Respect and convert character encoding of all strings sent
7
+ to the server. #231
8
+ - Add PostgreSQL-9.5 functions PQsslInUse(), PQsslAttribute()
9
+ and PQsslAttributeNames().
10
+ - Various documentation fixes and improvements.
11
+ - Add mechanism to build without pg_config:
12
+ gem install pg -- --with-pg-config=ignore
13
+ - Update Windows binary gems to Ruby-2.3, PostgreSQL 9.5.4 and
14
+ OpenSSL 1.0.2f.
15
+ - Add JSON coders and add them to BasicTypeMapForResults and
16
+ BasicTypeMapBasedOnResult
17
+ - Allow build from git per bundler.
18
+
19
+ Bugfixes:
20
+ - Release GVL while calling PQsetClientEncoding(). #245
21
+ - Add __EXTENSIONS__ to Solaris/SmartOS for Ruby >= 2.3.x. #236
22
+ - Fix wrong exception when running SQL while in Connection#copy_data
23
+ block for output
24
+
25
+
26
+ == v0.18.4 [2015-11-13] Michael Granger <ged@FaerieMUD.org>
27
+
28
+ Enhancements:
29
+ - Fixing compilation problems with Microsoft Visual Studio 2008. GH #10
30
+ - Avoid name clash with xcode and jemalloc. PR#22, PR#23
31
+
32
+ Bugfixes:
33
+ - Avoid segfault, when quote_ident or TextEncoder::Identifier
34
+ is called with Array containing non-strings. #226
35
+
36
+
37
+ == v0.18.3 [2015-09-03] Michael Granger <ged@FaerieMUD.org>
38
+
39
+ Enhancements:
40
+ - Use rake-compiler-dock to build windows gems easily.
41
+ - Add CI-tests on appveyor and fix test cases accordingly.
42
+
43
+ Bugfixes:
44
+ - Fix data type resulting in wrong base64 encoding.
45
+ - Change instance_of checks to kind_of for subclassing. #220
46
+ - TextDecoder::Date returns an actual Ruby Date instead of a Time
47
+ (thanks to Thomas Ramfjord)
48
+
49
+
50
+ == v0.18.2 [2015-05-14] Michael Granger <ged@FaerieMUD.org>
51
+
52
+ Enhancements:
53
+
54
+ - Allow URI connection string (thanks to Chris Bandy)
55
+ - Allow Array type parameter to conn.quote_ident
56
+
57
+ Bugfixes:
58
+
59
+ - Speedups and fixes for PG::TextDecoder::Identifier and quoting behavior
60
+ - Revert addition of PG::Connection#hostaddr [#202].
61
+ - Fix decoding of fractional timezones and timestamps [#203]
62
+ - Fixes for non-C99 compilers
63
+ - Avoid possible symbol name clash when linking againt static libpq.
64
+
65
+
1
66
  == v0.18.1 [2015-01-05] Michael Granger <ged@FaerieMUD.org>
2
67
 
3
68
  Correct the minimum compatible Ruby version to 1.9.3. #199
@@ -19,6 +84,7 @@ Enhancements:
19
84
  - Add Enumerator variant to PG::Result#each and #each_row.
20
85
  - Add PG::Connection#conninfo and #hostaddr.
21
86
  - Add PG.init_openssl and PG.init_ssl methods.
87
+ - Add PG::Result.inspect
22
88
  - Force zero termination for all text strings that are given to libpq.
23
89
  It raises an ArgumentError if the string contains a null byte.
24
90
  - Update Windows cross build to PostgreSQL 9.3.
data/README-Windows.rdoc CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  In order to build this extension on MS Windows you will need a couple things.
4
4
 
5
- First, a compiler. For the one click installer this means you should either
6
- use VC++ 6.0 or the compiler that comes with cygwin or mingw if you're
7
- building on that platform.
5
+ First, a compiler. For the one click installer this means you should use
6
+ the DevKit or the compiler that comes with cygwin if you're building on that
7
+ platform.
8
8
 
9
9
  If you've built Ruby yourself, you should use the same compiler to build
10
10
  this library that you used to build Ruby.
@@ -29,34 +29,23 @@ Adjust your path accordingly. BE SURE TO USE THE SHORT PATH NAMES! If you
29
29
  try to use a path with spaces in it, the nmake.exe program will choke.
30
30
 
31
31
 
32
- == Cross compiling for mswin32
32
+ == Building binary 'pg' gems for MS Windows
33
33
 
34
- Using rake-compiler a cross compiled pg gem can be build on a Linux or MacOS X
35
- host for the win32 platform. The generated gem is statically linked against
36
- libpq and libssl. OpenSSL and PostgreSQL are downloaded and compiled from the
37
- sources. There are no runtime dependencies to any but the standard Windows
38
- DLLs.
34
+ Binary gems for windows can be built on Linux, OS-X and even on Windows
35
+ with the help of docker. This is how regular windows gems are built for
36
+ rubygems.org .
39
37
 
40
- Install mingw32 using the instructions in rake-compiler's README.
41
- For Debian/Ubuntu it is <tt>apt-get install gcc-mingw32</tt> .
42
- Use ruby-1.8.7 for the following commands.
38
+ To do this, install boot2docker [on Windows](https://github.com/boot2docker/windows-installer/releases)
39
+ or [on OS X](https://github.com/boot2docker/osx-installer/releases) and make
40
+ sure it is started. A native Docker installation is best on Linux.
43
41
 
44
- Download and cross compile ruby 1.8 and 1.9 for win32 with:
42
+ Then run:
45
43
 
46
- rake-compiler cross-ruby VERSION=1.8.7-p352
47
- rake-compiler cross-ruby VERSION=1.9.2-p290
44
+ rake gem:windows
48
45
 
49
- Download and cross compile pg for win32:
50
-
51
- rake cross native gem
52
-
53
- or with custom versions:
54
-
55
- rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.2 \
56
- OPENSSL_VERSION=1.0.0e POSTGRESQL_VERSION=9.1.1
57
-
58
- If everything works, there should be pg-VERSION-x86-mingw32.gem in the pkg
59
- directory.
46
+ This will download a docker image suited for building windows gems, and it
47
+ will download and build OpenSSL and PostgreSQL. Finally the gem is built
48
+ containing binaries for all supported ruby versions.
60
49
 
61
50
 
62
51
  == Reporting Problems
data/README.rdoc CHANGED
@@ -4,12 +4,14 @@ home :: https://bitbucket.org/ged/ruby-pg
4
4
  mirror :: https://github.com/ged/ruby-pg
5
5
  docs :: http://deveiate.org/code/pg
6
6
 
7
+ {<img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/ged/ruby-pg">}[https://gitter.im/ged/ruby-pg?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge]
8
+
7
9
 
8
10
  == Description
9
11
 
10
12
  Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
11
13
 
12
- It works with {PostgreSQL 8.4 and later}[http://www.postgresql.org/support/versioning/].
14
+ It works with {PostgreSQL 9.1 and later}[http://www.postgresql.org/support/versioning/].
13
15
 
14
16
  A small example usage:
15
17
 
@@ -21,7 +23,7 @@ A small example usage:
21
23
  conn = PG.connect( dbname: 'sales' )
22
24
  conn.exec( "SELECT * FROM pg_stat_activity" ) do |result|
23
25
  puts " PID | User | Query"
24
- result.each do |row|
26
+ result.each do |row|
25
27
  puts " %7d | %-16s | %s " %
26
28
  row.values_at('procpid', 'usename', 'current_query')
27
29
  end
@@ -29,15 +31,16 @@ A small example usage:
29
31
 
30
32
  == Build Status
31
33
 
32
- {<img src="https://travis-ci.org/ged/ruby-pg.png?branch=master" alt="Build Status" />}[https://travis-ci.org/ged/ruby-pg]
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]
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]
33
36
 
34
37
 
35
38
  == Requirements
36
39
 
37
- * Ruby 1.9.3-p392, or 2.0.0-p0.
38
- * PostgreSQL 8.4.x or later (with headers, -dev packages, etc).
40
+ * Ruby 2.2
41
+ * PostgreSQL 9.1.x or later (with headers, -dev packages, etc).
39
42
 
40
- 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
41
44
  not regularly tested.
42
45
 
43
46
 
@@ -63,6 +66,10 @@ There's also {a Google+ group}[http://goo.gl/TFy1U] and a
63
66
  {mailing list}[http://groups.google.com/group/ruby-pg] if you get stuck, or just
64
67
  want to chat about something.
65
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
+
66
73
 
67
74
  == Type Casts
68
75
 
@@ -109,7 +116,7 @@ needs for type casting. The default type map is PG::TypeMapAllStrings.
109
116
 
110
117
  A type map can be assigned per connection or per query respectively per
111
118
  result set. Type maps can also be used for COPY in and out data streaming.
112
-
119
+ See PG::Connection#copy_data .
113
120
 
114
121
  == Contributing
115
122
 
@@ -130,7 +137,7 @@ Lars Kanis <lars@greiz-reinsdorf.de>.
130
137
 
131
138
  == Copying
132
139
 
133
- Copyright (c) 1997-2013 by the authors.
140
+ Copyright (c) 1997-2016 by the authors.
134
141
 
135
142
  * Jeff Davis <ruby-pg@j-davis.com>
136
143
  * Guy Decoux (ts) <decoux@moulon.inra.fr>
@@ -142,7 +149,7 @@ Copyright (c) 1997-2013 by the authors.
142
149
  * Noboru Saitou <noborus@netlab.jp>
143
150
 
144
151
  You may redistribute this software under the same terms as Ruby itself; see
145
- 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
146
153
  for details.
147
154
 
148
155
  Portions of the code are from the PostgreSQL project, and are distributed
data/Rakefile CHANGED
@@ -55,29 +55,24 @@ $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
63
  self.dependency 'rake-compiler', '~> 0.9', :developer
64
+ self.dependency 'rake-compiler-dock', '~> 0.5', :developer
64
65
  self.dependency 'hoe', '~> 3.12', :developer
65
66
  self.dependency 'hoe-deveiate', '~> 0.6', :developer
66
67
  self.dependency 'hoe-bundler', '~> 1.0', :developer
67
68
  self.dependency 'rspec', '~> 3.0', :developer
68
69
 
69
- self.spec_extras[:licenses] = ['BSD', 'Ruby', 'GPL']
70
70
  self.spec_extras[:extensions] = [ 'ext/extconf.rb' ]
71
71
 
72
- self.require_ruby_version( '>= 1.9.3' )
72
+ self.require_ruby_version( '>= 2.0.0' )
73
73
 
74
74
  self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
75
75
  self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
76
- self.spec_extras[:rdoc_options] = [
77
- '-f', 'fivefish',
78
- '-t', 'pg: The Ruby Interface to PostgreSQL',
79
- '-m', 'README.rdoc',
80
- ]
81
76
 
82
77
  self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
83
78
  end
@@ -85,7 +80,7 @@ end
85
80
  ENV['VERSION'] ||= $hoespec.spec.version.to_s
86
81
 
87
82
  # Tests should pass before checking in
88
- task 'hg:precheckin' => [ :check_history, :check_manifest, :spec ]
83
+ task 'hg:precheckin' => [ :check_history, :check_manifest, :spec, :gemspec ]
89
84
 
90
85
  # Support for 'rvm specs'
91
86
  task :specs => :spec
@@ -101,7 +96,7 @@ task :test do
101
96
  # the installed gem dir. So we clear the task rake-compiler set up
102
97
  # to break the dependency between :spec and :compile when running under
103
98
  # rubygems-test, and then run :spec.
104
- Rake::Task[ EXT.to_s ].clear
99
+ Rake::Task[ EXT.to_s ].clear if File.exist?(EXT.to_s)
105
100
  Rake::Task[ :spec ].execute
106
101
  end
107
102
 
@@ -136,8 +131,22 @@ Rake::ExtensionTask.new do |ext|
136
131
 
137
132
  # Add libpq.dll to windows binary gemspec
138
133
  ext.cross_compiling do |spec|
139
- # mingw32-platform strings differ (RUBY_PLATFORM=i386-mingw32 vs. x86-mingw32 for rubygems)
140
- spec.files << "lib/#{spec.platform.to_s.gsub(/^x86-/, "i386-")}/libpq.dll"
134
+ spec.files << "lib/libpq.dll"
135
+ end
136
+ end
137
+
138
+
139
+ # Use the fivefish formatter for docs generated from development checkout
140
+ if File.directory?( '.hg' )
141
+ require 'rdoc/task'
142
+
143
+ Rake::Task[ 'docs' ].clear
144
+ RDoc::Task.new( 'docs' ) do |rdoc|
145
+ rdoc.main = "README.rdoc"
146
+ rdoc.rdoc_files.include( "*.rdoc", "ChangeLog", "lib/**/*.rb", 'ext/**/*.{c,h}' )
147
+ rdoc.generator = :fivefish
148
+ rdoc.title = "PG: The Ruby PostgreSQL Driver"
149
+ rdoc.rdoc_dir = 'doc'
141
150
  end
142
151
  end
143
152
 
@@ -150,6 +159,7 @@ file 'ChangeLog' do |task|
150
159
  if File.exist?('.hg/branch')
151
160
  $stderr.puts "Updating the changelog..."
152
161
  begin
162
+ include Hoe::MercurialHelpers
153
163
  content = make_changelog()
154
164
  rescue NameError
155
165
  abort "Packaging tasks require the hoe-mercurial plugin (gem install hoe-mercurial)"
@@ -179,9 +189,7 @@ task :update_error_codes do
179
189
 
180
190
  ERRORCODES_TXT = "ext/errorcodes.txt"
181
191
  sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
182
- end
183
192
 
184
- file 'ext/errorcodes.def' => ['ext/errorcodes.rb', 'ext/errorcodes.txt'] do
185
193
  ruby 'ext/errorcodes.rb', 'ext/errorcodes.txt', 'ext/errorcodes.def'
186
194
  end
187
195
 
@@ -195,12 +203,14 @@ file GEMSPEC => __FILE__
195
203
  task GEMSPEC do |task|
196
204
  spec = $hoespec.spec
197
205
  spec.files.delete( '.gemtest' )
198
- spec.version = "#{spec.version}.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
206
+ spec.signing_key = nil
207
+ spec.version = "#{spec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
208
+ spec.cert_chain = [ 'certs/ged.pem' ]
199
209
  File.open( task.name, 'w' ) do |fh|
200
210
  fh.write( spec.to_ruby )
201
211
  end
202
212
  end
203
213
 
204
- CLOBBER.include( GEMSPEC.to_s )
214
+ CLOBBER.include( '*.gemspec' )
205
215
  task :default => :gemspec
206
216
 
data/Rakefile.cross CHANGED
@@ -21,17 +21,28 @@ end
21
21
  class CrossLibrary < OpenStruct
22
22
  include Rake::DSL
23
23
 
24
- def initialize(for_platform, openssl_config)
24
+ def initialize(for_platform, openssl_config, toolchain)
25
25
  super()
26
26
 
27
27
  self.for_platform = for_platform
28
28
  self.openssl_config = openssl_config
29
+ self.host_platform = toolchain
29
30
 
30
31
  # Cross-compilation constants
31
- self.openssl_version = ENV['OPENSSL_VERSION'] || '1.0.1i'
32
- self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '9.3.5'
33
-
34
- self.compile_home = Pathname( "./build" ).expand_path
32
+ self.openssl_version = ENV['OPENSSL_VERSION'] || '1.0.2h'
33
+ self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '9.5.4'
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 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
35
46
  self.static_sourcesdir = compile_home + 'sources'
36
47
  self.static_builddir = compile_home + 'builds' + for_platform
37
48
 
@@ -67,17 +78,6 @@ class CrossLibrary < OpenStruct
67
78
  self.postgresql_lib = static_postgresql_libdir + 'libpq.dll'
68
79
  self.postgresql_patches = Rake::FileList[ (MISCDIR + "postgresql-#{postgresql_version}.*.patch").to_s ]
69
80
 
70
- # Use rake-compilers config.yml to determine the toolchain that was used
71
- # to build Ruby for this platform.
72
- self.host_platform = begin
73
- config_file = YAML.load_file(File.expand_path("~/.rake-compiler/config.yml"))
74
- _, rbfile = config_file.find{|key, fname| key.start_with?("rbconfig-#{for_platform}-") }
75
- IO.read(rbfile).match(/CONFIG\["CC"\] = "(.*)"/)[1].sub(/\-gcc/, '')
76
- rescue
77
- nil
78
- end
79
-
80
-
81
81
  # clean intermediate files and folders
82
82
  CLEAN.include( static_builddir.to_s )
83
83
 
@@ -217,6 +217,11 @@ class CrossLibrary < OpenStruct
217
217
 
218
218
  # make libpq.dll
219
219
  task postgresql_lib => [ postgresql_global_makefile ] do |t|
220
+ # Work around missing dependency to libcommon in PostgreSQL-9.4.0
221
+ chdir( static_postgresql_srcdir + "common" ) do
222
+ sh 'make', "-j#{NUM_CPUS}"
223
+ end
224
+
220
225
  chdir( postgresql_lib.dirname ) do
221
226
  sh 'make',
222
227
  "-j#{NUM_CPUS}",
@@ -230,7 +235,7 @@ class CrossLibrary < OpenStruct
230
235
  task :libpq => postgresql_lib
231
236
 
232
237
  # copy libpq.dll to lib dir
233
- dest_libpq = "lib/#{for_platform}/#{postgresql_lib.basename}"
238
+ dest_libpq = "lib/#{postgresql_lib.basename}"
234
239
  directory File.dirname(dest_libpq)
235
240
  file dest_libpq => [postgresql_lib, File.dirname(dest_libpq)] do
236
241
  cp postgresql_lib, dest_libpq
@@ -246,10 +251,10 @@ end
246
251
 
247
252
  if File.exist?(File.expand_path("~/.rake-compiler/config.yml"))
248
253
  CrossLibraries = [
249
- ['i386-mingw32', 'mingw'],
250
- ['x64-mingw32', 'mingw64'],
251
- ].map do |platform, openssl_config|
252
- CrossLibrary.new platform, openssl_config
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
253
258
  end
254
259
  else
255
260
  $stderr.puts "Cross-compilation disabled -- rake-compiler not properly installed"
@@ -278,3 +283,19 @@ ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
278
283
  sh "x86_64-w64-mingw32-strip -S tmp/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/pg_ext.so"
279
284
  end
280
285
  end
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
+
295
+ RakeCompilerDock.sh <<-EOT
296
+ mkdir ~/.gem &&
297
+ (cp build/gem/gem-*.pem ~/.gem/ || true) &&
298
+ bundle install &&
299
+ rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.6:2.0.0:1.9.3
300
+ EOT
301
+ 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 );
@@ -466,6 +474,10 @@
466
474
  VALUE klass = define_error_class( "ERIESrfProtocolViolated", "39" );
467
475
  register_error_class( "39P02", klass );
468
476
  }
477
+ {
478
+ VALUE klass = define_error_class( "ERIEEventTriggerProtocolViolated", "39" );
479
+ register_error_class( "39P03", klass );
480
+ }
469
481
  {
470
482
  VALUE klass = define_error_class( "SavepointException", NULL );
471
483
  register_error_class( "3B000", klass );
@@ -916,6 +928,10 @@
916
928
  VALUE klass = define_error_class( "TooManyRows", "P0" );
917
929
  register_error_class( "P0003", klass );
918
930
  }
931
+ {
932
+ VALUE klass = define_error_class( "AssertFailure", "P0" );
933
+ register_error_class( "P0004", klass );
934
+ }
919
935
  {
920
936
  VALUE klass = define_error_class( "InternalError", NULL );
921
937
  register_error_class( "XX000", klass );