pg 0.21.0 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data/.appveyor.yml +36 -0
  4. data/.gems +6 -0
  5. data/.github/workflows/binary-gems.yml +86 -0
  6. data/.github/workflows/source-gem.yml +130 -0
  7. data/.gitignore +13 -0
  8. data/.hgsigs +34 -0
  9. data/.hgtags +41 -0
  10. data/.irbrc +23 -0
  11. data/.pryrc +23 -0
  12. data/.tm_properties +21 -0
  13. data/.travis.yml +49 -0
  14. data/Gemfile +14 -0
  15. data/History.rdoc +291 -4
  16. data/Manifest.txt +8 -4
  17. data/README-Windows.rdoc +4 -4
  18. data/README.ja.rdoc +1 -2
  19. data/README.rdoc +62 -16
  20. data/Rakefile +32 -142
  21. data/Rakefile.cross +69 -71
  22. data/certs/ged.pem +24 -0
  23. data/certs/larskanis-2022.pem +26 -0
  24. data/ext/errorcodes.def +84 -0
  25. data/ext/errorcodes.rb +1 -1
  26. data/ext/errorcodes.txt +23 -2
  27. data/ext/extconf.rb +109 -52
  28. data/ext/gvl_wrappers.c +8 -0
  29. data/ext/gvl_wrappers.h +40 -33
  30. data/ext/pg.c +211 -146
  31. data/ext/pg.h +85 -95
  32. data/ext/pg_binary_decoder.c +82 -15
  33. data/ext/pg_binary_encoder.c +13 -12
  34. data/ext/pg_coder.c +145 -30
  35. data/ext/pg_connection.c +1349 -929
  36. data/ext/pg_copy_coder.c +60 -23
  37. data/ext/pg_record_coder.c +519 -0
  38. data/ext/pg_result.c +613 -207
  39. data/ext/pg_text_decoder.c +606 -40
  40. data/ext/pg_text_encoder.c +190 -59
  41. data/ext/pg_tuple.c +575 -0
  42. data/ext/pg_type_map.c +42 -9
  43. data/ext/pg_type_map_all_strings.c +19 -5
  44. data/ext/pg_type_map_by_class.c +54 -24
  45. data/ext/pg_type_map_by_column.c +73 -34
  46. data/ext/pg_type_map_by_mri_type.c +48 -19
  47. data/ext/pg_type_map_by_oid.c +55 -25
  48. data/ext/pg_type_map_in_ruby.c +51 -20
  49. data/ext/{util.c → pg_util.c} +12 -12
  50. data/ext/{util.h → pg_util.h} +2 -2
  51. data/lib/pg/basic_type_map_based_on_result.rb +47 -0
  52. data/lib/pg/basic_type_map_for_queries.rb +193 -0
  53. data/lib/pg/basic_type_map_for_results.rb +81 -0
  54. data/lib/pg/basic_type_registry.rb +296 -0
  55. data/lib/pg/binary_decoder.rb +23 -0
  56. data/lib/pg/coder.rb +24 -3
  57. data/lib/pg/connection.rb +600 -46
  58. data/lib/pg/constants.rb +2 -1
  59. data/lib/pg/exceptions.rb +2 -1
  60. data/lib/pg/result.rb +14 -2
  61. data/lib/pg/text_decoder.rb +21 -26
  62. data/lib/pg/text_encoder.rb +32 -8
  63. data/lib/pg/tuple.rb +30 -0
  64. data/lib/pg/type_map_by_column.rb +3 -2
  65. data/lib/pg/version.rb +4 -0
  66. data/lib/pg.rb +51 -38
  67. data/misc/openssl-pg-segfault.rb +31 -0
  68. data/misc/postgres/History.txt +9 -0
  69. data/misc/postgres/Manifest.txt +5 -0
  70. data/misc/postgres/README.txt +21 -0
  71. data/misc/postgres/Rakefile +21 -0
  72. data/misc/postgres/lib/postgres.rb +16 -0
  73. data/misc/ruby-pg/History.txt +9 -0
  74. data/misc/ruby-pg/Manifest.txt +5 -0
  75. data/misc/ruby-pg/README.txt +21 -0
  76. data/misc/ruby-pg/Rakefile +21 -0
  77. data/misc/ruby-pg/lib/ruby/pg.rb +16 -0
  78. data/pg.gemspec +32 -0
  79. data/sample/array_insert.rb +20 -0
  80. data/sample/async_api.rb +106 -0
  81. data/sample/async_copyto.rb +39 -0
  82. data/sample/async_mixed.rb +56 -0
  83. data/sample/check_conn.rb +21 -0
  84. data/sample/copydata.rb +71 -0
  85. data/sample/copyfrom.rb +81 -0
  86. data/sample/copyto.rb +19 -0
  87. data/sample/cursor.rb +21 -0
  88. data/sample/disk_usage_report.rb +177 -0
  89. data/sample/issue-119.rb +94 -0
  90. data/sample/losample.rb +69 -0
  91. data/sample/minimal-testcase.rb +17 -0
  92. data/sample/notify_wait.rb +72 -0
  93. data/sample/pg_statistics.rb +285 -0
  94. data/sample/replication_monitor.rb +222 -0
  95. data/sample/test_binary_values.rb +33 -0
  96. data/sample/wal_shipper.rb +434 -0
  97. data/sample/warehouse_partitions.rb +311 -0
  98. data.tar.gz.sig +0 -0
  99. metadata +96 -229
  100. metadata.gz.sig +0 -0
  101. data/ChangeLog +0 -6595
  102. data/lib/pg/basic_type_mapping.rb +0 -426
  103. data/lib/pg/deprecated_constants.rb +0 -21
  104. data/spec/data/expected_trace.out +0 -26
  105. data/spec/data/random_binary_data +0 -0
  106. data/spec/helpers.rb +0 -352
  107. data/spec/pg/basic_type_mapping_spec.rb +0 -305
  108. data/spec/pg/connection_spec.rb +0 -1676
  109. data/spec/pg/result_spec.rb +0 -456
  110. data/spec/pg/type_map_by_class_spec.rb +0 -138
  111. data/spec/pg/type_map_by_column_spec.rb +0 -222
  112. data/spec/pg/type_map_by_mri_type_spec.rb +0 -136
  113. data/spec/pg/type_map_by_oid_spec.rb +0 -149
  114. data/spec/pg/type_map_in_ruby_spec.rb +0 -164
  115. data/spec/pg/type_map_spec.rb +0 -22
  116. data/spec/pg/type_spec.rb +0 -777
  117. data/spec/pg_spec.rb +0 -50
