pg 1.2.2-x64-mingw32 → 1.2.3-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee4f0a4364a2d1a4aba9fd2b0df81e623258c6aeded90cdf309822de1918fc41
4
- data.tar.gz: f00e7705b93387cec9f3a7c5b6fd3bdf6c7d5f6c23834de6106ec38800ddb1ce
3
+ metadata.gz: 3253303ff32bb3dd583ec84c7be3d9a579bc96959e2b95d36164c30b73895d28
4
+ data.tar.gz: '019c5aeeb7bd930a777d81b670dab10aca756105f5fb999f65bab0bf0831af96'
5
5
  SHA512:
6
- metadata.gz: 4dfeba9f6b831261c6d90ee2662af9467cec5c2d748300efc125a5303cb62387a6d64bee329cb7a1cb4ee928b3ee44370577864acfcfe2aea6e7a5041b44a2fa
7
- data.tar.gz: d057b3fd8ea1b3b070b549039f2d6148c046bd0d465449969af26a7ff118adea0632c962f3c91a9e58aa2fc19d47335d1c634b0ea18aa0691179f395c9bb0910
6
+ metadata.gz: 308f6cfdd6365cc2be88d0e277d70a61bc1f21485b43614fbd671b95a524d1adc0abb75b6ee60f6e6ff24bbbe1f58fc28d00eda3df8846597d95e88137f65278
7
+ data.tar.gz: 4153ac49911b655e78f88eec13f0cbeabfa8890e1637f7345660556081dc1795b08388c30b8cc2e3c2fae115928f872022be36fe644db3f0e90ba1fd6f4dafe7
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,12 @@
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
+
1
10
  == v1.2.2 [2020-01-06] Michael Granger <ged@FaerieMUD.org>
2
11
 
3
12
  Enhancements:
@@ -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 work with earlier versions of Ruby/PostgreSQL as well, but those are
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
@@ -115,7 +115,7 @@ Rake::ExtensionTask.new do |ext|
115
115
  ext.lib_dir = 'lib'
116
116
  ext.source_pattern = "*.{c,h}"
117
117
  ext.cross_compile = true
118
- ext.cross_platform = CrossLibraries.map &:for_platform
118
+ ext.cross_platform = CrossLibraries.map(&:for_platform)
119
119
 
120
120
  ext.cross_config_options += CrossLibraries.map do |lib|
