pg 1.3.0.rc2-x86-mingw32 → 1.3.2-x86-mingw32

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: fbf738a155a8bfb9b2476e2dc0e6d96e81beeb996b26eaed3d8f81e404493010
4
- data.tar.gz: fb06a6941a5ff08ac1a56f86f2fe7a19eb1e5a888fb02ff56621071c91d1c759
3
+ metadata.gz: 3b2d524251b3c5c9dc707282858b33d6a58af1343e665022b215a44779416ff9
4
+ data.tar.gz: 76ca33a83b6eb375fa8929c5043685db3a67cbdf90bb944e70be2b9a81e56fe6
5
5
  SHA512:
6
- metadata.gz: 1711b8d508ce6fb63e4ad8a3735d11cdee732c232f833a68ae11254f6837b4ee9873ff2bdd810a6786f9e0e19738e1155210c0739f967d6d1bfc6193817ac6b1
7
- data.tar.gz: 9159739ae3b2ef97e38bdcee2a2a5e2a060060230e53731ea9b1a6fc131f456d845f65814282ee7ad403ec3ecc0671c180f2b00682ce2383e425b0a7cf3a7343
6
+ metadata.gz: 85993b177e54786984bbe8ab450dabb187526511ecc9667514692bbb037f562a31b3366931aa5a9c6f46630975c380de23a0413214c46dd19e16d4ff21cd326a
7
+ data.tar.gz: 1ec89aad7c3823abf649501dd9ad66748bdff8826a04163d5ce9c74b60999be747acdd60aa9a334cdad20f484d210544594f2ed4dcfee549d754a5bd4b622ba0
checksums.yaml.gz.sig CHANGED
Binary file
data/.appveyor.yml CHANGED
@@ -29,7 +29,7 @@ environment:
29
29
  matrix:
30
30
  - ruby_version: "head"
31
31
  RUBYDOWNLOAD: x86
32
- PGVERSION: 10.16-1-windows
32
+ PGVERSION: 10.20-1-windows
33
33
  PGVER: 10
34
34
  - ruby_version: "25"
35
35
  PGVERSION: 9.3.25-1-windows
@@ -45,10 +45,10 @@ jobs:
45
45
  include:
46
46
  - ruby: "3.1"
47
47
  platform: "x64-mingw-ucrt"
48
- PGVERSION: 14.0-1-windows-x64
48
+ PGVERSION: 14.2-1-windows-x64
49
49
  - ruby: "2.5"
50
50
  platform: "x64-mingw32"
51
- PGVERSION: 10.16-1-windows
51
+ PGVERSION: 10.20-1-windows
52
52
 
53
53
  runs-on: windows-latest
54
54
  env:
@@ -79,6 +79,7 @@ jobs:
79
79
  echo "PGUSER=$env:USERNAME" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
80
80
  echo "PGPASSWORD=" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
81
81
 
82
+ - run: gem update --system
82
83
  - run: bundle install
83
84
  - run: gem install --local pg-*${{ matrix.platform }}.gem --verbose
84
85
  - name: Run specs
@@ -31,7 +31,7 @@ jobs:
31
31
  include:
32
32
  - os: windows
33
33
  ruby: "head"
34
- PGVERSION: 14.1-1-windows-x64
34
+ PGVERSION: 14.2-1-windows-x64
35
35
  PGVER: "14"
36
36
  - os: windows
37
37
  ruby: "2.5"
@@ -54,7 +54,7 @@ jobs:
54
54
  PGVER: "14"
55
55
  - os: macos
56
56
  ruby: "head"
57
- PGVERSION: 14.1-1-osx
57
+ PGVERSION: 14.2-1-osx
58
58
  PGVER: "14"
59
59
 
60
60
  runs-on: ${{ matrix.os }}-latest
@@ -110,10 +110,10 @@ jobs:
110
110
  unzip postgresql-$PGVERSION-binaries.zip && \
111
111
  echo `pwd`/pgsql/bin >> $GITHUB_PATH
112
112
 
113
+ - run: gem update --system
113
114
  - run: bundle install
114
115
 
115
116
  - run: gem install --local *.gem --verbose