data/ext/pg.c CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * pg.c - Toplevel extension
3
- * $Id: pg.c,v c77d0997b4e4 2016/08/20 17:30:03 ged $
3
+ * $Id$
4
4
  *
5
5
  * Author/s:
6
6
  *
@@ -16,7 +16,7 @@
16
16
  * See Contributors.rdoc for the many additional fine people that have contributed
17
17
  * to this library over the years.
18
18
  *
19
- * Copyright (c) 1997-2016 by the authors.
19
+ * Copyright (c) 1997-2019 by the authors.
20
20
  *
21
21
  * You may redistribute this software under the same terms as Ruby itself; see
22
22
  * https://www.ruby-lang.org/en/about/license.txt or the BSDL file in the source
@@ -47,7 +47,9 @@
47
47
  */
48
48
 
49
49
  #include "pg.h"
50
+ #include "pg_config.h"
50
51
 
52
+ int pg_skip_deprecation_warning;
51
53
  VALUE rb_mPG;
52
54
  VALUE rb_mPGconstants;
53
55
 
@@ -69,7 +71,6 @@ VALUE rb_mPGconstants;
69
71
  * M17n functions
70
72
  */
71
73
 
72
- #ifdef M17N_SUPPORTED
73
74
  /**
74
75
  * The mapping from canonical encoding names in PostgreSQL to ones in Ruby.
75
76
  */
@@ -143,9 +144,6 @@ pg_find_or_create_johab(void)
143
144
  }
144
145
 
145
146
  enc_index = rb_define_dummy_encoding(aliases[0]);
146
- for (i = 1; i < sizeof(aliases)/sizeof(aliases[0]); ++i) {
147
- ENC_ALIAS(aliases[i], aliases[0]);
148
- }
149
147
  return rb_enc_from_index(enc_index);
150
148
  }
151
149
 
@@ -229,8 +227,6 @@ pg_get_rb_encoding_as_pg_encoding( rb_encoding *enc )
229
227
  return encname;
230
228
  }
231
229
 
232
- #endif /* M17N_SUPPORTED */
233
-
234
230
 
235
231
  /*
236
232
  * Ensures that the given string has enough capacity to take expand_len
@@ -260,45 +256,26 @@ pg_get_rb_encoding_as_pg_encoding( rb_encoding *enc )
260
256
  * rb_str_set_len( string, current_out - RSTRING_PTR(string) );
261
257
  *
262
258
  */
