pg 1.3.0.rc2 → 1.3.0.rc3

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: '01977a78278505c93856525a241f0f1bd8d4aefbec15c2851ee3acf27f57b22a'
4
- data.tar.gz: b570352e689abc3eef0b129b5533bdecf814b0587a9852d9c0137880372c9fdd
3
+ metadata.gz: 3b18ac1f1e20350b0ecaba8a4ac2f7ce03595832032df15656bec776e5cc7122
4
+ data.tar.gz: f53771eb5bbd48eaf298f7eecba977a5eeb082dfc59700f0f086151bf646d037
5
5
  SHA512:
6
- metadata.gz: e4b30c1e706f276d6e623a5171b17084923fb858c7d0f5986b8baba37b3403aa79e9a044ec3c787da99a7fe51d1efb5772ae64512e7df731001ae4e187668392
7
- data.tar.gz: a2679e47f258f04b1be5fcb58359a79310e6478293d905745c44e902c21336054c22f4ac5e72f4ce96f533caecb529d377a6f82a976ece74ffc98fe6e0709299
6
+ metadata.gz: 9a46cb6ccbb650023647a719e9a0c69fedea7534a3c076d7b5708926e3113ac6b1e8e669cd4507e1a6120643c19217c95aff8c30b264842b60ed7b8a504cdb2c
7
+ data.tar.gz: 2aa5dfdcda711849d777c3825880810422b14af0f513b4086ee6d6b56ffc163992356f1876680437369e3561a297dd6b6802b778ff2a9d33b8611a578d3523f4
checksums.yaml.gz.sig CHANGED
Binary file
@@ -113,7 +113,6 @@ jobs:
113
113
  - run: bundle install
114
114
 
115
115
  - run: gem install --local *.gem --verbose
116
- continue-on-error: ${{ matrix.ruby == 'truffleruby-head' }}
117
116
 
118
117
  - name: Run specs
119
118
  continue-on-error: ${{ matrix.ruby == 'truffleruby-head' }}
data/ext/pg_connection.c CHANGED
@@ -968,8 +968,8 @@ static VALUE pgconn_sync_exec_params( int, VALUE *, VALUE );
968
968
  * However #async_exec has two advantages:
969
969
  *
970
970
  * 1. #async_exec can be aborted by signals (like Ctrl-C), while #exec blocks signal processing until the query is answered.
971
- * 2. Ruby VM gets notified about IO blocked operations.
972
- * It can therefore schedule things like garbage collection, while queries are running like in this proposal: https://bugs.ruby-lang.org/issues/14723
971
+ * 2. Ruby VM gets notified about IO blocked operations and can pass them through <tt>Fiber.scheduler</tt>.
972
+ * So only <tt>async_*</tt> methods are compatible to event based schedulers like the async gem.
973
973
  */
974
974
  static VALUE
975
975
  pgconn_sync_exec(int argc, VALUE *argv, VALUE self)
@@ -2208,17 +2208,25 @@ pgconn_notifies(VALUE self)
2208
2208
  }
2209
2209
 
2210
2210
 
2211
- #if !defined(HAVE_RB_IO_WAIT)
2211
+ #if defined(HAVE_RB_IO_WAIT)
2212
+
2213
+ /* Use our own function and constants names, to avoid conflicts with truffleruby-head on its road to ruby-3.0 compatibility. */
2214
+ #define pg_rb_io_wait rb_io_wait
2215
+ #define PG_RUBY_IO_READABLE RUBY_IO_READABLE
2216
+ #define PG_RUBY_IO_WRITABLE RUBY_IO_WRITABLE
2217
+ #define PG_RUBY_IO_PRIORITY RUBY_IO_PRIORITY
2218
+
2219
+ #else
2212
2220
  /* For compat with ruby < 3.0 */
2213
2221
 
2214
2222
  typedef enum {
2215
- RUBY_IO_READABLE = RB_WAITFD_IN,
2216
- RUBY_IO_WRITABLE = RB_WAITFD_OUT,
2217
- RUBY_IO_PRIORITY = RB_WAITFD_PRI,
2218
- } rb_io_event_t;
2223
+ PG_RUBY_IO_READABLE = RB_WAITFD_IN,
2224
+ PG_RUBY_IO_WRITABLE = RB_WAITFD_OUT,
2225
+ PG_RUBY_IO_PRIORITY = RB_WAITFD_PRI,
2226
+ } pg_rb_io_event_t;
2219
2227
 
2220
2228
  static VALUE
