pg 1.1.4 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/ChangeLog +0 -6595
  5. data/History.rdoc +86 -0
  6. data/Manifest.txt +3 -2
  7. data/README-Windows.rdoc +4 -4
  8. data/README.ja.rdoc +1 -2
  9. data/README.rdoc +44 -9
  10. data/Rakefile +8 -6
  11. data/Rakefile.cross +57 -56
  12. data/ext/errorcodes.def +64 -0
  13. data/ext/errorcodes.txt +18 -2
  14. data/ext/extconf.rb +6 -6
  15. data/ext/pg.c +132 -95
  16. data/ext/pg.h +21 -18
  17. data/ext/pg_binary_decoder.c +9 -9
  18. data/ext/pg_binary_encoder.c +13 -12
  19. data/ext/pg_coder.c +21 -9
  20. data/ext/pg_connection.c +388 -298
  21. data/ext/pg_copy_coder.c +6 -3
  22. data/ext/pg_record_coder.c +491 -0
  23. data/ext/pg_result.c +279 -127
  24. data/ext/pg_text_decoder.c +14 -8
  25. data/ext/pg_text_encoder.c +180 -48
  26. data/ext/pg_tuple.c +14 -6
  27. data/ext/pg_type_map.c +1 -1
  28. data/ext/pg_type_map_all_strings.c +4 -4
  29. data/ext/pg_type_map_by_class.c +9 -4
  30. data/ext/pg_type_map_by_column.c +7 -6
  31. data/ext/pg_type_map_by_mri_type.c +1 -1
  32. data/ext/pg_type_map_by_oid.c +3 -2
  33. data/ext/pg_type_map_in_ruby.c +1 -1
  34. data/ext/{util.c → pg_util.c} +5 -5
  35. data/ext/{util.h → pg_util.h} +0 -0
  36. data/lib/pg.rb +4 -4
  37. data/lib/pg/basic_type_mapping.rb +81 -18
  38. data/lib/pg/binary_decoder.rb +1 -0
  39. data/lib/pg/coder.rb +22 -1
  40. data/lib/pg/connection.rb +2 -2
  41. data/lib/pg/constants.rb +1 -0
  42. data/lib/pg/exceptions.rb +1 -0
  43. data/lib/pg/result.rb +13 -1
  44. data/lib/pg/text_decoder.rb +2 -3
  45. data/lib/pg/text_encoder.rb +8 -18
  46. data/lib/pg/type_map_by_column.rb +2 -1
  47. data/spec/helpers.rb +11 -11
  48. data/spec/pg/basic_type_mapping_spec.rb +140 -18
  49. data/spec/pg/connection_spec.rb +166 -89
  50. data/spec/pg/result_spec.rb +194 -4
  51. data/spec/pg/tuple_spec.rb +55 -2
  52. data/spec/pg/type_map_by_class_spec.rb +1 -1
  53. data/spec/pg/type_map_by_column_spec.rb +5 -1
  54. data/spec/pg/type_map_by_oid_spec.rb +2 -2
  55. data/spec/pg/type_spec.rb +180 -6
  56. metadata +31 -30
  57. metadata.gz.sig +0 -0
@@ -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)
@@ -288,7 +288,20 @@ describe PG::Connection do
288
288
  expect( @conn.host ).to eq( "localhost" )
289
289
  end
290
290
 