263
- #ifdef HAVE_RB_STR_MODIFY_EXPAND
264
- /* Use somewhat faster version with access to string capacity on MRI */
265
- char *
266
- pg_rb_str_ensure_capa( VALUE str, long expand_len, char *curr_ptr, char **end_ptr )
267
- {
268
- long curr_len = curr_ptr - RSTRING_PTR(str);
269
- long curr_capa = rb_str_capacity( str );
270
- if( curr_capa < curr_len + expand_len ){
271
- rb_str_set_len( str, curr_len );
272
- rb_str_modify_expand( str, (curr_len + expand_len) * 2 - curr_capa );
273
- curr_ptr = RSTRING_PTR(str) + curr_len;
274
- }
275
- if( end_ptr )
276
- *end_ptr = RSTRING_PTR(str) + rb_str_capacity( str );
277
- return curr_ptr;
278
- }
279
- #else
280
- /* Use the more portable version */
281
- char *
282
- pg_rb_str_ensure_capa( VALUE str, long expand_len, char *curr_ptr, char **end_ptr )
283
- {
284
- long curr_len = curr_ptr - RSTRING_PTR(str);
285
- long curr_capa = RSTRING_LEN( str );
286
- if( curr_capa < curr_len + expand_len ){
287
- rb_str_resize( str, (curr_len + expand_len) * 2 - curr_capa );
288
- curr_ptr = RSTRING_PTR(str) + curr_len;
289
- }
290
- if( end_ptr )
291
- *end_ptr = RSTRING_PTR(str) + RSTRING_LEN(str);
292
- return curr_ptr;
259
+ char *
260
+ pg_rb_str_ensure_capa( VALUE str, long expand_len, char *curr_ptr, char **end_ptr )
261
+ {
262
+ long curr_len = curr_ptr - RSTRING_PTR(str);
263
+ long curr_capa = rb_str_capacity( str );
264
+ if( curr_capa < curr_len + expand_len ){
265
+ rb_str_set_len( str, curr_len );
266
+ rb_str_modify_expand( str, (curr_len + expand_len) * 2 - curr_capa );
267
+ curr_ptr = RSTRING_PTR(str) + curr_len;
293
268
  }
294
- #endif
269
+ if( end_ptr )
270
+ *end_ptr = RSTRING_PTR(str) + rb_str_capacity( str );
271
+ return curr_ptr;
272
+ }
295
273
 
296
274
 
297
275
  /**************************************************************************
298
276
  * Module Methods
299
277
  **************************************************************************/
300
278
 
301
- #ifdef HAVE_PQLIBVERSION
302
279
  /*
303
280
  * call-seq:
304
281
  * PG.library_version -> Integer
@@ -316,7 +293,6 @@ pg_s_library_version(VALUE self)
316
293
  UNUSED( self );
317
294
  return INT2NUM(PQlibVersion());
318
295
  }
319
- #endif
320
296
 
321
297
 
322
298
  /*
@@ -356,8 +332,7 @@ pg_to_bool_int(VALUE value)
356
332
  * If your application initializes libssl and/or libcrypto libraries and libpq is
357
333
  * built with SSL support, you should call PG.init_openssl() to tell libpq that the
358
334
  * libssl and/or libcrypto libraries have been initialized by your application,
359
- * so that libpq will not also initialize those libraries. See
360
- * http://h71000.www7.hp.com/doc/83final/BA554_90007/ch04.html for details on the SSL API.
335
+ * so that libpq will not also initialize those libraries.
361
336
  *
362
337
  * When do_ssl is +true+, libpq will initialize the OpenSSL library before first
363
338
  * opening a database connection. When do_crypto is +true+, the libcrypto library
@@ -404,15 +379,20 @@ pg_s_init_ssl(VALUE self, VALUE do_ssl)
404
379
  void
405
380
  Init_pg_ext()
406
381
  {
382
+ if( RTEST(rb_eval_string("ENV['PG_SKIP_DEPRECATION_WARNING']")) ){
383
+ /* Set all bits to disable all deprecation warnings. */
384
+ pg_skip_deprecation_warning = 0xFFFF;
385
+ } else {
386
+ pg_skip_deprecation_warning = 0;
387
+ }
388
+
407
389
  rb_mPG = rb_define_module( "PG" );
408
390
  rb_mPGconstants = rb_define_module_under( rb_mPG, "Constants" );
409
391
 
410
392
  /*************************
411
393
  * PG module methods
412
394
  *************************/
413
- #ifdef HAVE_PQLIBVERSION
414
395
  rb_define_singleton_method( rb_mPG, "library_version", pg_s_library_version, 0 );
415
- #endif
416
396
  rb_define_singleton_method( rb_mPG, "isthreadsafe", pg_s_threadsafe_p, 0 );
417
397
  SINGLETON_ALIAS( rb_mPG, "is_threadsafe?", "isthreadsafe" );
418
398
  SINGLETON_ALIAS( rb_mPG, "threadsafe?", "isthreadsafe" );
@@ -436,14 +416,34 @@ Init_pg_ext()
436
416
  rb_define_const(rb_mPGconstants, "CONNECTION_MADE", INT2FIX(CONNECTION_MADE));
437
417
  /* Waiting for a response from the server. */
438
418
  rb_define_const(rb_mPGconstants, "CONNECTION_AWAITING_RESPONSE", INT2FIX(CONNECTION_AWAITING_RESPONSE));
439
- /* Received authentication; waiting for backend start-up to finish. */
419
+ /* Received authentication; waiting for backend startup. */
440
420
  rb_define_const(rb_mPGconstants, "CONNECTION_AUTH_OK", INT2FIX(CONNECTION_AUTH_OK));
421
+ /* This state is no longer used. */
422
+ rb_define_const(rb_mPGconstants, "CONNECTION_SETENV", INT2FIX(CONNECTION_SETENV));
441
423
  /* Negotiating SSL encryption. */
442
424
  rb_define_const(rb_mPGconstants, "CONNECTION_SSL_STARTUP", INT2FIX(CONNECTION_SSL_STARTUP));
