pg 1.2.1 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.rdoc +16 -0
- data/README.rdoc +1 -1
- data/Rakefile +5 -3
- data/Rakefile.cross +52 -54
- data/ext/pg.h +1 -0
- data/ext/pg_coder.c +16 -4
- data/ext/pg_copy_coder.c +1 -0
- data/ext/pg_record_coder.c +1 -0
- data/ext/pg_type_map_by_class.c +5 -1
- data/lib/pg.rb +3 -2
- data/lib/pg/basic_type_mapping.rb +2 -2
- data/spec/helpers.rb +1 -3
- data/spec/pg/basic_type_mapping_spec.rb +10 -25
- data/spec/pg/connection_spec.rb +77 -39
- data/spec/pg/result_spec.rb +1 -1
- data/spec/pg/type_map_by_class_spec.rb +1 -1
- data/spec/pg/type_map_by_oid_spec.rb +2 -2
- metadata +19 -20
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bbf07a6db2bae71c6f6eee0b440f27f84ae21de66dbd97536499425cdbc9b54
|
4
|
+
data.tar.gz: 8860905a7fdb97cd007530b831ee8bf39f06c2c79d52361c7a825f897374830f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a304ec0488a34e03f257769d710dfd1b4e7261023c88bf91945f0c7af99178885c32ba920931dda01776dbc2a613de66d8cf86ee10d57c231ae44fba2544acf
|
7
|
+
data.tar.gz: 88aaaedfd420a601836c3c924b9e6c6e97770f9d16de62c6121c8420967ef43501c2988d8006e9d3261388af570590cadf27a806c72ca574796d76be013e4831
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
== v1.2.3 [2020-03-18] Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
Bugfixes:
|
4
|
+
|
5
|
+
- Fix possible segfault at `PG::Coder#encode`, `decode` or their implicit calls through
|
6
|
+
a typemap after GC.compact. #327
|
7
|
+
- Fix possible segfault in `PG::TypeMapByClass` after GC.compact. #328
|
8
|
+
|
9
|
+
|
10
|
+
== v1.2.2 [2020-01-06] Michael Granger <ged@FaerieMUD.org>
|
11
|
+
|
12
|
+
Enhancements:
|
13
|
+
|
14
|
+
- Add a binary gem for Ruby 2.7.
|
15
|
+
|
16
|
+
|
1
17
|
== v1.2.1 [2020-01-02] Michael Granger <ged@FaerieMUD.org>
|
2
18
|
|
3
19
|
Enhancements:
|
data/README.rdoc
CHANGED
@@ -39,7 +39,7 @@ A small example usage:
|
|
39
39
|
* Ruby 2.2 or newer
|
40
40
|
* PostgreSQL 9.2.x or later (with headers, -dev packages, etc).
|
41
41
|
|
42
|
-
It usually
|
42
|
+
It usually works with earlier versions of Ruby/PostgreSQL as well, but those are
|
43
43
|
not regularly tested.
|
44
44
|
|
45
45
|
|
data/Rakefile
CHANGED
@@ -35,6 +35,8 @@ TEST_DIRECTORY = BASEDIR + "tmp_test_specs"
|
|
35
35
|
|
36
36
|
CLOBBER.include( TEST_DIRECTORY.to_s )
|
37
37
|
CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
|
38
|
+
CLEAN.include "lib/*/libpq.dll"
|
39
|
+
CLEAN.include "lib/pg_ext.*"
|
38
40
|
|
39
41
|
# Set up Hoe plugins
|
40
42
|
Hoe.plugin :mercurial
|
@@ -61,7 +63,7 @@ $hoespec = Hoe.spec 'pg' do
|
|
61
63
|
self.developer 'Lars Kanis', 'lars@greiz-reinsdorf.de'
|
62
64
|
|
63
65
|
self.dependency 'rake-compiler', '~> 1.0', :developer
|
64
|
-
self.dependency 'rake-compiler-dock', ['~>
|
66
|
+
self.dependency 'rake-compiler-dock', ['~> 1.0'], :developer
|
65
67
|
self.dependency 'hoe-deveiate', '~> 0.9', :developer
|
66
68
|
self.dependency 'hoe-bundler', '~> 1.0', :developer
|
67
69
|
self.dependency 'rspec', '~> 3.5', :developer
|
@@ -113,7 +115,7 @@ Rake::ExtensionTask.new do |ext|
|
|
113
115
|
ext.lib_dir = 'lib'
|
114
116
|
ext.source_pattern = "*.{c,h}"
|
115
117
|
ext.cross_compile = true
|
116
|
-
ext.cross_platform = CrossLibraries.map
|
118
|
+
ext.cross_platform = CrossLibraries.map(&:for_platform)
|
117
119
|
|
118
120
|
ext.cross_config_options += CrossLibraries.map do |lib|
|
119
121
|
{
|
@@ -129,7 +131,7 @@ Rake::ExtensionTask.new do |ext|
|
|
129
131
|
|
130
132
|
# Add libpq.dll to windows binary gemspec
|
131
133
|
ext.cross_compiling do |spec|
|
132
|
-
spec.files << "lib/libpq.dll"
|
134
|
+
spec.files << "lib/#{spec.platform}/libpq.dll"
|
133
135
|
end
|
134
136
|
end
|
135
137
|
|
data/Rakefile.cross
CHANGED
@@ -37,7 +37,7 @@ class CrossLibrary < OpenStruct
|
|
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}"
|
@@ -81,17 +83,6 @@ class CrossLibrary < OpenStruct
|
|
81
83
|
# clean intermediate files and folders
|
82
84
|
CLEAN.include( static_builddir.to_s )
|
83
85
|
|
84
|
-
|
85
|
-
def download(url, save_to)
|
86
|
-
part = save_to+".part"
|
87
|
-
sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
|
88
|
-
FileUtils.mv part, save_to
|
89
|
-
end
|
90
|
-
|
91
|
-
def run(*args)
|
92
|
-
sh *args
|
93
|
-
end
|
94
|
-
|
95
86
|
#####################################################################
|
96
87
|
### C R O S S - C O M P I L A T I O N - T A S K S
|
97
88
|
#####################################################################
|
@@ -141,9 +132,9 @@ class CrossLibrary < OpenStruct
|
|
141
132
|
end
|
142
133
|
|
143
134
|
desc "compile static openssl libraries"
|
144
|
-
task
|
135
|
+
task "openssl_libs:#{for_platform}" => [ libssl, libcrypto ]
|
145
136
|
|
146
|
-
task
|
137
|
+
task "compile_static_openssl:#{for_platform}" => openssl_makefile do |t|
|
147
138
|
chdir( static_openssl_builddir ) do
|
148
139
|
cmd = cmd_prelude.dup
|
149
140
|
cmd << 'make' << "-j#{NUM_CPUS}" << 'build_libs'
|
@@ -153,12 +144,12 @@ class CrossLibrary < OpenStruct
|
|
153
144
|
end
|
154
145
|
|
155
146
|
desc "compile static #{libssl}"
|
156
|
-
file libssl =>
|
147
|
+
file libssl => "compile_static_openssl:#{for_platform}" do |t|
|
157
148
|
rm t.name.gsub(/\.a$/, ".dll.a")
|
158
149
|
end
|
159
150
|
|
160
151
|
desc "compile static #{libcrypto}"
|
161
|
-
file libcrypto =>
|
152
|
+
file libcrypto => "compile_static_openssl:#{for_platform}" do |t|
|
162
153
|
rm t.name.gsub(/\.a$/, ".dll.a")
|
163
154
|
end
|
164
155
|
|
@@ -189,7 +180,7 @@ class CrossLibrary < OpenStruct
|
|
189
180
|
end
|
190
181
|
|
191
182
|
# generate the makefile in a clean build location
|
192
|
-
file postgresql_global_makefile => [ static_postgresql_builddir,
|
183
|
+
file postgresql_global_makefile => [ static_postgresql_builddir, "openssl_libs:#{for_platform}" ] do |t|
|
193
184
|
options = [
|
194
185
|
"--target=#{host_platform}",
|
195
186
|
"--host=#{host_platform}",
|
@@ -231,10 +222,10 @@ class CrossLibrary < OpenStruct
|
|
231
222
|
|
232
223
|
|
233
224
|
#desc 'compile libpg.a'
|
234
|
-
task
|
225
|
+
task "native:#{for_platform}" => postgresql_lib
|
235
226
|
|
236
227
|
# copy libpq.dll to lib dir
|
237
|
-
dest_libpq = "lib/#{postgresql_lib.basename}"
|
228
|
+
dest_libpq = "lib/#{for_platform}/#{postgresql_lib.basename}"
|
238
229
|
directory File.dirname(dest_libpq)
|
239
230
|
file dest_libpq => [postgresql_lib, File.dirname(dest_libpq)] do
|
240
231
|
cp postgresql_lib, dest_libpq
|
@@ -246,22 +237,27 @@ class CrossLibrary < OpenStruct
|
|
246
237
|
cp postgresql_lib, stage_libpq
|
247
238
|
end
|
248
239
|
end
|
249
|
-
end
|
250
240
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
].map do |platform, openssl_config, toolchain|
|
256
|
-
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
|
257
245
|
end
|
258
|
-
|
259
|
-
|
260
|
-
|
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
|
261
257
|
end
|
262
258
|
|
263
259
|
desc 'cross compile pg for win32'
|
264
|
-
task :cross => [ :mingw32
|
260
|
+
task :cross => [ :mingw32 ]
|
265
261
|
|
266
262
|
task :mingw32 do
|
267
263
|
# Use Rake::ExtensionCompiler helpers to find the proper host
|
@@ -272,30 +268,32 @@ task :mingw32 do
|
|
272
268
|
end
|
273
269
|
end
|
274
270
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
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
|
284
285
|
end
|
285
286
|
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
bundle install --local &&
|
299
|
-
rake cross native gem MAKE="make -j`nproc`"
|
300
|
-
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}"
|
301
299
|
end
|
data/ext/pg.h
CHANGED
@@ -304,6 +304,7 @@ VALUE pg_obj_to_i _(( VALUE ));
|
|
304
304
|
VALUE pg_tmbc_allocate _(( void ));
|
305
305
|
void pg_coder_init_encoder _(( VALUE ));
|
306
306
|
void pg_coder_init_decoder _(( VALUE ));
|
307
|
+
void pg_coder_mark _(( t_pg_coder * ));
|
307
308
|
char *pg_rb_str_ensure_capa _(( VALUE, long, char *, char ** ));
|
308
309
|
|
309
310
|
#define PG_RB_STR_ENSURE_CAPA( str, expand_len, curr_ptr, end_ptr ) \
|
data/ext/pg_coder.c
CHANGED
@@ -61,11 +61,23 @@ pg_coder_init_decoder( VALUE self )
|
|
61
61
|
rb_iv_set( self, "@name", Qnil );
|
62
62
|
}
|
63
63
|
|
64
|
+
void
|
65
|
+
pg_coder_mark(t_pg_coder *this)
|
66
|
+
{
|
67
|
+
rb_gc_mark(this->coder_obj);
|
68
|
+
}
|
69
|
+
|
70
|
+
static void
|
71
|
+
pg_composite_coder_mark(t_pg_composite_coder *this)
|
72
|
+
{
|
73
|
+
pg_coder_mark(&this->comp);
|
74
|
+
}
|
75
|
+
|
64
76
|
static VALUE
|
65
77
|
pg_simple_encoder_allocate( VALUE klass )
|
66
78
|
{
|
67
79
|
t_pg_coder *this;
|
68
|
-
VALUE self = Data_Make_Struct( klass, t_pg_coder,
|
80
|
+
VALUE self = Data_Make_Struct( klass, t_pg_coder, pg_coder_mark, -1, this );
|
69
81
|
pg_coder_init_encoder( self );
|
70
82
|
return self;
|
71
83
|
}
|
@@ -74,7 +86,7 @@ static VALUE
|
|
74
86
|
pg_composite_encoder_allocate( VALUE klass )
|
75
87
|
{
|
76
88
|
t_pg_composite_coder *this;
|
77
|
-
VALUE self = Data_Make_Struct( klass, t_pg_composite_coder,
|
89
|
+
VALUE self = Data_Make_Struct( klass, t_pg_composite_coder, pg_composite_coder_mark, -1, this );
|
78
90
|
pg_coder_init_encoder( self );
|
79
91
|
this->elem = NULL;
|
80
92
|
this->needs_quotation = 1;
|
@@ -87,7 +99,7 @@ static VALUE
|
|
87
99
|
pg_simple_decoder_allocate( VALUE klass )
|
88
100
|
{
|
89
101
|
t_pg_coder *this;
|
90
|
-
VALUE self = Data_Make_Struct( klass, t_pg_coder,
|
102
|
+
VALUE self = Data_Make_Struct( klass, t_pg_coder, pg_coder_mark, -1, this );
|
91
103
|
pg_coder_init_decoder( self );
|
92
104
|
return self;
|
93
105
|
}
|
@@ -96,7 +108,7 @@ static VALUE
|
|
96
108
|
pg_composite_decoder_allocate( VALUE klass )
|
97
109
|
{
|
98
110
|
t_pg_composite_coder *this;
|
99
|
-
VALUE self = Data_Make_Struct( klass, t_pg_composite_coder,
|
111
|
+
VALUE self = Data_Make_Struct( klass, t_pg_composite_coder, pg_composite_coder_mark, -1, this );
|
100
112
|
pg_coder_init_decoder( self );
|
101
113
|
this->elem = NULL;
|
102
114
|
this->needs_quotation = 1;
|
data/ext/pg_copy_coder.c
CHANGED
data/ext/pg_record_coder.c
CHANGED
data/ext/pg_type_map_by_class.c
CHANGED
@@ -126,7 +126,11 @@ pg_tmbk_mark( t_tmbk *this )
|
|
126
126
|
{
|
127
127
|
rb_gc_mark(this->typemap.default_typemap);
|
128
128
|
rb_gc_mark(this->klass_to_coder);
|
129
|
-
|
129
|
+
rb_gc_mark(this->self);
|
130
|
+
/* Clear the cache, to be safe from changes of klass VALUE by GC.compact.
|
131
|
+
* TODO: Move cache clearing to compactation callback provided by Ruby-2.7+.
|
132
|
+
*/
|
133
|
+
memset(&this->cache_row, 0, sizeof(this->cache_row));
|
130
134
|
}
|
131
135
|
|
132
136
|
static VALUE
|
data/lib/pg.rb
CHANGED
@@ -22,7 +22,8 @@ rescue LoadError
|
|
22
22
|
end
|
23
23
|
|
24
24
|
# Temporary add this directory for DLL search, so that libpq.dll can be found.
|
25
|
-
|
25
|
+
# mingw32-platform strings differ (RUBY_PLATFORM=i386-mingw32 vs. x86-mingw32 for rubygems)
|
26
|
+
add_dll_path.call(File.join(__dir__, RUBY_PLATFORM.gsub(/^i386-/, "x86-"))) do
|
26
27
|
require "#{major_minor}/pg_ext"
|
27
28
|
end
|
28
29
|
else
|
@@ -36,7 +37,7 @@ end
|
|
36
37
|
module PG
|
37
38
|
|
38
39
|
# Library version
|
39
|
-
VERSION = '1.2.
|
40
|
+
VERSION = '1.2.3'
|
40
41
|
|
41
42
|
# VCS revision
|
42
43
|
REVISION = %q$Revision: 6f611e78845a $
|
@@ -118,13 +118,13 @@ module PG::BasicTypeRegistry
|
|
118
118
|
def build_coder_maps(connection)
|
119
119
|
if supports_ranges?(connection)
|
120
120
|
result = connection.exec <<-SQL
|
121
|
-
SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype
|
121
|
+
SELECT t.oid, t.typname::text, t.typelem, t.typdelim, t.typinput::text, r.rngsubtype
|
122
122
|
FROM pg_type as t
|
123
123
|
LEFT JOIN pg_range as r ON oid = rngtypid
|
124
124
|
SQL
|
125
125
|
else
|
126
126
|
result = connection.exec <<-SQL
|
127
|
-
SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput
|
127
|
+
SELECT t.oid, t.typname::text, t.typelem, t.typdelim, t.typinput::text
|
128
128
|
FROM pg_type as t
|
129
129
|
SQL
|
130
130
|
end
|
data/spec/helpers.rb
CHANGED
@@ -225,7 +225,7 @@ module PG::TestingHelpers
|
|
225
225
|
rescue => err
|
226
226
|
$stderr.puts "%p during test setup: %s" % [ err.class, err.message ]
|
227
227
|
$stderr.puts "See #{@logfile} for details."
|
228
|
-
$stderr.puts
|
228
|
+
$stderr.puts err.backtrace if $DEBUG
|
229
229
|
fail
|
230
230
|
end
|
231
231
|
|
@@ -370,8 +370,6 @@ RSpec.configure do |config|
|
|
370
370
|
else
|
371
371
|
config.filter_run_excluding :windows
|
372
372
|
end
|
373
|
-
config.filter_run_excluding :socket_io unless
|
374
|
-
PG::Connection.instance_methods.map( &:to_sym ).include?( :socket_io )
|
375
373
|
|
376
374
|
config.filter_run_excluding( :postgresql_93 ) if PG.library_version < 90300
|
377
375
|
config.filter_run_excluding( :postgresql_94 ) if PG.library_version < 90400
|
@@ -21,14 +21,6 @@ ensure
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def expect_to_typecase_result_value_warning
|
25
|
-
warning = 'Warning: no type cast defined for type "name" with oid 19. '\
|
26
|
-
"Please cast this type explicitly to TEXT to be safe for future changes.\n"\
|
27
|
-
'Warning: no type cast defined for type "regproc" with oid 24. '\
|
28
|
-
"Please cast this type explicitly to TEXT to be safe for future changes.\n"
|
29
|
-
expect { yield }.to output(warning).to_stderr
|
30
|
-
end
|
31
|
-
|
32
24
|
describe 'Basic type mapping' do
|
33
25
|
|
34
26
|
describe PG::BasicTypeMapForQueries do
|
@@ -318,9 +310,7 @@ describe 'Basic type mapping' do
|
|
318
310
|
it "should convert format #{format} timestamps per TimestampUtc" do
|
319
311
|
restore_type("timestamp") do
|
320
312
|
PG::BasicTypeRegistry.register_type 0, 'timestamp', nil, PG::TextDecoder::TimestampUtc
|
321
|
-
|
322
|
-
@conn.type_map_for_results = PG::BasicTypeMapForResults.new(@conn)
|
323
|
-
end
|
313
|
+
@conn.type_map_for_results = PG::BasicTypeMapForResults.new(@conn)
|
324
314
|
res = @conn.exec_params( "SELECT CAST('2013-07-31 23:58:59+02' AS TIMESTAMP WITHOUT TIME ZONE),
|
325
315
|
CAST('1913-12-31 23:58:59.1231-03' AS TIMESTAMP WITHOUT TIME ZONE),
|
326
316
|
CAST('4714-11-24 23:58:59.1231-03 BC' AS TIMESTAMP WITHOUT TIME ZONE),
|
@@ -342,9 +332,7 @@ describe 'Basic type mapping' do
|
|
342
332
|
restore_type("timestamp") do
|
343
333
|
PG::BasicTypeRegistry.register_type 0, 'timestamp', nil, PG::TextDecoder::TimestampUtcToLocal
|
344
334
|
PG::BasicTypeRegistry.register_type 1, 'timestamp', nil, PG::BinaryDecoder::TimestampUtcToLocal
|
345
|
-
|
346
|
-
@conn.type_map_for_results = PG::BasicTypeMapForResults.new(@conn)
|
347
|
-
end
|
335
|
+
@conn.type_map_for_results = PG::BasicTypeMapForResults.new(@conn)
|
348
336
|
res = @conn.exec_params( "SELECT CAST('2013-07-31 23:58:59+02' AS TIMESTAMP WITHOUT TIME ZONE),
|
349
337
|
CAST('1913-12-31 23:58:59.1231-03' AS TIMESTAMP WITHOUT TIME ZONE),
|
350
338
|
CAST('4714-11-24 23:58:59.1231-03 BC' AS TIMESTAMP WITHOUT TIME ZONE),
|
@@ -366,9 +354,7 @@ describe 'Basic type mapping' do
|
|
366
354
|
restore_type("timestamp") do
|
367
355
|
PG::BasicTypeRegistry.register_type 0, 'timestamp', nil, PG::TextDecoder::TimestampLocal
|
368
356
|
PG::BasicTypeRegistry.register_type 1, 'timestamp', nil, PG::BinaryDecoder::TimestampLocal
|
369
|
-
|
370
|
-
@conn.type_map_for_results = PG::BasicTypeMapForResults.new(@conn)
|
371
|
-
end
|
357
|
+
@conn.type_map_for_results = PG::BasicTypeMapForResults.new(@conn)
|
372
358
|
res = @conn.exec_params( "SELECT CAST('2013-07-31 23:58:59' AS TIMESTAMP WITHOUT TIME ZONE),
|
373
359
|
CAST('1913-12-31 23:58:59.1231' AS TIMESTAMP WITHOUT TIME ZONE),
|
374
360
|
CAST('4714-11-24 23:58:59.1231-03 BC' AS TIMESTAMP WITHOUT TIME ZONE),
|
@@ -503,7 +489,6 @@ describe 'Basic type mapping' do
|
|
503
489
|
sql_vals = vals.map{|v| "CAST('#{v}' AS inet)"}
|
504
490
|
res = @conn.exec_params(("SELECT " + sql_vals.join(', ')), [], format )
|
505
491
|
vals.each_with_index do |v, i|
|
506
|
-
val = res.getvalue(0,i)
|
507
492
|
expect( res.getvalue(0,i) ).to eq( IPAddr.new(v) )
|
508
493
|
end
|
509
494
|
end
|
@@ -527,22 +512,22 @@ describe 'Basic type mapping' do
|
|
527
512
|
sql_vals = vals.map { |v| "CAST('#{v}' AS cidr)" }
|
528
513
|
res = @conn.exec_params(("SELECT " + sql_vals.join(', ')), [], format )
|
529
514
|
vals.each_with_index do |v, i|
|
530
|
-
|
515
|
+
val = res.getvalue(0,i)
|
531
516
|
ip, prefix = v.split('/', 2)
|
532
|
-
|
517
|
+
expect( val.to_s ).to eq( ip )
|
533
518
|
if val.respond_to?(:prefix)
|
534
519
|
val_prefix = val.prefix
|
535
520
|
else
|
536
|
-
|
521
|
+
default_prefix = (val.family == Socket::AF_INET ? 32 : 128)
|
537
522
|
range = val.to_range
|
538
523
|
val_prefix = default_prefix - Math.log(((range.end.to_i - range.begin.to_i) + 1), 2).to_i
|
539
524
|
end
|
540
525
|
if v.include?('/')
|
541
|
-
|
526
|
+
expect( val_prefix ).to eq( prefix.to_i )
|
542
527
|
elsif v.include?('.')
|
543
|
-
|
544
|
-
|
545
|
-
|
528
|
+
expect( val_prefix ).to eq( 32 )
|
529
|
+
else
|
530
|
+
expect( val_prefix ).to eq( 128 )
|
546
531
|
end
|
547
532
|
end
|
548
533
|
end
|
data/spec/pg/connection_spec.rb
CHANGED
@@ -173,7 +173,7 @@ describe PG::Connection do
|
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
176
|
-
it "can connect asynchronously"
|
176
|
+
it "can connect asynchronously" do
|
177
177
|
tmpconn = described_class.connect_start( @conninfo )
|
178
178
|
expect( tmpconn ).to be_a( described_class )
|
179
179
|
|
@@ -182,7 +182,7 @@ describe PG::Connection do
|
|
182
182
|
tmpconn.finish
|
183
183
|
end
|
184
184
|
|
185
|
-
it "can connect asynchronously for the duration of a block"
|
185
|
+
it "can connect asynchronously for the duration of a block" do
|
186
186
|
conn = nil
|
187
187
|
|
188
188
|
described_class.connect_start(@conninfo) do |tmpconn|
|
@@ -196,7 +196,7 @@ describe PG::Connection do
|
|
196
196
|
expect( conn ).to be_finished()
|
197
197
|
end
|
198
198
|
|
199
|
-
context "with async established connection"
|
199
|
+
context "with async established connection" do
|
200
200
|
before :each do
|
201
201
|
@conn2 = described_class.connect_start( @conninfo )
|
202
202
|
wait_for_polling_ok(@conn2)
|
@@ -340,10 +340,10 @@ describe PG::Connection do
|
|
340
340
|
@conn.trace( trace_io )
|
341
341
|
trace_io.close
|
342
342
|
|
343
|
-
|
343
|
+
@conn.exec("SELECT 1 AS one")
|
344
344
|
@conn.untrace
|
345
345
|
|
346
|
-
|
346
|
+
@conn.exec("SELECT 2 AS two")
|
347
347
|
|
348
348
|
trace_data = trace_file.read
|
349
349
|
|
@@ -902,7 +902,7 @@ describe PG::Connection do
|
|
902
902
|
end
|
903
903
|
|
904
904
|
|
905
|
-
it "handles server close while asynchronous connect"
|
905
|
+
it "handles server close while asynchronous connect" do
|
906
906
|
serv = TCPServer.new( '127.0.0.1', 54320 )
|
907
907
|
conn = described_class.connect_start( '127.0.0.1', 54320, "", "", "me", "xxxx", "somedb" )
|
908
908
|
expect( [PG::PGRES_POLLING_WRITING, PG::CONNECTION_OK] ).to include conn.connect_poll
|
@@ -963,7 +963,7 @@ describe PG::Connection do
|
|
963
963
|
conn.close
|
964
964
|
end
|
965
965
|
|
966
|
-
it "closes the IO fetched from #socket_io when the connection is closed", :without_transaction
|
966
|
+
it "closes the IO fetched from #socket_io when the connection is closed", :without_transaction do
|
967
967
|
conn = PG.connect( @conninfo )
|
968
968
|
io = conn.socket_io
|
969
969
|
conn.finish
|
@@ -971,7 +971,7 @@ describe PG::Connection do
|
|
971
971
|
expect { conn.socket_io }.to raise_error( PG::ConnectionBad, /connection is closed/i )
|
972
972
|
end
|
973
973
|
|
974
|
-
it "closes the IO fetched from #socket_io when the connection is reset", :without_transaction
|
974
|
+
it "closes the IO fetched from #socket_io when the connection is reset", :without_transaction do
|
975
975
|
conn = PG.connect( @conninfo )
|
976
976
|
io = conn.socket_io
|
977
977
|
conn.reset
|
@@ -1622,6 +1622,7 @@ describe PG::Connection do
|
|
1622
1622
|
|
1623
1623
|
expect( event ).to eq( "Möhre" )
|
1624
1624
|
expect( event.encoding ).to eq( Encoding::UTF_8 )
|
1625
|
+
expect( pid ).to be_a_kind_of(Integer)
|
1625
1626
|
expect( msg ).to eq( '世界線航跡蔵' )
|
1626
1627
|
expect( msg.encoding ).to eq( Encoding::UTF_8 )
|
1627
1628
|
end
|
@@ -1702,12 +1703,12 @@ describe PG::Connection do
|
|
1702
1703
|
row_encoder = PG::TextEncoder::CopyRow.new type_map: tm
|
1703
1704
|
|
1704
1705
|
@conn.exec( "CREATE TEMP TABLE copytable (col1 TEXT)" )
|
1705
|
-
|
1706
|
+
@conn.copy_data( "COPY copytable FROM STDOUT" ) do |res|
|
1706
1707
|
@conn.put_copy_data [1], row_encoder
|
1707
1708
|
@conn.put_copy_data ["2"], row_encoder
|
1708
1709
|
end
|
1709
1710
|
|
1710
|
-
|
1711
|
+
@conn.copy_data( "COPY copytable FROM STDOUT", row_encoder ) do |res|
|
1711
1712
|
@conn.put_copy_data [3]
|
1712
1713
|
@conn.put_copy_data ["4"]
|
1713
1714
|
end
|
@@ -1757,7 +1758,7 @@ describe PG::Connection do
|
|
1757
1758
|
|
1758
1759
|
it "can process #copy_data input queries with row encoder and respects character encoding" do
|
1759
1760
|
@conn2.exec( "CREATE TEMP TABLE copytable (col1 TEXT)" )
|
1760
|
-
|
1761
|
+
@conn2.copy_data( "COPY copytable FROM STDOUT" ) do |res|
|
1761
1762
|
@conn2.put_copy_data [1]
|
1762
1763
|
@conn2.put_copy_data ["Möhre".encode("utf-16le")]
|
1763
1764
|
end
|
@@ -1808,7 +1809,7 @@ describe PG::Connection do
|
|
1808
1809
|
it "can process #copy_data output with row decoder and respects character encoding" do
|
1809
1810
|
@conn2.internal_encoding = Encoding::ISO8859_1
|
1810
1811
|
rows = []
|
1811
|
-
|
1812
|
+
@conn2.copy_data( "COPY (VALUES('1'), ('Möhre')) TO STDOUT".encode("utf-16le") ) do |res|
|
1812
1813
|
while row=@conn2.get_copy_data
|
1813
1814
|
rows << row
|
1814
1815
|
end
|
@@ -1871,34 +1872,71 @@ describe PG::Connection do
|
|
1871
1872
|
end
|
1872
1873
|
|
1873
1874
|
describe "deprecated forms of methods" do
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1875
|
+
if PG::VERSION < "2"
|
1876
|
+
it "should forward exec to exec_params" do
|
1877
|
+
res = @conn.exec("VALUES($1::INT)", [7]).values
|
1878
|
+
expect(res).to eq( [["7"]] )
|
1879
|
+
res = @conn.exec("VALUES($1::INT)", [7], 1).values
|
1880
|
+
expect(res).to eq( [[[7].pack("N")]] )
|
1881
|
+
res = @conn.exec("VALUES(8)", [], 1).values
|
1882
|
+
expect(res).to eq( [[[8].pack("N")]] )
|
1883
|
+
end
|
1884
|
+
|
1885
|
+
it "should forward exec_params to exec" do
|
1886
|
+
res = @conn.exec_params("VALUES(3); VALUES(4)").values
|
1887
|
+
expect(res).to eq( [["4"]] )
|
1888
|
+
res = @conn.exec_params("VALUES(3); VALUES(4)", nil).values
|
1889
|
+
expect(res).to eq( [["4"]] )
|
1890
|
+
res = @conn.exec_params("VALUES(3); VALUES(4)", nil, nil).values
|
1891
|
+
expect(res).to eq( [["4"]] )
|
1892
|
+
res = @conn.exec_params("VALUES(3); VALUES(4)", nil, 1).values
|
1893
|
+
expect(res).to eq( [["4"]] )
|
1894
|
+
res = @conn.exec_params("VALUES(3); VALUES(4)", nil, nil, nil).values
|
1895
|
+
expect(res).to eq( [["4"]] )
|
1896
|
+
expect{
|
1897
|
+
@conn.exec_params("VALUES(3); VALUES(4)", nil, nil, nil, nil).values
|
1898
|
+
}.to raise_error(ArgumentError)
|
1899
|
+
end
|
1900
|
+
|
1901
|
+
it "should forward send_query to send_query_params" do
|
1902
|
+
@conn.send_query("VALUES($1)", [5])
|
1903
|
+
expect(@conn.get_last_result.values).to eq( [["5"]] )
|
1904
|
+
end
|
1905
|
+
|
1906
|
+
it "should respond_to socket", :unix do
|
1907
|
+
expect( @conn.socket ).to eq( @conn.socket_io.fileno )
|
1908
|
+
end
|
1909
|
+
else
|
1910
|
+
# Method forwarding removed by PG::VERSION >= "2"
|
1911
|
+
it "shouldn't forward exec to exec_params" do
|
1912
|
+
expect do
|
1913
|
+
@conn.exec("VALUES($1::INT)", [7])
|
1914
|
+
end.to raise_error(ArgumentError)
|
1915
|
+
end
|
1916
|
+
|
1917
|
+
it "shouldn't forward exec_params to exec" do
|
1918
|
+
expect do
|
1919
|
+
@conn.exec_params("VALUES(3); VALUES(4)")
|
1920
|
+
end.to raise_error(ArgumentError)
|
1921
|
+
end
|
1922
|
+
|
1923
|
+
it "shouldn't forward send_query to send_query_params" do
|
1924
|
+
expect do
|
1925
|
+
@conn.send_query("VALUES($1)", [5])
|
1926
|
+
end.to raise_error(ArgumentError)
|
1927
|
+
end
|
1928
|
+
|
1929
|
+
it "shouldn't forward async_exec_params to async_exec" do
|
1930
|
+
expect do
|
1931
|
+
@conn.async_exec_params("VALUES(1)")
|
1932
|
+
end.to raise_error(ArgumentError)
|
1933
|
+
end
|
1898
1934
|
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1935
|
+
it "shouldn't respond_to socket" do
|
1936
|
+
expect do
|
1937
|
+
@conn.socket
|
1938
|
+
end.to raise_error(ArgumentError)
|
1939
|
+
end
|
1902
1940
|
end
|
1903
1941
|
|
1904
1942
|
it "shouldn't forward send_query_params to send_query" do
|
data/spec/pg/result_spec.rb
CHANGED
@@ -300,7 +300,7 @@ describe PG::Result do
|
|
300
300
|
it "detects division by zero as SQLSTATE 22012" do
|
301
301
|
sqlstate = nil
|
302
302
|
begin
|
303
|
-
|
303
|
+
@conn.exec("SELECT 1/0")
|
304
304
|
rescue PG::Error => e
|
305
305
|
sqlstate = e.result.result_error_field( PG::PG_DIAG_SQLSTATE ).to_i
|
306
306
|
end
|
@@ -132,7 +132,7 @@ describe PG::TypeMapByClass do
|
|
132
132
|
it "should raise error on invalid coder object" do
|
133
133
|
tm[TrueClass] = "dummy"
|
134
134
|
expect{
|
135
|
-
|
135
|
+
@conn.exec_params( "SELECT $1", [true], 0, tm )
|
136
136
|
}.to raise_error(NoMethodError, /undefined method.*call/)
|
137
137
|
end
|
138
138
|
end
|
@@ -54,8 +54,8 @@ describe PG::TypeMapByOid do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should check format when deleting coders" do
|
57
|
-
expect{ tm.rm_coder
|
58
|
-
expect{ tm.rm_coder
|
57
|
+
expect{ tm.rm_coder(2, 123) }.to raise_error(ArgumentError)
|
58
|
+
expect{ tm.rm_coder(-1, 123) }.to raise_error(ArgumentError)
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should check format when adding coders" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Granger
|
@@ -11,9 +11,9 @@ bindir: bin
|
|
11
11
|
cert_chain:
|
12
12
|
- |
|
13
13
|
-----BEGIN CERTIFICATE-----
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
MIID+DCCAmCgAwIBAgIBAjANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdnZWQv
|
15
|
+
REM9RmFlcmllTVVEL0RDPW9yZzAeFw0xOTEyMjQyMDE5NTFaFw0yMDEyMjMyMDE5
|
16
|
+
NTFaMCIxIDAeBgNVBAMMF2dlZC9EQz1GYWVyaWVNVUQvREM9b3JnMIIBojANBgkq
|
17
17
|
hkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAvyVhkRzvlEs0fe7145BYLfN6njX9ih5H
|
18
18
|
L60U0p0euIurpv84op9CNKF9tx+1WKwyQvQP7qFGuZxkSUuWcP/sFhDXL1lWUuIl
|
19
19
|
M4uHbGCRmOshDrF4dgnBeOvkHr1fIhPlJm5FO+Vew8tSQmlDsosxLUx+VB7DrVFO
|
@@ -22,20 +22,19 @@ cert_chain:
|
|
22
22
|
vQ66lts4alKC69TE5cuKasWBm+16A4aEe3XdZBRNmtOu/g81gvwA7fkJHKllJuaI
|
23
23
|
dXzdHqq+zbGZVSQ7pRYHYomD0IiDe1DbIouFnPWmagaBnGHwXkDT2bKKP+s2v21m
|
24
24
|
ozilJg4aar2okb/RA6VS87o+d7g6LpDDMMQjH4G9OPnJENLdhu8KnPw/ivSVvQw7
|
25
|
-
N2I4L/ZOIe2DIVuYH7aLHfjZDQv/
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
XrxOxp8o0uOkU7FdLSGsyqJ2LzsR4obN
|
25
|
+
N2I4L/ZOIe2DIVuYH7aLHfjZDQv/mNgpAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYD
|
26
|
+
VR0PBAQDAgSwMB0GA1UdDgQWBBRyjf55EbrHagiRLqt5YAd3yb8k4DANBgkqhkiG
|
27
|
+
9w0BAQsFAAOCAYEAifxlz7x0EfT3fjhM520ZEIrWa+tLMuLKNefkY18u8tZnx4EX
|
28
|
+
Xxwh3tna3fvNfrOrdY5leIj1dbv4FTRg+gIBnIxAySqvpGvI/Axg5EdYbwninCLL
|
29
|
+
LAKCmRo+5QwaPMYN2zdHIjGrp8jg1neCo5zy6tVvyTv0DMI6FLrydVJYduMMDFSy
|
30
|
+
gQKR1rVOcCJtnBnLCF9+kKEUKohAHOmGsE7OBZFnjMIpH5yUDUVJKByv0gIipFt0
|
31
|
+
1T6zff6oVU0w8WBiNKR381+6sF3wIZVnVY0XeJg6hNL+YecE8ILxLhHTmtT/BO0S
|
32
|
+
3xPze9uXDR+iD6HYl8KU5QEg/dXFPhfQb512vVkTJDZvMcwu6PxDUjHFChLjAji/
|
33
|
+
AZXjg1C5E9znTkeUR8ieU9F1MOKoiH57a5lYSTI8Ga8PpsNXTxNeXc16Ob26CqrJ
|
34
|
+
83uuAYSy65yXDGXXPVBeKPVnYrqp91pqpS5Nh7wfuiCrE8lgU8PATh7K4BV1UhAT
|
35
|
+
0MHbAT42wTYkfUj3
|
37
36
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-
|
37
|
+
date: 2020-03-18 00:00:00.000000000 Z
|
39
38
|
dependencies:
|
40
39
|
- !ruby/object:Gem::Dependency
|
41
40
|
name: hoe-mercurial
|
@@ -99,14 +98,14 @@ dependencies:
|
|
99
98
|
requirements:
|
100
99
|
- - "~>"
|
101
100
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
101
|
+
version: '1.0'
|
103
102
|
type: :development
|
104
103
|
prerelease: false
|
105
104
|
version_requirements: !ruby/object:Gem::Requirement
|
106
105
|
requirements:
|
107
106
|
- - "~>"
|
108
107
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
108
|
+
version: '1.0'
|
110
109
|
- !ruby/object:Gem::Dependency
|
111
110
|
name: hoe-bundler
|
112
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -317,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
317
316
|
- !ruby/object:Gem::Version
|
318
317
|
version: '0'
|
319
318
|
requirements: []
|
320
|
-
rubygems_version: 3.0.
|
319
|
+
rubygems_version: 3.0.6
|
321
320
|
signing_key:
|
322
321
|
specification_version: 4
|
323
322
|
summary: Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/]
|
metadata.gz.sig
CHANGED
Binary file
|