pg 0.18.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data/BSDL +2 -2
  4. data/ChangeLog +689 -5
  5. data/History.rdoc +84 -0
  6. data/Manifest.txt +0 -18
  7. data/README.rdoc +13 -10
  8. data/Rakefile +16 -19
  9. data/Rakefile.cross +21 -24
  10. data/ext/errorcodes.def +33 -0
  11. data/ext/errorcodes.txt +15 -1
  12. data/ext/extconf.rb +21 -33
  13. data/ext/gvl_wrappers.c +4 -0
  14. data/ext/gvl_wrappers.h +27 -39
  15. data/ext/pg.c +18 -50
  16. data/ext/pg.h +13 -80
  17. data/ext/pg_binary_encoder.c +8 -8
  18. data/ext/pg_coder.c +31 -10
  19. data/ext/pg_connection.c +340 -225
  20. data/ext/pg_copy_coder.c +34 -4
  21. data/ext/pg_result.c +24 -22
  22. data/ext/pg_text_encoder.c +62 -42
  23. data/ext/pg_type_map.c +14 -7
  24. data/lib/pg/basic_type_mapping.rb +35 -8
  25. data/lib/pg/connection.rb +53 -12
  26. data/lib/pg/result.rb +10 -5
  27. data/lib/pg/text_decoder.rb +7 -0
  28. data/lib/pg/text_encoder.rb +8 -0
  29. data/lib/pg.rb +18 -10
  30. data/spec/helpers.rb +8 -15
  31. data/spec/pg/basic_type_mapping_spec.rb +54 -0
  32. data/spec/pg/connection_spec.rb +384 -209
  33. data/spec/pg/result_spec.rb +14 -7
  34. data/spec/pg/type_map_by_class_spec.rb +2 -2
  35. data/spec/pg/type_map_by_mri_type_spec.rb +1 -1
  36. data/spec/pg/type_spec.rb +83 -3
  37. data/spec/pg_spec.rb +1 -1
  38. data.tar.gz.sig +0 -0
  39. metadata +55 -64
  40. metadata.gz.sig +0 -0
  41. data/sample/array_insert.rb +0 -20
  42. data/sample/async_api.rb +0 -106
  43. data/sample/async_copyto.rb +0 -39
  44. data/sample/async_mixed.rb +0 -56
  45. data/sample/check_conn.rb +0 -21
  46. data/sample/copyfrom.rb +0 -81
  47. data/sample/copyto.rb +0 -19
  48. data/sample/cursor.rb +0 -21
  49. data/sample/disk_usage_report.rb +0 -186
  50. data/sample/issue-119.rb +0 -94
  51. data/sample/losample.rb +0 -69
  52. data/sample/minimal-testcase.rb +0 -17
  53. data/sample/notify_wait.rb +0 -72
  54. data/sample/pg_statistics.rb +0 -294
  55. data/sample/replication_monitor.rb +0 -231
  56. data/sample/test_binary_values.rb +0 -33
  57. data/sample/wal_shipper.rb +0 -434
  58. data/sample/warehouse_partitions.rb +0 -320
@@ -39,7 +39,7 @@ describe PG::Result do
39
39
  expect( e.to_a ).to eq [{'a'=>'1', 'b'=>'2'}]
40
40
  end
41
41
 
42
- context "result streaming", :postgresql_92 do
42
+ context "result streaming" do
43
43
  it "can iterate over all tuples in single row mode" do
44
44
  @conn.send_query( "SELECT generate_series(2,4) AS a; SELECT 1 AS b, generate_series(5,6) AS c" )
45
45
  @conn.set_single_row_mode
@@ -100,11 +100,11 @@ describe PG::Result do
100
100
  expect( res[0]['n'] ).to be_nil()
101
101
  end
102
102
 
103
- it "encapsulates errors in a PGError object" do
103
+ it "encapsulates errors in a PG::Error object" do
104
104
  exception = nil
105
105
  begin
106
106
  @conn.exec( "SELECT * FROM nonexistant_table" )
107
- rescue PGError => err
107
+ rescue PG::Error => err
108
108
  exception = err