443
- /* Negotiating environment-driven parameter settings. */
444
- rb_define_const(rb_mPGconstants, "CONNECTION_SETENV", INT2FIX(CONNECTION_SETENV));
445
- /* Internal state: connect() needed. */
425
+ /* Internal state - PG.connect() needed. */
446
426
  rb_define_const(rb_mPGconstants, "CONNECTION_NEEDED", INT2FIX(CONNECTION_NEEDED));
427
+ #if PG_MAJORVERSION_NUM >= 10
428
+ /* Checking if session is read-write. Available since PostgreSQL-10. */
429
+ rb_define_const(rb_mPGconstants, "CONNECTION_CHECK_WRITABLE", INT2FIX(CONNECTION_CHECK_WRITABLE));
430
+ #endif
431
+ #if PG_MAJORVERSION_NUM >= 10
432
+ /* Consuming any extra messages. Available since PostgreSQL-10. */
433
+ rb_define_const(rb_mPGconstants, "CONNECTION_CONSUME", INT2FIX(CONNECTION_CONSUME));
434
+ #endif
435
+ #if PG_MAJORVERSION_NUM >= 12
436
+ /* Negotiating GSSAPI. Available since PostgreSQL-12. */
437
+ rb_define_const(rb_mPGconstants, "CONNECTION_GSS_STARTUP", INT2FIX(CONNECTION_GSS_STARTUP));
438
+ #endif
439
+ #if PG_MAJORVERSION_NUM >= 13
440
+ /* Checking target server properties. Available since PostgreSQL-13. */
441
+ rb_define_const(rb_mPGconstants, "CONNECTION_CHECK_TARGET", INT2FIX(CONNECTION_CHECK_TARGET));
442
+ #endif
443
+ #if PG_MAJORVERSION_NUM >= 14
444
+ /* Checking if server is in standby mode. Available since PostgreSQL-14. */
445
+ rb_define_const(rb_mPGconstants, "CONNECTION_CHECK_STANDBY", INT2FIX(CONNECTION_CHECK_STANDBY));
446
+ #endif
447
447
 
448
448
  /****** PG::Connection CLASS CONSTANTS: Nonblocking connection polling status ******/
449
449
 
@@ -458,27 +458,48 @@ Init_pg_ext()
458
458
 
459
459
  /****** PG::Connection CLASS CONSTANTS: Transaction Status ******/
460
460
 
461
- /* Transaction is currently idle (#transaction_status) */
461
+ /* Transaction is currently idle ( Connection#transaction_status ) */
462
462
  rb_define_const(rb_mPGconstants, "PQTRANS_IDLE", INT2FIX(PQTRANS_IDLE));
463
- /* Transaction is currently active; query has been sent to the server, but not yet completed. (#transaction_status) */
463
+ /* Transaction is currently active; query has been sent to the server, but not yet completed. ( Connection#transaction_status ) */
464
464
  rb_define_const(rb_mPGconstants, "PQTRANS_ACTIVE", INT2FIX(PQTRANS_ACTIVE));
465
- /* Transaction is currently idle, in a valid transaction block (#transaction_status) */
465
+ /* Transaction is currently idle, in a valid transaction block ( Connection#transaction_status ) */
466
466
  rb_define_const(rb_mPGconstants, "PQTRANS_INTRANS", INT2FIX(PQTRANS_INTRANS));
467
- /* Transaction is currently idle, in a failed transaction block (#transaction_status) */
467
+ /* Transaction is currently idle, in a failed transaction block ( Connection#transaction_status ) */
468
468
  rb_define_const(rb_mPGconstants, "PQTRANS_INERROR", INT2FIX(PQTRANS_INERROR));
469
- /* Transaction's connection is bad (#transaction_status) */
469
+ /* Transaction's connection is bad ( Connection#transaction_status ) */
470
470
  rb_define_const(rb_mPGconstants, "PQTRANS_UNKNOWN", INT2FIX(PQTRANS_UNKNOWN));
471
471
 
472
472
  /****** PG::Connection CLASS CONSTANTS: Error Verbosity ******/
473
473
 
474
- /* Terse error verbosity level (#set_error_verbosity) */
474
+ /* Error verbosity level ( Connection#set_error_verbosity ).
475
+ * In TERSE mode, returned messages include severity, primary text, and position only; this will normally fit on a single line. */
475
476
  rb_define_const(rb_mPGconstants, "PQERRORS_TERSE", INT2FIX(PQERRORS_TERSE));
476
- /* Default error verbosity level (#set_error_verbosity) */
477
+ /* Error verbosity level ( Connection#set_error_verbosity ).
478
+ * The DEFAULT mode produces messages that include the above plus any detail, hint, or context fields (these might span multiple lines). */
477
479
  rb_define_const(rb_mPGconstants, "PQERRORS_DEFAULT", INT2FIX(PQERRORS_DEFAULT));
478
- /* Verbose error verbosity level (#set_error_verbosity) */
480
+ /* Error verbosity level ( Connection#set_error_verbosity ).
481
+ * The VERBOSE mode includes all available fields. */
479
482
  rb_define_const(rb_mPGconstants, "PQERRORS_VERBOSE", INT2FIX(PQERRORS_VERBOSE));
