pg 1.3.3 → 1.5.3

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.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.appveyor.yml +15 -9
  4. data/.github/workflows/binary-gems.yml +43 -12
  5. data/.github/workflows/source-gem.yml +28 -20
  6. data/.gitignore +11 -2
  7. data/.travis.yml +2 -2
  8. data/{History.rdoc → History.md} +302 -115
  9. data/README.ja.md +276 -0
  10. data/README.md +286 -0
  11. data/Rakefile +15 -6
  12. data/Rakefile.cross +7 -11
  13. data/certs/larskanis-2023.pem +24 -0
  14. data/ext/errorcodes.def +4 -0
  15. data/ext/errorcodes.rb +0 -0
  16. data/ext/errorcodes.txt +2 -1
  17. data/ext/extconf.rb +0 -0
  18. data/ext/pg.c +14 -54
  19. data/ext/pg.h +12 -5
  20. data/ext/pg_binary_decoder.c +80 -1
  21. data/ext/pg_binary_encoder.c +225 -1
  22. data/ext/pg_coder.c +17 -8
  23. data/ext/pg_connection.c +385 -266
  24. data/ext/pg_copy_coder.c +307 -18
  25. data/ext/pg_errors.c +1 -1
  26. data/ext/pg_record_coder.c +12 -9
  27. data/ext/pg_result.c +117 -34
  28. data/ext/pg_text_decoder.c +28 -10
  29. data/ext/pg_text_encoder.c +23 -10
  30. data/ext/pg_tuple.c +36 -39
  31. data/ext/pg_type_map.c +4 -3
  32. data/ext/pg_type_map_all_strings.c +3 -3
  33. data/ext/pg_type_map_by_class.c +6 -4
  34. data/ext/pg_type_map_by_column.c +9 -5
  35. data/ext/pg_type_map_by_mri_type.c +1 -1
  36. data/ext/pg_type_map_by_oid.c +8 -5
  37. data/ext/pg_type_map_in_ruby.c +6 -3
  38. data/lib/pg/basic_type_map_based_on_result.rb +21 -1
  39. data/lib/pg/basic_type_map_for_queries.rb +13 -8
  40. data/lib/pg/basic_type_map_for_results.rb +26 -3
  41. data/lib/pg/basic_type_registry.rb +36 -33
  42. data/lib/pg/binary_decoder/date.rb +9 -0
  43. data/lib/pg/binary_decoder/timestamp.rb +26 -0
  44. data/lib/pg/binary_encoder/timestamp.rb +20 -0
  45. data/lib/pg/coder.rb +15 -13
  46. data/lib/pg/connection.rb +269 -139
  47. data/lib/pg/exceptions.rb +14 -1
  48. data/lib/pg/text_decoder/date.rb +18 -0
  49. data/lib/pg/text_decoder/inet.rb +9 -0
  50. data/lib/pg/text_decoder/json.rb +14 -0
  51. data/lib/pg/text_decoder/numeric.rb +9 -0
  52. data/lib/pg/text_decoder/timestamp.rb +30 -0
  53. data/lib/pg/text_encoder/date.rb +12 -0
  54. data/lib/pg/text_encoder/inet.rb +28 -0
  55. data/lib/pg/text_encoder/json.rb +14 -0
  56. data/lib/pg/text_encoder/numeric.rb +9 -0
  57. data/lib/pg/text_encoder/timestamp.rb +24 -0
  58. data/lib/pg/version.rb +1 -1
  59. data/lib/pg.rb +59 -19
  60. data/misc/openssl-pg-segfault.rb +0 -0
  61. data/pg.gemspec +4 -2
  62. data/rakelib/task_extension.rb +1 -1
  63. data/sample/array_insert.rb +0 -0
  64. data/sample/async_api.rb +3 -7
  65. data/sample/async_copyto.rb +0 -0
  66. data/sample/async_mixed.rb +0 -0
  67. data/sample/check_conn.rb +0 -0
  68. data/sample/copydata.rb +0 -0
  69. data/sample/copyfrom.rb +0 -0
  70. data/sample/copyto.rb +0 -0
  71. data/sample/cursor.rb +0 -0
  72. data/sample/disk_usage_report.rb +0 -0
  73. data/sample/issue-119.rb +0 -0
  74. data/sample/losample.rb +0 -0
  75. data/sample/minimal-testcase.rb +0 -0
  76. data/sample/notify_wait.rb +0 -0
  77. data/sample/pg_statistics.rb +0 -0
  78. data/sample/replication_monitor.rb +0 -0
  79. data/sample/test_binary_values.rb +0 -0
  80. data/sample/wal_shipper.rb +0 -0
  81. data/sample/warehouse_partitions.rb +0 -0
  82. data/translation/.po4a-version +7 -0
  83. data/translation/po/all.pot +910 -0
  84. data/translation/po/ja.po +1047 -0
  85. data/translation/po4a.cfg +12 -0
  86. data.tar.gz.sig +0 -0
  87. metadata +101 -32
  88. metadata.gz.sig +0 -0
  89. data/README.ja.rdoc +0 -13
  90. data/README.rdoc +0 -214
  91. data/lib/pg/binary_decoder.rb +0 -23
  92. data/lib/pg/constants.rb +0 -12
  93. data/lib/pg/text_decoder.rb +0 -46
  94. data/lib/pg/text_encoder.rb +0 -59
data/ext/pg_coder.c CHANGED
@@ -35,7 +35,7 @@ pg_coder_init_encoder( VALUE self )
35
35
  this->enc_func = NULL;
36
36
  }
