pg 1.3.4 → 1.3.5

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
  SHA256:
3
- metadata.gz: 474c4e35a7ad4b1699e8a9cba4962442e8a66899489db5f88aeccc41f3323ab2
4
- data.tar.gz: 645b283b84bcd7676353ca62efde6bbd2b1a3feea7fc43ef1921882cce3ee032
3
+ metadata.gz: 0bb3782224d0c471417ceaa47d1355d5a06be2590fb3671fde73882346db0c5c
4
+ data.tar.gz: cd728b238d0b174f02a31c38afbd990177f81eec8516a1c953ee7bade1ddb4c6
5
5
  SHA512:
6
- metadata.gz: 14595674eb04b991f007cf5e2b6a965574f9411ab352a26e3adc602eae72c0f03591d46c9d2e6bf25545cb19734877008868e95952f59a28ad5f1481ff7e0d15
7
- data.tar.gz: 0d9c09338f69f695c751573b086d5feeafbd32781cfbd2b697ab36df898a210adf68e11e164165581fa9fdef39fea98d00b86fe7a08862b3d38709c87bfb1b0d
6
+ metadata.gz: d7b3ad8293281fb830274dc0e3d6e3c59c1dca85ea4f112f0aaf3a7629f61e315747f1e6ecad96e7a9528d42eeb3baafb819b7360d02acfc636ae7cb2d24ef42
7
+ data.tar.gz: f2476f2c7b1950346adf87c3675b838b9c57c909d6d787b50f4cf418ccb51296a02677faac7910378a665daa087f2aa552375f72ca42ba428e539cf07e80392c
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,22 @@
1
+ == v1.3.5 [2022-03-31] Lars Kanis <lars@greiz-reinsdorf.de>
2
+
3
+ Bugfixes:
4
+
5
+ - Handle PGRES_COMMAND_OK in pgresult_stream_any. #447
6
+ Fixes usage when trying to stream the result of a procedure call that returns no results.
7
+
8
+ Enhancements:
9
+
10
+ - Rename BasicTypeRegistry#define_default_types to #register_default_types to use a more consistent terminology.
11
+ Keeping define_default_types for compatibility.
12
+ - BasicTypeRegistry: return self instead of objects by accident.
13
+ This allows call chaining.
14
+ - Add some April fun. #449
15
+
16
+ Documentation:
17
+ - Refine documentation of conn.socket_io and conn.connect_poll
18
+
19
+
1
20
  == v1.3.4 [2022-03-10] Lars Kanis <lars@greiz-reinsdorf.de>
2
21
 
3
22
  Bugfixes:
data/ext/extconf.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require 'pp'
2
4
  require 'mkmf'
3
5
 
@@ -167,3 +169,32 @@ end
167
169
  create_header()
168
170
  create_makefile( "pg_ext" )
169
171
 
172
+
173
+ def message!(important_message)
174
+ message important_message
175
+ if !$stdout.tty? && File.chardev?('/dev/tty')
176
+ File.open('/dev/tty', 'w') do |tty|
177
+ tty.print important_message
178
+ end
179
+ end
180
+ rescue
181
+ end
182
+
183
+ if "2022-04-01" == Time.now.strftime("%Y-%m-%d")
184
+ message! <<-EOM
185
+ ===================================================================
186
+ HEADS UP! Prepare for pg-1.4.2022 ! 🎉🎉🎉
187
+
188
+ Now that psycopg3 has most of the features of ruby-pg, we plan to
189
+ switch to using it as our foundation for the next pg release.
190
+ It will run through pycall and requires a working python setup.
191
+ This will minimize our development and maintenance efforts, since
192
+ it allows us to use one and the same code base for both programming
193
+ languages - ruby and python. 👏😃
194
+
195
+ And we follow the recent merge of the Django and Rails teams! ❤️
196
+
197
+ Stay up-to-date at https://github.com/ged/ruby-pg/issues/449
198
+ ===================================================================
199
+ EOM
200
+ end
data/ext/pg_connection.c CHANGED
@@ -450,17 +450,18 @@ pgconn_s_encrypt_password(VALUE self, VALUE password, VALUE username)
450
450
  * the asynchronous connection is ready
