pg 0.18.4-x64-mingw32 → 0.19.0.pre20160817083826-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/ChangeLog +686 -167
  5. data/History.rdoc +23 -0
  6. data/README.rdoc +6 -6
  7. data/Rakefile +10 -12
  8. data/Rakefile.cross +6 -6
  9. data/ext/errorcodes.def +16 -0
  10. data/ext/errorcodes.txt +5 -1
  11. data/ext/extconf.rb +9 -1
  12. data/ext/gvl_wrappers.h +4 -0
  13. data/ext/pg.c +1 -1
  14. data/ext/pg.h +6 -3
  15. data/ext/pg_binary_decoder.c +1 -1
  16. data/ext/pg_binary_encoder.c +8 -8
  17. data/ext/pg_coder.c +30 -9
  18. data/ext/pg_connection.c +203 -77
  19. data/ext/pg_copy_coder.c +34 -4
  20. data/ext/pg_result.c +2 -2
  21. data/ext/pg_text_decoder.c +1 -1
  22. data/ext/pg_text_encoder.c +62 -42
  23. data/ext/pg_type_map.c +1 -1
  24. data/ext/pg_type_map_all_strings.c +1 -1
  25. data/ext/pg_type_map_by_class.c +1 -1
  26. data/ext/pg_type_map_by_column.c +1 -1
  27. data/ext/pg_type_map_by_mri_type.c +1 -1
  28. data/ext/pg_type_map_by_oid.c +1 -1
  29. data/ext/pg_type_map_in_ruby.c +1 -1
  30. data/ext/util.c +1 -1
  31. data/lib/2.0/pg_ext.so +0 -0
  32. data/lib/2.1/pg_ext.so +0 -0
  33. data/lib/2.2/pg_ext.so +0 -0
  34. data/lib/2.3/pg_ext.so +0 -0
  35. data/lib/libpq.dll +0 -0
  36. data/lib/pg.rb +3 -3
  37. data/lib/pg/basic_type_mapping.rb +35 -8
  38. data/lib/pg/connection.rb +46 -6
  39. data/lib/pg/result.rb +6 -2
  40. data/lib/pg/text_decoder.rb +7 -0
  41. data/lib/pg/text_encoder.rb +8 -0
  42. data/sample/disk_usage_report.rb +1 -1
  43. data/sample/pg_statistics.rb +1 -1
  44. data/sample/replication_monitor.rb +1 -1
  45. data/spec/helpers.rb +6 -9
  46. data/spec/pg/basic_type_mapping_spec.rb +54 -0
  47. data/spec/pg/connection_spec.rb +130 -23
  48. data/spec/pg/type_map_by_class_spec.rb +1 -1
  49. data/spec/pg/type_map_by_mri_type_spec.rb +1 -1
  50. data/spec/pg/type_spec.rb +82 -2
  51. metadata +33 -35
  52. metadata.gz.sig +0 -0
  53. data/lib/x64-mingw32/libpq.dll +0 -0
@@ -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
 
@@ -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)
@@ -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
 
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: 0.19.0.pre20160817083826
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Michael Granger
@@ -11,27 +11,26 @@ bindir: bin
11
11
  cert_chain:
12
12
  - |
13
13
  -----BEGIN CERTIFICATE-----
14
- MIIDbDCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANnZWQx
15
- GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
16
- HhcNMTUwNDAxMjEyNDEzWhcNMTYwMzMxMjEyNDEzWjA+MQwwCgYDVQQDDANnZWQx
17
- GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
18
- ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDb92mkyYwuGBg1oRxt2tkH
19
- +Uo3LAsaL/APBfSLzy8o3+B3AUHKCjMUaVeBoZdWtMHB75X3VQlvXfZMyBxj59Vo
20
- cDthr3zdao4HnyrzAIQf7BO5Y8KBwVD+yyXCD/N65TTwqsQnO3ie7U5/9ut1rnNr
21
- OkOzAscMwkfQxBkXDzjvAWa6UF4c5c9kR/T79iA21kDx9+bUMentU59aCJtUcbxa
22
- 7kcKJhPEYsk4OdxR9q2dphNMFDQsIdRO8rywX5FRHvcb+qnXC17RvxLHtOjysPtp
23
- EWsYoZMxyC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ZhmU++0Cd7Kq9/TyP/shIP3IjqHjVLCnJ3P6f1cl5rxZ
21
+ gqo+d3BAoDrmPk0rtaf6QopwUw9RBiF8V4HqvpiY+ruJotP5UQDP4/lVOKvA8PI9
22
+ P0GmVbFBrbc7Zt5h78N3UyOK0u+nvOC23BvyHXzCtcFsXCoEkt+Wwh0RFqVZdnjM
23
+ LMO2vULHKKHDdX54K/sbVCj9pN9h1aotNzrEyo55zxn0G9PHg/G3P8nMvAXPkUTe
24
+ brhXrfCwWRvOXA4TAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0G
25
+ A1UdDgQWBBRAHK81igrXodaDj8a8/BIKsaZrETANBgkqhkiG9w0BAQUFAAOCAQEA
26
+ q2VlqIpcq21tixYN4SvBjHbFlZ3Ji8ibEqAF5LnECFgTKHZHLC32Uz3rxrHQpuQm
27
+ ZlzQY8fDCsGc0lh6YrHbUGg7BoDyTJnRMGBnXGHHsXSIYpmC7x+qAxp8xf1AvvEl
28
+ kmcb7LJN+2QzrpgJmDpNIPJMejM5NOvg1e+qvpNWpOf1u/S0HMpw4u4I99wbiZSo
29
+ ZQVoPQLB5AFRh5V3qOk6/qF1TxIAQl+OEqUGT7UWv2XYYaZS2FLbK8MqRyWzAYSc
30
+ PizTJCem24R2bzZN5VGvA5tpqgwytgcFq1PZofgFxK2uKPCS+tmsA8wIjjGzFsnR
31
+ WfgqWGyHn5K4wejsMic/uA==
33
32
  -----END CERTIFICATE-----