291
- EXPECTED_TRACE_OUTPUT = %{
291
+ it "can set error verbosity" do
292
+ old = @conn.set_error_verbosity( PG::PQERRORS_TERSE )
293
+ new = @conn.set_error_verbosity( old )
294
+ expect( new ).to eq( PG::PQERRORS_TERSE )
295
+ end
296
+
297
+ it "can set error context visibility", :postgresql_96 do
298
+ old = @conn.set_error_context_visibility( PG::PQSHOW_CONTEXT_NEVER )
299
+ new = @conn.set_error_context_visibility( old )
300
+ expect( new ).to eq( PG::PQSHOW_CONTEXT_NEVER )
301
+ end
302
+
303
+ let(:expected_trace_output) do
304
+ %{
292
305
  To backend> Msg Q
293
306
  To backend> "SELECT 1 AS one"
294
307
  To backend> Msg complete, length 21
@@ -316,6 +329,7 @@ describe PG::Connection do
316
329
  From backend (#4)> 5
317
330
  From backend> T
318
331
  }.gsub( /^\t{2}/, '' ).lstrip
332
+ end
319
333
 
320
334
  it "trace and untrace client-server communication", :unix do
321
335
  # be careful to explicitly close files so that the
@@ -326,10 +340,10 @@ describe PG::Connection do
326
340
  @conn.trace( trace_io )
327
341
  trace_io.close
328
342
 
329
- res = @conn.exec("SELECT 1 AS one")
343
+ @conn.exec("SELECT 1 AS one")
330
344
  @conn.untrace
331
345
 
332
- res = @conn.exec("SELECT 2 AS two")
346
+ @conn.exec("SELECT 2 AS two")
333
347
 
334
348
  trace_data = trace_file.read
335
349
 
@@ -341,7 +355,7 @@ describe PG::Connection do
341
355
  # From backend> T
342
356
  trace_data.sub!( /(From backend> Z\nFrom backend \(#4\)> 5\n){3}/m, '\\1\\1' )
343
357
 
344
- expect( trace_data ).to eq( EXPECTED_TRACE_OUTPUT )
358
+ expect( trace_data ).to eq( expected_trace_output )
345
359
  end
346
360
 
347
361
  it "allows a query to be cancelled" do
@@ -356,8 +370,6 @@ describe PG::Connection do
356
370
  end
357
371
 
358
372
  it "can stop a thread that runs a blocking query with async_exec" do
359
- pending "this does not work on Rubinius" if RUBY_ENGINE=='rbx'
360
-
361
373
  start = Time.now
362
374
  t = Thread.new do
363
375
  @conn.async_exec( 'select pg_sleep(10)' )
@@ -371,24 +383,16 @@ describe PG::Connection do
371
383
 
372
384
  it "should work together with signal handlers", :unix do
373
385
  signal_received = false
374
- trap 'USR1' do
386
+ trap 'USR2' do
375
387
  signal_received = true
376
388
  end
377
389
 
378
390
  Thread.new do
379
391
  sleep 0.1
380
- Process.kill("USR1", Process.pid)
392
+ Process.kill("USR2", Process.pid)
381
393
  end
382
394
  @conn.exec("select pg_sleep(0.3)")
383
395
  expect( signal_received ).to be_truthy
384
-
385
- signal_received = false
386
- Thread.new do
387
- sleep 0.1
388
- Process.kill("USR1", Process.pid)
389
- end
390
- @conn.async_exec("select pg_sleep(0.3)")
391
- expect( signal_received ).to be_truthy
392
396
  end
393
397
 
394
398
 
@@ -571,7 +575,7 @@ describe PG::Connection do
571
575
  expect( @conn.wait_for_notify( 1 ) ).to be_nil
572
576
  expect( notices.first ).to_not be_nil
573
577
  et = Time.now
574
- expect( (et - notices.first[1]) ).to be >= 0.4
578
+ expect( (et - notices.first[1]) ).to be >= 0.3
575
579
  expect( (et - st) ).to be >= 0.9
576
580
  expect( (et - st) ).to be < 1.4
577
581
  end
@@ -675,7 +679,7 @@ describe PG::Connection do
675
679
  @conn.copy_data( "COPY copytable FROM STDOUT" ) do |res|
676
680
  @conn.put_copy_data "xyz\n"
677
681
  end
678
- }.to raise_error(PG::Error, /invalid input syntax for integer/)
682
+ }.to raise_error(PG::Error, /invalid input syntax for .*integer/)
679
683
  end
680
684
  expect( @conn ).to still_be_usable
681
685
  end
@@ -898,7 +902,7 @@ describe PG::Connection do
898
902
  end
899
903
 
900
904
 
901
- it "handles server close while asynchronous connect", :socket_io do
905
+ it "handles server close while asynchronous connect" do
902
906
  serv = TCPServer.new( '127.0.0.1', 54320 )
903
907
  conn = described_class.connect_start( '127.0.0.1', 54320, "", "", "me", "xxxx", "somedb" )
904
908
  expect( [PG::PGRES_POLLING_WRITING, PG::CONNECTION_OK] ).to include conn.connect_poll
@@ -959,7 +963,7 @@ describe PG::Connection do
959
963
  conn.close
960
964
  end
961
965
 
962
- 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
963
967
  conn = PG.connect( @conninfo )
964
968
  io = conn.socket_io
965
969
  conn.finish
@@ -967,7 +971,7 @@ describe PG::Connection do
967
971
  expect { conn.socket_io }.to raise_error( PG::ConnectionBad, /connection is closed/i )
968
972
  end
969
973
 
970
- 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
971
975
  conn = PG.connect( @conninfo )
972
976
  io = conn.socket_io
973
977
  conn.reset
@@ -1233,53 +1237,41 @@ describe PG::Connection do
1233
1237
 
1234
1238
  end
1235
1239
 
1236
- context "multinationalization support", :ruby_19 do
1240
+ context "multinationalization support" do
1237
1241
 
1238
1242
  describe "rubyforge #22925: m17n support" do
1239
1243
  it "should return results in the same encoding as the client (iso-8859-1)" do
1240
- out_string = nil
1241
- @conn.transaction do |conn|
1242
- conn.internal_encoding = 'iso8859-1'
1243
- res = conn.exec_params("VALUES ('fantasia')", [], 0)
1244
- out_string = res[0]['column1']
1245
- end
1244
+ @conn.internal_encoding = 'iso8859-1'
1245
+ res = @conn.exec_params("VALUES ('fantasia')", [], 0)
1246
+ out_string = res[0]['column1']
1246
1247
  expect( out_string ).to eq( 'fantasia' )
1247
1248
  expect( out_string.encoding ).to eq( Encoding::ISO8859_1 )
1248
1249
  end
1249
1250
 
1250
1251
  it "should return results in the same encoding as the client (utf-8)" do
1251
- out_string = nil
1252
- @conn.transaction do |conn|
1253
- conn.internal_encoding = 'utf-8'
1254
- res = conn.exec_params("VALUES ('世界線航跡蔵')", [], 0)
1255
- out_string = res[0]['column1']
1256
- end
1252
+ @conn.internal_encoding = 'utf-8'
1253
+ res = @conn.exec_params("VALUES ('世界線航跡蔵')", [], 0)
1254
+ out_string = res[0]['column1']
1257
1255
  expect( out_string ).to eq( '世界線航跡蔵' )
1258
1256
  expect( out_string.encoding ).to eq( Encoding::UTF_8 )
1259
1257
  end
1260
1258
 
1261
1259
  it "should return results in the same encoding as the client (EUC-JP)" do
1262
- out_string = nil
1263
- @conn.transaction do |conn|
1264
- conn.internal_encoding = 'EUC-JP'
1265
- stmt = "VALUES ('世界線航跡蔵')".encode('EUC-JP')
1266
- res = conn.exec_params(stmt, [], 0)
1267
- out_string = res[0]['column1']
1268
- end
1260
+ @conn.internal_encoding = 'EUC-JP'
1261
+ stmt = "VALUES ('世界線航跡蔵')".encode('EUC-JP')
1262
+ res = @conn.exec_params(stmt, [], 0)
1263
+ out_string = res[0]['column1']
1269
1264
  expect( out_string ).to eq( '世界線航跡蔵'.encode('EUC-JP') )
1270
1265
  expect( out_string.encoding ).to eq( Encoding::EUC_JP )
1271
1266
  end
1272
1267
 
1273
1268
  it "returns the results in the correct encoding even if the client_encoding has " +
1274
1269
  "changed since the results were fetched" do
1275
- out_string = nil
1276
- @conn.transaction do |conn|
1277
- conn.internal_encoding = 'EUC-JP'
1278
- stmt = "VALUES ('世界線航跡蔵')".encode('EUC-JP')
1279
- res = conn.exec_params(stmt, [], 0)
1280
- conn.internal_encoding = 'utf-8'
1281
- out_string = res[0]['column1']
1282
- end
1270
+ @conn.internal_encoding = 'EUC-JP'
1271
+ stmt = "VALUES ('世界線航跡蔵')".encode('EUC-JP')
1272
+ res = @conn.exec_params(stmt, [], 0)
1273
+ @conn.internal_encoding = 'utf-8'
1274
+ out_string = res[0]['column1']
1283
1275
  expect( out_string ).to eq( '世界線航跡蔵'.encode('EUC-JP') )
1284
1276
  expect( out_string.encoding ).to eq( Encoding::EUC_JP )
1285
1277
  end
@@ -1358,6 +1350,21 @@ describe PG::Connection do
1358
1350
  expect { @conn.set_client_encoding( :invalid ) }.to raise_error(TypeError)
1359
1351
  expect { @conn.set_client_encoding( nil ) }.to raise_error(TypeError)
1360
1352
  end
1353
+
1354
+ it "can use an encoding with high index for client encoding" do
1355
+ # Allocate a lot of encoding indices, so that MRI's ENCODING_INLINE_MAX is exceeded
1356
+ unless Encoding.name_list.include?("pgtest-0")
1357
+ 256.times do |eidx|
1358
+ Encoding::UTF_8.replicate("pgtest-#{eidx}")
1359
+ end
1360
+ end
1361
+
1362
+ # Now allocate the JOHAB encoding with an unusual high index
1363
+ @conn.set_client_encoding "JOHAB"
1364
+ val = @conn.exec("SELECT chr(x'3391'::int)").values[0][0]
1365
+ expect( val.encoding.name ).to eq( "JOHAB" )
1366
+ end
1367
+
1361
1368
  end
1362
1369
 
1363
1370
  describe "respect and convert character encoding of input strings" do
@@ -1501,7 +1508,7 @@ describe PG::Connection do
1501
1508
 
1502
1509
  describe "Ruby 1.9.x default_internal encoding" do
1503
1510
 
1504
- it "honors the Encoding.default_internal if it's set and the synchronous interface is used" do
1511
+ it "honors the Encoding.default_internal if it's set and the synchronous interface is used", :without_transaction do
1505
1512
  @conn.transaction do |txn_conn|
1506
1513
  txn_conn.internal_encoding = Encoding::ISO8859_1
1507
1514
  txn_conn.exec( "CREATE TABLE defaultinternaltest ( foo text )" )
@@ -1603,9 +1610,8 @@ describe PG::Connection do
1603
1610
  end
1604
1611
  end
1605
1612
 
1606
- it "receives properly encoded text from wait_for_notify" do
1613
+ it "receives properly encoded text from wait_for_notify", :without_transaction do
1607
1614
  @conn.internal_encoding = 'utf-8'
1608
- @conn.exec( 'ROLLBACK' )
1609
1615
  @conn.exec( 'LISTEN "Möhre"' )
1610
1616
  @conn.exec( %Q{NOTIFY "Möhre", '世界線航跡蔵'} )
1611
1617
  event, pid, msg = nil
@@ -1616,13 +1622,13 @@ describe PG::Connection do
1616
1622
 
1617
1623
  expect( event ).to eq( "Möhre" )
1618
1624
  expect( event.encoding ).to eq( Encoding::UTF_8 )
1625
+ expect( pid ).to be_a_kind_of(Integer)
1619
1626
  expect( msg ).to eq( '世界線航跡蔵' )
1620
1627
  expect( msg.encoding ).to eq( Encoding::UTF_8 )
1621
1628
  end
1622
1629
 
1623
- it "returns properly encoded text from notifies" do
1630
+ it "returns properly encoded text from notifies", :without_transaction do
1624
1631
  @conn.internal_encoding = 'utf-8'
1625
- @conn.exec( 'ROLLBACK' )
1626
1632
  @conn.exec( 'LISTEN "Möhre"' )
1627
1633
  @conn.exec( %Q{NOTIFY "Möhre", '世界線航跡蔵'} )
1628
1634
  @conn.exec( 'UNLISTEN "Möhre"' )
@@ -1636,7 +1642,7 @@ describe PG::Connection do
1636
1642
  end
1637
1643
  end
1638
1644
 
1639
- context "OS thread support", :ruby_19 do
1645
+ context "OS thread support" do
1640
1646
  it "Connection#exec shouldn't block a second thread" do
1641
1647
  t = Thread.new do
1642
1648
  @conn.exec( "select pg_sleep(1)" )
@@ -1697,12 +1703,12 @@ describe PG::Connection do
1697
1703
  row_encoder = PG::TextEncoder::CopyRow.new type_map: tm
1698
1704
 
1699
1705
  @conn.exec( "CREATE TEMP TABLE copytable (col1 TEXT)" )
1700
- res2 = @conn.copy_data( "COPY copytable FROM STDOUT" ) do |res|
1706
+ @conn.copy_data( "COPY copytable FROM STDOUT" ) do |res|
1701
1707
  @conn.put_copy_data [1], row_encoder
1702
1708
  @conn.put_copy_data ["2"], row_encoder
1703
1709
  end
1704
1710
 
1705
- res2 = @conn.copy_data( "COPY copytable FROM STDOUT", row_encoder ) do |res|
1711
+ @conn.copy_data( "COPY copytable FROM STDOUT", row_encoder ) do |res|
1706
1712
  @conn.put_copy_data [3]
1707
1713
  @conn.put_copy_data ["4"]
1708
1714
  end
@@ -1752,7 +1758,7 @@ describe PG::Connection do
1752
1758
 
1753
1759
  it "can process #copy_data input queries with row encoder and respects character encoding" do
1754
1760
  @conn2.exec( "CREATE TEMP TABLE copytable (col1 TEXT)" )
1755
- res2 = @conn2.copy_data( "COPY copytable FROM STDOUT" ) do |res|
1761
+ @conn2.copy_data( "COPY copytable FROM STDOUT" ) do |res|
1756
1762
  @conn2.put_copy_data [1]
1757
1763
  @conn2.put_copy_data ["Möhre".encode("utf-16le")]
1758
1764
  end
@@ -1803,7 +1809,7 @@ describe PG::Connection do
1803
1809
  it "can process #copy_data output with row decoder and respects character encoding" do
1804
1810
  @conn2.internal_encoding = Encoding::ISO8859_1
1805
1811
  rows = []
1806
- 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|
1807
1813
  while row=@conn2.get_copy_data
1808
1814
  rows << row
1809
1815
  end
@@ -1831,35 +1837,106 @@ describe PG::Connection do
1831
1837
  end
1832
1838
  end
1833
1839
 
1834
- describe "deprecated forms of methods" do
1835
- it "should forward exec to exec_params" do
1836
- res = @conn.exec("VALUES($1::INT)", [7]).values
1837
- expect(res).to eq( [["7"]] )
1838
- res = @conn.exec("VALUES($1::INT)", [7], 1).values
1839
- expect(res).to eq( [[[7].pack("N")]] )
1840
- res = @conn.exec("VALUES(8)", [], 1).values
1841
- expect(res).to eq( [[[8].pack("N")]] )
1842
- end
1843
-
1844
- it "should forward exec_params to exec" do
1845
- res = @conn.exec_params("VALUES(3); VALUES(4)").values
1846
- expect(res).to eq( [["4"]] )
1847
- res = @conn.exec_params("VALUES(3); VALUES(4)", nil).values
1848
- expect(res).to eq( [["4"]] )
1849
- res = @conn.exec_params("VALUES(3); VALUES(4)", nil, nil).values
1850
- expect(res).to eq( [["4"]] )
1851
- res = @conn.exec_params("VALUES(3); VALUES(4)", nil, 1).values
1852
- expect(res).to eq( [["4"]] )
1853
- res = @conn.exec_params("VALUES(3); VALUES(4)", nil, nil, nil).values
1854
- expect(res).to eq( [["4"]] )
1855
- expect{
1856
- @conn.exec_params("VALUES(3); VALUES(4)", nil, nil, nil, nil).values
1857
- }.to raise_error(ArgumentError)
1840
+ describe :field_name_type do
1841
+ before :each do
1842
+ @conn2 = PG.connect(@conninfo)
1858
1843
  end
1844
+ after :each do
1845
+ @conn2.close
1846
+ end
1847
+
1848
+ it "uses string field names per default" do
1849
+ expect(@conn2.field_name_type).to eq(:string)
1850
+ end
1851
+
1852
+ it "can set string field names" do
1853
+ @conn2.field_name_type = :string
1854
+ expect(@conn2.field_name_type).to eq(:string)
1855
+ res = @conn2.exec("SELECT 1 as az")
1856
+ expect(res.field_name_type).to eq(:string)
1857
+ expect(res.fields).to eq(["az"])
1858
+ end
1859
+
1860
+ it "can set symbol field names" do
1861
+ @conn2.field_name_type = :symbol
1862
+ expect(@conn2.field_name_type).to eq(:symbol)
1863
+ res = @conn2.exec("SELECT 1 as az")
1864
+ expect(res.field_name_type).to eq(:symbol)
1865
+ expect(res.fields).to eq([:az])
1866
+ end
1867
+
1868
+ it "can't set invalid values" do
1869
+ expect{ @conn2.field_name_type = :sym }.to raise_error(ArgumentError, /invalid argument :sym/)
1870
+ expect{ @conn2.field_name_type = "symbol" }.to raise_error(ArgumentError, /invalid argument "symbol"/)
1871
+ end
1872
+ end
1873
+
1874
+ describe "deprecated forms of methods" do
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
1859
1884
 
1860
- it "should forward send_query to send_query_params" do
1861
- @conn.send_query("VALUES($1)", [5])
1862
- expect(@conn.get_last_result.values).to eq( [["5"]] )
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
1934
+
1935
+ it "shouldn't respond_to socket" do
1936
+ expect do
1937
+ @conn.socket
1938
+ end.to raise_error(ArgumentError)
1939
+ end
1863
1940
  end
1864
1941
 
1865
1942
  it "shouldn't forward send_query_params to send_query" do