121
121
  {
@@ -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
@@ -83,17 +83,6 @@ class CrossLibrary < OpenStruct
83
83
  # clean intermediate files and folders
84
84
  CLEAN.include( static_builddir.to_s )
85
85
 
86
-
87
- def download(url, save_to)
88
- part = save_to+".part"
89
- sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
90
- FileUtils.mv part, save_to
91
- end
92
-
93
- def run(*args)
94
- sh *args
95
- end
96
-
97
86
  #####################################################################
98
87
  ### C R O S S - C O M P I L A T I O N - T A S K S
99
88
  #####################################################################
@@ -248,6 +237,16 @@ class CrossLibrary < OpenStruct
248
237
  cp postgresql_lib, stage_libpq
249
238
  end
250
239
  end
240
+
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
245
+ end
246
+
247
+ def run(*args)
248
+ sh(*args)
249
+ end
251
250
  end
252
251
 
253
252
  CrossLibraries = [
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 ) \
@@ -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, NULL, -1, this );
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, NULL, -1, this );
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, NULL, -1, this );
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, NULL, -1, this );
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;
@@ -23,6 +23,7 @@ typedef struct {
23
23
  static void
24
24
  pg_copycoder_mark( t_pg_copycoder *this )
25
25
  {
26
+ pg_coder_mark(&this->comp);
26
27
  rb_gc_mark(this->typemap);
27
28
  rb_gc_mark(this->null_string);
28
29
  }
@@ -18,6 +18,7 @@ typedef struct {
18
18
  static void
19
19
  pg_recordcoder_mark( t_pg_recordcoder *this )
20
20
  {
21
+ pg_coder_mark(&this->comp);
21
22
  rb_gc_mark(this->typemap);
22
23
  }
23
24
 
@@ -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
- /* All coders are in the Hash, so no need to mark the cache. */
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
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/lib/pg.rb CHANGED
@@ -37,7 +37,7 @@ end
37
37
  module PG
38
38
 
39
39
  # Library version
40
- VERSION = '1.2.2'
40
+ VERSION = '1.2.3'
41
41
 
42
42
  # VCS revision
43
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
Binary file
@@ -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 *err.backtrace if $DEBUG
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
- expect_to_typecase_result_value_warning do
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
- expect_to_typecase_result_value_warning do
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
- expect_to_typecase_result_value_warning do
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
- val = res.getvalue(0,i)
515
+ val = res.getvalue(0,i)
531
516
  ip, prefix = v.split('/', 2)
532
- expect( val.to_s ).to eq( ip )
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
- default_prefix = (val.family == Socket::AF_INET ? 32 : 128)
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
- expect( val_prefix ).to eq( prefix.to_i )
526
+ expect( val_prefix ).to eq( prefix.to_i )
542
527
  elsif v.include?('.')
543
- expect( val_prefix ).to eq( 32 )
544
- else
545
- expect( val_prefix ).to eq( 128 )
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
@@ -173,7 +173,7 @@ describe PG::Connection do
173
173
  end
174
174
  end
175
175
 
176
- it "can connect asynchronously", :socket_io do
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", :socket_io do
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", :socket_io do
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
- res = @conn.exec("SELECT 1 AS one")
343
+ @conn.exec("SELECT 1 AS one")
344
344
  @conn.untrace
345
345
 
346
- res = @conn.exec("SELECT 2 AS two")
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", :socket_io do
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, :socket_io do
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, :socket_io do
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
- res2 = @conn.copy_data( "COPY copytable FROM STDOUT" ) do |res|
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
- res2 = @conn.copy_data( "COPY copytable FROM STDOUT", row_encoder ) do |res|
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
- res2 = @conn2.copy_data( "COPY copytable FROM STDOUT" ) do |res|
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
- res2 = @conn2.copy_data( "COPY (VALUES('1'), ('Möhre')) TO STDOUT".encode("utf-16le") ) do |res|
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
- it "should forward exec to exec_params" do
1875
- res = @conn.exec("VALUES($1::INT)", [7]).values
1876
- expect(res).to eq( [["7"]] )
1877
- res = @conn.exec("VALUES($1::INT)", [7], 1).values
1878
- expect(res).to eq( [[[7].pack("N")]] )
1879
- res = @conn.exec("VALUES(8)", [], 1).values
1880
- expect(res).to eq( [[[8].pack("N")]] )
1881
- end
1882
-
1883
- it "should forward exec_params to exec" do
1884
- res = @conn.exec_params("VALUES(3); VALUES(4)").values
1885
- expect(res).to eq( [["4"]] )
1886
- res = @conn.exec_params("VALUES(3); VALUES(4)", nil).values
1887
- expect(res).to eq( [["4"]] )
1888
- res = @conn.exec_params("VALUES(3); VALUES(4)", nil, nil).values
1889
- expect(res).to eq( [["4"]] )
1890
- res = @conn.exec_params("VALUES(3); VALUES(4)", nil, 1).values
1891
- expect(res).to eq( [["4"]] )
1892
- res = @conn.exec_params("VALUES(3); VALUES(4)", nil, nil, nil).values
1893
- expect(res).to eq( [["4"]] )
1894
- expect{
1895
- @conn.exec_params("VALUES(3); VALUES(4)", nil, nil, nil, nil).values
1896
- }.to raise_error(ArgumentError)
1897
- end
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
- it "should forward send_query to send_query_params" do
1900
- @conn.send_query("VALUES($1)", [5])
1901
- expect(@conn.get_last_result.values).to eq( [["5"]] )
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
@@ -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
- res = @conn.exec("SELECT 1/0")
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
- res = @conn.exec_params( "SELECT $1", [true], 0, tm )
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 2, 123 }.to raise_error(ArgumentError)
58
- expect{ tm.rm_coder -1, 123 }.to raise_error(ArgumentError)
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.2
4
+ version: 1.2.3
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Michael Granger
@@ -34,7 +34,7 @@ cert_chain:
34
34
  83uuAYSy65yXDGXXPVBeKPVnYrqp91pqpS5Nh7wfuiCrE8lgU8PATh7K4BV1UhAT
35
35
  0MHbAT42wTYkfUj3
36
36
  -----END CERTIFICATE-----
37
- date: 2020-01-08 00:00:00.000000000 Z
37
+ date: 2020-03-18 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: hoe-mercurial
metadata.gz.sig CHANGED
Binary file