pg 0.18.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data/BSDL +2 -2
- data/ChangeLog +798 -7
- data/History.rdoc +96 -0
- data/Manifest.txt +0 -18
- data/README.rdoc +16 -11
- data/Rakefile +31 -24
- data/Rakefile.cross +21 -24
- data/ext/errorcodes.def +33 -0
- data/ext/errorcodes.txt +15 -1
- data/ext/extconf.rb +22 -33
- data/ext/gvl_wrappers.c +4 -0
- data/ext/gvl_wrappers.h +27 -39
- data/ext/pg.c +18 -50
- data/ext/pg.h +13 -80
- data/ext/pg_binary_decoder.c +3 -1
- data/ext/pg_binary_encoder.c +14 -12
- data/ext/pg_coder.c +31 -10
- data/ext/pg_connection.c +340 -225
- data/ext/pg_copy_coder.c +34 -4
- data/ext/pg_result.c +24 -22
- data/ext/pg_text_decoder.c +3 -1
- data/ext/pg_text_encoder.c +65 -42
- data/ext/pg_type_map.c +20 -13
- data/ext/pg_type_map_by_column.c +7 -7
- data/lib/pg/basic_type_mapping.rb +35 -8
- data/lib/pg/connection.rb +53 -12
- data/lib/pg/result.rb +10 -5
- data/lib/pg/text_decoder.rb +7 -0
- data/lib/pg/text_encoder.rb +8 -0
- data/lib/pg.rb +18 -10
- data/spec/helpers.rb +8 -15
- data/spec/pg/basic_type_mapping_spec.rb +54 -0
- data/spec/pg/connection_spec.rb +390 -209
- data/spec/pg/result_spec.rb +14 -7
- data/spec/pg/type_map_by_class_spec.rb +2 -2
- data/spec/pg/type_map_by_mri_type_spec.rb +1 -1
- data/spec/pg/type_spec.rb +90 -3
- data/spec/pg_spec.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +56 -69
- metadata.gz.sig +0 -0
- data/sample/array_insert.rb +0 -20
- data/sample/async_api.rb +0 -106
- data/sample/async_copyto.rb +0 -39
- data/sample/async_mixed.rb +0 -56
- data/sample/check_conn.rb +0 -21
- data/sample/copyfrom.rb +0 -81
- data/sample/copyto.rb +0 -19
- data/sample/cursor.rb +0 -21
- data/sample/disk_usage_report.rb +0 -186
- data/sample/issue-119.rb +0 -94
- data/sample/losample.rb +0 -69
- data/sample/minimal-testcase.rb +0 -17
- data/sample/notify_wait.rb +0 -72
- data/sample/pg_statistics.rb +0 -294
- data/sample/replication_monitor.rb +0 -231
- data/sample/test_binary_values.rb +0 -33
- data/sample/wal_shipper.rb +0 -434
- data/sample/warehouse_partitions.rb +0 -320
data/spec/pg/result_spec.rb
CHANGED
@@ -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"
|
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
|
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
|
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
|
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
|
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"
|
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 =
|
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[
|
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',
|
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',
|
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
|
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
|
@@ -206,6 +221,20 @@ describe "PG::Type derivations" do
|
|
206
221
|
expect( quoted_type.encode(['schema','table','col']) ).to eq( %["schema"."table"."col"] )
|
207
222
|
expect( quoted_type.encode(['A.','.B']) ).to eq( %["A.".".B"] )
|
208
223
|
expect( quoted_type.encode(%['A"."B']) ).to eq( %["'A"".""B'"] )
|
224
|
+
expect( quoted_type.encode( nil ) ).to be_nil
|
225
|
+
end
|
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
|
+
|
234
|
+
it "will raise a TypeError for invalid arguments to quote_ident" do
|
235
|
+
quoted_type = PG::TextEncoder::Identifier.new
|
236
|
+
expect{ quoted_type.encode( [nil] ) }.to raise_error(TypeError)
|
237
|
+
expect{ quoted_type.encode( [['a']] ) }.to raise_error(TypeError)
|
209
238
|
end
|
210
239
|
end
|
211
240
|
|
@@ -213,6 +242,12 @@ describe "PG::Type derivations" do
|
|
213
242
|
expect( intenc_incrementer.encode(3) ).to eq( "4 " )
|
214
243
|
end
|
215
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
|
+
|
216
251
|
it "should return when ruby encoder returns non string values" do
|
217
252
|
expect( intenc_incrementer_with_int_result.encode(3) ).to eq( 4 )
|
218
253
|
end
|
@@ -440,9 +475,18 @@ describe "PG::Type derivations" do
|
|
440
475
|
end
|
441
476
|
|
442
477
|
context 'array of types with encoder in ruby space' do
|
443
|
-
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
|
444
486
|
array_type = PG::TextEncoder::Array.new elements_type: intenc_incrementer, needs_quotation: true
|
445
|
-
|
487
|
+
r = array_type.encode([3,4], Encoding::CP850)
|
488
|
+
expect( r ).to eq( %[{"4 ","5 "}] )
|
489
|
+
expect( r.encoding ).to eq( Encoding::CP850 )
|
446
490
|
end
|
447
491
|
|
448
492
|
it 'encodes without quotation' do
|
@@ -450,6 +494,20 @@ describe "PG::Type derivations" do
|
|
450
494
|
expect( array_type.encode([3,4]) ).to eq( %[{4 ,5 }] )
|
451
495
|
end
|
452
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
|
+
|
453
511
|
it "should raise when ruby encoder returns non string values" do
|
454
512
|
array_type = PG::TextEncoder::Array.new elements_type: intenc_incrementer_with_int_result, needs_quotation: false
|
455
513
|
expect{ array_type.encode([3,4]) }.to raise_error(TypeError)
|
@@ -466,6 +524,13 @@ describe "PG::Type derivations" do
|
|
466
524
|
quoted_type = PG::TextEncoder::QuotedLiteral.new elements_type: textenc_string_array
|
467
525
|
expect( quoted_type.encode(["'A\",","\\B'"]) ).to eq( %['{"''A\\",","\\\\B''"}'] )
|
468
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
|
469
534
|
end
|
470
535
|
end
|
471
536
|
|
@@ -515,9 +580,19 @@ describe "PG::Type derivations" do
|
|
515
580
|
expect( e.encode("(\xFBm") ).to eq("KPtt")
|
516
581
|
end
|
517
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
|
+
|
518
590
|
it "should encode Strings as base64 in BinaryDecoder" do
|
519
591
|
e = PG::BinaryDecoder::ToBase64.new
|
520
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)
|
521
596
|
end
|
522
597
|
|
523
598
|
it "should encode Integers as base64" do
|
@@ -604,6 +679,12 @@ describe "PG::Type derivations" do
|
|
604
679
|
expect( encoder.encode([:xyz, 123, 2456, 34567, 456789, 5678901, [1,2,3], 12.1, "abcdefg", nil]) ).
|
605
680
|
to eq("xyz\t123\t2456\t34567\t456789\t5678901\t[1, 2, 3]\t12.1\tabcdefg\t\\N\n")
|
606
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
|
607
688
|
end
|
608
689
|
|
609
690
|
context "with TypeMapByClass" do
|
@@ -668,6 +749,12 @@ describe "PG::Type derivations" do
|
|
668
749
|
it "should decode different types of Ruby objects" do
|
669
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"] )
|
670
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
|
671
758
|
end
|
672
759
|
end
|
673
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"
|
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.
|
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
|
-
|
14
|
+
MIIEbDCCAtSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANnZWQx
|
15
15
|
GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
|
16
|
-
|
16
|
+
HhcNMTcwOTI3MDAzMDQ0WhcNMTgwOTI3MDAzMDQ0WjA+MQwwCgYDVQQDDANnZWQx
|
17
17
|
GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
18
|
+
ggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC/JWGRHO+USzR97vXjkFgt
|
19
|
+
83qeNf2KHkcvrRTSnR64i6um/ziin0I0oX23H7VYrDJC9A/uoUa5nGRJS5Zw/+wW
|
20
|
+
ENcvWVZS4iUzi4dsYJGY6yEOsXh2CcF46+QevV8iE+UmbkU75V7Dy1JCaUOyizEt
|
21
|
+
TH5UHsOtUU7k9TYARt/TgYZKuaoAMZZd5qyVqhF1vV+7/Qzmp89NGflXf2xYP26a
|
22
|
+
4MAX2qqKX/FKXqmFO+AGsbwYTEds1mksBF3fGsFgsQWxftG8GfZQ9+Cyu2+l1eOw
|
23
|
+
cZ+lPcg834G9DrqW2zhqUoLr1MTly4pqxYGb7XoDhoR7dd1kFE2a067+DzWC/ADt
|
24
|
+
+QkcqWUm5oh1fN0eqr7NsZlVJDulFgdiiYPQiIN7UNsii4Wc9aZqBoGcYfBeQNPZ
|
25
|
+
soo/6za/bWajOKUmDhpqvaiRv9EDpVLzuj53uDoukMMwxCMfgb04+ckQ0t2G7wqc
|
26
|
+
/D+K9JW9DDs3Yjgv9k4h7YMhW5gftosd+NkNC/+Y2CkCAwEAAaN1MHMwCQYDVR0T
|
27
|
+
BAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFHKN/nkRusdqCJEuq3lgB3fJvyTg
|
28
|
+
MBwGA1UdEQQVMBOBEWdlZEBGYWVyaWVNVUQub3JnMBwGA1UdEgQVMBOBEWdlZEBG
|
29
|
+
YWVyaWVNVUQub3JnMA0GCSqGSIb3DQEBBQUAA4IBgQB/qyi5pCjK8ceoKalfVAjS
|
30
|
+
vG64FEnLnD1bm39T5UaFIRmo+abZtfpg2QhwKvPbPjOicau2+m+MDQ2Cc3tgyaC3
|
31
|
+
dZxcP6w8APFg4AId09uWAZKf0xajvBMS2aOz8Bbmag6fwqRRkTMqsNYnmqcF7aRT
|
32
|
+
DuEzbEMfaOUYjU9RuB48vr4q8yRft0ww+3jq5iwNkrX1buL2pwBbyvgms6D/BV41
|
33
|
+
MaTVMjsHqJUwU2xVfhGtxGAWAer5S1HGYHkbio6mGVtiie0uWjmnzi7ppIlMr48a
|
34
|
+
7BNTsoZ+/JRk3iQWmmNsyFT7xfqBKye7cH11BX8V8P4MeGB5YWlMI+Myj5DZY3fQ
|
35
|
+
st2AGD4rb1l0ia7PfubcBThSIdz61eCb8gRi/RiZZwb3/7+eyEncLJzt2Ob9fGSF
|
36
|
+
X0qdrKi+2aZZ0NGuFj9AItBsVmAvkBGIpX4TEKQp5haEbPpmaqO5nIIhV26PXmyT
|
37
|
+
OMKv6pWsoS81vw5KAGBmfX8nht/Py90DQrbRvakATGI=
|
33
38
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
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.
|
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.
|
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:
|
84
|
+
name: rake-compiler
|
80
85
|
requirement: !ruby/object:Gem::Requirement
|
81
86
|
requirements:
|
82
87
|
- - "~>"
|
83
88
|
- !ruby/object:Gem::Version
|
84
|
-
version: '
|
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: '
|
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.
|
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.
|
113
|
+
version: '0.6'
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 0.6.2
|
106
117
|
- !ruby/object:Gem::Dependency
|
107
|
-
name:
|
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
|
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
|
130
|
+
version: '1.0'
|
120
131
|
- !ruby/object:Gem::Dependency
|
121
|
-
name:
|
132
|
+
name: rspec
|
122
133
|
requirement: !ruby/object:Gem::Requirement
|
123
134
|
requirements:
|
124
135
|
- - "~>"
|
125
136
|
- !ruby/object:Gem::Version
|
126
|
-
version: '3.
|
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.
|
144
|
+
version: '3.5'
|
134
145
|
- !ruby/object:Gem::Dependency
|
135
|
-
name:
|
146
|
+
name: rdoc
|
136
147
|
requirement: !ruby/object:Gem::Requirement
|
137
148
|
requirements:
|
138
149
|
- - "~>"
|
139
150
|
- !ruby/object:Gem::Version
|
140
|
-
version: '1
|
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
|
158
|
+
version: '5.1'
|
148
159
|
- !ruby/object:Gem::Dependency
|
149
|
-
name:
|
160
|
+
name: hoe
|
150
161
|
requirement: !ruby/object:Gem::Requirement
|
151
162
|
requirements:
|
152
163
|
- - "~>"
|
153
164
|
- !ruby/object:Gem::Version
|
154
|
-
version: '3.
|
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.
|
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
|
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
|
-
|
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,17 +296,11 @@ 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:
|
312
|
-
- "
|
313
|
-
- fivefish
|
314
|
-
- "-t"
|
315
|
-
- 'pg: The Ruby Interface to PostgreSQL'
|
316
|
-
- "-m"
|
303
|
+
- "--main"
|
317
304
|
- README.rdoc
|
318
305
|
require_paths:
|
319
306
|
- lib
|
@@ -321,7 +308,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
321
308
|
requirements:
|
322
309
|
- - ">="
|
323
310
|
- !ruby/object:Gem::Version
|
324
|
-
version:
|
311
|
+
version: 2.0.0
|
325
312
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
326
313
|
requirements:
|
327
314
|
- - ">="
|
@@ -329,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
329
316
|
version: '0'
|
330
317
|
requirements: []
|
331
318
|
rubyforge_project:
|
332
|
-
rubygems_version: 2.
|
319
|
+
rubygems_version: 2.7.3
|
333
320
|
signing_key:
|
334
321
|
specification_version: 4
|
335
322
|
summary: Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/]
|
metadata.gz.sig
CHANGED
Binary file
|
data/sample/array_insert.rb
DELETED
@@ -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
|
-
|