pg 0.18.4 → 1.4.3

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