pg 1.5.6-x64-mingw32 → 1.5.7-x64-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: d8edaa42878fbf42973b532a75cc311ba482fb7850f0e922a6a4c9be093ca8d4
4
- data.tar.gz: 6414cf328b39c2163347529d7113fc4106a8f633380ed13dccc9dfe41eca5de0
3
+ metadata.gz: abe1d9e6bc63fd1f4d7c1abd7e7c3ec5487c65ca388687bcae01908b725a34a8
4
+ data.tar.gz: bdc8d6e675596757916a4027962779c5c65514b41a5ea4509bcba30db43dda83
5
5
  SHA512:
6
- metadata.gz: bdde5b8daa6b351a2196d10f0f9d483c9afecee9c22a359af3e11ee98c7edaa64169bfd129ea513cd435ab4cd93762a6e952de0335aa3c49adc7e11d8a8c8af6
7
- data.tar.gz: 7f6360b71e278a031263d0c5c97e59ba27cb357721ac702b8184e05133a57c9cc5a568368969ed28d4a79fc6dc57a8dc3f7f5e621d8ef13e5d79913f475fad7d
6
+ metadata.gz: a6d9dfebc6015cc3ea9178f009ff1cc1910c67a271319b0148443bdad4b4e66e98e635e80856aeaabbb2ca04d2aa06966d95497b1ec72f174c73931a09f648d4
7
+ data.tar.gz: 4ecc67022f3878cfeb7ab2722c4a621ad096146b942bf9167c61e6adee263d1c7a739f4da4c7aa1ebd75a2df5cad22a4214c7733528dd4946210cccbb725bbfa
checksums.yaml.gz.sig CHANGED
Binary file
data/.appveyor.yml CHANGED
@@ -38,5 +38,5 @@ on_failure:
38
38
  environment:
39
39
  matrix:
40
40
  - ruby_version: "head"
41
- RUBYDOWNLOAD: x86
41
+ RUBYDOWNLOAD: x64
42
42
  - ruby_version: "30-x64"
@@ -120,6 +120,7 @@ jobs:
120
120
  wget https://get.enterprisedb.com/postgresql/postgresql-$PGVERSION-binaries.zip && \
121
121
  sudo mkdir -p /Library/PostgreSQL && \
122
122
  sudo unzip postgresql-$PGVERSION-binaries.zip -d /Library/PostgreSQL/$PGVER && \
123
+ sudo mv /Library/PostgreSQL/$PGVER/pgsql/* /Library/PostgreSQL/$PGVER/ && \
123
124
  echo /Library/PostgreSQL/$PGVER/bin >> $GITHUB_PATH
124
125
 
125
126
  - run: gem update --system 3.3.26
@@ -130,6 +131,8 @@ jobs:
130
131
  - name: Run specs
131
132
  env:
132
133
  PG_DEBUG: 0
134
+ # Temprary fix only for Truffleruby-24.0.0:
135
+ TRUFFLERUBYOPT: --experimental-options --keep-handles-alive
133
136
  run: ruby -rpg -S rspec spec/**/*_spec.rb -cfdoc
134
137
 
135
138
  - name: Print logs if job failed
data/Gemfile CHANGED
@@ -11,7 +11,10 @@ group :development, :test do
11
11
  gem "rake-compiler-dock", "~> 1.0"
12
12
  gem "rdoc", "~> 6.4"
13
13
  gem "rspec", "~> 3.5"
14
+ gem "ostruct", "~> 0.5" # for Rakefile.cross
14
15
  # "bigdecimal" is a gem on ruby-3.4+ and it's optional for ruby-pg.
15
16
  # Specs should succeed without it, but 4 examples are then excluded.
17
+ # With bigdecimal commented out here, corresponding tests are omitted on ruby-3.4+ but are executed on ruby < 3.4.
18
+ # That way we can check both situations in CI.
16
19
  # gem "bigdecimal", "~> 3.0"
17
20
  end