109
109
  end
110
110
 
@@ -136,7 +136,7 @@ describe PG::Result do
136
136
  exception = nil
137
137
  begin
138
138
  @conn.exec( "INSERT INTO integrity VALUES (NULL)" )
139
- rescue PGError => err
139
+ rescue PG::Error => err
140
140
  exception = err
141
141
  end
142
142
  result = exception.result
@@ -152,7 +152,7 @@ describe PG::Result do
152
152
  sqlstate = nil
153
153
  begin
154
154
  res = @conn.exec("SELECT 1/0")
155
- rescue PGError => e
155
+ rescue PG::Error => e
156
156
  sqlstate = e.result.result_error_field( PG::PG_DIAG_SQLSTATE ).to_i
157
157
  end
158
158
  expect( sqlstate ).to eq( 22012 )
@@ -199,7 +199,7 @@ describe PG::Result do
199
199
  expect( out_bytes ).to eq( in_bytes )
200
200
  end
201
201
 
202
- it "returns the parameter type of the specified prepared statement parameter", :postgresql_92 do
202
+ it "returns the parameter type of the specified prepared statement parameter" do
203
203
  query = 'SELECT * FROM pg_stat_activity WHERE user = $1::name AND query = $2::text'
204
204
  @conn.prepare( 'queryfinder', query )
205
205
  res = @conn.describe_prepared( 'queryfinder' )
@@ -386,7 +386,7 @@ describe PG::Result do
386
386
  end
387
387
 
388
388
  it "the raised result is nil in case of a connection error" do