37
37
  this->dec_func = NULL;
38
- this->coder_obj = self;
38
+ RB_OBJ_WRITE(self, &this->coder_obj, self);
39
39
  this->oid = 0;
40
40
  this->format = 0;
41
41
  this->flags = 0;
@@ -54,7 +54,7 @@ pg_coder_init_decoder( VALUE self )
54
54
  } else {
55
55
  this->dec_func = NULL;
56
56
  }
57
- this->coder_obj = self;
57
+ RB_OBJ_WRITE(self, &this->coder_obj, self);
58
58
  this->oid = 0;
59
59
  this->format = 0;
60
60
  this->flags = 0;
@@ -99,7 +99,9 @@ const rb_data_type_t pg_coder_type = {
99
99
  },
100
100
  0,
101
101
  0,
102
- RUBY_TYPED_FREE_IMMEDIATELY,
102
+ // IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE()
103
+ // macro to update VALUE references, as to trigger write barriers.
104
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | PG_RUBY_TYPED_FROZEN_SHAREABLE,
103
105
  };
104
106
 
105
107
  static VALUE
@@ -121,7 +123,7 @@ static const rb_data_type_t pg_composite_coder_type = {
121
123
  },
122
124
  &pg_coder_type,
123
125
  0,
124
- RUBY_TYPED_FREE_IMMEDIATELY,
126
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | PG_RUBY_TYPED_FROZEN_SHAREABLE,
125
127
  };
126
128
 
127
129
  static VALUE
@@ -273,6 +275,7 @@ static VALUE
273
275
  pg_coder_oid_set(VALUE self, VALUE oid)
274
276
  {
275
277
  t_pg_coder *this = RTYPEDDATA_DATA(self);
278
+ rb_check_frozen(self);
276
279
  this->oid = NUM2UINT(oid);
277
280
  return oid;
278
281
  }
@@ -304,6 +307,7 @@ static VALUE
304
307
  pg_coder_format_set(VALUE self, VALUE format)
305
308
  {
306
309
  t_pg_coder *this = RTYPEDDATA_DATA(self);
310
+ rb_check_frozen(self);
307
311
  this->format = NUM2INT(format);
308
312
  return format;
309
313
  }
@@ -335,6 +339,7 @@ static VALUE
335
339
  pg_coder_flags_set(VALUE self, VALUE flags)
336
340
  {
337
341
  t_pg_coder *this = RTYPEDDATA_DATA(self);
342
+ rb_check_frozen(self);
338
343
  this->flags = NUM2INT(flags);
339
344
  return flags;
340
345
  }
@@ -366,6 +371,7 @@ static VALUE
366
371
  pg_coder_needs_quotation_set(VALUE self, VALUE needs_quotation)
367
372
  {
368
373
  t_pg_composite_coder *this = RTYPEDDATA_DATA(self);
374
+ rb_check_frozen(self);
369
375
  this->needs_quotation = RTEST(needs_quotation);
370
376
  return needs_quotation;
371
377
  }
@@ -396,6 +402,7 @@ static VALUE
396
402
  pg_coder_delimiter_set(VALUE self, VALUE delimiter)
397
403
  {
398
404
  t_pg_composite_coder *this = RTYPEDDATA_DATA(self);
405
+ rb_check_frozen(self);
399
406
  StringValue(delimiter);
400
407
  if(RSTRING_LEN(delimiter) != 1)
401
408
  rb_raise( rb_eArgError, "delimiter size must be one byte");
@@ -430,6 +437,7 @@ pg_coder_elements_type_set(VALUE self, VALUE elem_type)
430
437
  {
431
438
  t_pg_composite_coder *this = RTYPEDDATA_DATA( self );
432
439
 
440
+ rb_check_frozen(self);
433
441
  if ( NIL_P(elem_type) ){
434
442
  this->elem = NULL;
435
443
  } else if ( rb_obj_is_kind_of(elem_type, rb_cPG_Coder) ){
@@ -452,10 +460,10 @@ static const rb_data_type_t pg_coder_cfunc_type = {
452
460
  },
453
461
  0,
454
462
  0,
455
- RUBY_TYPED_FREE_IMMEDIATELY,
463
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | PG_RUBY_TYPED_FROZEN_SHAREABLE,
456
464
  };
457
465
 
458
- void
466
+ VALUE
459
467
  pg_define_coder( const char *name, void *func, VALUE base_klass, VALUE nsp )
460
468
  {
461
469
  VALUE cfunc_obj = TypedData_Wrap_Struct( rb_cObject, &pg_coder_cfunc_type, func );
@@ -468,9 +476,10 @@ pg_define_coder( const char *name, void *func, VALUE base_klass, VALUE nsp )
468
476
  if( nsp==rb_mPG_BinaryDecoder || nsp==rb_mPG_TextDecoder )
469
477
  rb_define_method( coder_klass, "decode", pg_coder_decode, -1 );
470
478
 
471
- rb_define_const( coder_klass, "CFUNC", cfunc_obj );
479
+ rb_define_const( coder_klass, "CFUNC", rb_obj_freeze(cfunc_obj) );
472
480
 
473
481
  RB_GC_GUARD(cfunc_obj);
482
+ return coder_klass;
474
483
  }
475
484
 
476
485
 
@@ -537,7 +546,7 @@ pg_coder_dec_func(t_pg_coder *this, int binary)
537
546
 
538
547
 
539
548
  void
540
- init_pg_coder()
549
+ init_pg_coder(void)
541
550
  {
542
551
  s_id_encode = rb_intern("encode");
543
552
  s_id_decode = rb_intern("decode");