116
- continue-on-error: ${{ matrix.ruby == 'truffleruby-head' }}
117
117
 
118
118
  - name: Run specs
119
119
  continue-on-error: ${{ matrix.ruby == 'truffleruby-head' }}
data/History.rdoc CHANGED
@@ -1,4 +1,33 @@
1
- == v1.3.0 [YYY-MM-DD] Michael Granger <ged@FaerieMUD.org>
1
+ == v1.3.2 [2022-02-14] Lars Kanis <lars@greiz-reinsdorf.de>
2
+
3
+ Bugfixes:
4
+
5
+ - Cancel only active query after failing transaction. #430
6
+ This avoids an incompatibility with pgbouncer since pg-1.3.0.
7
+ - Fix String objects with non-applied encoding when using COPY or record decoders. #427
8
+ - Update Windows fat binary gem to PostgreSQL-14.2.
9
+
10
+ Enhancements:
11
+
12
+ - Improve extconf.rb checks to reduces the number of compiler calls.
13
+ - Add a check for PGRES_PIPELINE_SYNC, to make sure the library version and the header files are PostgreSQL-14+. #429
14
+
15
+
16
+ == v1.3.1 [2022-02-01] Michael Granger <ged@FaerieMUD.org>
17
+
18
+ Bugfixes:
19
+
20
+ - Fix wrong handling of socket writability on Windows introduced in #417.
21
+ This caused starvation in conn.put_copy_data.
22
+ - Fix error in PG.version_string(true). #419
23
+ - Fix a regression in pg 1.3.0 where Ruby 2.x busy-looping any fractional seconds for every wait. #420
24
+
25
+ Enhancements:
26
+
27
+ - Raise an error when conn.copy_data is used in nonblocking mode.
28
+
29
+
30
+ == v1.3.0 [2022-01-20] Michael Granger <ged@FaerieMUD.org>
2
31
 
3
32
  Install Enhancements:
4
33
  - Print some install help if libpq wasn't found. #396
@@ -27,6 +56,8 @@ API Enhancements:
27
56
  - Make discard_results scheduler friendly
28
57
  - Do all socket waiting through the conn.socket_io object.
29
58
  - Avoid PG.connect blocking while address resolution by automatically providing the +hostaddr+ parameter.
59
+ - On Windows Fiber.scheduler support requires Ruby-3.1+.
60
+ It is also only partly usable since may ruby IO methods are not yet scheduler aware on Windows.
30
61
  - Add support for pipeline mode of PostgreSQL-14. #401
31
62
  - Allow specification of multiple hosts in PostgreSQL URI. #387
32
63
  - Add new method conn.backend_key - used to implement our own cancel method.
@@ -46,8 +77,9 @@ Other Enhancements:
46
77
  - Add PG::CONNECTION_* constants for conn.status of newer PostgreSQL versions.
47
78
  - Add better support for logical replication. #339
48
79
  - Change conn.socket_io to read+write mode and to a BasicSocket object instead of IO.
49
- - Use rb_io_wait() and the conn.socket_io object if available and remove Windows specific wait functions.
50
- Fall back to rb_wait_for_single_fd() on ruby < 3.0, which works on Windows as well.
80
+ - Use rb_io_wait() and the conn.socket_io object if available for better compatibility to Fiber.scheduler .
81
+ Fall back to rb_wait_for_single_fd() on ruby < 3.0.
82
+ - On Windows use a specialized wait function as a workaround for very poor performance of rb_io_wait(). #416
51
83
 
52
84
  Bugfixes:
53
85
  - Release GVL while calling PQping which is a blocking method, but it didn't release GVL so far.
@@ -62,6 +94,7 @@ Deprecated:
62
94
  Removed:
63
95
  - Remove support of ruby-2.2, 2.3 and 2.4. Minimum is ruby-2.5 now.
64
96
  - Remove support for PostgreSQL-9.2. Minimum is PostgreSQL-9.3 now.
97
+ - Remove constant PG::REVISION, which was broken since pg-1.1.4.
65
98
 
66
99
  Repository:
67
100
  - Replace Hoe by Bundler for gem packaging
