pg 0.19.0.pre20160817083826 → 0.19.0.pre20160820113039

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
  SHA1:
3
- metadata.gz: c49e1dff958fe6dd764cfaca8da5a8b5e73e4273
4
- data.tar.gz: 641472a239e3b4b94d6d4a3bf4ccfeccc04833a4
3
+ metadata.gz: 8058186c6bc4c34b0872a6ff898dd79402a68a5f
4
+ data.tar.gz: 3571df1473fea4349b51890f8c0ab8449ed42da4
5
5
  SHA512:
6
- metadata.gz: 7b59477570b1d6201d05686f1335fd2ea24b57824a1f686925f7f9f12730a5a5a9fdd9492a85d9700bd2c4c3fd57979b28b09d6b9745af3b016713c379009b3a
7
- data.tar.gz: aa58b0f6a12689e09eb95c514cdadd34591862aa3b0e70065ce06dc31a0d0a2dc6703883e4bf8fd385ac1eecffc8fc384dd728972d1896ad435e8901a3517ab4
6
+ metadata.gz: c1737c25dc56f669af2c1b0dc2a4fa3b6bc83233557b628da56b441c0fd2e8dab6ff8078b5687252a3cc932e8c63cd4a96e059b79745c545d782cdf685b47645
7
+ data.tar.gz: 01c63d8a07955cd36590d61d7c1beb43e9c5c0712f907ad9377672035efd45893a9ad15c01f51df3173a15f2780d29e1cdbe1126d365efdb7fb28d4fc9819a91
Binary file
Binary file
data/BSDL CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 1993-2010 Yukihiro Matsumoto. All rights reserved.
1
+ Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
2
2
 
3
3
  Redistribution and use in source and binary forms, with or without
4
4
  modification, are permitted provided that the following conditions
@@ -19,4 +19,4 @@ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
19
  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
20
  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
21
  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
- SUCH DAMAGE.
22
+ SUCH DAMAGE.
@@ -1,14 +1,26 @@
1
1
  == v0.19.0 [YYYY-MM-DD] Michael Granger <ged@FaerieMUD.org>
2
2
 
3
+ - Deprecate Ruby 1.9
4
+
3
5
  Enhancements:
4
6
  - Respect and convert character encoding of all strings sent
5
7
  to the server. #231
6
8
  - Add PostgreSQL-9.5 functions PQsslInUse(), PQsslAttribute()
7
9
  and PQsslAttributeNames().
8
10
  - Various documentation fixes and improvements.
11
+ - Add mechanism to build without pg_config:
12
+ gem install pg -- --with-pg-config=ignore
13
+ - Update Windows binary gems to Ruby-2.3, PostgreSQL 9.5.4 and
14
+ OpenSSL 1.0.2f.
15
+ - Add JSON coders and add them to BasicTypeMapForResults and
16
+ BasicTypeMapBasedOnResult
17
+ - Allow build from git per bundler.
9
18
 
10
19
  Bugfixes:
11
20
  - Release GVL while calling PQsetClientEncoding(). #245
21
+ - Add __EXTENSIONS__ to Solaris/SmartOS for Ruby >= 2.3.x. #236
22
+ - Fix wrong exception when running SQL while in Connection#copy_data
23
+ block for output
12
24
 
13
25
 
14
26
  == v0.18.4 [2015-11-13] Michael Granger <ged@FaerieMUD.org>
@@ -11,7 +11,7 @@ docs :: http://deveiate.org/code/pg
11
11
 
12
12
  Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
13
13
 