34
- date: 2015-11-13 00:00:00.000000000 Z
33
+ date: 2016-08-18 00:00:00.000000000 Z
35
34
  dependencies:
36
35
  - !ruby/object:Gem::Dependency
37
36
  name: hoe-mercurial
@@ -53,14 +52,14 @@ dependencies:
53
52
  requirements:
54
53
  - - "~>"
55
54
  - !ruby/object:Gem::Version
56
- version: '0.7'
55
+ version: '0.8'
57
56
  type: :development
58
57
  prerelease: false
59
58
  version_requirements: !ruby/object:Gem::Requirement
60
59
  requirements:
61
60
  - - "~>"
62
61
  - !ruby/object:Gem::Version
63
- version: '0.7'
62
+ version: '0.8'
64
63
  - !ruby/object:Gem::Dependency
65
64
  name: hoe-highline
66
65
  requirement: !ruby/object:Gem::Requirement
@@ -109,14 +108,14 @@ dependencies:
109
108
  requirements:
110
109
  - - "~>"
111
110
  - !ruby/object:Gem::Version
112
- version: '0.3'
111
+ version: '0.5'
113
112
  type: :development
114
113
  prerelease: false
115
114
  version_requirements: !ruby/object:Gem::Requirement
116
115
  requirements:
117
116
  - - "~>"
118
117
  - !ruby/object:Gem::Version
119
- version: '0.3'
118
+ version: '0.5'
120
119
  - !ruby/object:Gem::Dependency
121
120
  name: hoe
122
121
  requirement: !ruby/object:Gem::Requirement
@@ -162,7 +161,7 @@ dependencies:
162
161
  description: |-
163
162
  Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
164
163
 
165
- It works with {PostgreSQL 8.4 and later}[http://www.postgresql.org/support/versioning/].
164
+ It works with {PostgreSQL 9.1 and later}[http://www.postgresql.org/support/versioning/].
166
165
 
167
166
  A small example usage:
168
167
 
@@ -174,7 +173,7 @@ description: |-
174
173
  conn = PG.connect( dbname: 'sales' )
175
174
  conn.exec( "SELECT * FROM pg_stat_activity" ) do |result|
176
175
  puts " PID | User | Query"
177
- result.each do |row|
176
+ result.each do |row|
178
177
  puts " %7d | %-16s | %s " %
179
178
  row.values_at('procpid', 'usename', 'current_query')
180
179
  end
@@ -261,6 +260,8 @@ files:
261
260
  - lib/2.0/pg_ext.so
262
261
  - lib/2.1/pg_ext.so
263
262
  - lib/2.2/pg_ext.so
263
+ - lib/2.3/pg_ext.so
264
+ - lib/libpq.dll
264
265
  - lib/pg.rb
265
266
  - lib/pg/basic_type_mapping.rb
266
267
  - lib/pg/coder.rb
@@ -271,7 +272,6 @@ files:
271
272
  - lib/pg/text_decoder.rb
272
273
  - lib/pg/text_encoder.rb
273
274
  - lib/pg/type_map_by_column.rb
274
- - lib/x64-mingw32/libpq.dll
275
275
  - sample/array_insert.rb
276
276
  - sample/async_api.rb
277
277
  - sample/async_copyto.rb
@@ -306,9 +306,7 @@ files:
306
306
  - spec/pg_spec.rb
307
307
  homepage: https://bitbucket.org/ged/ruby-pg
308
308
  licenses:
309
- - BSD
310
- - Ruby
311
- - GPL
309
+ - BSD-3-Clause
312
310
  metadata: {}
313
311
  post_install_message:
314
312
  rdoc_options:
@@ -320,15 +318,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
320
318
  requirements:
321
319
  - - ">="
322
320
  - !ruby/object:Gem::Version
323
- version: 1.9.3
321
+ version: 2.0.0
324
322
  required_rubygems_version: !ruby/object:Gem::Requirement
325
323
  requirements:
326
- - - ">="
324
+ - - ">"
327
325
  - !ruby/object:Gem::Version
328
- version: '0'
326
+ version: 1.3.1
329
327
  requirements: []
330
328
  rubyforge_project:
331
- rubygems_version: 2.4.8
329
+ rubygems_version: 2.5.1
332
330
  signing_key:
333
331
  specification_version: 4
334
332
  summary: Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/]
metadata.gz.sig CHANGED
Binary file
Binary file