data/Rakefile.cross CHANGED
@@ -30,7 +30,7 @@ class CrossLibrary < OpenStruct
30
30
 
31
31
  # Cross-compilation constants
32
32
  self.openssl_version = ENV['OPENSSL_VERSION'] || '1.1.1m'
33
- self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '14.1'
33
+ self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '14.2'
34
34
 
35
35
  # Check if symlinks work in the current working directory.
36
36
  # This fails, if rake-compiler-dock is running on a Windows box.
data/certs/ged.pem CHANGED
@@ -1,7 +1,7 @@
1
1
  -----BEGIN CERTIFICATE-----
2
- MIID+DCCAmCgAwIBAgIBAzANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdnZWQv
3
- REM9RmFlcmllTVVEL0RDPW9yZzAeFw0yMDEyMjQyMDU1MjlaFw0yMTEyMjQyMDU1
4
- MjlaMCIxIDAeBgNVBAMMF2dlZC9EQz1GYWVyaWVNVUQvREM9b3JnMIIBojANBgkq
2
+ MIID+DCCAmCgAwIBAgIBBDANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdnZWQv
3
+ REM9RmFlcmllTVVEL0RDPW9yZzAeFw0yMjAxMDcyMzU4MTRaFw0yMzAxMDcyMzU4
4
+ MTRaMCIxIDAeBgNVBAMMF2dlZC9EQz1GYWVyaWVNVUQvREM9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ZWWjOcujlQs64QprxOtiv/MiisKb1Ng+
24
+ oL1mUdzB8KrZL4/WbG5YNX6UTtJbIOu9qEFbBAy4/jtIkJX+dlNoFwd4GXQW1YNO
25
+ nA==
26
+ -----END CERTIFICATE-----
data/ext/extconf.rb CHANGED
@@ -138,15 +138,18 @@ if /mingw/ =~ RUBY_PLATFORM && RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
138
138
  end
139
139
  end
140
140
 
141
- have_func 'PQconninfo' or
141
+ have_func 'PQconninfo', 'libpq-fe.h' or
142
142
  abort "Your PostgreSQL is too old. Either install an older version " +
143
143
  "of this gem or upgrade your database to at least PostgreSQL-9.3."
144
144
  # optional headers/functions
145
- have_func 'PQsslAttribute' # since PostgreSQL-9.5
146
- have_func 'PQresultVerboseErrorMessage' # since PostgreSQL-9.6
147
- have_func 'PQencryptPasswordConn' # since PostgreSQL-10
148
- have_func 'PQresultMemorySize' # since PostgreSQL-12
149
- have_func 'PQenterPipelineMode' # since PostgreSQL-14
145
+ have_func 'PQsslAttribute', 'libpq-fe.h' # since PostgreSQL-9.5
146
+ have_func 'PQresultVerboseErrorMessage', 'libpq-fe.h' # since PostgreSQL-9.6
147
+ have_func 'PQencryptPasswordConn', 'libpq-fe.h' # since PostgreSQL-10
148
+ have_func 'PQresultMemorySize', 'libpq-fe.h' # since PostgreSQL-12
149
+ have_func 'PQenterPipelineMode', 'libpq-fe.h' do |src| # since PostgreSQL-14
150
+ # Ensure header files fit as well
151
+ src + " int con(){ return PGRES_PIPELINE_SYNC; }"
152
+ end
150
153
  have_func 'timegm'
151
154
  have_func 'rb_gc_adjust_memory_usage' # since ruby-2.4
152
155
  have_func 'rb_gc_mark_movable' # since ruby-2.7
@@ -155,6 +158,7 @@ have_func 'rb_io_wait' # since ruby-3.0
155
158
  # unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
156
159
  have_header 'unistd.h'
157
160
  have_header 'inttypes.h'
161
+ have_header('ruby/fiber/scheduler.h') if RUBY_PLATFORM=~/mingw|mswin/
158
162
 
159
163
  checking_for "C99 variable length arrays" do
160
164
  $defs.push( "-DHAVE_VARIABLE_LENGTH_ARRAYS" ) if try_compile('void test_vla(int l){ int vla[l]; }')
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)
@@ -2207,18 +2207,124 @@ pgconn_notifies(VALUE self)
2207
2207
  return hash;
