pg 1.1.2-x64-mingw32 → 1.1.3-x64-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 297b04be76576c28a27569752072310064ffa03e
4
- data.tar.gz: 622e7a4704c211a83f75d4ee1df21c1babb576c0
3
+ metadata.gz: f6ceb296d0fc4b59f0ec35a39f733f945737d512
4
+ data.tar.gz: 5dddb54d70cddd40ad0e06c2d4833d6967e9355d
5
5
  SHA512:
6
- metadata.gz: d1d8fe76d249606aab43bd746f5e46f894a136f8717d72146fb7f3a1eb5c75d3938b31a41f0ad387a5160f76965233b18272d4785986fa5c7a9988f1e6854180
7
- data.tar.gz: 102409058cf84ee4b01bd94d04c142a24b71d7a2f9d6e19ed47776b959bd4b767a4e9e66d4d7e8ede7f7ff0b7c82a7de3e0662fdd5c45082f3314c96f4f44877
6
+ metadata.gz: dcffbd9981e91a73e9bcd1ee5e49aa0587da99271defdfb55d741368e82ec61caac5f6e150dc0c9f9e191cef11a7479ce4e2669375aad5436326ae2c5106d14c
7
+ data.tar.gz: d0ae758db5ed159c5771746a6f50bc87bd978bba9df10a908c2171e1fa0ca08ee6310f5a1b4ec79f78c8d66b40d1143ff923ce357b097b05a1e5bfd101831368
Binary file
data.tar.gz.sig CHANGED
@@ -1,2 +1,4 @@
1
- FE�,�0���j �=�W�`����F=�y ��f�暥�;�)��"=�j冫����Y;�qٳH�%��؛����q)�]S=�6��������; l@c��y�al�(�X�[jм�X��kY��,<�ߟj���T�u�;ۅ��X��,��W���7P����6����H�����~�nō���O}�T�5T"-6��z����E�΍n��0��y��v�͌��QEvMUǜ��9Ȫ�e�fFr�S&Jf���C�8��
2
- �;�?�jCb���hu�~��DZ���2�Tv/���Yz>>a���-����`]m��0>;H��3� �����j MՏ�[
1
+ (^�s���M���;ہ7�V��g<:��rt!�5.l�]������f��Wf<�Sm9;pd���H�~
2
+ ��2l{�$U��F1�7E����I��>�ة����r���IvB%�� �=xj\.oB�4����+�.���ꀷ�8T��E��|�I{Mߌ��,�\?s����VO�!��g�߿���ڋ�M���Pӹ�����((ʏ%����~�ֶ��
3
+ ��X�iR�vO�4z�
4
+ s���u��li��̼�1 (��º'��{@3�^�m�`�z���G�c�m)d4'�iQN>|�/lBi�% ���`���a�n|*��S9ej�B���& �cY�yd�9���y
@@ -1,3 +1,8 @@
1
+ == v1.1.3 [2018-09-06] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ - Revert opimization that was sometimes causing EBADF in rb_wait_for_single_fd().
4
+
5
+
1
6
  == v1.1.2 [2018-08-28] Michael Granger <ged@FaerieMUD.org>
2
7
 
3
8
  - Don't generate aliases for JOHAB encoding.
data/ext/pg.h CHANGED
@@ -101,9 +101,6 @@ typedef struct {
101
101
  /* Kind of PG::Coder object for casting COPY rows to ruby values */
102
102
  VALUE decoder_for_get_copy_data;
103
103
 
104
- /* The connection socket, used for rb_wait_for_single_fd() */
105
- int socket;
106
-
107
104
  /* enable/disable guessing size of PGresult's allocated memory */
108
105
  int guess_result_memsize;
109
106
  } t_pg_connection;
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * pg_connection.c - PG::Connection class extension
3
- * $Id: pg_connection.c,v be48d118eeed 2018/08/25 11:35:03 lars $
3
+ * $Id: pg_connection.c,v b49f54dc755b 2018/09/01 12:52:41 lars $
4
4
  *
5
5
  */
6
6
 
@@ -198,7 +198,6 @@ pgconn_s_allocate( VALUE klass )
198
198
  this->decoder_for_get_copy_data = Qnil;
199
199
  this->trace_stream = Qnil;
200
200
  this->external_encoding = Qnil;
201
- this->socket = -1;
202
201
  this->guess_result_memsize = 1;
203
202
 
204
203
  return self;
@@ -272,6 +271,7 @@ pgconn_init(int argc, VALUE *argv, VALUE self)
272
271
  this = pg_get_connection( self );
273
272
  conninfo = rb_funcall2( rb_cPGconn, rb_intern("parse_connect_args"), argc, argv );
274
273
  this->pgconn = gvl_PQconnectdb(StringValueCStr(conninfo));
274
+
275
275
  if(this->pgconn == NULL)
276
276
  rb_raise(rb_ePGerror, "PQconnectdb() unable to allocate structure");
277
277
 
@@ -281,10 +281,6 @@ pgconn_init(int argc, VALUE *argv, VALUE self)
281
281
  rb_exc_raise(error);
282
282
  }
283
283
 
284
- this->socket = PQsocket( this->pgconn );
285
- if ( this->socket < 0 )
286
- rb_raise(rb_eConnectionBad, "PQsocket() can't get socket descriptor");
287
-
288
284
  pgconn_set_default_encoding( self );
289
285
 
290
286
  if (rb_block_given_p()) {
@@ -335,10 +331,6 @@ pgconn_s_connect_start( int argc, VALUE *argv, VALUE klass )
335
331
  rb_exc_raise(error);
336
332
  }
337
333
 
338
- this->socket = PQsocket( this->pgconn );
339
- if ( this->socket < 0 )
340
- rb_raise(rb_eConnectionBad, "PQsocket() can't get socket descriptor");
341
-
342
334
  if ( rb_block_given_p() ) {
343
335
  return rb_ensure( rb_yield, rb_conn, pgconn_finish, rb_conn );
344
336
  }
@@ -2337,15 +2329,18 @@ pgconn_notifies(VALUE self)
2337
2329
  int rb_w32_wait_events( HANDLE *events, int num, DWORD timeout );
2338
2330
 
2339
2331
  static void *
2340
- wait_socket_readable( t_pg_connection *this, struct timeval *ptimeout, void *(*is_readable)(PGconn *) )
2332
+ wait_socket_readable( PGconn *conn, struct timeval *ptimeout, void *(*is_readable)(PGconn *) )
2341
2333
  {
2342
- PGconn *conn = this->pgconn;
2334
+ int sd = PQsocket( conn );
2343
2335
  void *retval;
2344
2336
  struct timeval aborttime={0,0}, currtime, waittime;
2345
2337
  DWORD timeout_milisec = INFINITE;
2346
2338
  DWORD wait_ret;
2347
2339
  WSAEVENT hEvent;
2348
2340
 
2341
+ if ( sd < 0 )
2342
+ rb_raise(rb_eConnectionBad, "PQsocket() can't get socket descriptor");
2343
+
2349
2344
  hEvent = WSACreateEvent();
2350
2345
 
2351
2346
  /* Check for connection errors (PQisBusy is true on connection errors) */
@@ -2360,7 +2355,7 @@ wait_socket_readable( t_pg_connection *this, struct timeval *ptimeout, void *(*i
2360
2355
  }
2361
2356
 
2362
2357
  while ( !(retval=is_readable(conn)) ) {
2363
- if ( WSAEventSelect(this->socket, hEvent, FD_READ|FD_CLOSE) == SOCKET_ERROR ) {
2358
+ if ( WSAEventSelect(sd, hEvent, FD_READ|FD_CLOSE) == SOCKET_ERROR ) {
2364
2359
  WSACloseEvent( hEvent );
2365
2360
  rb_raise( rb_eConnectionBad, "WSAEventSelect socket error: %d", WSAGetLastError() );
2366
2361
  }
@@ -2412,13 +2407,16 @@ wait_socket_readable( t_pg_connection *this, struct timeval *ptimeout, void *(*i
2412
2407
  /* non Win32 */
2413
2408
 
2414
2409
  static void *
2415
- wait_socket_readable( t_pg_connection *this, struct timeval *ptimeout, void *(*is_readable)(PGconn *))
2410
+ wait_socket_readable( PGconn *conn, struct timeval *ptimeout, void *(*is_readable)(PGconn *))
2416
2411
  {
2417
- PGconn *conn = this->pgconn;
2412
+ int sd = PQsocket( conn );
2418
2413
  int ret;
2419
2414
  void *retval;
2420
2415
  struct timeval aborttime={0,0}, currtime, waittime;
2421
2416
 
2417
+ if ( sd < 0 )
2418
+ rb_raise(rb_eConnectionBad, "PQsocket() can't get socket descriptor");
2419
+
2422
2420
  /* Check for connection errors (PQisBusy is true on connection errors) */
2423
2421
  if ( PQconsumeInput(conn) == 0 )
2424
2422
  rb_raise( rb_eConnectionBad, "PQconsumeInput() %s", PQerrorMessage(conn) );
@@ -2437,7 +2435,7 @@ wait_socket_readable( t_pg_connection *this, struct timeval *ptimeout, void *(*i
2437
2435
  /* Is the given timeout valid? */
2438
2436
  if( !ptimeout || (waittime.tv_sec >= 0 && waittime.tv_usec >= 0) ){
2439
2437
  /* Wait for the socket to become readable before checking again */
2440
- ret = rb_wait_for_single_fd( this->socket, RB_WAITFD_IN, ptimeout ? &waittime : NULL );
2438
+ ret = rb_wait_for_single_fd( sd, RB_WAITFD_IN, ptimeout ? &waittime : NULL );
2441
2439
  } else {
2442
2440
  ret = 0;
2443
2441
  }
@@ -2484,7 +2482,7 @@ notify_readable(PGconn *conn)
2484
2482
  static VALUE
2485
2483
  pgconn_wait_for_notify(int argc, VALUE *argv, VALUE self)
2486
2484
  {
2487
- t_pg_connection *this = pg_get_connection_safe( self );
2485
+ PGconn *conn = pg_get_pgconn( self );
2488
2486
  PGnotify *pnotification;
2489
2487
  struct timeval timeout;
2490
2488
  struct timeval *ptimeout = NULL;
@@ -2500,7 +2498,7 @@ pgconn_wait_for_notify(int argc, VALUE *argv, VALUE self)
2500
2498
  ptimeout = &timeout;
2501
2499
  }
2502
2500
 
2503
- pnotification = (PGnotify*) wait_socket_readable( this, ptimeout, notify_readable);
2501
+ pnotification = (PGnotify*) wait_socket_readable( conn, ptimeout, notify_readable);
2504
2502
 
2505
2503
  /* Return nil if the select timed out */
2506
2504
  if ( !pnotification ) return Qnil;
@@ -3078,7 +3076,7 @@ get_result_readable(PGconn *conn)
3078
3076
  */
3079
3077
  static VALUE
3080
3078
  pgconn_block( int argc, VALUE *argv, VALUE self ) {
3081
- t_pg_connection *this = pg_get_connection_safe( self );
3079
+ PGconn *conn = pg_get_pgconn( self );
3082
3080
 
3083
3081
  struct timeval timeout;
3084
3082
  struct timeval *ptimeout = NULL;
@@ -3093,7 +3091,7 @@ pgconn_block( int argc, VALUE *argv, VALUE self ) {
3093
3091
  ptimeout = &timeout;
3094
3092
  }
3095
3093
 
3096
- ret = wait_socket_readable( this, ptimeout, get_result_readable);
3094
+ ret = wait_socket_readable( conn, ptimeout, get_result_readable);
3097
3095
 
3098
3096
  if( !ret )
3099
3097
  return Qfalse;
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/lib/pg.rb CHANGED
@@ -35,10 +35,10 @@ end
35
35
  module PG
36
36
 
37
37
  # Library version
38
- VERSION = '1.1.2'
38
+ VERSION = '1.1.3'
39
39
 
40
40
  # VCS revision
41
- REVISION = %q$Revision: bbf57bf7e583 $
41
+ REVISION = %q$Revision: 6f611e78845a $
42
42
 
43
43
  class NotAllCopyDataRetrieved < PG::Error
44
44
  end
@@ -228,6 +228,22 @@ describe PG::Connection do
228
228
 
229
229
  res = @conn2.query("SELECT 4")
230
230
  end
231
+
232
+ it "can use conn.reset_start to restart the connection" do
233
+ ios = IO.pipe
234
+ conn = described_class.connect_start( @conninfo )
235
+ wait_for_polling_ok(conn)
236
+
237
+ # Close the two pipe file descriptors, so that the file descriptor of
238
+ # newly established connection is probably distinct from the previous one.
239
+ ios.each(&:close)
240
+ conn.reset_start
241
+ wait_for_polling_ok(conn)
242
+
243
+ # The new connection should work even when the file descriptor has changed.
244
+ expect( conn.exec("SELECT 1").values ).to eq([["1"]])
245
+ conn.close
246
+ end
231
247
  end
232
248
 
233
249
  it "raises proper error when sending fails" do
@@ -914,6 +930,20 @@ describe PG::Connection do
914
930
  expect { conn.finish }.to raise_error( PG::ConnectionBad, /connection is closed/i )
915
931
  end
916
932
 
933
+ it "can use conn.reset to restart the connection" do
934
+ ios = IO.pipe
935
+ conn = PG.connect( @conninfo )
936
+
937
+ # Close the two pipe file descriptors, so that the file descriptor of
938
+ # newly established connection is probably distinct from the previous one.
939
+ ios.each(&:close)
940
+ conn.reset
941
+
942
+ # The new connection should work even when the file descriptor has changed.
943
+ expect( conn.exec("SELECT 1").values ).to eq([["1"]])
944
+ conn.close
945
+ end
946
+
917
947
  it "closes the IO fetched from #socket_io when the connection is closed", :without_transaction, :socket_io do
918
948
  conn = PG.connect( @conninfo )
919
949
  io = conn.socket_io
@@ -939,7 +969,7 @@ describe PG::Connection do
939
969
  end
940
970
  serv.close
941
971
  expect{ conn.block }.to raise_error(PG::ConnectionBad, /server closed the connection unexpectedly/)
942
- expect{ conn.block }.to raise_error(PG::ConnectionBad, /connection not open/)
972
+ expect{ conn.block }.to raise_error(PG::ConnectionBad, /can't get socket descriptor/)
943
973
  end
944
974
 
945
975
  it "sets the fallback_application_name on new connections" do
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.1.2
4
+ version: 1.1.3
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Michael Granger
@@ -36,7 +36,7 @@ cert_chain:
36
36
  X0qdrKi+2aZZ0NGuFj9AItBsVmAvkBGIpX4TEKQp5haEbPpmaqO5nIIhV26PXmyT
37
37
  OMKv6pWsoS81vw5KAGBmfX8nht/Py90DQrbRvakATGI=
38
38
  -----END CERTIFICATE-----
39
- date: 2018-08-29 00:00:00.000000000 Z
39
+ date: 2018-09-07 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hoe-mercurial
metadata.gz.sig CHANGED
Binary file