451
451
  *
452
452
  * Example:
453
- * conn = PG::Connection.connect_start("dbname=mydatabase")
454
- * socket = conn.socket_io
453
+ * require "io/wait"
454
+ *
455
+ * conn = PG::Connection.connect_start(dbname: 'mydatabase')
455
456
  * status = conn.connect_poll
456
457
  * while(status != PG::PGRES_POLLING_OK) do
457
458
  * # do some work while waiting for the connection to complete
458
459
  * if(status == PG::PGRES_POLLING_READING)
459
- * if(not select([socket], [], [], 10.0))
460
+ * unless conn.socket_io.wait_readable(10.0)
460
461
  * raise "Asynchronous connection timed out!"
461
462
  * end
462
463
  * elsif(status == PG::PGRES_POLLING_WRITING)
463
- * if(not select([], [socket], [], 10.0))
464
+ * unless conn.socket_io.wait_writable(10.0)
464
465
  * raise "Asynchronous connection timed out!"
465
466
  * end
466
467
  * end
@@ -818,13 +819,15 @@ pgconn_socket(VALUE self)
818
819
  * call-seq:
819
820
  * conn.socket_io() -> IO
820
821
  *
821
- * Fetch a memorized IO object created from the Connection's underlying socket.
822
- * This object can be used for IO.select to wait for events while running
823
- * asynchronous API calls.
822
+ * Fetch an IO object created from the Connection's underlying socket.
823
+ * This object can be used per <tt>socket_io.wait_readable</tt>, <tt>socket_io.wait_writable</tt> or for <tt>IO.select</tt> to wait for events while running asynchronous API calls.
824
+ * <tt>IO#wait_*able</tt> is is <tt>Fiber.scheduler</tt> compatible in contrast to <tt>IO.select</tt>.
825
+ *
826
+ * The IO object can change while the connection is established, but is memorized afterwards.
827
+ * So be sure not to cache the IO object, but repeat calling <tt>conn.socket_io</tt> instead.
824
828
  *
825
- * Using this instead of #socket avoids the problem of the underlying connection
826
- * being closed by Ruby when an IO created using <tt>IO.for_fd(conn.socket)</tt>
827
- * goes out of scope. In contrast to #socket, it also works on Windows.
829
+ * Using this method also works on Windows in contrast to using #socket .
830
+ * It also avoids the problem of the underlying connection being closed by Ruby when an IO created using <tt>IO.for_fd(conn.socket)</tt> goes out of scope.
828
831
  */
829
832
  static VALUE
830
833
  pgconn_socket_io(VALUE self)
@@ -344,10 +344,12 @@ record_isspace(char ch)
344
344
  * oids = conn.exec( "SELECT (NULL::complex).*" )
345
345
  * # Build a type map (PG::TypeMapByColumn) for decoding the "complex" type
346
346
  * dtm = PG::BasicTypeMapForResults.new(conn).build_column_map( oids )
347
- * # Register a record decoder for decoding our type "complex"
348
- * PG::BasicTypeRegistry.register_coder(PG::TextDecoder::Record.new(type_map: dtm, name: "complex"))
349
- * # Apply the basic type registry to all results retrieved from the server
350
- * conn.type_map_for_results = PG::BasicTypeMapForResults.new(conn)
347
+ * # Build a type map and populate with basic types
348
+ * btr = PG::BasicTypeRegistry.new.register_default_types
349
+ * # Register a new record decoder for decoding our type "complex"
350
+ * btr.register_coder(PG::TextDecoder::Record.new(type_map: dtm, name: "complex"))
351
+ * # Apply our basic type registry to all results retrieved from the server
352
+ * conn.type_map_for_results = PG::BasicTypeMapForResults.new(conn, registry: btr)
351
353
  * # Now queries decode the "complex" type (and many basic types) automatically
352
354
  * conn.exec("SELECT * FROM my_table").to_a