2221
- rb_io_wait(VALUE io, VALUE events, VALUE timeout) {
2229
+ pg_rb_io_wait(VALUE io, VALUE events, VALUE timeout) {
2222
2230
  rb_io_t *fptr;
2223
2231
  struct timeval waittime;
2224
2232
  int res;
@@ -2267,7 +2275,7 @@ wait_socket_readable( VALUE self, struct timeval *ptimeout, void *(*is_readable)
2267
2275
  /* Is the given timeout valid? */
2268
2276
  if( !ptimeout || (waittime.tv_sec >= 0 && waittime.tv_usec >= 0) ){
2269
2277
  /* Wait for the socket to become readable before checking again */
2270
- ret = rb_io_wait(socket_io, RB_INT2NUM(RUBY_IO_READABLE), wait_timeout);
2278
+ ret = pg_rb_io_wait(socket_io, RB_INT2NUM(PG_RUBY_IO_READABLE), wait_timeout);
2271
2279
  } else {
2272
2280
  ret = Qfalse;
2273
2281
  }
@@ -2304,9 +2312,9 @@ pgconn_async_flush(VALUE self)
2304
2312
  /* wait for the socket to become read- or write-ready */
2305
2313
  int events;
2306
2314
  VALUE socket_io = pgconn_socket_io(self);
2307
- events = RB_NUM2INT(rb_io_wait(socket_io, RB_INT2NUM(RUBY_IO_READABLE | RUBY_IO_WRITABLE), Qnil));
2315
+ events = RB_NUM2INT(pg_rb_io_wait(socket_io, RB_INT2NUM(PG_RUBY_IO_READABLE | PG_RUBY_IO_WRITABLE), Qnil));
2308
2316
 
2309
- if (events & RUBY_IO_READABLE)
2317
+ if (events & PG_RUBY_IO_READABLE)
2310
2318
  pgconn_consume_input(self);
2311
2319
  }
2312
2320
  return Qtrue;
@@ -3013,10 +3021,10 @@ pgconn_discard_results(VALUE self)
3013
3021
  int status;
3014
3022
 
3015
3023
  /* pgconn_block() raises an exception in case of errors.
3016
- * To avoid this call rb_io_wait() and PQconsumeInput() without rb_raise().
3024
+ * To avoid this call pg_rb_io_wait() and PQconsumeInput() without rb_raise().
3017
3025
  */
3018
3026
  while( gvl_PQisBusy(conn) ){
3019
- rb_io_wait(socket_io, RB_INT2NUM(RUBY_IO_READABLE), Qnil);
3027
+ pg_rb_io_wait(socket_io, RB_INT2NUM(PG_RUBY_IO_READABLE), Qnil);
3020
3028
  if ( PQconsumeInput(conn) == 0 ) {
3021
3029
  pgconn_close_socket_io(self);
3022
3030
  return Qfalse;
@@ -3037,7 +3045,7 @@ pgconn_discard_results(VALUE self)
3037
3045
  int st = gvl_PQgetCopyData(conn, &buffer, 1);
3038
3046
  if( st == 0 ) {
3039
3047
  /* would block -> wait for readable data */
3040
- rb_io_wait(socket_io, RB_INT2NUM(RUBY_IO_READABLE), Qnil);
3048
+ pg_rb_io_wait(socket_io, RB_INT2NUM(PG_RUBY_IO_READABLE), Qnil);
3041
3049
  if ( PQconsumeInput(conn) == 0 ) {
3042
3050
  pgconn_close_socket_io(self);
3043
3051
  return Qfalse;
@@ -3076,6 +3084,7 @@ pgconn_discard_results(VALUE self)
3076
3084
  * #exec is an alias for #async_exec which is almost identical to #sync_exec .
3077
3085
  * #sync_exec is implemented on the simpler synchronous command processing API of libpq, whereas
3078
3086
  * #async_exec is implemented on the asynchronous API and on ruby's IO mechanisms.
3087
+ * Only #async_exec is compatible to <tt>Fiber.scheduler</tt> based asynchronous IO processing introduced in ruby-3.0.
3079
3088
  * Both methods ensure that other threads can process while waiting for the server to
3080
3089
  * complete the request, but #sync_exec blocks all signals to be processed until the query is finished.
3081
3090
  * This is most notably visible by a delayed reaction to Control+C.
data/lib/pg/connection.rb CHANGED
@@ -21,6 +21,13 @@ require 'socket'
21
21
  #
22
22
  # See the PG::Result class for information on working with the results of a query.
23
23
  #
24
+ # Many methods of this class have three variants kind of:
25
+ # 1. #exec - the base method which is an alias to #async_exec .
26
+ # This is the method that should be used in general.
27
+ # 2. #async_exec - the async aware version of the method, implemented by libpq's async API.
28
+ # 3. #sync_exec - the method version that is implemented by blocking function(s) of libpq.
29
+ #
30
+ # Sync and async version of the method can be switched by Connection.async_api= , however it is not recommended to change the default.
24
31
  class PG::Connection
25
32
 
26
33
  # The order the options are passed to the ::connect method.
@@ -690,7 +697,7 @@ class PG::Connection
690
697
  #
691
698
  # Raises a PG::Error if the connection fails.
692
699
  def new(*args, **kwargs)
693
- conn = PG::Connection.connect_start(*args, **kwargs ) or
700
+ conn = self.connect_start(*args, **kwargs ) or
694
701
  raise(PG::Error, "Unable to create a new connection")
695
702
 
696
703
  raise(PG::ConnectionBad, conn.error_message) if conn.status == PG::CONNECTION_BAD
data/lib/pg/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module PG
2
2
  # Library version
3
- VERSION = '1.3.0.rc2'
3
+ VERSION = '1.3.0.rc3'
4
4
  end
data/lib/pg.rb CHANGED
@@ -63,8 +63,8 @@ module PG
63
63
 
64
64
 
65
65
  ### Convenience alias for PG::Connection.new.
66
- def self::connect( *args )
67
- return PG::Connection.new( *args )
66
+ def self::connect( *args, **kwargs )
67
+ return PG::Connection.new( *args, **kwargs )
68
68
  end
69
69
 
70
70
 
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.0.rc2
4
+ version: 1.3.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -36,7 +36,7 @@ cert_chain:
36
36
  d5T9wAD7jW/0seVujw+76/YOJWO3Dft+FQmMBbdd8s3J47HbN9R2mDt6fl6he+X/
37
37
  gw==
38
38
  -----END CERTIFICATE-----
39
- date: 2022-01-08 00:00:00.000000000 Z
39
+ date: 2022-01-13 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