14
- It works with {PostgreSQL 8.4 and later}[http://www.postgresql.org/support/versioning/].
14
+ It works with {PostgreSQL 9.1 and later}[http://www.postgresql.org/support/versioning/].
15
15
 
16
16
  A small example usage:
17
17
 
@@ -37,10 +37,10 @@ A small example usage:
37
37
 
38
38
  == Requirements
39
39
 
40
- * Ruby 1.9.3-p392, or 2.0.0-p0.
41
- * PostgreSQL 8.4.x or later (with headers, -dev packages, etc).
40
+ * Ruby 2.2
41
+ * PostgreSQL 9.1.x or later (with headers, -dev packages, etc).
42
42
 
43
- It may work with earlier versions of Ruby/PostgreSQL as well, but those are
43
+ It usually work with earlier versions of Ruby/PostgreSQL as well, but those are
44
44
  not regularly tested.
45
45
 
46
46
 
@@ -66,6 +66,10 @@ There's also {a Google+ group}[http://goo.gl/TFy1U] and a
66
66
  {mailing list}[http://groups.google.com/group/ruby-pg] if you get stuck, or just
67
67
  want to chat about something.
68
68
 
69
+ If you want to install as a signed gem, the public certs of the gem signers
70
+ can be found in {the `certs` directory}[https://bitbucket.org/ged/ruby-pg/src/tip/certs/]
71
+ of the repository.
72
+
69
73
 
70
74
  == Type Casts
71
75
 
@@ -133,7 +137,7 @@ Lars Kanis <lars@greiz-reinsdorf.de>.
133
137
 
134
138
  == Copying
135
139
 
136
- Copyright (c) 1997-2015 by the authors.
140
+ Copyright (c) 1997-2016 by the authors.
137
141
 
138
142
  * Jeff Davis <ruby-pg@j-davis.com>
139
143
  * Guy Decoux (ts) <decoux@moulon.inra.fr>
@@ -145,7 +149,7 @@ Copyright (c) 1997-2015 by the authors.
145
149
  * Noboru Saitou <noborus@netlab.jp>
146
150
 
147
151
  You may redistribute this software under the same terms as Ruby itself; see
148
- http://www.ruby-lang.org/en/LICENSE.txt or the LICENSE file in the source
152
+ https://www.ruby-lang.org/en/about/license.txt or the BSDL file in the source
149
153
  for details.
150
154
 
151
155
  Portions of the code are from the PostgreSQL project, and are distributed
data/Rakefile CHANGED
@@ -189,9 +189,7 @@ task :update_error_codes do
189
189
 
190
190
  ERRORCODES_TXT = "ext/errorcodes.txt"
191
191
  sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
192
- end
193
192
 
194
- file 'ext/errorcodes.def' => ['ext/errorcodes.rb', 'ext/errorcodes.txt'] do
195
193
  ruby 'ext/errorcodes.rb', 'ext/errorcodes.txt', 'ext/errorcodes.def'
196
194
  end
197
195
 
@@ -205,7 +203,6 @@ file GEMSPEC => __FILE__
205
203
  task GEMSPEC do |task|
206
204
  spec = $hoespec.spec
207
205
  spec.files.delete( '.gemtest' )
208
- spec.signing_key = nil
209
206
  spec.version = "#{spec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
210
207
  spec.cert_chain = [ 'certs/ged.pem' ]
211
208
  File.open( task.name, 'w' ) do |fh|
data/ext/pg.c CHANGED
@@ -1,12 +1,13 @@
1
1
  /*
2
2
  * pg.c - Toplevel extension
3
- * $Id: pg.c,v b60c89ee93c8 2015/02/11 20:59:36 lars $
3
+ * $Id: pg.c,v c77d0997b4e4 2016/08/20 17:30:03 ged $
4
4
  *
5
5
  * Author/s:
6
6
  *
7
7
  * - Jeff Davis <ruby-pg@j-davis.com>
8
8
  * - Guy Decoux (ts) <decoux@moulon.inra.fr>
9
9
  * - Michael Granger <ged@FaerieMUD.org>
10
+ * - Lars Kanis <lars@greiz-reinsdorf.de>
10
11
  * - Dave Lee
11
12
  * - Eiji Matsumoto <usagi@ruby.club.or.jp>
12
13
  * - Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -15,10 +16,10 @@
15
16
  * See Contributors.rdoc for the many additional fine people that have contributed
16
17
  * to this library over the years.
17
18
  *
18
- * Copyright (c) 1997-2015 by the authors.
19
+ * Copyright (c) 1997-2016 by the authors.
19
20
  *
20
21
  * You may redistribute this software under the same terms as Ruby itself; see
21
- * http://www.ruby-lang.org/en/LICENSE.txt or the LICENSE file in the source
22
+ * https://www.ruby-lang.org/en/about/license.txt or the BSDL file in the source
22
23
  * for details.
23
24
  *
24
25
  * Portions of the code are from the PostgreSQL project, and are distributed
@@ -188,7 +188,8 @@ module PG::BasicTypeRegistry
188
188
  # register_type 'polygon', OID::Text.new
189
189
  # register_type 'circle', OID::Text.new
190
190
  # register_type 'hstore', OID::Hstore.new
191
- # register_type 'json', OID::Json.new
191
+ register_type 0, 'json', PG::TextEncoder::JSON, PG::TextDecoder::JSON
192
+ alias_type 0, 'jsonb', 'json'
192
193
  # register_type 'citext', OID::Text.new
193
194
  # register_type 'ltree', OID::Text.new
194
195
  #
@@ -339,10 +340,11 @@ end
339
340
  # OIDs of supported type casts are not hard-coded in the sources, but are retrieved from the
340
341
  # PostgreSQL's pg_type table in PG::BasicTypeMapForQueries.new .
341
342
  #
342
- # Query params are type casted based on the MRI internal type of the given value.
343
+ # Query params are type casted based on the class of the given value.
343
344
  #
344
345
  # Higher level libraries will most likely not make use of this class, but use their
345
- # own set of rules to choose suitable encoders and decoders.
346
+ # own derivation of PG::TypeMapByClass or another set of rules to choose suitable
347
+ # encoders and decoders for the values to be sent.
346
348
  #
347
349
  # Example:
348
350
  # conn = PG::Connection.new
@@ -186,7 +186,7 @@ class PG::Connection
186
186
  raise
187
187
  else
188
188
  res = get_last_result
189
- if res.result_status != PGRES_COMMAND_OK
189
+ if !res || res.result_status != PGRES_COMMAND_OK
190
190
  while get_copy_data
191
191
  end
192
192
  while get_result
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'date'
4
+ require 'json'
4
5
 
5
6
  module PG
6
7
  module TextDecoder
@@ -39,6 +40,12 @@ module PG
39
40
  end
40
41
  end
41
42
  end
43
+
44
+ class JSON < SimpleDecoder
45
+ def decode(string, tuple=nil, field=nil)
46
+ ::JSON.load(string)
47
+ end
48
+ end
42
49
  end
43
50
  end # module PG
44
51
 
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'json'
4
+
3
5
  module PG
4
6
  module TextEncoder
5
7
  class Date < SimpleEncoder
@@ -22,6 +24,12 @@ module PG
22
24
  value.respond_to?(:strftime) ? value.strftime(STRFTIME_ISO_DATETIME_WITH_TIMEZONE) : value
23
25
  end
24
26
  end
27
+
28
+ class JSON < SimpleEncoder
29
+ def encode(value)
30
+ ::JSON.dump(value)
31
+ end
32
+ end
25
33
  end
26
34
  end # module PG
27
35
 
@@ -166,6 +166,27 @@ describe 'Basic type mapping' do
166
166
  end
167
167
  end
168
168
 
169
+ it "should do JSON conversions", :postgresql_94 do
170
+ [0].each do |format|
171
+ ['JSON', 'JSONB'].each do |type|
172
+ res = @conn.exec( "SELECT CAST('123' AS #{type}),
173
+ CAST('12.3' AS #{type}),
174
+ CAST('true' AS #{type}),
175
+ CAST('false' AS #{type}),
176
+ CAST('null' AS #{type}),
177
+ CAST('[1, \"a\", null]' AS #{type}),
178
+ CAST('{\"b\" : [2,3]}' AS #{type})", [], format )
179
+ expect( res.getvalue(0,0) ).to eq( 123 )
180
+ expect( res.getvalue(0,1) ).to be_within(0.1).of( 12.3 )
181
+ expect( res.getvalue(0,2) ).to eq( true )
182
+ expect( res.getvalue(0,3) ).to eq( false )
183
+ expect( res.getvalue(0,4) ).to eq( nil )
184
+ expect( res.getvalue(0,5) ).to eq( [1, "a", nil] )
185
+ expect( res.getvalue(0,6) ).to eq( {"b" => [2, 3]} )
186
+ end
187
+ end
188
+ end
189
+
169
190
  it "should do array type conversions" do
170
191
  [0].each do |format|
171
192
  res = @conn.exec( "SELECT CAST('{1,2,3}' AS INT2[]), CAST('{{1,2},{3,4}}' AS INT2[][]),
@@ -228,6 +249,39 @@ describe 'Basic type mapping' do
228
249
  res = @conn.exec( "SELECT * FROM copytable" )
229
250
  expect( res.values ).to eq( [['a', '123', '{5,4,3}'], ['b', '234', '{2,3}']] )
230
251
  end
252
+
253
+ it "can do JSON conversions", :postgresql_94 do
254
+ ['JSON', 'JSONB'].each do |type|
255
+ sql = "SELECT CAST('123' AS #{type}),
256
+ CAST('12.3' AS #{type}),
257
+ CAST('true' AS #{type}),
258
+ CAST('false' AS #{type}),
259
+ CAST('null' AS #{type}),
260
+ CAST('[1, \"a\", null]' AS #{type}),
261
+ CAST('{\"b\" : [2,3]}' AS #{type})"
262
+
263
+ tm = basic_type_mapping.build_column_map( @conn.exec( sql ) )
264
+ expect( tm.coders.map(&:name) ).to eq( [type.downcase] * 7 )
265
+
266
+ res = @conn.exec_params( "SELECT $1, $2, $3, $4, $5, $6, $7",
267
+ [ 123,
268
+ 12.3,
269
+ true,
270
+ false,
271
+ nil,
272
+ [1, "a", nil],
273
+ {"b" => [2, 3]},
274
+ ], 0, tm )
275
+
276
+ expect( res.getvalue(0,0) ).to eq( "123" )
277
+ expect( res.getvalue(0,1) ).to eq( "12.3" )
278
+ expect( res.getvalue(0,2) ).to eq( "true" )
279
+ expect( res.getvalue(0,3) ).to eq( "false" )
280
+ expect( res.getvalue(0,4) ).to eq( nil )
281
+ expect( res.getvalue(0,5).gsub(" ","") ).to eq( "[1,\"a\",null]" )
282
+ expect( res.getvalue(0,6).gsub(" ","") ).to eq( "{\"b\":[2,3]}" )
283
+ end
284
+ end
231
285
  end
232
286
 
233
287
  context "with usage of result oids for copy encoder selection" do
@@ -643,6 +643,31 @@ describe PG::Connection do
643
643
  expect( @conn ).to still_be_usable
644
644
  end
645
645
 
646
+ it "gracefully handle SQL statements while in #copy_data for input" do
647
+ @conn.exec "ROLLBACK"
648
+ @conn.transaction do
649
+ @conn.exec( "CREATE TEMP TABLE copytable (col1 INT)" )
650
+ expect {
651
+ @conn.copy_data( "COPY copytable FROM STDOUT" ) do |res|
652
+ @conn.exec "SELECT 1"
653
+ end
654
+ }.to raise_error(PG::Error, /no COPY in progress/)
655
+ end
656
+ expect( @conn ).to still_be_usable
657
+ end
658
+
659
+ it "gracefully handle SQL statements while in #copy_data for output" do
660
+ @conn.exec "ROLLBACK"
661
+ @conn.transaction do
662
+ expect {
663
+ @conn.copy_data( "COPY (VALUES(1), (2)) TO STDOUT" ) do |res|
664
+ @conn.exec "SELECT 3"
665
+ end
666
+ }.to raise_error(PG::Error, /no COPY in progress/)
667
+ end
668
+ expect( @conn ).to still_be_usable
669
+ end
670
+
646
671
  it "should raise an error for non copy statements in #copy_data" do
647
672
  expect {
648
673
  @conn.copy_data( "SELECT 1" ){}
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.19.0.pre20160817083826
4
+ version: 0.19.0.pre20160820113039
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -11,26 +11,32 @@ bindir: bin
11
11
  cert_chain:
12
12
  - |
13
13
  -----BEGIN CERTIFICATE-----
14
- MIIDMDCCAhigAwIBAgIBAjANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANnZWQx
14
+ MIIEbDCCAtSgAwIBAgIBATANBgkqhkiG9w0BAQsFADA+MQwwCgYDVQQDDANnZWQx
15
15
  GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
16
- HhcNMTYwNjAyMDE1NTQ2WhcNMTcwNjAyMDE1NTQ2WjA+MQwwCgYDVQQDDANnZWQx
16
+ HhcNMTYwODIwMTgxNzQyWhcNMTcwODIwMTgxNzQyWjA+MQwwCgYDVQQDDANnZWQx
17
17
  GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
18
- ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDb92mkyYwuGBg1oRxt2tkH
19
- +Uo3LAsaL/APBfSLzy8o3+B3AUHKCjMUaVeBoZdWtMHB75X3VQlvXfZMyBxj59Vo
20
- cDthr3zdao4HnyrzAIQf7BO5Y8KBwVD+yyXCD/N65TTwqsQnO3ie7U5/9ut1rnNr
21
- OkOzAscMwkfQxBkXDzjvAWa6UF4c5c9kR/T79iA21kDx9+bUMentU59aCJtUcbxa
22
- 7kcKJhPEYsk4OdxR9q2dphNMFDQsIdRO8rywX5FRHvcb+qnXC17RvxLHtOjysPtp
23
- EWsYoZMxyCDJpUqbwoeiM+tAHoz2ABMv3Ahie3Qeb6+MZNAtMmaWfBx3dg2u+/WN
24
- AgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBSZ0hCV
25
- qoHr122fGKelqffzEQBhszANBgkqhkiG9w0BAQUFAAOCAQEAF2XCzj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BOBEWdlZEBGYWVyaWVNVUQub3JnMBwGA1UdEgQVMBOBEWdlZEBG
29
+ YWVyaWVNVUQub3JnMA0GCSqGSIb3DQEBCwUAA4IBgQAPJzKiT0zBU7kpqe0aS2qb
30
+ FI0PJ4y5I8buU4IZGUD5NEt/N7pZNfOyBxkrZkXhS44Fp+xwBH5ebLbq/WY78Bqd
31
+ db0z6ZgW4LMYMpWFfbXsRbd9TU2f52L8oMAhxOvF7Of5qJMVWuFQ8FPagk2iHrdH
32
+ inYLQagqAF6goWTXgAJCdPd6SNeeSNqA6vlY7CV1Jh5kfNJJ6xu/CVij1GzCLu/5
33
+ DMOr26DBv+qLJRRC/2h34uX71q5QgeOyxvMg+7V3u/Q06DXyQ2VgeeqiwDFFpEH0
34
+ PFkdPO6ZqbTRcLfNH7mFgCBJjsfSjJrn0sPBlYyOXgCoByfZnZyrIMH/UY+lgQqS
35
+ 6Von1VDsfQm0eJh5zYZD64ZF86phSR7mUX3mXItwH04HrZwkWpvgd871DZVR3i1n
36
+ w8aNA5re5+Rt/Vvjxj5AcEnZnZiz5x959NaddQocX32Z1unHw44pzRNUur1GInfW
37
+ p4vpx2kUSFSAGjtCbDGTNV2AH8w9OU4xEmNz8c5lyoA=
32
38
  -----END CERTIFICATE-----
33
- date: 2016-08-17 00:00:00.000000000 Z
39
+ date: 2016-08-20 00:00:00.000000000 Z
34
40
  dependencies:
35
41
  - !ruby/object:Gem::Dependency
36
42
  name: hoe-mercurial
@@ -161,7 +167,7 @@ dependencies:
161
167
  description: |-
162
168
  Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
163
169
 
164
- It works with {PostgreSQL 8.4 and later}[http://www.postgresql.org/support/versioning/].
170
+ It works with {PostgreSQL 9.1 and later}[http://www.postgresql.org/support/versioning/].
165
171
 
166
172
  A small example usage:
167
173
 
Binary file