353
355
  * # => [{"v1"=>[2.0, 3.0], "v2"=>[4.0, 5.0]}, {"v1"=>[6.0, 7.0], "v2"=>[8.0, 9.0]}]
data/ext/pg_result.c CHANGED
@@ -1457,6 +1457,7 @@ pgresult_stream_any(VALUE self, void (*yielder)(VALUE, int, int, void*), void* d
1457
1457
 
1458
1458
  switch( PQresultStatus(pgresult) ){
1459
1459
  case PGRES_TUPLES_OK:
1460
+ case PGRES_COMMAND_OK:
1460
1461
  if( ntuples == 0 )
1461
1462
  return self;
1462
1463
  rb_raise( rb_eInvalidResultStatus, "PG::Result is not in single row mode");
@@ -22,7 +22,7 @@ require 'pg' unless defined?( PG )
22
22
  # end
23
23
  #
24
24
  # conn = PG.connect
25
- # regi = PG::BasicTypeRegistry.new.define_default_types
25
+ # regi = PG::BasicTypeRegistry.new.register_default_types
26
26
  # regi.register_type(0, 'inet', InetEncoder, InetDecoder)
27
27
  # conn.type_map_for_results = PG::BasicTypeMapForResults.new(conn, registry: regi)
28
28
  class PG::BasicTypeRegistry
@@ -184,6 +184,7 @@ class PG::BasicTypeRegistry
184
184
  name = coder.name || raise(ArgumentError, "name of #{coder.inspect} must be defined")
185
185
  h[:encoder][name] = coder if coder.respond_to?(:encode)
186
186
  h[:decoder][name] = coder if coder.respond_to?(:decode)
187
+ self
187
188
  end
188
189
 
189
190
  # Register the given +encoder_class+ and/or +decoder_class+ for casting a PostgreSQL type.
@@ -193,6 +194,7 @@ class PG::BasicTypeRegistry
193
194
  def register_type(format, name, encoder_class, decoder_class)
194
195
  register_coder(encoder_class.new(name: name, format: format)) if encoder_class
195
196
  register_coder(decoder_class.new(name: name, format: format)) if decoder_class
197
+ self
196
198
  end
197
199
 
198
200
  # Alias the +old+ type to the +new+ type.
@@ -205,10 +207,11 @@ class PG::BasicTypeRegistry
205
207
  @coders_by_name[format][ende].delete(new)
206
208
  end
207
209
  end
210
+ self
208
211
  end
209
212
 
210
213
  # Populate the registry with all builtin types of ruby-pg
211
- def define_default_types
214
+ def register_default_types
212
215
  register_type 0, 'int2', PG::TextEncoder::Integer, PG::TextDecoder::Integer
213
216
  alias_type 0, 'int4', 'int2'
214
217
  alias_type 0, 'int8', 'int2'
@@ -281,8 +284,10 @@ class PG::BasicTypeRegistry
281
284
  self
282
285
  end
283
286
 
287
+ alias define_default_types register_default_types
288
+
284
289
  # @private
285
- DEFAULT_TYPE_REGISTRY = PG::BasicTypeRegistry.new.define_default_types
290
+ DEFAULT_TYPE_REGISTRY = PG::BasicTypeRegistry.new.register_default_types
286
291
 
287
292
  # Delegate class method calls to DEFAULT_TYPE_REGISTRY
288
293
  class << self
data/lib/pg/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module PG
2
2
  # Library version
3
- VERSION = '1.3.4'
3
+ VERSION = '1.3.5'
4
4
  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: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -36,7 +36,7 @@ cert_chain:
36
36
  oL1mUdzB8KrZL4/WbG5YNX6UTtJbIOu9qEFbBAy4/jtIkJX+dlNoFwd4GXQW1YNO
37
37
  nA==
38
38
  -----END CERTIFICATE-----
39
- date: 2022-03-10 00:00:00.000000000 Z
39
+ date: 2022-03-31 00:00:00.000000000 Z
40
40
  dependencies: []
41
41
  description: Pg is the Ruby interface to the PostgreSQL RDBMS. It works with PostgreSQL
42
42
  9.3 and later.
metadata.gz.sig CHANGED
Binary file