Hello community, here is the log from the commit of package rubygem-pg for openSUSE:Leap:15.2 checked in at 2020-05-18 11:01:03 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/rubygem-pg (Old) and /work/SRC/openSUSE:Leap:15.2/.rubygem-pg.new.2738 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-pg" Mon May 18 11:01:03 2020 rev:12 rq:806252 version:1.2.3 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/rubygem-pg/rubygem-pg.changes 2020-03-15 07:15:03.969088254 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.rubygem-pg.new.2738/rubygem-pg.changes 2020-05-18 11:01:04.502845171 +0200 @@ -1,0 +2,6 @@ +Thu May 7 21:13:42 UTC 2020 - Stephan Kulow <[email protected]> + +- updated to version 1.2.3 + see installed ChangeLog + +------------------------------------------------------------------- Old: ---- pg-1.2.2.gem New: ---- pg-1.2.3.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-pg.spec ++++++ --- /var/tmp/diff_new_pack.jU9fYf/_old 2020-05-18 11:01:04.998846197 +0200 +++ /var/tmp/diff_new_pack.jU9fYf/_new 2020-05-18 11:01:05.002846206 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-pg -Version: 1.2.2 +Version: 1.2.3 Release: 0 %define mod_name pg %define mod_full_name %{mod_name}-%{version} ++++++ pg-1.2.2.gem -> pg-1.2.3.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/History.rdoc new/History.rdoc --- old/History.rdoc 2020-01-08 19:31:52.000000000 +0100 +++ new/History.rdoc 2020-03-18 21:15:12.000000000 +0100 @@ -1,3 +1,12 @@ +== v1.2.3 [2020-03-18] Michael Granger <[email protected]> + +Bugfixes: + +- Fix possible segfault at `PG::Coder#encode`, `decode` or their implicit calls through + a typemap after GC.compact. #327 +- Fix possible segfault in `PG::TypeMapByClass` after GC.compact. #328 + + == v1.2.2 [2020-01-06] Michael Granger <[email protected]> Enhancements: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.rdoc new/README.rdoc --- old/README.rdoc 2020-01-08 19:31:52.000000000 +0100 +++ new/README.rdoc 2020-03-18 21:15:12.000000000 +0100 @@ -39,7 +39,7 @@ * Ruby 2.2 or newer * PostgreSQL 9.2.x or later (with headers, -dev packages, etc). -It usually work with earlier versions of Ruby/PostgreSQL as well, but those are +It usually works with earlier versions of Ruby/PostgreSQL as well, but those are not regularly tested. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Rakefile new/Rakefile --- old/Rakefile 2020-01-08 19:31:52.000000000 +0100 +++ new/Rakefile 2020-03-18 21:15:12.000000000 +0100 @@ -115,7 +115,7 @@ ext.lib_dir = 'lib' ext.source_pattern = "*.{c,h}" ext.cross_compile = true - ext.cross_platform = CrossLibraries.map &:for_platform + ext.cross_platform = CrossLibraries.map(&:for_platform) ext.cross_config_options += CrossLibraries.map do |lib| { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Rakefile.cross new/Rakefile.cross --- old/Rakefile.cross 2020-01-08 19:31:52.000000000 +0100 +++ new/Rakefile.cross 2020-03-18 21:15:12.000000000 +0100 @@ -37,7 +37,7 @@ begin FileUtils.rm_f '.test_symlink' FileUtils.ln_s '/', '.test_symlink' - rescue SystemCallError + rescue NotImplementedError, SystemCallError # Symlinks don't work -> use home directory instead self.compile_home = Pathname( "~/.ruby-pg-build" ).expand_path else @@ -83,17 +83,6 @@ # clean intermediate files and folders CLEAN.include( static_builddir.to_s ) - - def download(url, save_to) - part = save_to+".part" - sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}" - FileUtils.mv part, save_to - end - - def run(*args) - sh *args - end - ##################################################################### ### C R O S S - C O M P I L A T I O N - T A S K S ##################################################################### @@ -248,6 +237,16 @@ cp postgresql_lib, stage_libpq end end + + def download(url, save_to) + part = save_to+".part" + sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}" + FileUtils.mv part, save_to + end + + def run(*args) + sh(*args) + end end CrossLibraries = [ Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ Binary files old/checksums.yaml.gz.sig and new/checksums.yaml.gz.sig differ Binary files old/data.tar.gz.sig and new/data.tar.gz.sig differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/pg.h new/ext/pg.h --- old/ext/pg.h 2020-01-08 19:31:52.000000000 +0100 +++ new/ext/pg.h 2020-03-18 21:15:12.000000000 +0100 @@ -304,6 +304,7 @@ VALUE pg_tmbc_allocate _(( void )); void pg_coder_init_encoder _(( VALUE )); void pg_coder_init_decoder _(( VALUE )); +void pg_coder_mark _(( t_pg_coder * )); char *pg_rb_str_ensure_capa _(( VALUE, long, char *, char ** )); #define PG_RB_STR_ENSURE_CAPA( str, expand_len, curr_ptr, end_ptr ) \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/pg_coder.c new/ext/pg_coder.c --- old/ext/pg_coder.c 2020-01-08 19:31:52.000000000 +0100 +++ new/ext/pg_coder.c 2020-03-18 21:15:12.000000000 +0100 @@ -61,11 +61,23 @@ rb_iv_set( self, "@name", Qnil ); } +void +pg_coder_mark(t_pg_coder *this) +{ + rb_gc_mark(this->coder_obj); +} + +static void +pg_composite_coder_mark(t_pg_composite_coder *this) +{ + pg_coder_mark(&this->comp); +} + static VALUE pg_simple_encoder_allocate( VALUE klass ) { t_pg_coder *this; - VALUE self = Data_Make_Struct( klass, t_pg_coder, NULL, -1, this ); + VALUE self = Data_Make_Struct( klass, t_pg_coder, pg_coder_mark, -1, this ); pg_coder_init_encoder( self ); return self; } @@ -74,7 +86,7 @@ pg_composite_encoder_allocate( VALUE klass ) { t_pg_composite_coder *this; - VALUE self = Data_Make_Struct( klass, t_pg_composite_coder, NULL, -1, this ); + VALUE self = Data_Make_Struct( klass, t_pg_composite_coder, pg_composite_coder_mark, -1, this ); pg_coder_init_encoder( self ); this->elem = NULL; this->needs_quotation = 1; @@ -87,7 +99,7 @@ pg_simple_decoder_allocate( VALUE klass ) { t_pg_coder *this; - VALUE self = Data_Make_Struct( klass, t_pg_coder, NULL, -1, this ); + VALUE self = Data_Make_Struct( klass, t_pg_coder, pg_coder_mark, -1, this ); pg_coder_init_decoder( self ); return self; } @@ -96,7 +108,7 @@ pg_composite_decoder_allocate( VALUE klass ) { t_pg_composite_coder *this; - VALUE self = Data_Make_Struct( klass, t_pg_composite_coder, NULL, -1, this ); + VALUE self = Data_Make_Struct( klass, t_pg_composite_coder, pg_composite_coder_mark, -1, this ); pg_coder_init_decoder( self ); this->elem = NULL; this->needs_quotation = 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/pg_copy_coder.c new/ext/pg_copy_coder.c --- old/ext/pg_copy_coder.c 2020-01-08 19:31:52.000000000 +0100 +++ new/ext/pg_copy_coder.c 2020-03-18 21:15:12.000000000 +0100 @@ -23,6 +23,7 @@ static void pg_copycoder_mark( t_pg_copycoder *this ) { + pg_coder_mark(&this->comp); rb_gc_mark(this->typemap); rb_gc_mark(this->null_string); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/pg_record_coder.c new/ext/pg_record_coder.c --- old/ext/pg_record_coder.c 2020-01-08 19:31:52.000000000 +0100 +++ new/ext/pg_record_coder.c 2020-03-18 21:15:12.000000000 +0100 @@ -18,6 +18,7 @@ static void pg_recordcoder_mark( t_pg_recordcoder *this ) { + pg_coder_mark(&this->comp); rb_gc_mark(this->typemap); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/pg_type_map_by_class.c new/ext/pg_type_map_by_class.c --- old/ext/pg_type_map_by_class.c 2020-01-08 19:31:52.000000000 +0100 +++ new/ext/pg_type_map_by_class.c 2020-03-18 21:15:12.000000000 +0100 @@ -126,7 +126,11 @@ { rb_gc_mark(this->typemap.default_typemap); rb_gc_mark(this->klass_to_coder); - /* All coders are in the Hash, so no need to mark the cache. */ + rb_gc_mark(this->self); + /* Clear the cache, to be safe from changes of klass VALUE by GC.compact. + * TODO: Move cache clearing to compactation callback provided by Ruby-2.7+. + */ + memset(&this->cache_row, 0, sizeof(this->cache_row)); } static VALUE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pg/basic_type_mapping.rb new/lib/pg/basic_type_mapping.rb --- old/lib/pg/basic_type_mapping.rb 2020-01-08 19:31:52.000000000 +0100 +++ new/lib/pg/basic_type_mapping.rb 2020-03-18 21:15:12.000000000 +0100 @@ -118,13 +118,13 @@ def build_coder_maps(connection) if supports_ranges?(connection) result = connection.exec <<-SQL - SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype + SELECT t.oid, t.typname::text, t.typelem, t.typdelim, t.typinput::text, r.rngsubtype FROM pg_type as t LEFT JOIN pg_range as r ON oid = rngtypid SQL else result = connection.exec <<-SQL - SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput + SELECT t.oid, t.typname::text, t.typelem, t.typdelim, t.typinput::text FROM pg_type as t SQL end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pg.rb new/lib/pg.rb --- old/lib/pg.rb 2020-01-08 19:31:52.000000000 +0100 +++ new/lib/pg.rb 2020-03-18 21:15:12.000000000 +0100 @@ -37,7 +37,7 @@ module PG # Library version - VERSION = '1.2.2' + VERSION = '1.2.3' # VCS revision REVISION = %q$Revision: 6f611e78845a $ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2020-01-08 19:31:52.000000000 +0100 +++ new/metadata 2020-03-18 21:15:12.000000000 +0100 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: pg version: !ruby/object:Gem::Version - version: 1.2.2 + version: 1.2.3 platform: ruby authors: - Michael Granger @@ -34,7 +34,7 @@ 83uuAYSy65yXDGXXPVBeKPVnYrqp91pqpS5Nh7wfuiCrE8lgU8PATh7K4BV1UhAT 0MHbAT42wTYkfUj3 -----END CERTIFICATE----- -date: 2020-01-08 00:00:00.000000000 Z +date: 2020-03-18 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: hoe-mercurial @@ -56,14 +56,14 @@ requirements: - - "~>" - !ruby/object:Gem::Version - version: '0.9' + version: '0.10' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: '0.9' + version: '0.10' - !ruby/object:Gem::Dependency name: hoe-highline requirement: !ruby/object:Gem::Requirement Binary files old/metadata.gz.sig and new/metadata.gz.sig differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/helpers.rb new/spec/helpers.rb --- old/spec/helpers.rb 2020-01-08 19:31:52.000000000 +0100 +++ new/spec/helpers.rb 2020-03-18 21:15:12.000000000 +0100 @@ -225,7 +225,7 @@ rescue => err $stderr.puts "%p during test setup: %s" % [ err.class, err.message ] $stderr.puts "See #{@logfile} for details." - $stderr.puts *err.backtrace if $DEBUG + $stderr.puts err.backtrace if $DEBUG fail end @@ -370,8 +370,6 @@ else config.filter_run_excluding :windows end - config.filter_run_excluding :socket_io unless - PG::Connection.instance_methods.map( &:to_sym ).include?( :socket_io ) config.filter_run_excluding( :postgresql_93 ) if PG.library_version < 90300 config.filter_run_excluding( :postgresql_94 ) if PG.library_version < 90400 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/pg/basic_type_mapping_spec.rb new/spec/pg/basic_type_mapping_spec.rb --- old/spec/pg/basic_type_mapping_spec.rb 2020-01-08 19:31:52.000000000 +0100 +++ new/spec/pg/basic_type_mapping_spec.rb 2020-03-18 21:15:12.000000000 +0100 @@ -21,14 +21,6 @@ end end -def expect_to_typecase_result_value_warning - warning = 'Warning: no type cast defined for type "name" with oid 19. '\ - "Please cast this type explicitly to TEXT to be safe for future changes.\n"\ - 'Warning: no type cast defined for type "regproc" with oid 24. '\ - "Please cast this type explicitly to TEXT to be safe for future changes.\n" - expect { yield }.to output(warning).to_stderr -end - describe 'Basic type mapping' do describe PG::BasicTypeMapForQueries do @@ -318,9 +310,7 @@ it "should convert format #{format} timestamps per TimestampUtc" do restore_type("timestamp") do PG::BasicTypeRegistry.register_type 0, 'timestamp', nil, PG::TextDecoder::TimestampUtc - expect_to_typecase_result_value_warning do - @conn.type_map_for_results = PG::BasicTypeMapForResults.new(@conn) - end + @conn.type_map_for_results = PG::BasicTypeMapForResults.new(@conn) res = @conn.exec_params( "SELECT CAST('2013-07-31 23:58:59+02' AS TIMESTAMP WITHOUT TIME ZONE), CAST('1913-12-31 23:58:59.1231-03' AS TIMESTAMP WITHOUT TIME ZONE), CAST('4714-11-24 23:58:59.1231-03 BC' AS TIMESTAMP WITHOUT TIME ZONE), @@ -342,9 +332,7 @@ restore_type("timestamp") do PG::BasicTypeRegistry.register_type 0, 'timestamp', nil, PG::TextDecoder::TimestampUtcToLocal PG::BasicTypeRegistry.register_type 1, 'timestamp', nil, PG::BinaryDecoder::TimestampUtcToLocal - expect_to_typecase_result_value_warning do - @conn.type_map_for_results = PG::BasicTypeMapForResults.new(@conn) - end + @conn.type_map_for_results = PG::BasicTypeMapForResults.new(@conn) res = @conn.exec_params( "SELECT CAST('2013-07-31 23:58:59+02' AS TIMESTAMP WITHOUT TIME ZONE), CAST('1913-12-31 23:58:59.1231-03' AS TIMESTAMP WITHOUT TIME ZONE), CAST('4714-11-24 23:58:59.1231-03 BC' AS TIMESTAMP WITHOUT TIME ZONE), @@ -366,9 +354,7 @@ restore_type("timestamp") do PG::BasicTypeRegistry.register_type 0, 'timestamp', nil, PG::TextDecoder::TimestampLocal PG::BasicTypeRegistry.register_type 1, 'timestamp', nil, PG::BinaryDecoder::TimestampLocal - expect_to_typecase_result_value_warning do - @conn.type_map_for_results = PG::BasicTypeMapForResults.new(@conn) - end + @conn.type_map_for_results = PG::BasicTypeMapForResults.new(@conn) res = @conn.exec_params( "SELECT CAST('2013-07-31 23:58:59' AS TIMESTAMP WITHOUT TIME ZONE), CAST('1913-12-31 23:58:59.1231' AS TIMESTAMP WITHOUT TIME ZONE), CAST('4714-11-24 23:58:59.1231-03 BC' AS TIMESTAMP WITHOUT TIME ZONE), @@ -503,7 +489,6 @@ sql_vals = vals.map{|v| "CAST('#{v}' AS inet)"} res = @conn.exec_params(("SELECT " + sql_vals.join(', ')), [], format ) vals.each_with_index do |v, i| - val = res.getvalue(0,i) expect( res.getvalue(0,i) ).to eq( IPAddr.new(v) ) end end @@ -527,22 +512,22 @@ sql_vals = vals.map { |v| "CAST('#{v}' AS cidr)" } res = @conn.exec_params(("SELECT " + sql_vals.join(', ')), [], format ) vals.each_with_index do |v, i| - val = res.getvalue(0,i) + val = res.getvalue(0,i) ip, prefix = v.split('/', 2) - expect( val.to_s ).to eq( ip ) + expect( val.to_s ).to eq( ip ) if val.respond_to?(:prefix) val_prefix = val.prefix else - default_prefix = (val.family == Socket::AF_INET ? 32 : 128) + default_prefix = (val.family == Socket::AF_INET ? 32 : 128) range = val.to_range val_prefix = default_prefix - Math.log(((range.end.to_i - range.begin.to_i) + 1), 2).to_i end if v.include?('/') - expect( val_prefix ).to eq( prefix.to_i ) + expect( val_prefix ).to eq( prefix.to_i ) elsif v.include?('.') - expect( val_prefix ).to eq( 32 ) - else - expect( val_prefix ).to eq( 128 ) + expect( val_prefix ).to eq( 32 ) + else + expect( val_prefix ).to eq( 128 ) end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/pg/connection_spec.rb new/spec/pg/connection_spec.rb --- old/spec/pg/connection_spec.rb 2020-01-08 19:31:52.000000000 +0100 +++ new/spec/pg/connection_spec.rb 2020-03-18 21:15:12.000000000 +0100 @@ -173,7 +173,7 @@ end end - it "can connect asynchronously", :socket_io do + it "can connect asynchronously" do tmpconn = described_class.connect_start( @conninfo ) expect( tmpconn ).to be_a( described_class ) @@ -182,7 +182,7 @@ tmpconn.finish end - it "can connect asynchronously for the duration of a block", :socket_io do + it "can connect asynchronously for the duration of a block" do conn = nil described_class.connect_start(@conninfo) do |tmpconn| @@ -196,7 +196,7 @@ expect( conn ).to be_finished() end - context "with async established connection", :socket_io do + context "with async established connection" do before :each do @conn2 = described_class.connect_start( @conninfo ) wait_for_polling_ok(@conn2) @@ -340,10 +340,10 @@ @conn.trace( trace_io ) trace_io.close - res = @conn.exec("SELECT 1 AS one") + @conn.exec("SELECT 1 AS one") @conn.untrace - res = @conn.exec("SELECT 2 AS two") + @conn.exec("SELECT 2 AS two") trace_data = trace_file.read @@ -902,7 +902,7 @@ end - it "handles server close while asynchronous connect", :socket_io do + it "handles server close while asynchronous connect" do serv = TCPServer.new( '127.0.0.1', 54320 ) conn = described_class.connect_start( '127.0.0.1', 54320, "", "", "me", "xxxx", "somedb" ) expect( [PG::PGRES_POLLING_WRITING, PG::CONNECTION_OK] ).to include conn.connect_poll @@ -963,7 +963,7 @@ conn.close end - it "closes the IO fetched from #socket_io when the connection is closed", :without_transaction, :socket_io do + it "closes the IO fetched from #socket_io when the connection is closed", :without_transaction do conn = PG.connect( @conninfo ) io = conn.socket_io conn.finish @@ -971,7 +971,7 @@ expect { conn.socket_io }.to raise_error( PG::ConnectionBad, /connection is closed/i ) end - it "closes the IO fetched from #socket_io when the connection is reset", :without_transaction, :socket_io do + it "closes the IO fetched from #socket_io when the connection is reset", :without_transaction do conn = PG.connect( @conninfo ) io = conn.socket_io conn.reset @@ -1622,6 +1622,7 @@ expect( event ).to eq( "Möhre" ) expect( event.encoding ).to eq( Encoding::UTF_8 ) + expect( pid ).to be_a_kind_of(Integer) expect( msg ).to eq( '世界線航跡蔵' ) expect( msg.encoding ).to eq( Encoding::UTF_8 ) end @@ -1702,12 +1703,12 @@ row_encoder = PG::TextEncoder::CopyRow.new type_map: tm @conn.exec( "CREATE TEMP TABLE copytable (col1 TEXT)" ) - res2 = @conn.copy_data( "COPY copytable FROM STDOUT" ) do |res| + @conn.copy_data( "COPY copytable FROM STDOUT" ) do |res| @conn.put_copy_data [1], row_encoder @conn.put_copy_data ["2"], row_encoder end - res2 = @conn.copy_data( "COPY copytable FROM STDOUT", row_encoder ) do |res| + @conn.copy_data( "COPY copytable FROM STDOUT", row_encoder ) do |res| @conn.put_copy_data [3] @conn.put_copy_data ["4"] end @@ -1757,7 +1758,7 @@ it "can process #copy_data input queries with row encoder and respects character encoding" do @conn2.exec( "CREATE TEMP TABLE copytable (col1 TEXT)" ) - res2 = @conn2.copy_data( "COPY copytable FROM STDOUT" ) do |res| + @conn2.copy_data( "COPY copytable FROM STDOUT" ) do |res| @conn2.put_copy_data [1] @conn2.put_copy_data ["Möhre".encode("utf-16le")] end @@ -1808,7 +1809,7 @@ it "can process #copy_data output with row decoder and respects character encoding" do @conn2.internal_encoding = Encoding::ISO8859_1 rows = [] - res2 = @conn2.copy_data( "COPY (VALUES('1'), ('Möhre')) TO STDOUT".encode("utf-16le") ) do |res| + @conn2.copy_data( "COPY (VALUES('1'), ('Möhre')) TO STDOUT".encode("utf-16le") ) do |res| while [email protected]_copy_data rows << row end @@ -1871,34 +1872,71 @@ end describe "deprecated forms of methods" do - it "should forward exec to exec_params" do - res = @conn.exec("VALUES($1::INT)", [7]).values - expect(res).to eq( [["7"]] ) - res = @conn.exec("VALUES($1::INT)", [7], 1).values - expect(res).to eq( [[[7].pack("N")]] ) - res = @conn.exec("VALUES(8)", [], 1).values - expect(res).to eq( [[[8].pack("N")]] ) - end - - it "should forward exec_params to exec" do - res = @conn.exec_params("VALUES(3); VALUES(4)").values - expect(res).to eq( [["4"]] ) - res = @conn.exec_params("VALUES(3); VALUES(4)", nil).values - expect(res).to eq( [["4"]] ) - res = @conn.exec_params("VALUES(3); VALUES(4)", nil, nil).values - expect(res).to eq( [["4"]] ) - res = @conn.exec_params("VALUES(3); VALUES(4)", nil, 1).values - expect(res).to eq( [["4"]] ) - res = @conn.exec_params("VALUES(3); VALUES(4)", nil, nil, nil).values - expect(res).to eq( [["4"]] ) - expect{ - @conn.exec_params("VALUES(3); VALUES(4)", nil, nil, nil, nil).values - }.to raise_error(ArgumentError) - end + if PG::VERSION < "2" + it "should forward exec to exec_params" do + res = @conn.exec("VALUES($1::INT)", [7]).values + expect(res).to eq( [["7"]] ) + res = @conn.exec("VALUES($1::INT)", [7], 1).values + expect(res).to eq( [[[7].pack("N")]] ) + res = @conn.exec("VALUES(8)", [], 1).values + expect(res).to eq( [[[8].pack("N")]] ) + end + + it "should forward exec_params to exec" do + res = @conn.exec_params("VALUES(3); VALUES(4)").values + expect(res).to eq( [["4"]] ) + res = @conn.exec_params("VALUES(3); VALUES(4)", nil).values + expect(res).to eq( [["4"]] ) + res = @conn.exec_params("VALUES(3); VALUES(4)", nil, nil).values + expect(res).to eq( [["4"]] ) + res = @conn.exec_params("VALUES(3); VALUES(4)", nil, 1).values + expect(res).to eq( [["4"]] ) + res = @conn.exec_params("VALUES(3); VALUES(4)", nil, nil, nil).values + expect(res).to eq( [["4"]] ) + expect{ + @conn.exec_params("VALUES(3); VALUES(4)", nil, nil, nil, nil).values + }.to raise_error(ArgumentError) + end + + it "should forward send_query to send_query_params" do + @conn.send_query("VALUES($1)", [5]) + expect(@conn.get_last_result.values).to eq( [["5"]] ) + end + + it "should respond_to socket", :unix do + expect( @conn.socket ).to eq( @conn.socket_io.fileno ) + end + else + # Method forwarding removed by PG::VERSION >= "2" + it "shouldn't forward exec to exec_params" do + expect do + @conn.exec("VALUES($1::INT)", [7]) + end.to raise_error(ArgumentError) + end + + it "shouldn't forward exec_params to exec" do + expect do + @conn.exec_params("VALUES(3); VALUES(4)") + end.to raise_error(ArgumentError) + end + + it "shouldn't forward send_query to send_query_params" do + expect do + @conn.send_query("VALUES($1)", [5]) + end.to raise_error(ArgumentError) + end + + it "shouldn't forward async_exec_params to async_exec" do + expect do + @conn.async_exec_params("VALUES(1)") + end.to raise_error(ArgumentError) + end - it "should forward send_query to send_query_params" do - @conn.send_query("VALUES($1)", [5]) - expect(@conn.get_last_result.values).to eq( [["5"]] ) + it "shouldn't respond_to socket" do + expect do + @conn.socket + end.to raise_error(ArgumentError) + end end it "shouldn't forward send_query_params to send_query" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/pg/result_spec.rb new/spec/pg/result_spec.rb --- old/spec/pg/result_spec.rb 2020-01-08 19:31:52.000000000 +0100 +++ new/spec/pg/result_spec.rb 2020-03-18 21:15:12.000000000 +0100 @@ -300,7 +300,7 @@ it "detects division by zero as SQLSTATE 22012" do sqlstate = nil begin - res = @conn.exec("SELECT 1/0") + @conn.exec("SELECT 1/0") rescue PG::Error => e sqlstate = e.result.result_error_field( PG::PG_DIAG_SQLSTATE ).to_i end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/pg/type_map_by_class_spec.rb new/spec/pg/type_map_by_class_spec.rb --- old/spec/pg/type_map_by_class_spec.rb 2020-01-08 19:31:52.000000000 +0100 +++ new/spec/pg/type_map_by_class_spec.rb 2020-03-18 21:15:12.000000000 +0100 @@ -132,7 +132,7 @@ it "should raise error on invalid coder object" do tm[TrueClass] = "dummy" expect{ - res = @conn.exec_params( "SELECT $1", [true], 0, tm ) + @conn.exec_params( "SELECT $1", [true], 0, tm ) }.to raise_error(NoMethodError, /undefined method.*call/) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/pg/type_map_by_oid_spec.rb new/spec/pg/type_map_by_oid_spec.rb --- old/spec/pg/type_map_by_oid_spec.rb 2020-01-08 19:31:52.000000000 +0100 +++ new/spec/pg/type_map_by_oid_spec.rb 2020-03-18 21:15:12.000000000 +0100 @@ -54,8 +54,8 @@ end it "should check format when deleting coders" do - expect{ tm.rm_coder 2, 123 }.to raise_error(ArgumentError) - expect{ tm.rm_coder -1, 123 }.to raise_error(ArgumentError) + expect{ tm.rm_coder(2, 123) }.to raise_error(ArgumentError) + expect{ tm.rm_coder(-1, 123) }.to raise_error(ArgumentError) end it "should check format when adding coders" do