480
483
 
481
- #ifdef HAVE_PQPING
484
+ /* PQERRORS_SQLSTATE was introduced in PG-12 together with PQresultMemorySize() */
485
+ #ifdef HAVE_PQRESULTMEMORYSIZE
486
+ /* Error verbosity level ( Connection#set_error_verbosity ).
487
+ * The SQLSTATE mode includes only the error severity and the SQLSTATE error code, if one is available (if not, the output is like TERSE mode).
488
+ *
489
+ * Available since PostgreSQL-12.
490
+ */
491
+ rb_define_const(rb_mPGconstants, "PQERRORS_SQLSTATE", INT2FIX(PQERRORS_SQLSTATE));
492
+ #endif
493
+
494
+ #ifdef HAVE_PQRESULTVERBOSEERRORMESSAGE
495
+ /* See Connection#set_error_context_visibility */
496
+ rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_NEVER", INT2FIX(PQSHOW_CONTEXT_NEVER));
497
+ /* See Connection#set_error_context_visibility */
498
+ rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_ERRORS", INT2FIX(PQSHOW_CONTEXT_ERRORS));
499
+ /* See Connection#set_error_context_visibility */
500
+ rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_ALWAYS", INT2FIX(PQSHOW_CONTEXT_ALWAYS));
501
+ #endif
502
+
482
503
  /****** PG::Connection CLASS CONSTANTS: Check Server Status ******/
483
504
 
484
505
  /* Server is accepting connections. */
@@ -489,152 +510,196 @@ Init_pg_ext()
489
510
  rb_define_const(rb_mPGconstants, "PQPING_NO_RESPONSE", INT2FIX(PQPING_NO_RESPONSE));
490
511
  /* Connection not attempted (bad params). */
491
512
  rb_define_const(rb_mPGconstants, "PQPING_NO_ATTEMPT", INT2FIX(PQPING_NO_ATTEMPT));
492
- #endif
493
513
 
494
514
  /****** PG::Connection CLASS CONSTANTS: Large Objects ******/
495
515
 
496
- /* Flag for #lo_creat, #lo_open -- open for writing */
516
+ /* Flag for Connection#lo_creat, Connection#lo_open -- open for writing */
497
517
  rb_define_const(rb_mPGconstants, "INV_WRITE", INT2FIX(INV_WRITE));
498
- /* Flag for #lo_creat, #lo_open -- open for reading */
518
+ /* Flag for Connection#lo_creat, Connection#lo_open -- open for reading */
499
519
  rb_define_const(rb_mPGconstants, "INV_READ", INT2FIX(INV_READ));
500
- /* Flag for #lo_lseek -- seek from object start */
520
+ /* Flag for Connection#lo_lseek -- seek from object start */
501
521
  rb_define_const(rb_mPGconstants, "SEEK_SET", INT2FIX(SEEK_SET));
502
- /* Flag for #lo_lseek -- seek from current position */
522
+ /* Flag for Connection#lo_lseek -- seek from current position */
503
523
  rb_define_const(rb_mPGconstants, "SEEK_CUR", INT2FIX(SEEK_CUR));
504
- /* Flag for #lo_lseek -- seek from object end */
524
+ /* Flag for Connection#lo_lseek -- seek from object end */
505
525
  rb_define_const(rb_mPGconstants, "SEEK_END", INT2FIX(SEEK_END));
506
526
 
507
527
  /****** PG::Result CONSTANTS: result status ******/
508
528
 
509
- /* #result_status constant: The string sent to the server was empty. */
529
+ /* Result#result_status constant - The string sent to the server was empty. */
510
530
  rb_define_const(rb_mPGconstants, "PGRES_EMPTY_QUERY", INT2FIX(PGRES_EMPTY_QUERY));
511
- /* #result_status constant: Successful completion of a command returning no data. */
531
+ /* Result#result_status constant - Successful completion of a command returning no data. */
512
532
  rb_define_const(rb_mPGconstants, "PGRES_COMMAND_OK", INT2FIX(PGRES_COMMAND_OK));
513
- /* #result_status constant: Successful completion of a command returning data
514
- (such as a SELECT or SHOW). */
533
+ /* Result#result_status constant - Successful completion of a command returning data (such as a SELECT or SHOW). */
515
534
  rb_define_const(rb_mPGconstants, "PGRES_TUPLES_OK", INT2FIX(PGRES_TUPLES_OK));
516
- /* #result_status constant: Copy Out (from server) data transfer started. */
535
+ /* Result#result_status constant - Copy Out (from server) data transfer started. */
517
536
  rb_define_const(rb_mPGconstants, "PGRES_COPY_OUT", INT2FIX(PGRES_COPY_OUT));
518
- /* #result_status constant: Copy In (to server) data transfer started. */
537
+ /* Result#result_status constant - Copy In (to server) data transfer started. */
519
538
  rb_define_const(rb_mPGconstants, "PGRES_COPY_IN", INT2FIX(PGRES_COPY_IN));