data/History.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## v1.5.7 [2024-07-28] Lars Kanis <lars@greiz-reinsdorf.de>
2
+
3
+ - Remove deprecated use of fptr->fd.[#562](https://github.com/ged/ruby-pg/pull/562)
4
+ Direct access is disallowed since ruby-3.4.
5
+ - Make `pgconn_connect_poll` close the socket prior to calling `PQconnectPoll`. [#564](https://github.com/ged/ruby-pg/pull/564)
6
+ This could result in an exception while connecting when used multi threaded.
7
+ - Fix several typos and improve spelling in documentation and code. [#566](https://github.com/ged/ruby-pg/pull/566)
8
+ - Add missing PG::RollbackTransaction as an option to exit conn.transaction. [#560](https://github.com/ged/ruby-pg/pull/560)
9
+ Usage like in rails: https://api.rubyonrails.org/classes/ActiveRecord/Rollback.html
10
+ - Don't print a warning when bigdecimal is required on ruby-3.4+ [#574](https://github.com/ged/ruby-pg/pull/574)
11
+
12
+
1
13
  ## v1.5.6 [2024-03-01] Lars Kanis <lars@greiz-reinsdorf.de>
2
14
 
3
15
  - Renew address resolution (DNS) in conn.reset. [#558](https://github.com/ged/ruby-pg/pull/558)
@@ -92,7 +104,7 @@ Removed:
92
104
  Repository:
93
105
 
94
106
  - `rake test` tries to find PostgreSQL server commands by pg_config [#503](https://github.com/ged/ruby-pg/pull/503)
95
- So there's no need to set the PATH manuelly any longer.
107
+ So there's no need to set the PATH manually any longer.
96
108
 
97
109
 
98
110
  ## v1.4.6 [2023-02-26] Lars Kanis <lars@greiz-reinsdorf.de>
@@ -161,7 +173,7 @@ Added:
161
173
  Bugfixes:
162
174
 
163
175
  - Try IPv6 and IPv4 addresses, if DNS resolves to both. [#452](https://github.com/ged/ruby-pg/pull/452)
164
- - Re-add block-call semantics to PG::Connection.new accidently removed in pg-1.3.0. [#454](https://github.com/ged/ruby-pg/pull/454)
176
+ - Re-add block-call semantics to PG::Connection.new accidentally removed in pg-1.3.0. [#454](https://github.com/ged/ruby-pg/pull/454)
165
177
  - Handle client error after all data consumed in #copy_data for output. [#455](https://github.com/ged/ruby-pg/pull/455)
166
178
  - Avoid spurious keyword argument warning on Ruby 2.7. [#456](https://github.com/ged/ruby-pg/pull/456)
167
179
  - Change connection setup to respect connect_timeout parameter. [#459](https://github.com/ged/ruby-pg/pull/459)
@@ -200,7 +212,7 @@ Bugfixes:
200
212
 
201
213
  - Don't leak IO in case of connection errors. [#439](https://github.com/ged/ruby-pg/pull/439)
202
214
  Previously it was kept open until the PG::Connection was garbage collected.
203
- - Fix a performance regession in conn.get_result noticed in single row mode. [#442](https://github.com/ged/ruby-pg/pull/442)
215
+ - Fix a performance regression in conn.get_result noticed in single row mode. [#442](https://github.com/ged/ruby-pg/pull/442)
204
216
  - Fix occasional error Errno::EBADF (Bad file descriptor) while connecting. [#444](https://github.com/ged/ruby-pg/pull/444)
205
217
  - Fix compatibility of res.stream_each* methods with Fiber.scheduler. [#446](https://github.com/ged/ruby-pg/pull/446)
206
218
  - Remove FL_TEST and FL_SET, which are MRI-internal. [#437](https://github.com/ged/ruby-pg/pull/437)
@@ -286,7 +298,7 @@ Type cast enhancements:
286
298
  - Add PG::BasicTypeMapForQueries::BinaryData for encoding of bytea columns. [#348](https://github.com/ged/ruby-pg/pull/348)
287
299
  - Reduce time to build coder maps and permit to reuse them for several type maps per PG::BasicTypeRegistry::CoderMapsBundle.new(conn) . [#376](https://github.com/ged/ruby-pg/pull/376)
288
300
  - Make BasicTypeRegistry a class and use a global default instance of it.
289
- Now a local type registry can be instanciated and given to the type map, to avoid changing shared global states.
301
+ Now a local type registry can be instantiated and given to the type map, to avoid changing shared global states.
290
302
  - Allow PG::BasicTypeMapForQueries to take a Proc as callback for undefined types.
291
303
 
292
304
  Other Enhancements:
data/Rakefile.cross CHANGED
@@ -31,8 +31,8 @@ class CrossLibrary < OpenStruct
31
31
  self.host_platform = toolchain
32
32
 
33
33
  # Cross-compilation constants
34
- self.openssl_version = ENV['OPENSSL_VERSION'] || '3.2.1'
35
- self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '16.2'
34
+ self.openssl_version = ENV['OPENSSL_VERSION'] || '3.3.1'
35
+ self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '16.3'
36
36
 
37
37
  # Check if symlinks work in the current working directory.
38
38
  # This fails, if rake-compiler-dock is running on a Windows box.
@@ -291,7 +291,7 @@ CrossLibraries.each do |xlib|
291
291
  RakeCompilerDock.sh <<-EOT, platform: platform
292
292
  (cp build/gem/gem-*.pem ~/.gem/ || true) &&
293
293
  bundle install --local &&
294
- rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKE="make -j`nproc`" RUBY_CC_VERSION=3.3.0:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0:2.5.0
294
+ rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKEOPTS=-j`nproc` RUBY_CC_VERSION=3.3.0:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0:2.5.0
295
295
  EOT
296
296
  end
297
297
  desc "Build the windows binary gems"
data/ext/extconf.rb CHANGED
@@ -9,6 +9,8 @@ if ENV['MAINTAINER_MODE']
9
9
  ' -ggdb' <<
10
10
  ' -DDEBUG' <<
11
11
  ' -pedantic'
12
+ $LDFLAGS <<
13
+ ' -ggdb'
12
14
  end
13
15
 
14
16
  if pgdir = with_config( 'pg' )
@@ -158,6 +160,7 @@ have_func 'timegm'
158
160
  have_func 'rb_gc_adjust_memory_usage' # since ruby-2.4
159
161
  have_func 'rb_gc_mark_movable' # since ruby-2.7
160
162
  have_func 'rb_io_wait' # since ruby-3.0
163
+ have_func 'rb_io_descriptor' # since ruby-3.1
161
164
 
162
165
  # unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
163
166
  have_header 'unistd.h'
data/ext/pg.c CHANGED
@@ -543,7 +543,7 @@ Init_pg_ext(void)
543
543
  /* Result#result_error_field argument constant
544
544
  *
545
545
  * The SQLSTATE code for the error.
546
- * The SQLSTATE code identies the type of error that has occurred; it can be used by front-end applications to perform specific operations (such as error handling) in response to a particular database error.
546
+ * The SQLSTATE code identifies the type of error that has occurred; it can be used by front-end applications to perform specific operations (such as error handling) in response to a particular database error.
547
547
  * For a list of the possible SQLSTATE codes, see Appendix A.
548
548
  * This field is not localizable, and is always present.
549
549
  */
data/ext/pg_connection.c CHANGED
@@ -33,8 +33,8 @@ static VALUE pgconn_async_flush(VALUE self);
33
33
  #ifdef __GNUC__
34
34
  __attribute__((format(printf, 3, 4)))
35
35
  #endif
36
- static void
37
- pg_raise_conn_error( VALUE klass, VALUE self, const char *format, ...)
36
+ NORETURN( static void
37
+ pg_raise_conn_error( VALUE klass, VALUE self, const char *format, ...))
38
38
  {
39
39
  VALUE msg, error;
40
40
  va_list ap;
@@ -515,9 +515,9 @@ static VALUE
515
515
  pgconn_connect_poll(VALUE self)
516
516
  {
517
517
  PostgresPollingStatusType status;
518
- status = gvl_PQconnectPoll(pg_get_pgconn(self));
519
518
 
520
519
  pgconn_close_socket_io(self);
520
+ status = gvl_PQconnectPoll(pg_get_pgconn(self));
521
521
 
522
522
  return INT2FIX((int)status);
523
523
  }
@@ -615,9 +615,9 @@ static VALUE
615
615
  pgconn_reset_poll(VALUE self)
616
616
  {
617
617
  PostgresPollingStatusType status;
618
- status = gvl_PQresetPoll(pg_get_pgconn(self));
619
618
 
620
619
  pgconn_close_socket_io(self);
620
+ status = gvl_PQresetPoll(pg_get_pgconn(self));
621
621
 
622
622
  return INT2FIX((int)status);
623
623
  }
@@ -2266,6 +2266,17 @@ pgconn_notifies(VALUE self)
2266
2266
  return hash;
2267
2267
  }
2268
2268
 
2269
+ #ifndef HAVE_RB_IO_DESCRIPTOR
2270
+ static int
2271
+ rb_io_descriptor(VALUE io)
2272
+ {
2273
+ Check_Type(io, T_FILE);
2274
+ rb_io_t *fptr = RFILE(io)->fptr;
2275
+ rb_io_check_closed(fptr);
2276
+ return fptr->fd;
2277
+ }
2278
+ #endif
2279
+
2269
2280
  #if defined(_WIN32)
2270
2281
 
2271
2282
  /* We use a specialized implementation of rb_io_wait() on Windows.
@@ -2286,7 +2297,6 @@ int rb_w32_wait_events( HANDLE *events, int num, DWORD timeout );
2286
2297
 
2287
2298
  static VALUE
2288
2299
  pg_rb_thread_io_wait(VALUE io, VALUE events, VALUE timeout) {
2289
- rb_io_t *fptr;
2290
2300
  struct timeval ptimeout;
2291
2301
 
2292
2302
  struct timeval aborttime={0,0}, currtime, waittime;
@@ -2297,7 +2307,6 @@ pg_rb_thread_io_wait(VALUE io, VALUE events, VALUE timeout) {
2297
2307
  long w32_events = 0;
2298
2308
  DWORD wait_ret;
2299
2309
 
2300
- GetOpenFile((io), fptr);
2301
2310
  if( !NIL_P(timeout) ){
2302
2311
  ptimeout.tv_sec = (time_t)(NUM2DBL(timeout));
2303
2312
  ptimeout.tv_usec = (time_t)((NUM2DBL(timeout) - (double)ptimeout.tv_sec) * 1e6);
@@ -2311,7 +2320,7 @@ pg_rb_thread_io_wait(VALUE io, VALUE events, VALUE timeout) {
2311
2320
  if(rb_events & PG_RUBY_IO_PRIORITY) w32_events |= FD_OOB;
2312
2321
 
2313
2322
  for(;;) {
2314
- if ( WSAEventSelect(_get_osfhandle(fptr->fd), hEvent, w32_events) == SOCKET_ERROR ) {
2323
+ if ( WSAEventSelect(_get_osfhandle(rb_io_descriptor(io)), hEvent, w32_events) == SOCKET_ERROR ) {
2315
2324
  WSACloseEvent( hEvent );
2316
2325
  rb_raise( rb_eConnectionBad, "WSAEventSelect socket error: %d", WSAGetLastError() );
2317
2326
  }
@@ -2354,7 +2363,7 @@ static VALUE
2354
2363
  pg_rb_io_wait(VALUE io, VALUE events, VALUE timeout) {
2355
2364
  #if defined(HAVE_RUBY_FIBER_SCHEDULER_H)
2356
2365
  /* We don't support Fiber.scheduler on Windows ruby-3.0 because there is no fast way to check whether a scheduler is active.
2357
- * Fortunatelly ruby-3.1 offers a C-API for it.
2366
+ * Fortunately ruby-3.1 offers a C-API for it.
2358
2367
  */
2359
2368
  VALUE scheduler = rb_fiber_scheduler_current();
2360
2369
 
@@ -2384,16 +2393,14 @@ typedef enum {
2384
2393
 
2385
2394
  static VALUE
2386
2395
  pg_rb_io_wait(VALUE io, VALUE events, VALUE timeout) {
2387
- rb_io_t *fptr;
2388
2396
  struct timeval waittime;
2389
2397
  int res;
2390
2398
 
2391
- GetOpenFile((io), fptr);
2392
2399
  if( !NIL_P(timeout) ){
2393
2400
  waittime.tv_sec = (time_t)(NUM2DBL(timeout));
2394
2401
  waittime.tv_usec = (time_t)((NUM2DBL(timeout) - (double)waittime.tv_sec) * 1e6);
2395
2402
  }
2396
- res = rb_wait_for_single_fd(fptr->fd, NUM2UINT(events), NIL_P(timeout) ? NULL : &waittime);
2403
+ res = rb_wait_for_single_fd(rb_io_descriptor(io), NUM2UINT(events), NIL_P(timeout) ? NULL : &waittime);
2397
2404
 
2398
2405
  return UINT2NUM(res);
2399
2406
  }
@@ -3162,7 +3169,7 @@ pgconn_async_get_last_result(VALUE self)
3162
3169
  * Returns:
3163
3170
  * * +nil+ when the connection is already idle
3164
3171
  * * +true+ when some results have been discarded
3165
- * * +false+ when a failure occured and the connection was closed
3172
+ * * +false+ when a failure occurred and the connection was closed
3166
3173
  *
3167
3174
  */
3168
3175
  static VALUE
data/ext/pg_copy_coder.c CHANGED
@@ -235,7 +235,7 @@ pg_text_enc_copy_row(t_pg_coder *conv, VALUE value, char *out, VALUE *intermedia
235
235
  char *ptr1;
236
236
  char *ptr2;
237
237
  int strlen;
238
- int backslashs;
238
+ int backslashes;
239
239
  VALUE subint;
240
240
  VALUE entry;
241
241
 
@@ -286,19 +286,19 @@ pg_text_enc_copy_row(t_pg_coder *conv, VALUE value, char *out, VALUE *intermedia
286
286
  ptr2 = current_out + strlen;
287
287
 
288
288
  /* count required backlashs */
289
- for(backslashs = 0; ptr1 != ptr2; ptr1++) {
289
+ for(backslashes = 0; ptr1 != ptr2; ptr1++) {
290
290
  /* Escape backslash itself, newline, carriage return, and the current delimiter character. */
291
291
  if(*ptr1 == '\\' || *ptr1 == '\n' || *ptr1 == '\r' || *ptr1 == this->delimiter){
292
- backslashs++;
292
+ backslashes++;
293
293
  }
294
294
  }
295
295
 
296
296
  ptr1 = current_out + strlen;
297
- ptr2 = current_out + strlen + backslashs;
297
+ ptr2 = current_out + strlen + backslashes;
298
298
  current_out = ptr2;
299
299
 
300
300
  /* Then store the escaped string on the final position, walking
301
- * right to left, until all backslashs are placed. */
301
+ * right to left, until all backslashes are placed. */
302
302
  while( ptr1 != ptr2 ) {
303
303
  *--ptr2 = *--ptr1;
304
304
  if(*ptr1 == '\\' || *ptr1 == '\n' || *ptr1 == '\r' || *ptr1 == this->delimiter){
@@ -391,7 +391,7 @@ pg_bin_enc_copy_row(t_pg_coder *conv, VALUE value, char *out, VALUE *intermediat
391
391
 
392
392
  switch(TYPE(entry)){
393
393
  case T_NIL:
394
- /* 4 bytes for -1 indicationg a NULL value */
394
+ /* 4 bytes for -1 indicating a NULL value */
395
395
  PG_RB_STR_ENSURE_CAPA( *intermediate, 4, current_out, end_capa_ptr );
396
396
  write_nbo32(-1, current_out);
397
397
  current_out += 4;
@@ -198,7 +198,7 @@ pg_text_enc_record(t_pg_coder *conv, VALUE value, char *out, VALUE *intermediate
198
198
  char *ptr1;
199
199
  char *ptr2;
200
200
  long strlen;
201
- int backslashs;
201
+ int backslashes;
202
202
  VALUE subint;
203
203
  VALUE entry;
204
204
 
@@ -249,19 +249,19 @@ pg_text_enc_record(t_pg_coder *conv, VALUE value, char *out, VALUE *intermediate
249
249
  ptr2 = current_out + strlen;
250
250
 
251
251
  /* count required backlashs */
252
- for(backslashs = 0; ptr1 != ptr2; ptr1++) {
252
+ for(backslashes = 0; ptr1 != ptr2; ptr1++) {
253
253
  /* Escape backslash itself, newline, carriage return, and the current delimiter character. */
254
254
  if(*ptr1 == '"' || *ptr1 == '\\'){
255
- backslashs++;
255
+ backslashes++;
256
256
  }
257
257
  }
258
258
 
259
259
  ptr1 = current_out + strlen;
260
- ptr2 = current_out + strlen + backslashs;
260
+ ptr2 = current_out + strlen + backslashes;
261
261
  current_out = ptr2;
262
262
 
263
263
  /* Then store the escaped string on the final position, walking
264
- * right to left, until all backslashs are placed. */
264
+ * right to left, until all backslashes are placed. */
265
265
  while( ptr1 != ptr2 ) {
266
266
  *--ptr2 = *--ptr1;
267
267
  if(*ptr1 == '"' || *ptr1 == '\\'){
data/ext/pg_result.c CHANGED
@@ -664,7 +664,7 @@ pgresult_verbose_error_message(VALUE self, VALUE verbosity, VALUE show_context)
664
664
  * An example:
665
665
  *
666
666
  * begin
667
- * conn.exec( "SELECT * FROM nonexistant_table" )
667
+ * conn.exec( "SELECT * FROM nonexistent_table" )
668
668
  * rescue PG::Error => err
669
669
  * p [
670
670
  * err.result.error_field( PG::Result::PG_DIAG_SEVERITY ),
@@ -684,7 +684,7 @@ pgresult_verbose_error_message(VALUE self, VALUE verbosity, VALUE show_context)
684
684
  *
685
685
  * Outputs:
686
686
  *
687
- * ["ERROR", "42P01", "relation \"nonexistant_table\" does not exist", nil, nil,
687
+ * ["ERROR", "42P01", "relation \"nonexistent_table\" does not exist", nil, nil,
688
688
  * "15", nil, nil, nil, "path/to/parse_relation.c", "857", "parserOpenTable"]
689
689
  */
690
690
  static VALUE
@@ -174,7 +174,7 @@ pg_text_dec_numeric(t_pg_coder *conv, const char *val, int len, int tuple, int f
174
174
  static VALUE
175
175
  init_pg_text_decoder_numeric(VALUE rb_mPG_TextDecoder)
176
176
  {
177
- rb_require("bigdecimal");
177
+ rb_funcall(rb_mPG, rb_intern("require_bigdecimal_without_warning"), 0);
178
178
  s_id_BigDecimal = rb_intern("BigDecimal");
179
179
 
180
180
  /* dummy = rb_define_class_under( rb_mPG_TextDecoder, "Numeric", rb_cPG_SimpleDecoder ); */
@@ -377,7 +377,7 @@ init_pg_text_encoder_numeric(VALUE rb_mPG_TextDecoder)
377
377
  {
378
378
  s_str_F = rb_str_freeze(rb_str_new_cstr("F"));
379
379
  rb_global_variable(&s_str_F);
380
- rb_require("bigdecimal");
380
+ rb_funcall(rb_mPG, rb_intern("require_bigdecimal_without_warning"), 0);
381
381
  s_cBigDecimal = rb_const_get(rb_cObject, rb_intern("BigDecimal"));
382
382
 
383
383
  /* dummy = rb_define_class_under( rb_mPG_TextEncoder, "Numeric", rb_cPG_SimpleEncoder ); */
@@ -437,7 +437,7 @@ quote_array_buffer( void *_this, char *p_in, int strlen, char *p_out ){
437
437
  t_pg_composite_coder *this = _this;
438
438
  char *ptr1;
439
439
  char *ptr2;
440
- int backslashs = 0;
440
+ int backslashes = 0;
441
441
  int needquote;
442
442
 
443
443
  /* count data plus backslashes; detect chars needing quotes */
@@ -454,7 +454,7 @@ quote_array_buffer( void *_this, char *p_in, int strlen, char *p_out ){
454
454
 
455
455
  if (ch == '"' || ch == '\\'){
456
456
  needquote = 1;
457
- backslashs++;
457
+ backslashes++;
458
458
  } else if (ch == '{' || ch == '}' || ch == this->delimiter ||
459
459
  ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r' || ch == '\v' || ch == '\f'){
460
460
  needquote = 1;
@@ -463,12 +463,12 @@ quote_array_buffer( void *_this, char *p_in, int strlen, char *p_out ){
463
463
 
464
464
  if( needquote ){
465
465
  ptr1 = p_in + strlen;
466
- ptr2 = p_out + strlen + backslashs + 2;
466
+ ptr2 = p_out + strlen + backslashes + 2;
467
467
  /* Write end quote */
468
468
  *--ptr2 = '"';
469
469
 
470
470
  /* Then store the escaped string on the final position, walking
471
- * right to left, until all backslashs are placed. */
471
+ * right to left, until all backslashes are placed. */
472
472
  while( ptr1 != p_in ) {
473
473
  *--ptr2 = *--ptr1;
474
474
  if(*ptr2 == '"' || *ptr2 == '\\'){
@@ -477,7 +477,7 @@ quote_array_buffer( void *_this, char *p_in, int strlen, char *p_out ){
477
477
  }
478
478
  /* Write start quote */
479
479
  *p_out = '"';
480
- return strlen + backslashs + 2;
480
+ return strlen + backslashes + 2;
481
481
  } else {
482
482
  if( p_in != p_out )
483
483
  memcpy( p_out, p_in, strlen );
@@ -692,22 +692,22 @@ static int
692
692
  quote_literal_buffer( void *_this, char *p_in, int strlen, char *p_out ){
693
693
  char *ptr1;
694
694
  char *ptr2;
695
- int backslashs = 0;
695
+ int backslashes = 0;
696
696
 
697
697
  /* count required backlashs */
698
698
  for(ptr1 = p_in; ptr1 != p_in + strlen; ptr1++) {
699
699
  if (*ptr1 == '\''){
700
- backslashs++;
700
+ backslashes++;
701
701
  }
702
702
  }
703
703
 
704
704
  ptr1 = p_in + strlen;
705
- ptr2 = p_out + strlen + backslashs + 2;
705
+ ptr2 = p_out + strlen + backslashes + 2;
706
706
  /* Write end quote */
707
707
  *--ptr2 = '\'';
708
708
 
709
709
  /* Then store the escaped string on the final position, walking
710
- * right to left, until all backslashs are placed. */
710
+ * right to left, until all backslashes are placed. */
711
711
  while( ptr1 != p_in ) {
712
712
  *--ptr2 = *--ptr1;
713
713
  if(*ptr2 == '\''){
@@ -716,7 +716,7 @@ quote_literal_buffer( void *_this, char *p_in, int strlen, char *p_out ){
716
716
  }
717
717
  /* Write start quote */
718
718
  *p_out = '\'';
719
- return strlen + backslashs + 2;
719
+ return strlen + backslashes + 2;
720
720
  }
721
721
 
722
722
 
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
@@ -167,7 +167,7 @@ class PG::BasicTypeMapForQueries < PG::TypeMapByClass
167
167
  end
168
168
 
169
169
  begin
170
- require "bigdecimal"
170
+ PG.require_bigdecimal_without_warning
171
171
  has_bigdecimal = true
172
172
  rescue LoadError
173
173
  end
@@ -171,7 +171,14 @@ class PG::BasicTypeRegistry
171
171
  include Checker
172
172
 
173
173
  def initialize
174
- # The key of these hashs maps to the `typname` column from the table pg_type.
174
+ # @coders_by_name has a content of
175
+ # Array< Hash< Symbol: Hash< String: Coder > > >
176
+ #
177
+ # The layers are:
178
+ # * index of Array is 0 (text) and 1 (binary)
179
+ # * Symbol key in the middle Hash is :encoder and :decoder
180
+ # * String key in the inner Hash corresponds to the `typname` column in the table pg_type
181
+ # * Coder value in the inner Hash is the associated coder object
175
182
  @coders_by_name = []
176
183
  end
177
184
 
@@ -226,7 +233,7 @@ class PG::BasicTypeRegistry
226
233
  alias_type 0, 'oid', 'int2'
227
234
 
228
235
  begin
229
- require "bigdecimal"
236
+ PG.require_bigdecimal_without_warning
230
237
  register_type 0, 'numeric', PG::TextEncoder::Numeric, PG::TextDecoder::Numeric
231
238
  rescue LoadError
232
239
  end
data/lib/pg/connection.rb CHANGED
@@ -166,7 +166,10 @@ class PG::Connection
166
166
  # conn.put_copy_data ['more', 'data', 'to', 'copy']
167
167
  # end
168
168
  #
169
- # Also PG::BinaryEncoder::CopyRow can be used to send data in binary format to the server.
169
+ # All 4 CopyRow classes can take a type map to specify how the columns are mapped to and from the database format.
170
+ # For details see the particular CopyRow class description.
171
+ #
172
+ # PG::BinaryEncoder::CopyRow can be used to send data in binary format to the server.
170
173
  # In this case copy_data generates the header and trailer data automatically:
171
174
  # enco = PG::BinaryEncoder::CopyRow.new
172
175
  # conn.copy_data "COPY my_table FROM STDIN (FORMAT binary)", enco do
@@ -306,6 +309,11 @@ class PG::Connection
306
309
  rollback = false
307
310
  exec "BEGIN"
308
311
  yield(self)
312
+ rescue PG::RollbackTransaction
313
+ rollback = true
314
+ cancel if transaction_status == PG::PQTRANS_ACTIVE
315
+ block
316
+ exec "ROLLBACK"
309
317
  rescue Exception
310
318
  rollback = true
311
319
  cancel if transaction_status == PG::PQTRANS_ACTIVE
@@ -493,7 +501,7 @@ class PG::Connection
493
501
  # See also #copy_data.
494
502
  #
495
503
  def put_copy_data(buffer, encoder=nil)
496
- # sync_put_copy_data does a non-blocking attept to flush data.
504
+ # sync_put_copy_data does a non-blocking attempt to flush data.
497
505
  until res=sync_put_copy_data(buffer, encoder)
498
506
  # It didn't flush immediately and allocation of more buffering memory failed.
499
507
  # Wait for all data sent by doing a blocking flush.
data/lib/pg/exceptions.rb CHANGED
@@ -21,5 +21,11 @@ module PG
21
21
  class NotInBlockingMode < PG::Error
22
22
  end
23
23
 
24
+ # PG::Connection#transaction uses this exception to distinguish a deliberate rollback from other exceptional situations.
25
+ # Normally, raising an exception will cause the .transaction method to rollback the database transaction and pass on the exception.
26
+ # But if you raise an PG::RollbackTransaction exception, then the database transaction will be rolled back, without passing on the exception.
27
+ class RollbackTransaction < StandardError
28
+ end
29
+
24
30
  end # module PG
25
31
 
data/lib/pg/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module PG
2
2
  # Library version
3
- VERSION = '1.5.6'
3
+ VERSION = '1.5.7'
4
4
  end
data/lib/pg.rb CHANGED
@@ -126,4 +126,14 @@ module PG
126
126
  Warning.extend(TruffleFixWarn)
127
127
  end
128
128
 
129
+ # Ruby-3.4+ prints a warning, if bigdecimal is required but not in the Gemfile.
130
+ # But it's a false positive, since we enable bigdecimal depending features only if it's available.
131
+ # And most people don't need these features.
132
+ def self.require_bigdecimal_without_warning
133
+ oldverb, $VERBOSE = $VERBOSE, nil
134
+ require "bigdecimal"
135
+ ensure
136
+ $VERBOSE = oldverb
137
+ end
138
+
129
139
  end # module PG
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.5.6
4
+ version: 1.5.7
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Michael Granger
@@ -34,7 +34,7 @@ cert_chain:
34
34
  5wFER6XhvvLDFAMh/jMg+s7Wd5SbSHgHNSUaUGVtdWkVPOer6oF0aLdZUR3CETkn
35
35
  5nWXZma/BUd3YgYA/Xumc6QQqIS4p7mr
36
36
  -----END CERTIFICATE-----
37
- date: 2024-03-01 00:00:00.000000000 Z
37
+ date: 2024-07-28 00:00:00.000000000 Z
38
38
  dependencies: []
39
39
  description: Pg is the Ruby interface to the PostgreSQL RDBMS. It works with PostgreSQL
40
40
  9.3 and later.
metadata.gz.sig CHANGED
Binary file