2208
2208
  }
2209
2209
 
2210
+ #if defined(_WIN32)
2211
+
2212
+ /* We use a specialized implementation of rb_io_wait() on Windows.
2213
+ * This is because rb_io_wait() and rb_wait_for_single_fd() are very slow on Windows.
2214
+ */
2215
+
2216
+ #if defined(HAVE_RUBY_FIBER_SCHEDULER_H)
2217
+ #include <ruby/fiber/scheduler.h>
2218
+ #endif
2219
+
2220
+ typedef enum {
2221
+ PG_RUBY_IO_READABLE = RB_WAITFD_IN,
2222
+ PG_RUBY_IO_WRITABLE = RB_WAITFD_OUT,
2223
+ PG_RUBY_IO_PRIORITY = RB_WAITFD_PRI,
2224
+ } pg_rb_io_event_t;
2225
+
2226
+ int rb_w32_wait_events( HANDLE *events, int num, DWORD timeout );
2227
+
2228
+ static VALUE
2229
+ pg_rb_thread_io_wait(VALUE io, VALUE events, VALUE timeout) {
2230
+ rb_io_t *fptr;
2231
+ struct timeval ptimeout;
2232
+
2233
+ struct timeval aborttime={0,0}, currtime, waittime;
2234
+ DWORD timeout_milisec = INFINITE;
2235
+ HANDLE hEvent = WSACreateEvent();
2236
+
2237
+ long rb_events = NUM2UINT(events);
2238
+ long w32_events = 0;
2239
+ DWORD wait_ret;
2240
+
2241
+ GetOpenFile((io), fptr);
2242
+ if( !NIL_P(timeout) ){
2243
+ ptimeout.tv_sec = (time_t)(NUM2DBL(timeout));
2244
+ ptimeout.tv_usec = (time_t)((NUM2DBL(timeout) - (double)ptimeout.tv_sec) * 1e6);
2245
+
2246
+ gettimeofday(&currtime, NULL);
2247
+ timeradd(&currtime, &ptimeout, &aborttime);
2248
+ }
2249
+
2250
+ if(rb_events & PG_RUBY_IO_READABLE) w32_events |= FD_READ | FD_ACCEPT | FD_CLOSE;
2251
+ if(rb_events & PG_RUBY_IO_WRITABLE) w32_events |= FD_WRITE | FD_CONNECT;
2252
+ if(rb_events & PG_RUBY_IO_PRIORITY) w32_events |= FD_OOB;
2253
+
2254
+ for(;;) {
2255
+ if ( WSAEventSelect(_get_osfhandle(fptr->fd), hEvent, w32_events) == SOCKET_ERROR ) {
2256
+ WSACloseEvent( hEvent );
2257
+ rb_raise( rb_eConnectionBad, "WSAEventSelect socket error: %d", WSAGetLastError() );
2258
+ }
2259
+
2260
+ if ( !NIL_P(timeout) ) {
2261
+ gettimeofday(&currtime, NULL);
2262
+ timersub(&aborttime, &currtime, &waittime);
2263
+ timeout_milisec = (DWORD)( waittime.tv_sec * 1e3 + waittime.tv_usec / 1e3 );
2264
+ }
2265
+
2266
+ if( NIL_P(timeout) || (waittime.tv_sec >= 0 && waittime.tv_usec >= 0) ){
2267
+ /* Wait for the socket to become readable before checking again */
2268
+ wait_ret = rb_w32_wait_events( &hEvent, 1, timeout_milisec );
2269
+ } else {
2270
+ wait_ret = WAIT_TIMEOUT;
2271
+ }
2272
+
2273
+ if ( wait_ret == WAIT_TIMEOUT ) {
2274
+ WSACloseEvent( hEvent );
2275
+ return UINT2NUM(0);
2276
+ } else if ( wait_ret == WAIT_OBJECT_0 ) {
2277
+ WSACloseEvent( hEvent );
2278
+ /* The event we were waiting for. */
2279
+ return UINT2NUM(rb_events);
2280
+ } else if ( wait_ret == WAIT_OBJECT_0 + 1) {
2281
+ /* This indicates interruption from timer thread, GC, exception
2282
+ * from other threads etc... */
2283
+ rb_thread_check_ints();
2284
+ } else if ( wait_ret == WAIT_FAILED ) {
2285
+ WSACloseEvent( hEvent );
2286
+ rb_raise( rb_eConnectionBad, "Wait on socket error (WaitForMultipleObjects): %lu", GetLastError() );
2287
+ } else {
2288
+ WSACloseEvent( hEvent );
2289
+ rb_raise( rb_eConnectionBad, "Wait on socket abandoned (WaitForMultipleObjects)" );
2290
+ }
2291
+ }
2292
+ }
2293
+
2294
+ static VALUE
2295
+ pg_rb_io_wait(VALUE io, VALUE events, VALUE timeout) {
2296
+ #if defined(HAVE_RUBY_FIBER_SCHEDULER_H)
2297
+ /* We don't support Fiber.scheduler on Windows ruby-3.0 because there is no fast way to check whether a scheduler is active.
2298
+ * Fortunatelly ruby-3.1 offers a C-API for it.
2299
+ */
2300
+ VALUE scheduler = rb_fiber_scheduler_current();
2301
+
2302
+ if (!NIL_P(scheduler)) {
2303
+ return rb_io_wait(io, events, timeout);
2304
+ }
2305
+ #endif
2306
+ return pg_rb_thread_io_wait(io, events, timeout);
2307
+ }
2308
+
2309
+ #elif defined(HAVE_RB_IO_WAIT)
2310
+
2311
+ /* Use our own function and constants names, to avoid conflicts with truffleruby-head on its road to ruby-3.0 compatibility. */
2312
+ #define pg_rb_io_wait rb_io_wait
2313
+ #define PG_RUBY_IO_READABLE RUBY_IO_READABLE
2314
+ #define PG_RUBY_IO_WRITABLE RUBY_IO_WRITABLE
2315
+ #define PG_RUBY_IO_PRIORITY RUBY_IO_PRIORITY
2210
2316
 