520
- /* #result_status constant: The server’s response was not understood. */
539
+ /* Result#result_status constant - The server’s response was not understood. */
521
540
  rb_define_const(rb_mPGconstants, "PGRES_BAD_RESPONSE", INT2FIX(PGRES_BAD_RESPONSE));
522
- /* #result_status constant: A nonfatal error (a notice or warning) occurred. */
541
+ /* Result#result_status constant - A nonfatal error (a notice or warning) occurred. */
523
542
  rb_define_const(rb_mPGconstants, "PGRES_NONFATAL_ERROR",INT2FIX(PGRES_NONFATAL_ERROR));
524
- /* #result_status constant: A fatal error occurred. */
543
+ /* Result#result_status constant - A fatal error occurred. */
525
544
  rb_define_const(rb_mPGconstants, "PGRES_FATAL_ERROR", INT2FIX(PGRES_FATAL_ERROR));
526
- /* #result_status constant: Copy In/Out data transfer in progress. */
527
- #ifdef HAVE_CONST_PGRES_COPY_BOTH
545
+ /* Result#result_status constant - Copy In/Out data transfer in progress. */
528
546
  rb_define_const(rb_mPGconstants, "PGRES_COPY_BOTH", INT2FIX(PGRES_COPY_BOTH));
529
- #endif
530
- /* #result_status constant: Single tuple from larger resultset. */
531
- #ifdef HAVE_CONST_PGRES_SINGLE_TUPLE
547
+ /* Result#result_status constant - Single tuple from larger resultset. */
532
548
  rb_define_const(rb_mPGconstants, "PGRES_SINGLE_TUPLE", INT2FIX(PGRES_SINGLE_TUPLE));
549
+
550
+ #ifdef HAVE_PQENTERPIPELINEMODE
551
+ /* Result#result_status constant - The PG::Result represents a synchronization point in pipeline mode, requested by Connection#pipeline_sync.
552
+ *
553
+ * This status occurs only when pipeline mode has been selected. */
554
+ rb_define_const(rb_mPGconstants, "PGRES_PIPELINE_SYNC", INT2FIX(PGRES_PIPELINE_SYNC));
555
+
556
+ /* Result#result_status constant - The PG::Result represents a pipeline that has received an error from the server.
557
+ *
558
+ * Connection#get_result must be called repeatedly, and each time it will return this status code until the end of the current pipeline, at which point it will return PG::PGRES_PIPELINE_SYNC and normal processing can resume.
559
+ */
560
+ rb_define_const(rb_mPGconstants, "PGRES_PIPELINE_ABORTED", INT2FIX(PGRES_PIPELINE_ABORTED));
533
561
  #endif
534
562
 
535
563
  /****** Result CONSTANTS: result error field codes ******/
536
564
 
537
- /* #result_error_field argument constant: The severity; the field contents
538
- * are ERROR, FATAL, or PANIC (in an error message), or WARNING, NOTICE,
539
- * DEBUG, INFO, or LOG (in a notice message), or a localized translation
540
- * of one of these. Always present.
565
+ /* Result#result_error_field argument constant
566
+ *
567
+ * The severity; the field contents are ERROR, FATAL, or PANIC (in an error message), or WARNING, NOTICE, DEBUG, INFO, or LOG (in a notice message), or a localized translation
568
+ * of one of these.
569
+ * Always present.
541
570
  */
542
571
  rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY", INT2FIX(PG_DIAG_SEVERITY));
543
572
 
544
- /* #result_error_field argument constant: The SQLSTATE code for the
545
- * error. The SQLSTATE code identies the type of error that has occurred;
546
- * it can be used by front-end applications to perform specic operations
547
- * (such as er- ror handling) in response to a particular database
548
- * error. For a list of the possible SQLSTATE codes, see Appendix A.
549
- * This eld is not localizable, and is always present.
573
+ #ifdef PG_DIAG_SEVERITY_NONLOCALIZED
574
+ /* Result#result_error_field argument constant
575
+ *
576
+ * The severity; the field contents are ERROR, FATAL, or PANIC (in an error message), or WARNING, NOTICE, DEBUG, INFO, or LOG (in a notice message).
577
+ * This is identical to the PG_DIAG_SEVERITY field except that the contents are never localized.
578
+ *
579
+ * Available since PostgreSQL-9.6
580
+ */
581
+ rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY_NONLOCALIZED", INT2FIX(PG_DIAG_SEVERITY_NONLOCALIZED));
582
+ #endif
583
+ /* Result#result_error_field argument constant
584
+ *
585
+ * The SQLSTATE code for the error.
586
+ * 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.
587
+ * For a list of the possible SQLSTATE codes, see Appendix A.
588
+ * This field is not localizable, and is always present.
550
589
  */
551
590
  rb_define_const(rb_mPGconstants, "PG_DIAG_SQLSTATE", INT2FIX(PG_DIAG_SQLSTATE));
552
-
553
- /* #result_error_field argument constant: The primary human-readable
554
- * error message (typically one line). Always present. */
591
+ /* Result#result_error_field argument constant
592
+ *
593
+ * The primary human-readable error message (typically one line).
594
+ * Always present. */
555
595
  rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_PRIMARY", INT2FIX(PG_DIAG_MESSAGE_PRIMARY));
