pg 0.12.0-x86-mingw32 → 0.12.2-x86-mingw32

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/ChangeLog CHANGED
@@ -1,8 +1,106 @@
1
+ 2012-01-03 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * .hgtags:
4
+ Added tag v0.12.2 for changeset 88bd78632f86
5
+ [622bef3960c3] [tip]
6
+
7
+ * .hgsigs:
8
+ Added signature for changeset f3dfdb6929b7
9
+ [88bd78632f86] [v0.12.2]
10
+
11
+ * History.rdoc, ext/pg.c:
12
+ Bump patch version for release.
13
+ [f3dfdb6929b7]
14
+
15
+ * ext/pg.c, spec/m17n_spec.rb:
16
+ Encode the messages of PGErrors with the encoding of the connection.
17
+ (fixes #96)
18
+ [b62c49d91eb2]
19
+
20
+ * History.rdoc:
21
+ Updating history for Lars's patch
22
+ [5daf0ca646d2]
23
+
24
+ * spec/m17n_spec.rb, spec/pgconn_spec.rb, spec/pgresult_spec.rb:
25
+ Moved all the spec hooks to the top of the file
26
+ [42671e5d4d67]
27
+
28
+ 2012-01-03 Michael Granger <ged@faeriemud.org>
29
+
30
+ * Merged in larskanis/ruby-pg (pull request #4)
31
+ [8d88c47ccc9b]
32
+
33
+ 2012-01-03 Michael Granger <ged@FaerieMUD.org>
34
+
35
+ * Merged with 6fc514ea2547
36
+ [5ec3792d1cac]
37
+
38
+ 2011-12-27 Michael Granger <ged@FaerieMUD.org>
39
+
40
+ * History.rdoc:
41
+ Updating history file with the st.h change
42
+ [935f29411410]
43
+
44
+ 2012-01-03 Lars Kanis <kanis@comcard.de>
45
+
46
+ * ext/extconf.rb, ext/pg.h:
47
+ Alternatively include 'st.h' instead of 'ruby/st.h'. This fixes
48
+ compilation on Ruby 1.8.
49
+ [0cf272cb383f]
50
+
51
+ 2012-01-02 Michael Granger <ged@FaerieMUD.org>
52
+
53
+ * .hgtags:
54
+ Added tag v0.12.1 for changeset 21f84883e5c2
55
+ [6fc514ea2547]
56
+
57
+ * .hgsigs:
58
+ Added signature for changeset f72b14d349bf
59
+ [21f84883e5c2] [v0.12.1]
60
+
61
+ 2011-12-27 Michael Granger <ged@FaerieMUD.org>
62
+
63
+ * Merged with f8d66e32b9a8
64
+ [f72b14d349bf]
65
+
66
+ 2011-12-14 Michael Granger <ged@FaerieMUD.org>
67
+
68
+ * History.rdoc, ext/pg.c:
69
+ Bumped patch version, updated History.
70
+ [f8d66e32b9a8]
71
+
72
+ 2011-12-27 Michael Granger <ged@FaerieMUD.org>
73
+
74
+ * .tm_properties:
75
+ Adding my TextMate2 project settings
76
+ [daa6f202c54a]
77
+
78
+ * ext/extconf.rb, ext/pg.h:
79
+ Explicitly include the st.h file for interpreters that need it
80
+ (fixes #95)
81
+ [448cccfe5bbb]
82
+
83
+ * Rakefile.cross:
84
+ Allow native compiles without Mingw tools present
85
+ [f15ac13b396b]
86
+
87
+ * Rakefile, Rakefile.cross:
88
+ Whitespace consistency fixes
89
+ [784c6c5cbea9]
90
+
91
+ 2011-12-14 Michael Granger <ged@FaerieMUD.org>
92
+
93
+ * Rakefile:
94
+ Made rake-compiler a dev dependency. Thanks to eolamey@bitbucket and
95
+ Jeremy Evans for pointing out that it isn't needed for gem
96
+ installation. (Fixes #93)
97
+ [af645318f239]
98
+
1
99
  2011-12-07 Michael Granger <ged@FaerieMUD.org>
2
100
 
3
101
  * .hgtags:
4
102
  Added tag v0.12.0 for changeset b767401684d8
5
- [1060487e7621] [tip]
103
+ [1060487e7621]
6
104
 
7
105
  * .hgsigs:
8
106
  Added signature for changeset 19b551f972e2
@@ -1,3 +1,19 @@
1
+ == v0.12.2 [2012-01-03] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ - Fix for the 1.8.7 breakage introduced by the st.h fix for alternative Ruby
4
+ implementations (#97 and #98). Thanks to Lars Kanis for the patch.
5
+ - Encode error messages with the connection's encoding under 1.9 (#96)
6
+
7
+
8
+ == v0.12.1 [2011-12-14] Michael Granger <ged@FaerieMUD.org>
9
+
10
+ - Made rake-compiler a dev dependency, as Rubygems doesn't use the Rakefile
11
+ for compiling the extension. Thanks to eolamey@bitbucket and Jeremy Evans
12
+ for pointing this out.
13
+ - Added an explicit include for ruby/st.h for implementations that need it
14
+ (fixes #95).
15
+
16
+
1
17
  == v0.12.0 [2011-12-07] Michael Granger <ged@FaerieMUD.org>
2
18
 
3
19
  - PGconn#wait_for_notify
data/Rakefile CHANGED
@@ -55,7 +55,7 @@ $hoespec = Hoe.spec 'pg' do
55
55
  self.developer 'Jeff Davis', 'ruby-pg@j-davis.com'
56
56
  self.developer 'Michael Granger', 'ged@FaerieMUD.org'
57
57
 
58
- self.dependency 'rake-compiler', '~> 0.7'
58
+ self.dependency 'rake-compiler', '~> 0.7', :developer
59
59
  self.dependency 'rspec', '~> 2.6', :developer
60
60
 
61
61
  self.spec_extras[:licenses] = ['BSD', 'Ruby', 'GPL']
@@ -109,14 +109,14 @@ Rake::ExtensionTask.new do |ext|
109
109
  ext.cross_compile = true
110
110
  ext.cross_platform = %w[i386-mingw32]
111
111
 
112
- # configure options only for cross compile
113
- ext.cross_config_options += [
114
- "--with-pg-include=#{STATIC_POSTGRESQL_LIBDIR}",
115
- "--with-opt-include=#{STATIC_POSTGRESQL_INCDIR}",
116
- "--with-pg-lib=#{STATIC_POSTGRESQL_LIBDIR}",
117
- "--with-opt-lib=#{STATIC_OPENSSL_BUILDDIR}",
118
- "--enable-static-build",
119
- ]
112
+ # configure options only for cross compile
113
+ ext.cross_config_options += [
114
+ "--with-pg-include=#{STATIC_POSTGRESQL_LIBDIR}",
115
+ "--with-opt-include=#{STATIC_POSTGRESQL_INCDIR}",
116
+ "--with-pg-lib=#{STATIC_POSTGRESQL_LIBDIR}",
117
+ "--with-opt-lib=#{STATIC_OPENSSL_BUILDDIR}",
118
+ "--enable-static-build",
119
+ ]
120
120
  end
121
121
 
122
122
 
@@ -127,7 +127,7 @@ end
127
127
  file 'ChangeLog' => '.hg/branch' do |task|
128
128
  $stderr.puts "Updating the changelog..."
129
129
  begin
130
- include Hoe::MercurialHelpers
130
+ include Hoe::MercurialHelpers
131
131
  content = make_changelog()
132
132
  rescue NameError
133
133
  abort "Packaging tasks require the hoe-mercurial plugin (gem install hoe-mercurial)"
@@ -10,11 +10,11 @@ require 'rake/extensioncompiler'
10
10
  MISCDIR = BASEDIR + 'misc'
11
11
 
12
12
  NUM_CPUS = if File.exist?('/proc/cpuinfo')
13
- File.read('/proc/cpuinfo').scan('processor').length
13
+ File.read('/proc/cpuinfo').scan('processor').length
14
14
  elsif RUBY_PLATFORM.include?( 'darwin' )
15
- `system_profiler SPHardwareDataType | grep 'Cores' | awk '{print $5}'`.chomp
15
+ `system_profiler SPHardwareDataType | grep 'Cores' | awk '{print $5}'`.chomp
16
16
  else
17
- 1
17
+ 1
18
18
  end
19
19
 
20
20
  # Cross-compilation constants
@@ -29,7 +29,7 @@ STATIC_BUILDDIR = COMPILE_HOME + 'builds'
29
29
  STATIC_OPENSSL_BUILDDIR = STATIC_BUILDDIR + "openssl-#{OPENSSL_VERSION}"
30
30
 
31
31
  OPENSSL_SOURCE_URI =
32
- URI( "http://www.openssl.org/source/openssl-#{OPENSSL_VERSION}.tar.gz" )
32
+ URI( "http://www.openssl.org/source/openssl-#{OPENSSL_VERSION}.tar.gz" )
33
33
  OPENSSL_TARBALL = STATIC_SOURCESDIR + File.basename( OPENSSL_SOURCE_URI.path )
34
34
  OPENSSL_MAKEFILE = STATIC_OPENSSL_BUILDDIR + 'Makefile'
35
35
 
@@ -41,9 +41,9 @@ OPENSSL_PATCHES = Rake::FileList[ MISCDIR + "openssl-#{OPENSSL_VERSIO
41
41
  # Static PostgreSQL build vars
42
42
  STATIC_POSTGRESQL_BUILDDIR = STATIC_BUILDDIR + "postgresql-#{POSTGRESQL_VERSION}"
43
43
  POSTGRESQL_SOURCE_URI = begin
44
- uristring = "http://ftp9.us.postgresql.org/pub/mirrors/postgresql/source/" +
45
- "v%s/postgresql-%s.tar.bz2" % [ POSTGRESQL_VERSION, POSTGRESQL_VERSION ]
46
- URI( uristring )
44
+ uristring = "http://ftp9.us.postgresql.org/pub/mirrors/postgresql/source/" +
45
+ "v%s/postgresql-%s.tar.bz2" % [ POSTGRESQL_VERSION, POSTGRESQL_VERSION ]
46
+ URI( uristring )
47
47
  end
48
48
  POSTGRESQL_TARBALL = STATIC_SOURCESDIR + File.basename( POSTGRESQL_SOURCE_URI.path )
49
49
 
@@ -56,7 +56,12 @@ POSTGRESQL_SHLIB_MAKEFILE = STATIC_POSTGRESQL_SRCDIR + 'Makefile.shlib'
56
56
  POSTGRESQL_SHLIB_MF_ORIG = STATIC_POSTGRESQL_SRCDIR + 'Makefile.shlib.orig'
57
57
  POSTGRESQL_LIB = STATIC_POSTGRESQL_LIBDIR + 'libpq.a'
58
58
 
59
- CROSS_PREFIX = Rake::ExtensionCompiler.mingw_host
59
+ CROSS_PREFIX = begin
60
+ Rake::ExtensionCompiler.mingw_host
61
+ rescue => err
62
+ $stderr.puts "Cross-compilation disabled -- %s" % [ err.message ]
63
+ 'unknown'
64
+ end
60
65
 
61
66
 
62
67
  # clean intermediate files and folders
@@ -66,13 +71,13 @@ CLEAN.include( STATIC_BUILDDIR.to_s )
66
71
  ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.3'
67
72
 
68
73
  def download(url, save_to)
69
- part = save_to+".part"
70
- sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
71
- FileUtils.mv part, save_to
74
+ part = save_to+".part"
75
+ sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
76
+ FileUtils.mv part, save_to
72
77
  end
73
78
 
74
79
  def run(*args)
75
- sh *args
80
+ sh *args
76
81
  end
77
82
 
78
83
  #####################################################################
@@ -89,62 +94,62 @@ directory STATIC_OPENSSL_BUILDDIR.to_s
89
94
 
90
95
  # openssl source file should be stored there
91
96
  file OPENSSL_TARBALL => STATIC_SOURCESDIR do |t|
92
- download( OPENSSL_SOURCE_URI, t.name )
97
+ download( OPENSSL_SOURCE_URI, t.name )
93
98
  end
94
99
 
95
100
  # Extract the openssl builds
96
101
  file STATIC_OPENSSL_BUILDDIR => OPENSSL_TARBALL do |t|
97
- puts "extracting %s to %s" % [ OPENSSL_TARBALL, STATIC_OPENSSL_BUILDDIR.parent ]
98
- STATIC_OPENSSL_BUILDDIR.mkpath
99
- run 'tar', '-xzf', OPENSSL_TARBALL.to_s, '-C', STATIC_OPENSSL_BUILDDIR.parent.to_s
100
- OPENSSL_MAKEFILE.unlink if OPENSSL_MAKEFILE.exist?
102
+ puts "extracting %s to %s" % [ OPENSSL_TARBALL, STATIC_OPENSSL_BUILDDIR.parent ]
103
+ STATIC_OPENSSL_BUILDDIR.mkpath
104
+ run 'tar', '-xzf', OPENSSL_TARBALL.to_s, '-C', STATIC_OPENSSL_BUILDDIR.parent.to_s
105
+ OPENSSL_MAKEFILE.unlink if OPENSSL_MAKEFILE.exist?
101
106
 
102
- OPENSSL_PATCHES.each do |patchfile|
103
- puts " applying patch #{patchfile}..."
104
- run 'patch', '-Np1', '-d', STATIC_OPENSSL_BUILDDIR.to_s,
105
- '-i', File.expand_path( patchfile, BASEDIR )
106
- end
107
+ OPENSSL_PATCHES.each do |patchfile|
108
+ puts " applying patch #{patchfile}..."
109
+ run 'patch', '-Np1', '-d', STATIC_OPENSSL_BUILDDIR.to_s,
110
+ '-i', File.expand_path( patchfile, BASEDIR )
111
+ end
107
112
  end
108
113
 
109
114
  CMD_PRELUDE = [
110
- 'env',
111
- "CC=#{CROSS_PREFIX}-gcc",
112
- "CFLAGS=-DDSO_WIN32",
113
- "AR=#{CROSS_PREFIX}-ar",
114
- "RANLIB=#{CROSS_PREFIX}-ranlib"
115
+ 'env',
116
+ "CC=#{CROSS_PREFIX}-gcc",
117
+ "CFLAGS=-DDSO_WIN32",
118
+ "AR=#{CROSS_PREFIX}-ar",
119
+ "RANLIB=#{CROSS_PREFIX}-ranlib"
115
120
  ]
116
121
 
117
122
 
118
123
  # generate the makefile in a clean build location
119
124
  file OPENSSL_MAKEFILE => STATIC_OPENSSL_BUILDDIR do |t|
120
- Dir.chdir( STATIC_OPENSSL_BUILDDIR ) do
121
- cmd = CMD_PRELUDE.dup
122
- cmd << "./Configure" << 'mingw'
125
+ Dir.chdir( STATIC_OPENSSL_BUILDDIR ) do
126
+ cmd = CMD_PRELUDE.dup
127
+ cmd << "./Configure" << 'mingw'
123
128
 
124
- run( *cmd )
125
- end
129
+ run( *cmd )
130
+ end
126
131
  end
127
132
 
128
133
  desc "compile static openssl libraries"
129
134
  task :openssl_libs => [ LIBSSLEAY32, LIBEAY32 ]
130
135
 
131
136
  task :compile_static_openssl => OPENSSL_MAKEFILE do |t|
132
- Dir.chdir( STATIC_OPENSSL_BUILDDIR ) do
133
- cmd = CMD_PRELUDE.dup
134
- cmd << 'make' << "-j#{NUM_CPUS}" << 'build_libs'
137
+ Dir.chdir( STATIC_OPENSSL_BUILDDIR ) do
138
+ cmd = CMD_PRELUDE.dup
139
+ cmd << 'make' << "-j#{NUM_CPUS}" << 'build_libs'
135
140
 
136
- run( *cmd )
137
- end
141
+ run( *cmd )
142
+ end
138
143
  end
139
144
 
140
145
  desc "compile static #{LIBEAY32}"
141
146
  file LIBEAY32 => :compile_static_openssl do |t|
142
- FileUtils.cp( STATIC_OPENSSL_BUILDDIR + 'libcrypto.a', LIBEAY32.to_s )
147
+ FileUtils.cp( STATIC_OPENSSL_BUILDDIR + 'libcrypto.a', LIBEAY32.to_s )
143
148
  end
144
149
 
145
150
  desc "compile static #{LIBSSLEAY32}"
146
151
  file LIBSSLEAY32 => :compile_static_openssl do |t|
147
- FileUtils.cp( STATIC_OPENSSL_BUILDDIR + 'libssl.a', LIBSSLEAY32.to_s )
152
+ FileUtils.cp( STATIC_OPENSSL_BUILDDIR + 'libssl.a', LIBSSLEAY32.to_s )
148
153
  end
149
154
 
150
155
 
@@ -157,61 +162,61 @@ directory STATIC_POSTGRESQL_BUILDDIR.to_s
157
162
 
158
163
  # postgresql source file should be stored there
159
164
  file POSTGRESQL_TARBALL => STATIC_SOURCESDIR do |t|
160
- download( POSTGRESQL_SOURCE_URI, t.name )
165
+ download( POSTGRESQL_SOURCE_URI, t.name )
161
166
  end
162
167
 
163
168
  # Extract the postgresql sources
164
169
  file STATIC_POSTGRESQL_BUILDDIR => POSTGRESQL_TARBALL do |t|
165
- puts "extracting %s to %s" % [ POSTGRESQL_TARBALL, STATIC_POSTGRESQL_BUILDDIR.parent ]
166
- STATIC_POSTGRESQL_BUILDDIR.mkpath
167
- run 'tar', '-xjf', POSTGRESQL_TARBALL.to_s, '-C', STATIC_POSTGRESQL_BUILDDIR.parent.to_s
168
- mv POSTGRESQL_SHLIB_MAKEFILE, POSTGRESQL_SHLIB_MF_ORIG
170
+ puts "extracting %s to %s" % [ POSTGRESQL_TARBALL, STATIC_POSTGRESQL_BUILDDIR.parent ]
171
+ STATIC_POSTGRESQL_BUILDDIR.mkpath
172
+ run 'tar', '-xjf', POSTGRESQL_TARBALL.to_s, '-C', STATIC_POSTGRESQL_BUILDDIR.parent.to_s
173
+ mv POSTGRESQL_SHLIB_MAKEFILE, POSTGRESQL_SHLIB_MF_ORIG
169
174
  end
170
175
 
171
176
  # generate the makefile in a clean build location
172
177
  file POSTGRESQL_GLOBAL_MAKEFILE => [ STATIC_POSTGRESQL_BUILDDIR, :openssl_libs ] do |t|
173
- options = [
174
- '--target=i386-mingw32',
175
- "--host=#{Rake::ExtensionCompiler.mingw_host}",
176
- '--with-openssl',
177
- '--without-zlib',
178
- '--disable-shared',
179
- ]
178
+ options = [
179
+ '--target=i386-mingw32',
180
+ "--host=#{Rake::ExtensionCompiler.mingw_host}",
181
+ '--with-openssl',
182
+ '--without-zlib',
183
+ '--disable-shared',
184
+ ]
180
185
 
181
- Dir.chdir( STATIC_POSTGRESQL_BUILDDIR ) do
182
- configure_path = STATIC_POSTGRESQL_BUILDDIR + 'configure'
183
- cmd = [ configure_path.to_s, *options ]
184
- cmd << "CFLAGS=-L#{STATIC_OPENSSL_BUILDDIR}"
185
- cmd << "LDFLAGS=-L#{STATIC_OPENSSL_BUILDDIR}"
186
- cmd << "LDFLAGS_SL=-L#{STATIC_OPENSSL_BUILDDIR}"
187
- cmd << "LIBS=-lwsock32 -lws2_32 -lgdi32"
188
- cmd << "CPPFLAGS=-I#{STATIC_OPENSSL_BUILDDIR}/include"
186
+ Dir.chdir( STATIC_POSTGRESQL_BUILDDIR ) do
187
+ configure_path = STATIC_POSTGRESQL_BUILDDIR + 'configure'
188
+ cmd = [ configure_path.to_s, *options ]
189
+ cmd << "CFLAGS=-L#{STATIC_OPENSSL_BUILDDIR}"
190
+ cmd << "LDFLAGS=-L#{STATIC_OPENSSL_BUILDDIR}"
191
+ cmd << "LDFLAGS_SL=-L#{STATIC_OPENSSL_BUILDDIR}"
192
+ cmd << "LIBS=-lwsock32 -lws2_32 -lgdi32"
193
+ cmd << "CPPFLAGS=-I#{STATIC_OPENSSL_BUILDDIR}/include"
189
194
 
190
- run( *cmd )
191
- end
195
+ run( *cmd )
196
+ end
192
197
  end
193
198
 
194
199
 
195
200
  # patch the Makefile.shlib -- depend on the build dir so it's only
196
201
  # rewritten if the tarball is re-extracted.
197
202
  file POSTGRESQL_SHLIB_MAKEFILE => POSTGRESQL_SHLIB_MF_ORIG do |t|
198
- tf = Tempfile.new( POSTGRESQL_SHLIB_MAKEFILE.basename )
199
- POSTGRESQL_SHLIB_MF_ORIG.open( File::RDONLY ) do |ifh|
200
- ifh.each_line do |line|
201
- tf.print( line.sub(/^(\s*haslibarule\s*=\s*yes)/, "# \\1 ") )
202
- end
203
- end
204
- tf.close
203
+ tf = Tempfile.new( POSTGRESQL_SHLIB_MAKEFILE.basename )
204
+ POSTGRESQL_SHLIB_MF_ORIG.open( File::RDONLY ) do |ifh|
205
+ ifh.each_line do |line|
206
+ tf.print( line.sub(/^(\s*haslibarule\s*=\s*yes)/, "# \\1 ") )
207
+ end
208
+ end
209
+ tf.close
205
210
 
206
- FileUtils.mv( tf.path, t.name, :verbose => $puts )
211
+ FileUtils.mv( tf.path, t.name, :verbose => $puts )
207
212
  end
208
213
 
209
214
 
210
215
  # make libpq.a
211
216
  task POSTGRESQL_LIB => [ POSTGRESQL_GLOBAL_MAKEFILE, POSTGRESQL_SHLIB_MAKEFILE ] do |t|
212
- Dir.chdir( POSTGRESQL_LIB.dirname ) do
213
- sh 'make', "-j#{NUM_CPUS}", POSTGRESQL_LIB.basename.to_s, 'PORTNAME=win32'
214
- end
217
+ Dir.chdir( POSTGRESQL_LIB.dirname ) do
218
+ sh 'make', "-j#{NUM_CPUS}", POSTGRESQL_LIB.basename.to_s, 'PORTNAME=win32'
219
+ end
215
220
  end
216
221
 
217
222
 
@@ -220,15 +225,15 @@ task :static_libpq => POSTGRESQL_LIB
220
225
 
221
226
  desc 'cross compile pg for win32'
222
227
  task :cross do
223
- ENV['CROSS_COMPILING'] = 'yes'
228
+ ENV['CROSS_COMPILING'] = 'yes'
224
229
  end
225
230
  task :cross => [ :mingw32, :static_libpq ]
226
231
 
227
232
  task :mingw32 do
228
- # Use Rake::ExtensionCompiler helpers to find the proper host
229
- unless Rake::ExtensionCompiler.mingw_host then
230
- warn "You need to install mingw32 cross compile functionality to be able to continue."
231
- warn "Please refer to your distribution/package manager documentation about installation."
232
- fail
233
- end
233
+ # Use Rake::ExtensionCompiler helpers to find the proper host
234
+ unless Rake::ExtensionCompiler.mingw_host then
235
+ warn "You need to install mingw32 cross compile functionality to be able to continue."
236
+ warn "Please refer to your distribution/package manager documentation about installation."
237
+ fail
238
+ end
234
239
  end
@@ -61,6 +61,7 @@ $defs.push( "-DHAVE_ST_NOTIFY_EXTRA" ) if
61
61
 
62
62
  # unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
63
63
  have_header 'unistd.h' unless enable_config("static-build")
64
+ have_header 'ruby/st.h' or have_header 'st.h' or abort "pg currently requires the ruby/st.h header"
64
65
 
65
66
  create_header()
66
67
  create_makefile( "pg_ext" )
data/ext/pg.c CHANGED
@@ -28,7 +28,7 @@ static VALUE rb_cPGconn;
28
28
  static VALUE rb_cPGresult;
29
29
  static VALUE rb_ePGError;
30
30
 
31
- static const char *VERSION = "0.12.0";
31
+ static const char *VERSION = "0.12.2";
32
32
 
33
33
 
34
34
  /* The following functions are part of libpq, but not
@@ -134,14 +134,17 @@ new_pgresult(PGresult *result)
134
134
  static void
135
135
  pgresult_check(VALUE rb_pgconn, VALUE rb_pgresult)
136
136
  {
137
- VALUE error;
137
+ VALUE error, exception;
138
138
  PGconn *conn = get_pgconn(rb_pgconn);
139
139
  PGresult *result;
140
140
  Data_Get_Struct(rb_pgresult, PGresult, result);
141
+ #ifdef M17N_SUPPORTED
142
+ rb_encoding *enc = pgconn_get_client_encoding_as_rb_encoding(conn);
143
+ #endif
141
144
 
142
145
  if(result == NULL)
143
146
  {
144
- error = rb_exc_new2(rb_ePGError, PQerrorMessage(conn));
147
+ error = rb_str_new2( PQerrorMessage(conn) );
145
148
  }
146
149
  else
147
150
  {
@@ -156,17 +159,21 @@ pgresult_check(VALUE rb_pgconn, VALUE rb_pgresult)
156
159
  case PGRES_BAD_RESPONSE:
157
160
  case PGRES_FATAL_ERROR:
158
161
  case PGRES_NONFATAL_ERROR:
159
- error = rb_exc_new2(rb_ePGError, PQresultErrorMessage(result));
162
+ error = rb_str_new2( PQresultErrorMessage(result) );
160
163
  break;
161
164
  default:
162
- error = rb_exc_new2(rb_ePGError,
163
- "internal error : unknown result status.");
165
+ error = rb_str_new2( "internal error : unknown result status." );
164
166
  }
165
167
  }
166
168
 
167
- rb_iv_set(error, "@connection", rb_pgconn);
168
- rb_iv_set(error, "@result", rb_pgresult);
169
- rb_exc_raise(error);
169
+ #ifdef M17N_SUPPORTED
170
+ rb_enc_set_index( error, rb_enc_to_index(enc) );
171
+ #endif
172
+ exception = rb_exc_new3( rb_ePGError, error );
173
+ rb_iv_set( exception, "@connection", rb_pgconn );
174
+ rb_iv_set( exception, "@result", rb_pgresult );
175
+ rb_exc_raise( exception );
176
+
170
177
  return;
171
178
  }
172
179
 
data/ext/pg.h CHANGED
@@ -14,6 +14,11 @@
14
14
  #endif /* HAVE_UNISTD_H */
15
15
 
16
16
  #include "ruby.h"
17
+ #ifdef HAVE_RUBY_ST_H
18
+ #include "ruby/st.h"
19
+ #elif HAVE_ST_H
20
+ #include "st.h"
21
+ #endif
17
22
  #include "libpq-fe.h"
18
23
  #include "libpq/libpq-fs.h" /* large-object interface */
19
24
  #include "compat.h"
Binary file
Binary file
@@ -26,6 +26,18 @@ describe "multinationalization support", :ruby_19 => true do
26
26
  @conn.exec( 'BEGIN' )
27
27
  end
28
28
 
29
+ after( :each ) do
30
+ @conn.exec( 'ROLLBACK' ) if @conn
31
+ end
32
+
33
+ after( :all ) do
34
+ teardown_testing_db( @conn ) if @conn
35
+ end
36
+
37
+
38
+ #
39
+ # Examples
40
+ #
29
41
 
30
42
  it "should return the same bytes in text format that are sent as inline text" do
31
43
  binary_file = File.join(Dir.pwd, 'spec/data', 'random_binary_data')
@@ -115,6 +127,7 @@ describe "multinationalization support", :ruby_19 => true do
115
127
  end
116
128
  end
117
129
 
130
+
118
131
  describe "Ruby 1.9.x default_internal encoding" do
119
132
 
120
133
  it "honors the Encoding.default_internal if it's set and the synchronous interface is used" do
@@ -141,11 +154,17 @@ describe "multinationalization support", :ruby_19 => true do
141
154
  end
142
155
 
143
156
 
144
- after( :each ) do
145
- @conn.exec( 'ROLLBACK' ) if @conn
146
- end
157
+ it "encodes exception messages with the connection's encoding (#96)" do
158
+ @conn.set_client_encoding( 'utf-8' )
159
+ @conn.exec "CREATE TABLE foo (bar TEXT)"
147
160
 
148
- after( :all ) do
149
- teardown_testing_db( @conn ) if @conn
161
+ begin
162
+ @conn.exec "INSERT INTO foo VALUES ('Côte d'Ivoire')"
163
+ rescue => err
164
+ err.message.encoding.should == Encoding::UTF_8
165
+ else
166
+ fail "No exception raised?!"
167
+ end
150
168
  end
169
+
151
170
  end
@@ -22,6 +22,7 @@ require 'timeout'
22
22
  describe PGconn do
23
23
  include PgTestingHelpers
24
24
 
25
+
25
26
  before( :all ) do
26
27
  @conn = setup_testing_db( "PGconn" )
27
28
  end
@@ -30,6 +31,19 @@ describe PGconn do
30
31
  @conn.exec( 'BEGIN' )
31
32
  end
32
33
 
34
+ after( :each ) do
35
+ @conn.exec( 'ROLLBACK' )
36
+ end
37
+
38
+ after( :all ) do
39
+ teardown_testing_db( @conn )
40
+ end
41
+
42
+
43
+ #
44
+ # Examples
45
+ #
46
+
33
47
  it "can create a connection option string from a Hash of options" do
34
48
  optstring = PGconn.parse_connect_args(
35
49
  :host => 'pgsql.example.com',
@@ -633,11 +647,4 @@ describe PGconn do
633
647
  result.should == { 'one' => '47' }
634
648
  end
635
649
 
636
- after( :each ) do
637
- @conn.exec( 'ROLLBACK' )
638
- end
639
-
640
- after( :all ) do
641
- teardown_testing_db( @conn )
642
- end
643
650
  end
@@ -29,6 +29,18 @@ describe PGresult do
29
29
  @conn.exec( 'BEGIN' )
30
30
  end
31
31
 
32
+ after( :each ) do
33
+ @conn.exec( 'ROLLBACK' )
34
+ end
35
+
36
+ after( :all ) do
37
+ teardown_testing_db( @conn )
38
+ end
39
+
40
+
41
+ #
42
+ # Examples
43
+ #
32
44
 
33
45
  it "should act as an array of hashes" do
34
46
  res = @conn.exec("SELECT 1 AS a, 2 AS b")
@@ -240,11 +252,4 @@ describe PGresult do
240
252
  res.ftablecol(1).should == 0 # and it shouldn't raise an exception, either
241
253
  end
242
254
 
243
- after( :each ) do
244
- @conn.exec( 'ROLLBACK' )
245
- end
246
-
247
- after( :all ) do
248
- teardown_testing_db( @conn )
249
- end
250
255
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg
3
3
  version: !ruby/object:Gem::Version
4
- hash: 47
4
+ hash: 43
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 12
9
- - 0
10
- version: 0.12.0
9
+ - 2
10
+ version: 0.12.2
11
11
  platform: x86-mingw32
12
12
  authors:
13
13
  - Jeff Davis
@@ -16,37 +16,37 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-12-08 00:00:00 Z
19
+ date: 2012-01-04 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rake-compiler
22
+ name: hoe-mercurial
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 5
29
+ hash: 25
30
30
  segments:
31
- - 0
32
- - 7
33
- version: "0.7"
34
- type: :runtime
31
+ - 1
32
+ - 3
33
+ - 1
34
+ version: 1.3.1
35
+ type: :development
35
36
  version_requirements: *id001
36
37
  - !ruby/object:Gem::Dependency
37
- name: hoe-mercurial
38
+ name: rake-compiler
38
39
  prerelease: false
39
40
  requirement: &id002 !ruby/object:Gem::Requirement
40
41
  none: false
41
42
  requirements:
42
43
  - - ~>
43
44
  - !ruby/object:Gem::Version
44
- hash: 25
45
+ hash: 5
45
46
  segments:
46
- - 1
47
- - 3
48
- - 1
49
- version: 1.3.1
47
+ - 0
48
+ - 7
49
+ version: "0.7"
50
50
  type: :development
51
51
  version_requirements: *id002
52
52
  - !ruby/object:Gem::Dependency