389
- c = PGconn.connect_start( '127.0.0.1', 54320, "", "", "me", "xxxx", "somedb" )
389
+ c = PG::Connection.connect_start( '127.0.0.1', 54320, "", "", "me", "xxxx", "somedb" )
390
390
  expect {
391
391
  c.exec "select 1"
392
392
  }.to raise_error {|error|
@@ -403,6 +403,13 @@ describe PG::Result do
403
403
  expect( r.cleared? ).to eq(true)
404
404
  end
405
405
 
406
+ it "can be inspected before and after clear" do
407
+ r = @conn.exec "select 1"
408
+ expect( r.inspect ).to match(/status=PGRES_TUPLES_OK/)
409
+ r.clear
410
+ expect( r.inspect ).to match(/cleared/)
411
+ end
412
+
406
413
  context 'result value conversions with TypeMapByColumn' do
407
414
  let!(:textdec_int){ PG::TextDecoder::Integer.new name: 'INT4', oid: 23 }
408
415
  let!(:textdec_float){ PG::TextDecoder::Float.new name: 'FLOAT4', oid: 700 }
@@ -59,7 +59,7 @@ describe PG::TypeMapByClass do
59
59
  it "should retrieve particular conversions" do
60
60
  expect( tm[Integer] ).to eq(binaryenc_int)
61
61
  expect( tm[Float] ).to eq(textenc_float)
62
- expect( tm[Bignum] ).to be_nil
62
+ expect( tm[Range] ).to be_nil
63
63
  expect( derived_tm[raise_class] ).to be_kind_of(Proc)
64
64
  expect( derived_tm[Array] ).to eq(:array_type_map_for)
65
65
  end
@@ -102,7 +102,7 @@ describe PG::TypeMapByClass do
102
102
 
103
103
  it "should allow mixed type conversions" do
104
104
  res = @conn.exec_params( "SELECT $1, $2, $3", [5, 1.23, :TestSymbol], 0, tm )
105
- expect( res.values ).to eq([['5', '1.23', '[:TestSymbol]']])
105
+ expect( res.values ).to eq([['5', '1.23', "[:TestSymbol, #{@conn.internal_encoding.inspect}]"]])
106
106
  expect( res.ftype(0) ).to eq(20)
107
107
  end
108
108
 
@@ -116,7 +116,7 @@ describe PG::TypeMapByMriType do
116
116
 
117
117
  it "should allow mixed type conversions" do
118
118
  res = @conn.exec_params( "SELECT $1, $2, $3", [5, 1.23, :TestSymbol], 0, tm )
119
- expect( res.values ).to eq([['5', '1.23', '[:TestSymbol]']])
119
+ expect( res.values ).to eq([['5', '1.23', "[:TestSymbol, #{@conn.internal_encoding.inspect}]"]])
120
120
  expect( res.ftype(0) ).to eq(20)
121
121
  end
122
122
 
data/spec/pg/type_spec.rb CHANGED
@@ -39,6 +39,14 @@ describe "PG::Type derivations" do
39
39
  end.new
40
40
  end
41
41
 
42
+ let!(:intenc_incrementer_with_encoding) do
43
+ Class.new(PG::SimpleEncoder) do
44
+ def encode(value, encoding)
45
+ r = (value.to_i + 1).to_s + " #{encoding}"
46
+ r.encode!(encoding)
47
+ end
48
+ end.new
49
+ end
42
50
  let!(:intenc_incrementer_with_int_result) do
43
51
  Class.new(PG::SimpleEncoder) do
44
52
  def encode(value)
@@ -67,7 +75,7 @@ describe "PG::Type derivations" do
67
75
  expect( intdec_incrementer.decode("3") ).to eq( 4 )
68
76
  end
69
77
 
70
- it "should decode integers of different lengths form text format" do
78
+ it "should decode integers of different lengths from text format" do
71
79
  30.times do |zeros|
72
80
  expect( textdec_int.decode("1" + "0"*zeros) ).to eq( 10 ** zeros )
73
81
  expect( textdec_int.decode(zeros==0 ? "0" : "9"*zeros) ).to eq( 10 ** zeros - 1 )
@@ -127,6 +135,13 @@ describe "PG::Type derivations" do
127
135
  expect( quoted_type.decode(%[a.b]) ).to eq( ['a','b'] )
128
136
  expect( quoted_type.decode(%[a]) ).to eq( ['a'] )
129
137
  end
138
+
139
+ it 'should split identifier string with correct character encoding' do
140
+ quoted_type = PG::TextDecoder::Identifier.new
141
+ v = quoted_type.decode(%[Héllo].encode("iso-8859-1")).first
142
+ expect( v.encoding ).to eq( Encoding::ISO_8859_1 )
143
+ expect( v ).to eq( %[Héllo].encode(Encoding::ISO_8859_1) )
144
+ end
130
145
  end
131
146
 
132
147
  it "should raise when decode method is called with wrong args" do
@@ -209,6 +224,13 @@ describe "PG::Type derivations" do
209
224
  expect( quoted_type.encode( nil ) ).to be_nil
210
225
  end
211
226
 
227
+ it 'should quote identifiers with correct character encoding' do
228
+ quoted_type = PG::TextEncoder::Identifier.new
229
+ v = quoted_type.encode(['Héllo'], "iso-8859-1")
230
+ expect( v ).to eq( %["Héllo"].encode(Encoding::ISO_8859_1) )
231
+ expect( v.encoding ).to eq( Encoding::ISO_8859_1 )
232
+ end
233
+
212
234
  it "will raise a TypeError for invalid arguments to quote_ident" do
213
235
  quoted_type = PG::TextEncoder::Identifier.new
214
236
  expect{ quoted_type.encode( [nil] ) }.to raise_error(TypeError)
@@ -220,6 +242,12 @@ describe "PG::Type derivations" do
220
242
  expect( intenc_incrementer.encode(3) ).to eq( "4 " )
221
243
  end
222
244
 
245
+ it "should encode with ruby encoder and given character encoding" do
246
+ r = intenc_incrementer_with_encoding.encode(3, Encoding::CP850)
247
+ expect( r ).to eq( "4 CP850" )
248
+ expect( r.encoding ).to eq( Encoding::CP850 )
249
+ end
250
+
223
251
  it "should return when ruby encoder returns non string values" do
224
252
  expect( intenc_incrementer_with_int_result.encode(3) ).to eq( 4 )
225
253
  end
@@ -447,9 +475,18 @@ describe "PG::Type derivations" do
447
475
  end
448
476
 
449
477
  context 'array of types with encoder in ruby space' do
450
- it 'encodes with quotation' do
478
+ it 'encodes with quotation and default character encoding' do
479
+ array_type = PG::TextEncoder::Array.new elements_type: intenc_incrementer, needs_quotation: true
480
+ r = array_type.encode([3,4])
481
+ expect( r ).to eq( %[{"4 ","5 "}] )
482
+ expect( r.encoding ).to eq( Encoding::ASCII_8BIT )
483
+ end
484
+
485
+ it 'encodes with quotation and given character encoding' do
451
486
  array_type = PG::TextEncoder::Array.new elements_type: intenc_incrementer, needs_quotation: true
452
- expect( array_type.encode([3,4]) ).to eq( %[{"4 ","5 "}] )
487
+ r = array_type.encode([3,4], Encoding::CP850)
488
+ expect( r ).to eq( %[{"4 ","5 "}] )
489
+ expect( r.encoding ).to eq( Encoding::CP850 )
453
490
  end
454
491
 
455
492
  it 'encodes without quotation' do
@@ -457,6 +494,20 @@ describe "PG::Type derivations" do
457
494
  expect( array_type.encode([3,4]) ).to eq( %[{4 ,5 }] )
458
495
  end
459
496
 
497
+ it 'encodes with default character encoding' do
498
+ array_type = PG::TextEncoder::Array.new elements_type: intenc_incrementer_with_encoding
499
+ r = array_type.encode([3,4])
500
+ expect( r ).to eq( %[{"4 ASCII-8BIT","5 ASCII-8BIT"}] )
501
+ expect( r.encoding ).to eq( Encoding::ASCII_8BIT )
502
+ end
503
+
504
+ it 'encodes with given character encoding' do
505
+ array_type = PG::TextEncoder::Array.new elements_type: intenc_incrementer_with_encoding
506
+ r = array_type.encode([3,4], Encoding::CP850)
507
+ expect( r ).to eq( %[{"4 CP850","5 CP850"}] )
508
+ expect( r.encoding ).to eq( Encoding::CP850 )
509
+ end
510
+
460
511
  it "should raise when ruby encoder returns non string values" do
461
512
  array_type = PG::TextEncoder::Array.new elements_type: intenc_incrementer_with_int_result, needs_quotation: false
462
513
  expect{ array_type.encode([3,4]) }.to raise_error(TypeError)
@@ -473,6 +524,13 @@ describe "PG::Type derivations" do
473
524
  quoted_type = PG::TextEncoder::QuotedLiteral.new elements_type: textenc_string_array
474
525
  expect( quoted_type.encode(["'A\",","\\B'"]) ).to eq( %['{"''A\\",","\\\\B''"}'] )
475
526
  end
527
+
528
+ it 'should quote literals with correct character encoding' do
529
+ quoted_type = PG::TextEncoder::QuotedLiteral.new elements_type: textenc_string_array
530
+ v = quoted_type.encode(["Héllo"], "iso-8859-1")
531
+ expect( v.encoding ).to eq( Encoding::ISO_8859_1 )
532
+ expect( v ).to eq( %['{Héllo}'].encode(Encoding::ISO_8859_1) )
533
+ end
476
534
  end
477
535
  end
478
536
 
@@ -522,9 +580,19 @@ describe "PG::Type derivations" do
522
580
  expect( e.encode("(\xFBm") ).to eq("KPtt")
523
581
  end
524
582
 
583
+ it 'should encode Strings as base64 with correct character encoding' do
584
+ e = PG::TextEncoder::ToBase64.new
585
+ v = e.encode("Héllo".encode("utf-16le"), "iso-8859-1")
586
+ expect( v ).to eq("SOlsbG8=")
587
+ expect( v.encoding ).to eq(Encoding::ISO_8859_1)
588
+ end
589
+
525
590
  it "should encode Strings as base64 in BinaryDecoder" do
526
591
  e = PG::BinaryDecoder::ToBase64.new
527
592
  expect( e.decode("x") ).to eq("eA==")
593
+ v = e.decode("Héllo".encode("utf-16le"))
594
+ expect( v ).to eq("SADpAGwAbABvAA==")
595
+ expect( v.encoding ).to eq(Encoding::ASCII_8BIT)
528
596
  end
529
597
 
530
598
  it "should encode Integers as base64" do
@@ -611,6 +679,12 @@ describe "PG::Type derivations" do
611
679
  expect( encoder.encode([:xyz, 123, 2456, 34567, 456789, 5678901, [1,2,3], 12.1, "abcdefg", nil]) ).
612
680
  to eq("xyz\t123\t2456\t34567\t456789\t5678901\t[1, 2, 3]\t12.1\tabcdefg\t\\N\n")
613
681
  end
682
+
683
+ it 'should output a string with correct character encoding' do
684
+ v = encoder.encode(["Héllo"], "iso-8859-1")
685
+ expect( v.encoding ).to eq( Encoding::ISO_8859_1 )
686
+ expect( v ).to eq( "Héllo\n".encode(Encoding::ISO_8859_1) )
687
+ end
614
688
  end
615
689
 
616
690
  context "with TypeMapByClass" do
@@ -675,6 +749,12 @@ describe "PG::Type derivations" do
675
749
  it "should decode different types of Ruby objects" do
676
750
  expect( decoder.decode("123\t \0#\t#\n#\r#\\ \t234\t#\x01#\002\n".gsub("#", "\\"))).to eq( ["123", " \0\t\n\r\\ ", "234", "\x01\x02"] )
677
751
  end
752
+
753
+ it 'should respect input character encoding' do
754
+ v = decoder.decode("Héllo\n".encode("iso-8859-1")).first
755
+ expect( v.encoding ).to eq(Encoding::ISO_8859_1)
756
+ expect( v ).to eq("Héllo".encode("iso-8859-1"))
757
+ end
678
758
  end
679
759
  end
680
760
 
data/spec/pg_spec.rb CHANGED
@@ -7,7 +7,7 @@ require 'pg'
7
7
 
8
8
  describe PG do
9
9
 
10
- it "knows what version of the libpq library is loaded", :postgresql_91 do
10
+ it "knows what version of the libpq library is loaded" do
11
11
  expect( PG.library_version ).to be_an( Integer )
12
12
  expect( PG.library_version ).to be >= 90100
13
13
  end
data.tar.gz.sig CHANGED
Binary file
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: 0.18.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -11,27 +11,32 @@ bindir: bin
11
11
  cert_chain:
12
12
  - |
13
13
  -----BEGIN CERTIFICATE-----
14
- MIIDbDCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANnZWQx
14
+ MIIEbDCCAtSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANnZWQx
15
15
  GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
16
- HhcNMTUwNDAxMjEyNDEzWhcNMTYwMzMxMjEyNDEzWjA+MQwwCgYDVQQDDANnZWQx
16
+ HhcNMTcwOTI3MDAzMDQ0WhcNMTgwOTI3MDAzMDQ0WjA+MQwwCgYDVQQDDANnZWQx
17
17
  GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
18
- ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDb92mkyYwuGBg1oRxt2tkH
19
- +Uo3LAsaL/APBfSLzy8o3+B3AUHKCjMUaV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NGuFj9AItBsVmAvkBGIpX4TEKQp5haEbPpmaqO5nIIhV26PXmyT
37
+ OMKv6pWsoS81vw5KAGBmfX8nht/Py90DQrbRvakATGI=
33
38
  -----END CERTIFICATE-----
34
- date: 2015-11-13 00:00:00.000000000 Z
39
+ date: 2018-01-10 00:00:00.000000000 Z
35
40
  dependencies:
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: hoe-mercurial
@@ -53,14 +58,14 @@ dependencies:
53
58
  requirements:
54
59
  - - "~>"
55
60
  - !ruby/object:Gem::Version
56
- version: '0.7'
61
+ version: '0.9'
57
62
  type: :development
58
63
  prerelease: false
59
64
  version_requirements: !ruby/object:Gem::Requirement
60
65
  requirements:
61
66
  - - "~>"
62
67
  - !ruby/object:Gem::Version
63
- version: '0.7'
68
+ version: '0.9'
64
69
  - !ruby/object:Gem::Dependency
65
70
  name: hoe-highline
66
71
  requirement: !ruby/object:Gem::Requirement
@@ -76,93 +81,99 @@ dependencies:
76
81
  - !ruby/object:Gem::Version
77
82
  version: '0.2'
78
83
  - !ruby/object:Gem::Dependency
79
- name: rdoc
84
+ name: rake-compiler
80
85
  requirement: !ruby/object:Gem::Requirement
81
86
  requirements:
82
87
  - - "~>"
83
88
  - !ruby/object:Gem::Version
84
- version: '4.0'
89
+ version: '1.0'
85
90
  type: :development
86
91
  prerelease: false
87
92
  version_requirements: !ruby/object:Gem::Requirement
88
93
  requirements:
89
94
  - - "~>"
90
95
  - !ruby/object:Gem::Version
91
- version: '4.0'
96
+ version: '1.0'
92
97
  - !ruby/object:Gem::Dependency
93
- name: rake-compiler
98
+ name: rake-compiler-dock
94
99
  requirement: !ruby/object:Gem::Requirement
95
100
  requirements:
96
101
  - - "~>"
97
102
  - !ruby/object:Gem::Version
98
- version: '0.9'
103
+ version: '0.6'
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 0.6.2
99
107
  type: :development
100
108
  prerelease: false
101
109
  version_requirements: !ruby/object:Gem::Requirement
102
110
  requirements:
103
111
  - - "~>"
104
112
  - !ruby/object:Gem::Version
105
- version: '0.9'
113
+ version: '0.6'
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 0.6.2
106
117
  - !ruby/object:Gem::Dependency
107
- name: rake-compiler-dock
118
+ name: hoe-bundler
108
119
  requirement: !ruby/object:Gem::Requirement
109
120
  requirements:
110
121
  - - "~>"
111
122
  - !ruby/object:Gem::Version
112
- version: '0.3'
123
+ version: '1.0'
113
124
  type: :development
114
125
  prerelease: false
115
126
  version_requirements: !ruby/object:Gem::Requirement
116
127
  requirements:
117
128
  - - "~>"
118
129
  - !ruby/object:Gem::Version
119
- version: '0.3'
130
+ version: '1.0'
120
131
  - !ruby/object:Gem::Dependency
121
- name: hoe
132
+ name: rspec
122
133
  requirement: !ruby/object:Gem::Requirement
123
134
  requirements:
124
135
  - - "~>"
125
136
  - !ruby/object:Gem::Version
126
- version: '3.12'
137
+ version: '3.5'
127
138
  type: :development
128
139
  prerelease: false
129
140
  version_requirements: !ruby/object:Gem::Requirement
130
141
  requirements:
131
142
  - - "~>"
132
143
  - !ruby/object:Gem::Version
133
- version: '3.12'
144
+ version: '3.5'
134
145
  - !ruby/object:Gem::Dependency
135
- name: hoe-bundler
146
+ name: rdoc
136
147
  requirement: !ruby/object:Gem::Requirement
137
148
  requirements:
138
149
  - - "~>"
139
150
  - !ruby/object:Gem::Version
140
- version: '1.0'
151
+ version: '5.1'
141
152
  type: :development
142
153
  prerelease: false
143
154
  version_requirements: !ruby/object:Gem::Requirement
144
155
  requirements:
145
156
  - - "~>"
146
157
  - !ruby/object:Gem::Version
147
- version: '1.0'
158
+ version: '5.1'
148
159
  - !ruby/object:Gem::Dependency
149
- name: rspec
160
+ name: hoe
150
161
  requirement: !ruby/object:Gem::Requirement
151
162
  requirements:
152
163
  - - "~>"
153
164
  - !ruby/object:Gem::Version
154
- version: '3.0'
165
+ version: '3.16'
155
166
  type: :development
156
167
  prerelease: false
157
168
  version_requirements: !ruby/object:Gem::Requirement
158
169
  requirements:
159
170
  - - "~>"
160
171
  - !ruby/object:Gem::Version
161
- version: '3.0'
172
+ version: '3.16'
162
173
  description: |-
163
174
  Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
164
175
 
165
- It works with {PostgreSQL 8.4 and later}[http://www.postgresql.org/support/versioning/].
176
+ It works with {PostgreSQL 9.2 and later}[http://www.postgresql.org/support/versioning/].
166
177
 
167
178
  A small example usage:
168
179
 
@@ -174,7 +185,7 @@ description: |-
174
185
  conn = PG.connect( dbname: 'sales' )
175
186
  conn.exec( "SELECT * FROM pg_stat_activity" ) do |result|
176
187
  puts " PID | User | Query"
177
- result.each do |row|
188
+ result.each do |row|
178
189
  puts " %7d | %-16s | %s " %
179
190
  row.values_at('procpid', 'usename', 'current_query')
180
191
  end
@@ -269,24 +280,6 @@ files:
269
280
  - lib/pg/text_decoder.rb
270
281
  - lib/pg/text_encoder.rb
271
282
  - lib/pg/type_map_by_column.rb
272
- - sample/array_insert.rb
273
- - sample/async_api.rb
274
- - sample/async_copyto.rb
275
- - sample/async_mixed.rb
276
- - sample/check_conn.rb
277
- - sample/copyfrom.rb
278
- - sample/copyto.rb
279
- - sample/cursor.rb
280
- - sample/disk_usage_report.rb
281
- - sample/issue-119.rb
282
- - sample/losample.rb
283
- - sample/minimal-testcase.rb
284
- - sample/notify_wait.rb
285
- - sample/pg_statistics.rb
286
- - sample/replication_monitor.rb
287
- - sample/test_binary_values.rb
288
- - sample/wal_shipper.rb
289
- - sample/warehouse_partitions.rb
290
283
  - spec/data/expected_trace.out
291
284
  - spec/data/random_binary_data
292
285
  - spec/helpers.rb
@@ -303,9 +296,7 @@ files:
303
296
  - spec/pg_spec.rb
304
297
  homepage: https://bitbucket.org/ged/ruby-pg
305
298
  licenses:
306
- - BSD
307
- - Ruby
308
- - GPL
299
+ - BSD-3-Clause
309
300
  metadata: {}
310
301
  post_install_message:
311
302
  rdoc_options:
@@ -317,7 +308,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
317
308
  requirements:
318
309
  - - ">="
319
310
  - !ruby/object:Gem::Version
320
- version: 1.9.3
311
+ version: 2.0.0
321
312
  required_rubygems_version: !ruby/object:Gem::Requirement
322
313
  requirements:
323
314
  - - ">="
@@ -325,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
325
316
  version: '0'
326
317
  requirements: []
327
318
  rubyforge_project:
328
- rubygems_version: 2.4.5.1
319
+ rubygems_version: 2.7.3
329
320
  signing_key:
330
321
  specification_version: 4
331
322
  summary: Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/]
metadata.gz.sig CHANGED
Binary file
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'pg'
4
-
5
- c = PG.connect( dbname: 'test' )
6
-
7
- # this one works:
8
- c.exec( "DROP TABLE IF EXISTS foo" )
9
- c.exec( "CREATE TABLE foo (strings character varying[]);" )
10
-
11
- # But using a prepared statement works:
12
- c.set_error_verbosity( PG::PQERRORS_VERBOSE )
13
- c.prepare( 'stmt', "INSERT INTO foo VALUES ($1);" )
14
-
15
- # This won't work
16
- #c.exec_prepared( 'stmt', ["ARRAY['this','that']"] )
17
-
18
- # but this will:
19
- c.exec_prepared( 'stmt', ["{'this','that'}"] )
20
-
data/sample/async_api.rb DELETED
@@ -1,106 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'pg'
4
-
5
- # This is a example of how to use the asynchronous API to query the
6
- # server without blocking other threads. It's intentionally low-level;
7
- # if you hooked up the PG::Connection#socket to some kind of reactor, you
8
- # could make this much nicer.
9
-
10
- TIMEOUT = 5.0 # seconds to wait for an async operation to complete
11
-
12
- # Print 'x' continuously to demonstrate that other threads aren't
13
- # blocked while waiting for the connection, for the query to be sent,
14
- # for results, etc. You might want to sleep inside the loop or
15
- # comment this out entirely for cleaner output.
16
- progress_thread = Thread.new { loop { print 'x' } }
17
-
18
- # Output progress messages
19
- def output_progress( msg )
20
- puts "\n>>> #{msg}\n"
21
- end
22
-
23
- # Start the connection
24
- output_progress "Starting connection..."
25
- conn = PG::Connection.connect_start( :dbname => 'test' ) or
26
- abort "Unable to create a new connection!"
27
- abort "Connection failed: %s" % [ conn.error_message ] if
28
- conn.status == PG::CONNECTION_BAD
29
-
30
- # Now grab a reference to the underlying socket so we know when the
31
- # connection is established
32
- socket = conn.socket_io
33
-
34
- # Track the progress of the connection, waiting for the socket to become readable/writable
35
- # before polling it
36
- poll_status = PG::PGRES_POLLING_WRITING
37
- until poll_status == PG::PGRES_POLLING_OK ||
38
- poll_status == PG::PGRES_POLLING_FAILED
39
-
40
- # If the socket needs to read, wait 'til it becomes readable to poll again
41
- case poll_status
42
- when PG::PGRES_POLLING_READING
43
- output_progress " waiting for socket to become readable"
44
- select( [socket], nil, nil, TIMEOUT ) or
45
- raise "Asynchronous connection timed out!"
46
-
47
- # ...and the same for when the socket needs to write
48
- when PG::PGRES_POLLING_WRITING
49
- output_progress " waiting for socket to become writable"
50
- select( nil, [socket], nil, TIMEOUT ) or
51
- raise "Asynchronous connection timed out!"
52
- end
53
-
54
- # Output a status message about the progress
55
- case conn.status
56
- when PG::CONNECTION_STARTED
57
- output_progress " waiting for connection to be made."
58
- when PG::CONNECTION_MADE
59
- output_progress " connection OK; waiting to send."
60
- when PG::CONNECTION_AWAITING_RESPONSE
61
- output_progress " waiting for a response from the server."
62
- when PG::CONNECTION_AUTH_OK
63
- output_progress " received authentication; waiting for backend start-up to finish."
64
- when PG::CONNECTION_SSL_STARTUP
65
- output_progress " negotiating SSL encryption."
66
- when PG::CONNECTION_SETENV
67
- output_progress " negotiating environment-driven parameter settings."
68
- when PG::CONNECTION_NEEDED
69
- output_progress " internal state: connect() needed."
70
- end
71
-
72
- # Check to see if it's finished or failed yet
73
- poll_status = conn.connect_poll
74
- end
75
-
76
- abort "Connect failed: %s" % [ conn.error_message ] unless conn.status == PG::CONNECTION_OK
77
-
78
- output_progress "Sending query"
79
- conn.send_query( "SELECT * FROM pg_stat_activity" )
80
-
81
- # Fetch results until there aren't any more
82
- loop do
83
- output_progress " waiting for a response"
84
-
85
- # Buffer any incoming data on the socket until a full result is ready.
86
- conn.consume_input
87
- while conn.is_busy
88
- select( [socket], nil, nil, TIMEOUT ) or
89
- raise "Timeout waiting for query response."
90
- conn.consume_input
91
- end
92
-
93
- # Fetch the next result. If there isn't one, the query is finished
94
- result = conn.get_result or break
95
-
96
- puts "\n\nQuery result:\n%p\n" % [ result.values ]
97
- end
98
-
99
- output_progress "Done."
100
- conn.finish
101
-
102
- if defined?( progress_thread )
103
- progress_thread.kill
104
- progress_thread.join
105
- end
106
-