556
-
557
- /* #result_error_field argument constant: Detail: an optional secondary
558
- * error message carrying more detail about the problem. Might run to
559
- * multiple lines.
596
+ /* Result#result_error_field argument constant
597
+ *
598
+ * Detail: an optional secondary error message carrying more detail about the problem.
599
+ * Might run to multiple lines.
560
600
  */
561
601
  rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_DETAIL", INT2FIX(PG_DIAG_MESSAGE_DETAIL));
562
-
563
- /* #result_error_field argument constant: Hint: an optional suggestion
564
- * what to do about the problem. This is intended to differ from detail
565
- * in that it offers advice (potentially inappropriate) rather than
566
- * hard facts. Might run to multiple lines.
602
+ /* Result#result_error_field argument constant
603
+ *
604
+ * Hint: an optional suggestion what to do about the problem.
605
+ * This is intended to differ from detail in that it offers advice (potentially inappropriate) rather than hard facts.
606
+ * Might run to multiple lines.
567
607
  */
568
-
569
608
  rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_HINT", INT2FIX(PG_DIAG_MESSAGE_HINT));
570
- /* #result_error_field argument constant: A string containing a decimal
571
- * integer indicating an error cursor position as an index into the
572
- * original statement string. The rst character has index 1, and
573
- * positions are measured in characters not bytes.
609
+ /* Result#result_error_field argument constant
610
+ *
611
+ * A string containing a decimal integer indicating an error cursor position as an index into the original statement string.
612
+ *
613
+ * The first character has index 1, and positions are measured in characters not bytes.
574
614
  */
575
-
576
615
  rb_define_const(rb_mPGconstants, "PG_DIAG_STATEMENT_POSITION", INT2FIX(PG_DIAG_STATEMENT_POSITION));
577
- /* #result_error_field argument constant: This is dened the same as
578
- * the PG_DIAG_STATEMENT_POSITION eld, but it is used when the cursor
579
- * position refers to an internally generated command rather than the
580
- * one submitted by the client. The PG_DIAG_INTERNAL_QUERY eld will
581
- * always appear when this eld appears.
616
+ /* Result#result_error_field argument constant
617
+ *
618
+ * This is defined the same as the PG_DIAG_STATEMENT_POSITION field, but it is used when the cursor position refers to an internally generated command rather than the one submitted by the client.
619
+ * The PG_DIAG_INTERNAL_QUERY field will always appear when this field appears.
582
620
  */
583
-
584
621
  rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_POSITION", INT2FIX(PG_DIAG_INTERNAL_POSITION));
585
- /* #result_error_field argument constant: The text of a failed
586
- * internally-generated command. This could be, for example, a SQL
587
- * query issued by a PL/pgSQL function.
622
+ /* Result#result_error_field argument constant
623
+ *
624
+ * The text of a failed internally-generated command.
625
+ * This could be, for example, a SQL query issued by a PL/pgSQL function.
588
626
  */
589
-
590
627
  rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_QUERY", INT2FIX(PG_DIAG_INTERNAL_QUERY));
591
- /* #result_error_field argument constant: An indication of the context
592
- * in which the error occurred. Presently this includes a call stack
593
- * traceback of active procedural language functions and internally-generated
594
- * queries. The trace is one entry per line, most recent rst.
628
+ /* Result#result_error_field argument constant
629
+ *
630
+ * An indication of the context in which the error occurred.
631
+ * Presently this includes a call stack traceback of active procedural language functions and internally-generated queries.
632
+ * The trace is one entry per line, most recent first.
595
633
  */
596
-
597
634
  rb_define_const(rb_mPGconstants, "PG_DIAG_CONTEXT", INT2FIX(PG_DIAG_CONTEXT));
598
- /* #result_error_field argument constant: The le name of the source-code
599
- * location where the error was reported. */
635
+ /* Result#result_error_field argument constant
636
+ *
637
+ * The file name of the source-code location where the error was reported. */
600
638
  rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FILE", INT2FIX(PG_DIAG_SOURCE_FILE));
601
639
 
602
- /* #result_error_field argument constant: The line number of the
603
- * source-code location where the error was reported. */
640
+ /* Result#result_error_field argument constant
641
+ *
642
+ * The line number of the source-code location where the error was reported. */
604
643
  rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_LINE", INT2FIX(PG_DIAG_SOURCE_LINE));
605
644
 
606
- /* #result_error_field argument constant: The name of the source-code
607
- * function reporting the error. */
645
+ /* Result#result_error_field argument constant
646
+ *
647
+ * The name of the source-code function reporting the error. */
608
648
  rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FUNCTION", INT2FIX(PG_DIAG_SOURCE_FUNCTION));
609
649
 