2211
- #if !defined(HAVE_RB_IO_WAIT)
2317
+ #else
2212
2318
  /* For compat with ruby < 3.0 */
2213
2319
 
2214
2320
  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;
2321
+ PG_RUBY_IO_READABLE = RB_WAITFD_IN,
2322
+ PG_RUBY_IO_WRITABLE = RB_WAITFD_OUT,
2323
+ PG_RUBY_IO_PRIORITY = RB_WAITFD_PRI,
2324
+ } pg_rb_io_event_t;
2219
2325
 
2220
2326
  static VALUE
2221
- rb_io_wait(VALUE io, VALUE events, VALUE timeout) {
2327
+ pg_rb_io_wait(VALUE io, VALUE events, VALUE timeout) {
2222
2328
  rb_io_t *fptr;
2223
2329
  struct timeval waittime;
2224
2330
  int res;
@@ -2226,7 +2332,7 @@ rb_io_wait(VALUE io, VALUE events, VALUE timeout) {
2226
2332
  GetOpenFile((io), fptr);
2227
2333
  if( !NIL_P(timeout) ){
2228
2334
  waittime.tv_sec = (time_t)(NUM2DBL(timeout));
2229
- waittime.tv_usec = (time_t)(NUM2DBL(timeout) - (double)waittime.tv_sec);
2335
+ waittime.tv_usec = (time_t)((NUM2DBL(timeout) - (double)waittime.tv_sec) * 1e6);
2230
2336
  }
2231
2337
  res = rb_wait_for_single_fd(fptr->fd, NUM2UINT(events), NIL_P(timeout) ? NULL : &waittime);
2232
2338
 
@@ -2267,7 +2373,7 @@ wait_socket_readable( VALUE self, struct timeval *ptimeout, void *(*is_readable)
2267
2373
  /* Is the given timeout valid? */
2268
2374
  if( !ptimeout || (waittime.tv_sec >= 0 && waittime.tv_usec >= 0) ){
2269
2375
  /* Wait for the socket to become readable before checking again */
2270
- ret = rb_io_wait(socket_io, RB_INT2NUM(RUBY_IO_READABLE), wait_timeout);
2376
+ ret = pg_rb_io_wait(socket_io, RB_INT2NUM(PG_RUBY_IO_READABLE), wait_timeout);
2271
2377
  } else {
2272
2378
  ret = Qfalse;
2273
2379
  }
@@ -2304,9 +2410,9 @@ pgconn_async_flush(VALUE self)
2304
2410
  /* wait for the socket to become read- or write-ready */
2305
2411
  int events;
2306
2412
  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));
2413
+ events = RB_NUM2INT(pg_rb_io_wait(socket_io, RB_INT2NUM(PG_RUBY_IO_READABLE | PG_RUBY_IO_WRITABLE), Qnil));
2308
2414
 
2309
- if (events & RUBY_IO_READABLE)
2415
+ if (events & PG_RUBY_IO_READABLE)
2310
2416
  pgconn_consume_input(self);
2311
2417
  }
2312
2418
  return Qtrue;
@@ -3013,10 +3119,10 @@ pgconn_discard_results(VALUE self)
3013
3119
  int status;
3014
3120
 
3015
3121
  /* pgconn_block() raises an exception in case of errors.
3016
- * To avoid this call rb_io_wait() and PQconsumeInput() without rb_raise().
3122
+ * To avoid this call pg_rb_io_wait() and PQconsumeInput() without rb_raise().
3017
3123
  */
3018
3124
  while( gvl_PQisBusy(conn) ){
3019
- rb_io_wait(socket_io, RB_INT2NUM(RUBY_IO_READABLE), Qnil);
3125
+ pg_rb_io_wait(socket_io, RB_INT2NUM(PG_RUBY_IO_READABLE), Qnil);
3020
3126
  if ( PQconsumeInput(conn) == 0 ) {
3021
3127
  pgconn_close_socket_io(self);
3022
3128
  return Qfalse;
@@ -3037,7 +3143,7 @@ pgconn_discard_results(VALUE self)
3037
3143
  int st = gvl_PQgetCopyData(conn, &buffer, 1);
3038
3144
  if( st == 0 ) {
3039
3145
  /* would block -> wait for readable data */
3040
- rb_io_wait(socket_io, RB_INT2NUM(RUBY_IO_READABLE), Qnil);
3146
+ pg_rb_io_wait(socket_io, RB_INT2NUM(PG_RUBY_IO_READABLE), Qnil);
3041
3147
  if ( PQconsumeInput(conn) == 0 ) {
3042
3148
  pgconn_close_socket_io(self);
3043
3149
  return Qfalse;
@@ -3076,6 +3182,7 @@ pgconn_discard_results(VALUE self)
3076
3182
  * #exec is an alias for #async_exec which is almost identical to #sync_exec .
3077
3183
  * #sync_exec is implemented on the simpler synchronous command processing API of libpq, whereas
3078
3184
  * #async_exec is implemented on the asynchronous API and on ruby's IO mechanisms.
3185
+ * Only #async_exec is compatible to <tt>Fiber.scheduler</tt> based asynchronous IO processing introduced in ruby-3.0.
3079
3186
  * Both methods ensure that other threads can process while waiting for the server to
3080
3187
  * complete the request, but #sync_exec blocks all signals to be processed until the query is finished.
3081
3188
  * This is most notably visible by a delayed reaction to Control+C.
@@ -134,7 +134,7 @@ pg_recordcoder_type_map_get(VALUE self)
134
134
  * tm = PG::TypeMapByColumn.new([PG::TextEncoder::Float.new]*2)
135
135
  * # Use this type map to encode the record:
136
136
  * PG::TextEncoder::Record.new(type_map: tm).encode([1,2])
137
- * # => "(\"1.0000000000000000E+00\",\"2.0000000000000000E+00\")"
137
+ * # => "(\"1.0\",\"2.0\")"
138
138
  *
139
139
  * Records can also be encoded and decoded directly to and from the database.
140
140
  * This avoids intermediate string allocations and is very fast.
@@ -76,6 +76,7 @@ pg_tmas_fit_to_copy_get( VALUE self )
76
76
  static VALUE
77
77
  pg_tmas_typecast_copy_get( t_typemap *p_typemap, VALUE field_str, int fieldno, int format, int enc_idx )
78
78
  {
79
+ rb_str_modify(field_str);
79
80
  if( format == 0 ){
80
81
  PG_ENCODING_SET_NOCHECK( field_str, enc_idx );
81
82
  } else {
@@ -150,10 +150,12 @@ pg_tmbc_typecast_copy_get( t_typemap *p_typemap, VALUE field_str, int fieldno, i
150
150
 
151
151
  /* Is it a pure String conversion? Then we can directly send field_str to the user. */
152
152
  if( dec_func == pg_text_dec_string ){
153
+ rb_str_modify(field_str);
153
154
  PG_ENCODING_SET_NOCHECK( field_str, enc_idx );
154
155
  return field_str;
155
156
  }
156
157
  if( dec_func == pg_bin_dec_bytea ){
158
+ rb_str_modify(field_str);
157
159
  PG_ENCODING_SET_NOCHECK( field_str, rb_ascii8bit_encindex() );
158
160
  return field_str;
159
161
  }
data/lib/2.5/pg_ext.so CHANGED
Binary file
data/lib/2.6/pg_ext.so CHANGED
Binary file
data/lib/2.7/pg_ext.so CHANGED
Binary file
data/lib/3.0/pg_ext.so CHANGED
Binary file
data/lib/3.1/pg_ext.so CHANGED
Binary file
data/lib/pg/connection.rb CHANGED
@@ -7,7 +7,7 @@ require 'io/wait'
7
7
  require 'socket'
8
8
 
9
9
  # The PostgreSQL connection class. The interface for this class is based on
10
- # {libpq}[http://www.postgresql.org/docs/9.2/interactive/libpq.html], the C
10
+ # {libpq}[http://www.postgresql.org/docs/current/libpq.html], the C
11
11
  # application programmer's interface to PostgreSQL. Some familiarity with libpq
12
12
  # is recommended, but not necessary.
13
13
  #
@@ -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.
@@ -234,6 +241,7 @@ class PG::Connection
234
241
  # ["more", "data", "to", "copy"]
235
242
 
236
243
  def copy_data( sql, coder=nil )
244
+ raise PG::NotInBlockingMode, "copy_data can not be used in nonblocking mode" if nonblocking?
237
245
  res = exec( sql )
238
246
 
239
247
  case res.result_status
@@ -305,7 +313,7 @@ class PG::Connection
305
313
  exec "BEGIN"
306
314
  res = yield(self)
307
315
  rescue Exception
308
- cancel if transaction_status != PG::PQTRANS_IDLE
316
+ cancel if transaction_status == PG::PQTRANS_ACTIVE
309
317
  block
310
318
  exec "ROLLBACK"
311
319
  raise
@@ -378,7 +386,7 @@ class PG::Connection
378
386
  # If the optional code block is given, it will be passed <i>result</i> as an argument,
379
387
  # and the PG::Result object will automatically be cleared when the block terminates.
380
388
  # In this instance, <code>conn.exec</code> returns the value of the block.
381
- def get_result(*args)
389
+ def get_result
382
390
  block
383
391
  sync_get_result
384
392
  end
@@ -690,7 +698,7 @@ class PG::Connection
690
698
  #
691
699
  # Raises a PG::Error if the connection fails.
692
700
  def new(*args, **kwargs)
693
- conn = PG::Connection.connect_start(*args, **kwargs ) or
701
+ conn = self.connect_start(*args, **kwargs ) or
694
702
  raise(PG::Error, "Unable to create a new connection")
695
703
 
696
704
  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.2'
4
4
  end
data/lib/pg.rb CHANGED
@@ -53,18 +53,20 @@ module PG
53
53
 
54
54
  class NotAllCopyDataRetrieved < PG::Error
55
55
  end
56
+ class NotInBlockingMode < PG::Error
57
+ end
56
58
 
57
- ### Get the PG library version. If +include_buildnum+ is +true+, include the build ID.
58
- def self::version_string( include_buildnum=false )
59
- vstring = "%s %s" % [ self.name, VERSION ]
60
- vstring << " (build %s)" % [ REVISION[/: ([[:xdigit:]]+)/, 1] || '0' ] if include_buildnum
61
- return vstring
59
+ # Get the PG library version.
60
+ #
61
+ # +include_buildnum+ is no longer used and any value passed will be ignored.
62
+ def self::version_string( include_buildnum=nil )
63
+ return "%s %s" % [ self.name, VERSION ]
62
64
  end
63
65
 
64
66
 
65
67
  ### Convenience alias for PG::Connection.new.
66
- def self::connect( *args )
67
- return PG::Connection.new( *args )
68
+ def self::connect( *args, **kwargs )
69
+ return PG::Connection.new( *args, **kwargs )
68
70
  end
69
71
 
70
72
 
Binary file
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.2
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Michael Granger
@@ -12,31 +12,31 @@ cert_chain:
12
12
  - |
13
13
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7cFXuOjAtflQ2
32
- n3EGZATdVzduNvUENzg6l1Ba+q/nRKKHq5CnG6+1YzOhdzYKFOwlYMi6jLQK33aV
33
- aLvq6jWUIpNbL/95ZdOR8Cd6KsCmK5Zvxd5FMMjrQCsZD6OgReshsok5r6tSiNXc
34
- YgnBIIAFeoeGz8q+dsm6hPtkii/zr25MPRPmKnbRV7bV/zlbmwpIPxhso95lq3R5
35
- H5q2yo7qMajDFkxRffqQO8ONvDLGecxbuv1QEyzNBdehVt4I7UedIfxyOvKd9cg2
36
- d5T9wAD7jW/0seVujw+76/YOJWO3Dft+FQmMBbdd8s3J47HbN9R2mDt6fl6he+X/
37
- gw==
29
+ AFWP7F/y3Oq3NgrqUOnjKOeDaBa7AqNhHS+PZg+C90lnJzMgOs4KKgZYxqSQVSab
30
+ SCEmzIO/StkXY4NpJ4fYLrHemf/fJy1wPyu+fNdp5SEEUwEo+2toRFlzTe4u4LdS
31
+ QC636nPPTMt8H3xz2wf/lUIUeo2Qc95Qt2BQM465ibbG9kmA3c7Sopx6yOabYOAl
32
+ KPRbOSEPiWYcF9Suuz8Gdf8jxEtPlnZiwRvnYJ+IHMq3XQCJWPpMzdDMbtlgHbXE
33
+ vq1zOTLMSYAS0UB3uionR4yo1hLz60odwkCm7qf0o2Ci/5OjtB0a89VuyqRU2vUJ
34
+ QH95WBjDJ6lCCW7J0mrMPnJQSUFTmufsU6jOChvPaCeAzW1YwrsP/YKnvwueG7ip
35
+ VOdW6RitjtFxhS7evRL0201+KUvLz12zZWWjOcujlQs64QprxOtiv/MiisKb1Ng+
36
+ oL1mUdzB8KrZL4/WbG5YNX6UTtJbIOu9qEFbBAy4/jtIkJX+dlNoFwd4GXQW1YNO
37
+ nA==
38
38
  -----END CERTIFICATE-----
39
- date: 2022-01-08 00:00:00.000000000 Z
39
+ date: 2022-02-14 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.
@@ -73,6 +73,7 @@ files:
73
73
  - Rakefile
74
74
  - Rakefile.cross
75
75
  - certs/ged.pem
76
+ - certs/larskanis-2022.pem
76
77
  - ext/errorcodes.def
77
78
  - ext/errorcodes.rb
78
79
  - ext/errorcodes.txt
@@ -181,9 +182,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
182
  version: 3.2.dev
182
183
  required_rubygems_version: !ruby/object:Gem::Requirement
183
184
  requirements:
184
- - - ">"
185
+ - - ">="
185
186
  - !ruby/object:Gem::Version
186
- version: 1.3.1
187
+ version: '0'
187
188
  requirements: []
188
189
  rubygems_version: 3.3.4
189
190
  signing_key:
metadata.gz.sig CHANGED
Binary file