610
- #ifdef HAVE_CONST_PG_DIAG_TABLE_NAME
611
- /* #result_error_field argument constant: If the error was associated with a
612
- * specific database object, the name of the schema containing that object, if any. */
650
+ #ifdef PG_DIAG_TABLE_NAME
651
+ /* Result#result_error_field argument constant
652
+ *
653
+ * If the error was associated with a specific database object, the name of the schema containing that object, if any. */
613
654
  rb_define_const(rb_mPGconstants, "PG_DIAG_SCHEMA_NAME", INT2FIX(PG_DIAG_SCHEMA_NAME));
614
655
 
615
- /* #result_error_field argument constant: If the error was associated with a
616
- *specific table, the name of the table. (When this field is present, the schema name
617
- * field provides the name of the table's schema.) */
656
+ /* Result#result_error_field argument constant
657
+ *
658
+ * If the error was associated with a specific table, the name of the table.
659
+ * (When this field is present, the schema name field provides the name of the table's schema.) */
618
660
  rb_define_const(rb_mPGconstants, "PG_DIAG_TABLE_NAME", INT2FIX(PG_DIAG_TABLE_NAME));
619
661
 
620
- /* #result_error_field argument constant: If the error was associated with a
621
- * specific table column, the name of the column. (When this field is present, the
622
- * schema and table name fields identify the table.) */
662
+ /* Result#result_error_field argument constant
663
+ *
664
+ * If the error was associated with a specific table column, the name of the column.
665
+ * (When this field is present, the schema and table name fields identify the table.) */
623
666
  rb_define_const(rb_mPGconstants, "PG_DIAG_COLUMN_NAME", INT2FIX(PG_DIAG_COLUMN_NAME));
624
667
 
625
- /* #result_error_field argument constant: If the error was associated with a
626
- * specific datatype, the name of the datatype. (When this field is present, the
627
- * schema name field provides the name of the datatype's schema.) */
668
+ /* Result#result_error_field argument constant
669
+ *
670
+ * If the error was associated with a specific datatype, the name of the datatype.
671
+ * (When this field is present, the schema name field provides the name of the datatype's schema.) */
628
672
  rb_define_const(rb_mPGconstants, "PG_DIAG_DATATYPE_NAME", INT2FIX(PG_DIAG_DATATYPE_NAME));
629
673
 
630
- /* #result_error_field argument constant: If the error was associated with a
631
- * specific constraint, the name of the constraint. The table or domain that the
632
- * constraint belongs to is reported using the fields listed above. (For this
633
- * purpose, indexes are treated as constraints, even if they weren't created with
634
- * constraint syntax.) */
674
+ /* Result#result_error_field argument constant
675
+ *
676
+ * If the error was associated with a specific constraint, the name of the constraint.
677
+ * The table or domain that the constraint belongs to is reported using the fields listed above.
678
+ * (For this purpose, indexes are treated as constraints, even if they weren't created with constraint syntax.) */
635
679
  rb_define_const(rb_mPGconstants, "PG_DIAG_CONSTRAINT_NAME", INT2FIX(PG_DIAG_CONSTRAINT_NAME));
636
680
  #endif
637
681
 
682
+ #ifdef HAVE_PQENTERPIPELINEMODE
683
+ /* Connection#pipeline_status constant
684
+ *
685
+ * The libpq connection is in pipeline mode.
686
+ */
687
+ rb_define_const(rb_mPGconstants, "PQ_PIPELINE_ON", INT2FIX(PQ_PIPELINE_ON));
688
+
689
+ /* Connection#pipeline_status constant
690
+ *
691
+ * The libpq connection is not in pipeline mode.
692
+ */
693
+ rb_define_const(rb_mPGconstants, "PQ_PIPELINE_OFF", INT2FIX(PQ_PIPELINE_OFF));
694
+
695
+ /* Connection#pipeline_status constant
696
+ *
697
+ * The libpq connection is in pipeline mode and an error occurred while processing the current pipeline.
698
+ * The aborted flag is cleared when PQgetResult returns a result of type PGRES_PIPELINE_SYNC.
699
+ */
700
+ rb_define_const(rb_mPGconstants, "PQ_PIPELINE_ABORTED", INT2FIX(PQ_PIPELINE_ABORTED));
701
+ #endif
702
+
638
703
  /* Invalid OID constant */
639
704
  rb_define_const(rb_mPGconstants, "INVALID_OID", INT2FIX(InvalidOid));
640
705
  rb_define_const(rb_mPGconstants, "InvalidOid", INT2FIX(InvalidOid));
@@ -642,9 +707,7 @@ Init_pg_ext()
642
707
  /* Add the constants to the toplevel namespace */
643
708
  rb_include_module( rb_mPG, rb_mPGconstants );
644
709
 
645
- #ifdef M17N_SUPPORTED
646
710
  enc_pg2ruby = st_init_numtable();
647
- #endif
648
711
 
649
712
  /* Initialize the main extension classes */
650
713
  init_pg_connection();
@@ -663,5 +726,7 @@ Init_pg_ext()
663
726
  init_pg_binary_encoder();
664
727
  init_pg_binary_decoder();
665
728
  init_pg_copycoder();
729
+ init_pg_recordcoder();
730
+ init_pg_tuple();
666
731
  }
667
732