pg 1.0.0 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/ChangeLog +0 -6595
  5. data/History.rdoc +156 -0
  6. data/Manifest.txt +8 -2
  7. data/README-Windows.rdoc +4 -4
  8. data/README.ja.rdoc +1 -2
  9. data/README.rdoc +55 -9
  10. data/Rakefile +9 -7
  11. data/Rakefile.cross +58 -57
  12. data/ext/errorcodes.def +68 -0
  13. data/ext/errorcodes.rb +1 -1
  14. data/ext/errorcodes.txt +19 -2
  15. data/ext/extconf.rb +7 -5
  16. data/ext/pg.c +141 -98
  17. data/ext/pg.h +64 -21
  18. data/ext/pg_binary_decoder.c +82 -15
  19. data/ext/pg_binary_encoder.c +13 -12
  20. data/ext/pg_coder.c +73 -12
  21. data/ext/pg_connection.c +625 -346
  22. data/ext/pg_copy_coder.c +16 -8
  23. data/ext/pg_record_coder.c +491 -0
  24. data/ext/pg_result.c +571 -191
  25. data/ext/pg_text_decoder.c +606 -40
  26. data/ext/pg_text_encoder.c +185 -54
  27. data/ext/pg_tuple.c +549 -0
  28. data/ext/pg_type_map.c +1 -1
  29. data/ext/pg_type_map_all_strings.c +4 -4
  30. data/ext/pg_type_map_by_class.c +9 -4
  31. data/ext/pg_type_map_by_column.c +7 -6
  32. data/ext/pg_type_map_by_mri_type.c +1 -1
  33. data/ext/pg_type_map_by_oid.c +3 -2
  34. data/ext/pg_type_map_in_ruby.c +1 -1
  35. data/ext/{util.c → pg_util.c} +10 -10
  36. data/ext/{util.h → pg_util.h} +2 -2
  37. data/lib/pg.rb +8 -6
  38. data/lib/pg/basic_type_mapping.rb +121 -25
  39. data/lib/pg/binary_decoder.rb +23 -0
  40. data/lib/pg/coder.rb +23 -2
  41. data/lib/pg/connection.rb +22 -3
  42. data/lib/pg/constants.rb +2 -1
  43. data/lib/pg/exceptions.rb +2 -1
  44. data/lib/pg/result.rb +14 -2
  45. data/lib/pg/text_decoder.rb +21 -26
  46. data/lib/pg/text_encoder.rb +32 -8
  47. data/lib/pg/tuple.rb +30 -0
  48. data/lib/pg/type_map_by_column.rb +3 -2
  49. data/spec/helpers.rb +52 -20
  50. data/spec/pg/basic_type_mapping_spec.rb +362 -37
  51. data/spec/pg/connection_spec.rb +376 -146
  52. data/spec/pg/connection_sync_spec.rb +41 -0
  53. data/spec/pg/result_spec.rb +240 -15
  54. data/spec/pg/tuple_spec.rb +333 -0
  55. data/spec/pg/type_map_by_class_spec.rb +2 -2
  56. data/spec/pg/type_map_by_column_spec.rb +6 -2
  57. data/spec/pg/type_map_by_mri_type_spec.rb +1 -1
  58. data/spec/pg/type_map_by_oid_spec.rb +3 -3
  59. data/spec/pg/type_map_in_ruby_spec.rb +1 -1
  60. data/spec/pg/type_map_spec.rb +1 -1
  61. data/spec/pg/type_spec.rb +363 -17
  62. data/spec/pg_spec.rb +1 -1
  63. metadata +47 -47
  64. metadata.gz.sig +0 -0
@@ -186,6 +186,10 @@
186
186
  VALUE klass = define_error_class( "InvalidParameterValue", "22" );
187
187
  register_error_class( "22023", klass );
188
188
  }
189
+ {
190
+ VALUE klass = define_error_class( "InvalidPrecedingOrFollowingSize", "22" );
191
+ register_error_class( "22013", klass );
192
+ }
189
193
  {
190
194
  VALUE klass = define_error_class( "InvalidRegularExpression", "22" );
191
195
  register_error_class( "2201B", klass );
@@ -298,6 +302,66 @@
298
302
  VALUE klass = define_error_class( "InvalidXmlProcessingInstruction", "22" );
299
303
  register_error_class( "2200T", klass );
300
304
  }
305
+ {
306
+ VALUE klass = define_error_class( "DuplicateJsonObjectKeyValue", "22" );
307
+ register_error_class( "22030", klass );
308
+ }
309
+ {
310
+ VALUE klass = define_error_class( "InvalidJsonText", "22" );
311
+ register_error_class( "22032", klass );
312
+ }
313
+ {
314
+ VALUE klass = define_error_class( "InvalidSqlJsonSubscript", "22" );
315
+ register_error_class( "22033", klass );
316
+ }
317
+ {
318
+ VALUE klass = define_error_class( "MoreThanOneSqlJsonItem", "22" );
319
+ register_error_class( "22034", klass );
320
+ }
321
+ {
322
+ VALUE klass = define_error_class( "NoSqlJsonItem", "22" );
323
+ register_error_class( "22035", klass );
324
+ }
325
+ {
326
+ VALUE klass = define_error_class( "NonNumericSqlJsonItem", "22" );
327
+ register_error_class( "22036", klass );
328
+ }
329
+ {
330
+ VALUE klass = define_error_class( "NonUniqueKeysInAJsonObject", "22" );
331
+ register_error_class( "22037", klass );
332
+ }
333
+ {
334
+ VALUE klass = define_error_class( "SingletonSqlJsonItemRequired", "22" );
335
+ register_error_class( "22038", klass );
336
+ }
337
+ {
338
+ VALUE klass = define_error_class( "SqlJsonArrayNotFound", "22" );
339
+ register_error_class( "22039", klass );
340
+ }
341
+ {
342
+ VALUE klass = define_error_class( "SqlJsonMemberNotFound", "22" );
343
+ register_error_class( "2203A", klass );
344
+ }
345
+ {
346
+ VALUE klass = define_error_class( "SqlJsonNumberNotFound", "22" );
347
+ register_error_class( "2203B", klass );
348
+ }
349
+ {
350
+ VALUE klass = define_error_class( "SqlJsonObjectNotFound", "22" );
351
+ register_error_class( "2203C", klass );
352
+ }
353
+ {
354
+ VALUE klass = define_error_class( "TooManyJsonArrayElements", "22" );
355
+ register_error_class( "2203D", klass );
356
+ }
357
+ {
358
+ VALUE klass = define_error_class( "TooManyJsonObjectMembers", "22" );
359
+ register_error_class( "2203E", klass );
360
+ }
361
+ {
362
+ VALUE klass = define_error_class( "SqlJsonScalarRequired", "22" );
363
+ register_error_class( "2203F", klass );
364
+ }
301
365
  {
302
366
  VALUE klass = define_error_class( "IntegrityConstraintViolation", NULL );
303
367
  register_error_class( "23000", klass );
@@ -763,6 +827,10 @@
763
827
  VALUE klass = define_error_class( "LockNotAvailable", "55" );
764
828
  register_error_class( "55P03", klass );
765
829
  }
830
+ {
831
+ VALUE klass = define_error_class( "UnsafeNewEnumValueUsage", "55" );
832
+ register_error_class( "55P04", klass );
833
+ }
766
834
  {
767
835
  VALUE klass = define_error_class( "OperatorIntervention", NULL );
768
836
  register_error_class( "57000", klass );
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
2
 
3
3
  def camelize(lower_case_and_underscored_word)
4
4
  lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
@@ -2,7 +2,7 @@
2
2
  # errcodes.txt
3
3
  # PostgreSQL error codes
4
4
  #
5
- # Copyright (c) 2003-2017, PostgreSQL Global Development Group
5
+ # Copyright (c) 2003-2019, PostgreSQL Global Development Group
6
6
  #
7
7
  # This list serves as the basis for generating source files containing error
8
8
  # codes. It is kept in a common format to make sure all these source files have
@@ -18,7 +18,7 @@
18
18
  # src/pl/tcl/pltclerrcodes.h
19
19
  # the same, for PL/Tcl
20
20
  #
21
- # doc/src/sgml/errcodes-list.sgml
21
+ # doc/src/sgml/errcodes-table.sgml
22
22
  # a SGML table of error codes for inclusion in the documentation
23
23
  #
24
24
  # The format of this file is one error code per line, with the following
@@ -177,6 +177,7 @@ Section: Class 22 - Data Exception
177
177
  22P06 E ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER nonstandard_use_of_escape_character
178
178
  22010 E ERRCODE_INVALID_INDICATOR_PARAMETER_VALUE invalid_indicator_parameter_value
179
179
  22023 E ERRCODE_INVALID_PARAMETER_VALUE invalid_parameter_value
180
+ 22013 E ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE invalid_preceding_or_following_size
180
181
  2201B E ERRCODE_INVALID_REGULAR_EXPRESSION invalid_regular_expression
181
182
  2201W E ERRCODE_INVALID_ROW_COUNT_IN_LIMIT_CLAUSE invalid_row_count_in_limit_clause
182
183
  2201X E ERRCODE_INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE invalid_row_count_in_result_offset_clause
@@ -205,6 +206,21 @@ Section: Class 22 - Data Exception
205
206
  2200N E ERRCODE_INVALID_XML_CONTENT invalid_xml_content
206
207
  2200S E ERRCODE_INVALID_XML_COMMENT invalid_xml_comment
207
208
  2200T E ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION invalid_xml_processing_instruction
209
+ 22030 E ERRCODE_DUPLICATE_JSON_OBJECT_KEY_VALUE duplicate_json_object_key_value
210
+ 22032 E ERRCODE_INVALID_JSON_TEXT invalid_json_text
211
+ 22033 E ERRCODE_INVALID_SQL_JSON_SUBSCRIPT invalid_sql_json_subscript
212
+ 22034 E ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM more_than_one_sql_json_item
213
+ 22035 E ERRCODE_NO_SQL_JSON_ITEM no_sql_json_item
214
+ 22036 E ERRCODE_NON_NUMERIC_SQL_JSON_ITEM non_numeric_sql_json_item
215
+ 22037 E ERRCODE_NON_UNIQUE_KEYS_IN_A_JSON_OBJECT non_unique_keys_in_a_json_object
216
+ 22038 E ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED singleton_sql_json_item_required
217
+ 22039 E ERRCODE_SQL_JSON_ARRAY_NOT_FOUND sql_json_array_not_found
218
+ 2203A E ERRCODE_SQL_JSON_MEMBER_NOT_FOUND sql_json_member_not_found
219
+ 2203B E ERRCODE_SQL_JSON_NUMBER_NOT_FOUND sql_json_number_not_found
220
+ 2203C E ERRCODE_SQL_JSON_OBJECT_NOT_FOUND sql_json_object_not_found
221
+ 2203D E ERRCODE_TOO_MANY_JSON_ARRAY_ELEMENTS too_many_json_array_elements
222
+ 2203E E ERRCODE_TOO_MANY_JSON_OBJECT_MEMBERS too_many_json_object_members
223
+ 2203F E ERRCODE_SQL_JSON_SCALAR_REQUIRED sql_json_scalar_required
208
224
 
209
225
  Section: Class 23 - Integrity Constraint Violation
210
226
 
@@ -400,6 +416,7 @@ Section: Class 55 - Object Not In Prerequisite State
400
416
  55006 E ERRCODE_OBJECT_IN_USE object_in_use
401
417
  55P02 E ERRCODE_CANT_CHANGE_RUNTIME_PARAM cant_change_runtime_param
402
418
  55P03 E ERRCODE_LOCK_NOT_AVAILABLE lock_not_available
419
+ 55P04 E ERRCODE_UNSAFE_NEW_ENUM_VALUE_USAGE unsafe_new_enum_value_usage
403
420
 
404
421
  Section: Class 57 - Operator Intervention
405
422
 
@@ -73,11 +73,13 @@ end
73
73
  have_func 'PQsetSingleRowMode' or
74
74
  abort "Your PostgreSQL is too old. Either install an older version " +
75
75
  "of this gem or upgrade your database to at least PostgreSQL-9.2."
76
- have_func 'PQconninfo'
77
- have_func 'PQsslAttribute'
78
- have_func 'PQencryptPasswordConn'
79
-
80
- have_const 'PG_DIAG_TABLE_NAME', 'libpq-fe.h'
76
+ have_func 'PQconninfo' # since PostgreSQL-9.3
77
+ have_func 'PQsslAttribute' # since PostgreSQL-9.5
78
+ have_func 'PQresultVerboseErrorMessage' # since PostgreSQL-9.6
79
+ have_func 'PQencryptPasswordConn' # since PostgreSQL-10
80
+ have_func 'PQresultMemorySize' # since PostgreSQL-12
81
+ have_func 'timegm'
82
+ have_func 'rb_gc_adjust_memory_usage' # since ruby-2.4
81
83
 
82
84
  # unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
83
85
  have_header 'unistd.h'
data/ext/pg.c CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * pg.c - Toplevel extension
3
- * $Id: pg.c,v 1f0926bfa9a5 2018/01/04 18:14:32 lars $
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
@@ -48,6 +48,7 @@
48
48
 
49
49
  #include "pg.h"
50
50
 
51
+ int pg_skip_deprecation_warning;
51
52
  VALUE rb_mPG;
52
53
  VALUE rb_mPGconstants;
53
54
 
@@ -142,9 +143,6 @@ pg_find_or_create_johab(void)
142
143
  }
143
144
 
144
145
  enc_index = rb_define_dummy_encoding(aliases[0]);
145
- for (i = 1; i < sizeof(aliases)/sizeof(aliases[0]); ++i) {
146
- rb_encdb_alias(aliases[i], aliases[0]);
147
- }
148
146
  return rb_enc_from_index(enc_index);
149
147
  }
150
148
 
@@ -333,8 +331,7 @@ pg_to_bool_int(VALUE value)
333
331
  * If your application initializes libssl and/or libcrypto libraries and libpq is
334
332
  * built with SSL support, you should call PG.init_openssl() to tell libpq that the
335
333
  * libssl and/or libcrypto libraries have been initialized by your application,
336
- * so that libpq will not also initialize those libraries. See
337
- * http://h71000.www7.hp.com/doc/83final/BA554_90007/ch04.html for details on the SSL API.
334
+ * so that libpq will not also initialize those libraries.
338
335
  *
339
336
  * When do_ssl is +true+, libpq will initialize the OpenSSL library before first
340
337
  * opening a database connection. When do_crypto is +true+, the libcrypto library
@@ -381,6 +378,13 @@ pg_s_init_ssl(VALUE self, VALUE do_ssl)
381
378
  void
382
379
  Init_pg_ext()
383
380
  {
381
+ if( RTEST(rb_eval_string("ENV['PG_SKIP_DEPRECATION_WARNING']")) ){
382
+ /* Set all bits to disable all deprecation warnings. */
383
+ pg_skip_deprecation_warning = 0xFFFF;
384
+ } else {
385
+ pg_skip_deprecation_warning = 0;
386
+ }
387
+
384
388
  rb_mPG = rb_define_module( "PG" );
385
389
  rb_mPGconstants = rb_define_module_under( rb_mPG, "Constants" );
386
390
 
@@ -417,7 +421,7 @@ Init_pg_ext()
417
421
  rb_define_const(rb_mPGconstants, "CONNECTION_SSL_STARTUP", INT2FIX(CONNECTION_SSL_STARTUP));
418
422
  /* Negotiating environment-driven parameter settings. */
419
423
  rb_define_const(rb_mPGconstants, "CONNECTION_SETENV", INT2FIX(CONNECTION_SETENV));
420
- /* Internal state: connect() needed. */
424
+ /* Internal state - PG.connect() needed. */
421
425
  rb_define_const(rb_mPGconstants, "CONNECTION_NEEDED", INT2FIX(CONNECTION_NEEDED));
422
426
 
423
427
  /****** PG::Connection CLASS CONSTANTS: Nonblocking connection polling status ******/
@@ -433,26 +437,48 @@ Init_pg_ext()
433
437
 
434
438
  /****** PG::Connection CLASS CONSTANTS: Transaction Status ******/
435
439
 
436
- /* Transaction is currently idle (#transaction_status) */
440
+ /* Transaction is currently idle ( Connection#transaction_status ) */
437
441
  rb_define_const(rb_mPGconstants, "PQTRANS_IDLE", INT2FIX(PQTRANS_IDLE));
438
- /* Transaction is currently active; query has been sent to the server, but not yet completed. (#transaction_status) */
442
+ /* Transaction is currently active; query has been sent to the server, but not yet completed. ( Connection#transaction_status ) */
439
443
  rb_define_const(rb_mPGconstants, "PQTRANS_ACTIVE", INT2FIX(PQTRANS_ACTIVE));
440
- /* Transaction is currently idle, in a valid transaction block (#transaction_status) */
444
+ /* Transaction is currently idle, in a valid transaction block ( Connection#transaction_status ) */
441
445
  rb_define_const(rb_mPGconstants, "PQTRANS_INTRANS", INT2FIX(PQTRANS_INTRANS));
442
- /* Transaction is currently idle, in a failed transaction block (#transaction_status) */
446
+ /* Transaction is currently idle, in a failed transaction block ( Connection#transaction_status ) */
443
447
  rb_define_const(rb_mPGconstants, "PQTRANS_INERROR", INT2FIX(PQTRANS_INERROR));
444
- /* Transaction's connection is bad (#transaction_status) */
448
+ /* Transaction's connection is bad ( Connection#transaction_status ) */
445
449
  rb_define_const(rb_mPGconstants, "PQTRANS_UNKNOWN", INT2FIX(PQTRANS_UNKNOWN));
446
450
 
447
451
  /****** PG::Connection CLASS CONSTANTS: Error Verbosity ******/
448
452
 
449
- /* Terse error verbosity level (#set_error_verbosity) */
453
+ /* Error verbosity level ( Connection#set_error_verbosity ).
454
+ * In TERSE mode, returned messages include severity, primary text, and position only; this will normally fit on a single line. */
450
455
  rb_define_const(rb_mPGconstants, "PQERRORS_TERSE", INT2FIX(PQERRORS_TERSE));
451
- /* Default error verbosity level (#set_error_verbosity) */
456
+ /* Error verbosity level ( Connection#set_error_verbosity ).
457
+ * The DEFAULT mode produces messages that include the above plus any detail, hint, or context fields (these might span multiple lines). */
452
458
  rb_define_const(rb_mPGconstants, "PQERRORS_DEFAULT", INT2FIX(PQERRORS_DEFAULT));
453
- /* Verbose error verbosity level (#set_error_verbosity) */
459
+ /* Error verbosity level ( Connection#set_error_verbosity ).
460
+ * The VERBOSE mode includes all available fields. */
454
461
  rb_define_const(rb_mPGconstants, "PQERRORS_VERBOSE", INT2FIX(PQERRORS_VERBOSE));
455
462
 
463
+ /* PQERRORS_SQLSTATE was introduced in PG-12 together with PQresultMemorySize() */
464
+ #ifdef HAVE_PQRESULTMEMORYSIZE
465
+ /* Error verbosity level ( Connection#set_error_verbosity ).
466
+ * 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).
467
+ *
468
+ * Available since PostgreSQL-12.
469
+ */
470
+ rb_define_const(rb_mPGconstants, "PQERRORS_SQLSTATE", INT2FIX(PQERRORS_SQLSTATE));
471
+ #endif
472
+
473
+ #ifdef HAVE_PQRESULTVERBOSEERRORMESSAGE
474
+ /* See Connection#set_error_context_visibility */
475
+ rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_NEVER", INT2FIX(PQSHOW_CONTEXT_NEVER));
476
+ /* See Connection#set_error_context_visibility */
477
+ rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_ERRORS", INT2FIX(PQSHOW_CONTEXT_ERRORS));
478
+ /* See Connection#set_error_context_visibility */
479
+ rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_ALWAYS", INT2FIX(PQSHOW_CONTEXT_ALWAYS));
480
+ #endif
481
+
456
482
  /****** PG::Connection CLASS CONSTANTS: Check Server Status ******/
457
483
 
458
484
  /* Server is accepting connections. */
@@ -466,141 +492,156 @@ Init_pg_ext()
466
492
 
467
493
  /****** PG::Connection CLASS CONSTANTS: Large Objects ******/
468
494
 
469
- /* Flag for #lo_creat, #lo_open -- open for writing */
495
+ /* Flag for Connection#lo_creat, Connection#lo_open -- open for writing */
470
496
  rb_define_const(rb_mPGconstants, "INV_WRITE", INT2FIX(INV_WRITE));
471
- /* Flag for #lo_creat, #lo_open -- open for reading */
497
+ /* Flag for Connection#lo_creat, Connection#lo_open -- open for reading */
472
498
  rb_define_const(rb_mPGconstants, "INV_READ", INT2FIX(INV_READ));
473
- /* Flag for #lo_lseek -- seek from object start */
499
+ /* Flag for Connection#lo_lseek -- seek from object start */
474
500
  rb_define_const(rb_mPGconstants, "SEEK_SET", INT2FIX(SEEK_SET));
475
- /* Flag for #lo_lseek -- seek from current position */
501
+ /* Flag for Connection#lo_lseek -- seek from current position */
476
502
  rb_define_const(rb_mPGconstants, "SEEK_CUR", INT2FIX(SEEK_CUR));
477
- /* Flag for #lo_lseek -- seek from object end */
503
+ /* Flag for Connection#lo_lseek -- seek from object end */
478
504
  rb_define_const(rb_mPGconstants, "SEEK_END", INT2FIX(SEEK_END));
479
505
 
480
506
  /****** PG::Result CONSTANTS: result status ******/
481
507
 
482
- /* #result_status constant: The string sent to the server was empty. */
508
+ /* Result#result_status constant - The string sent to the server was empty. */
483
509
  rb_define_const(rb_mPGconstants, "PGRES_EMPTY_QUERY", INT2FIX(PGRES_EMPTY_QUERY));
484
- /* #result_status constant: Successful completion of a command returning no data. */
510
+ /* Result#result_status constant - Successful completion of a command returning no data. */
485
511
  rb_define_const(rb_mPGconstants, "PGRES_COMMAND_OK", INT2FIX(PGRES_COMMAND_OK));
486
- /* #result_status constant: Successful completion of a command returning data
487
- (such as a SELECT or SHOW). */
512
+ /* Result#result_status constant - Successful completion of a command returning data (such as a SELECT or SHOW). */
488
513
  rb_define_const(rb_mPGconstants, "PGRES_TUPLES_OK", INT2FIX(PGRES_TUPLES_OK));
489
- /* #result_status constant: Copy Out (from server) data transfer started. */
514
+ /* Result#result_status constant - Copy Out (from server) data transfer started. */
490
515
  rb_define_const(rb_mPGconstants, "PGRES_COPY_OUT", INT2FIX(PGRES_COPY_OUT));
491
- /* #result_status constant: Copy In (to server) data transfer started. */
516
+ /* Result#result_status constant - Copy In (to server) data transfer started. */
492
517
  rb_define_const(rb_mPGconstants, "PGRES_COPY_IN", INT2FIX(PGRES_COPY_IN));
493
- /* #result_status constant: The server’s response was not understood. */
518
+ /* Result#result_status constant - The server’s response was not understood. */
494
519
  rb_define_const(rb_mPGconstants, "PGRES_BAD_RESPONSE", INT2FIX(PGRES_BAD_RESPONSE));
495
- /* #result_status constant: A nonfatal error (a notice or warning) occurred. */
520
+ /* Result#result_status constant - A nonfatal error (a notice or warning) occurred. */
496
521
  rb_define_const(rb_mPGconstants, "PGRES_NONFATAL_ERROR",INT2FIX(PGRES_NONFATAL_ERROR));
497
- /* #result_status constant: A fatal error occurred. */
522
+ /* Result#result_status constant - A fatal error occurred. */
498
523
  rb_define_const(rb_mPGconstants, "PGRES_FATAL_ERROR", INT2FIX(PGRES_FATAL_ERROR));
499
- /* #result_status constant: Copy In/Out data transfer in progress. */
524
+ /* Result#result_status constant - Copy In/Out data transfer in progress. */
500
525
  rb_define_const(rb_mPGconstants, "PGRES_COPY_BOTH", INT2FIX(PGRES_COPY_BOTH));
501
- /* #result_status constant: Single tuple from larger resultset. */
526
+ /* Result#result_status constant - Single tuple from larger resultset. */
502
527
  rb_define_const(rb_mPGconstants, "PGRES_SINGLE_TUPLE", INT2FIX(PGRES_SINGLE_TUPLE));
503
528
 
504
529
  /****** Result CONSTANTS: result error field codes ******/
505
530
 
506
- /* #result_error_field argument constant: The severity; the field contents
507
- * are ERROR, FATAL, or PANIC (in an error message), or WARNING, NOTICE,
508
- * DEBUG, INFO, or LOG (in a notice message), or a localized translation
509
- * of one of these. Always present.
531
+ /* Result#result_error_field argument constant
532
+ *
533
+ * 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
534
+ * of one of these.
535
+ * Always present.
510
536
  */
511
537
  rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY", INT2FIX(PG_DIAG_SEVERITY));
512
538
 
513
- /* #result_error_field argument constant: The SQLSTATE code for the
514
- * error. The SQLSTATE code identies the type of error that has occurred;
515
- * it can be used by front-end applications to perform specic operations
516
- * (such as er- ror handling) in response to a particular database
517
- * error. For a list of the possible SQLSTATE codes, see Appendix A.
518
- * This eld is not localizable, and is always present.
539
+ #ifdef PG_DIAG_SEVERITY_NONLOCALIZED
540
+ /* Result#result_error_field argument constant
541
+ *
542
+ * 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).
543
+ * This is identical to the PG_DIAG_SEVERITY field except that the contents are never localized.
544
+ *
545
+ * Available since PostgreSQL-9.6
546
+ */
547
+ rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY_NONLOCALIZED", INT2FIX(PG_DIAG_SEVERITY_NONLOCALIZED));
548
+ #endif
549
+ /* Result#result_error_field argument constant
550
+ *
551
+ * The SQLSTATE code for the error.
552
+ * The SQLSTATE code identies the type of error that has occurred; it can be used by front-end applications to perform specic operations (such as error handling) in response to a particular database error.
553
+ * For a list of the possible SQLSTATE codes, see Appendix A.
554
+ * This field is not localizable, and is always present.
519
555
  */
520
556
  rb_define_const(rb_mPGconstants, "PG_DIAG_SQLSTATE", INT2FIX(PG_DIAG_SQLSTATE));
521
-
522
- /* #result_error_field argument constant: The primary human-readable
523
- * error message (typically one line). Always present. */
557
+ /* Result#result_error_field argument constant
558
+ *
559
+ * The primary human-readable error message (typically one line).
560
+ * Always present. */
524
561
  rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_PRIMARY", INT2FIX(PG_DIAG_MESSAGE_PRIMARY));
525
-
526
- /* #result_error_field argument constant: Detail: an optional secondary
527
- * error message carrying more detail about the problem. Might run to
528
- * multiple lines.
562
+ /* Result#result_error_field argument constant
563
+ *
564
+ * Detail: an optional secondary error message carrying more detail about the problem.
565
+ * Might run to multiple lines.
529
566
  */
530
567
  rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_DETAIL", INT2FIX(PG_DIAG_MESSAGE_DETAIL));
531
-
532
- /* #result_error_field argument constant: Hint: an optional suggestion
533
- * what to do about the problem. This is intended to differ from detail
534
- * in that it offers advice (potentially inappropriate) rather than
535
- * hard facts. Might run to multiple lines.
568
+ /* Result#result_error_field argument constant
569
+ *
570
+ * Hint: an optional suggestion what to do about the problem.
571
+ * This is intended to differ from detail in that it offers advice (potentially inappropriate) rather than hard facts.
572
+ * Might run to multiple lines.
536
573
  */
537
-
538
574
  rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_HINT", INT2FIX(PG_DIAG_MESSAGE_HINT));
539
- /* #result_error_field argument constant: A string containing a decimal
540
- * integer indicating an error cursor position as an index into the
541
- * original statement string. The rst character has index 1, and
542
- * positions are measured in characters not bytes.
575
+ /* Result#result_error_field argument constant
576
+ *
577
+ * A string containing a decimal integer indicating an error cursor position as an index into the original statement string.
578
+ *
579
+ * The first character has index 1, and positions are measured in characters not bytes.
543
580
  */
544
-
545
581
  rb_define_const(rb_mPGconstants, "PG_DIAG_STATEMENT_POSITION", INT2FIX(PG_DIAG_STATEMENT_POSITION));
546
- /* #result_error_field argument constant: This is dened the same as
547
- * the PG_DIAG_STATEMENT_POSITION eld, but it is used when the cursor
548
- * position refers to an internally generated command rather than the
549
- * one submitted by the client. The PG_DIAG_INTERNAL_QUERY eld will
550
- * always appear when this eld appears.
582
+ /* Result#result_error_field argument constant
583
+ *
584
+ * 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.
585
+ * The PG_DIAG_INTERNAL_QUERY field will always appear when this field appears.
551
586
  */
552
-
553
587
  rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_POSITION", INT2FIX(PG_DIAG_INTERNAL_POSITION));
554
- /* #result_error_field argument constant: The text of a failed
555
- * internally-generated command. This could be, for example, a SQL
556
- * query issued by a PL/pgSQL function.
588
+ /* Result#result_error_field argument constant
589
+ *
590
+ * The text of a failed internally-generated command.
591
+ * This could be, for example, a SQL query issued by a PL/pgSQL function.
557
592
  */
558
-
559
593
  rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_QUERY", INT2FIX(PG_DIAG_INTERNAL_QUERY));
560
- /* #result_error_field argument constant: An indication of the context
561
- * in which the error occurred. Presently this includes a call stack
562
- * traceback of active procedural language functions and internally-generated
563
- * queries. The trace is one entry per line, most recent rst.
594
+ /* Result#result_error_field argument constant
595
+ *
596
+ * An indication of the context in which the error occurred.
597
+ * Presently this includes a call stack traceback of active procedural language functions and internally-generated queries.
598
+ * The trace is one entry per line, most recent first.
564
599
  */
565
-
566
600
  rb_define_const(rb_mPGconstants, "PG_DIAG_CONTEXT", INT2FIX(PG_DIAG_CONTEXT));
567
- /* #result_error_field argument constant: The le name of the source-code
568
- * location where the error was reported. */
601
+ /* Result#result_error_field argument constant
602
+ *
603
+ * The file name of the source-code location where the error was reported. */
569
604
  rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FILE", INT2FIX(PG_DIAG_SOURCE_FILE));
570
605
 
571
- /* #result_error_field argument constant: The line number of the
572
- * source-code location where the error was reported. */
606
+ /* Result#result_error_field argument constant
607
+ *
608
+ * The line number of the source-code location where the error was reported. */
573
609
  rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_LINE", INT2FIX(PG_DIAG_SOURCE_LINE));
574
610
 
575
- /* #result_error_field argument constant: The name of the source-code
576
- * function reporting the error. */
611
+ /* Result#result_error_field argument constant
612
+ *
613
+ * The name of the source-code function reporting the error. */
577
614
  rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FUNCTION", INT2FIX(PG_DIAG_SOURCE_FUNCTION));
578
615
 
579
- #ifdef HAVE_CONST_PG_DIAG_TABLE_NAME
580
- /* #result_error_field argument constant: If the error was associated with a
581
- * specific database object, the name of the schema containing that object, if any. */
616
+ #ifdef PG_DIAG_TABLE_NAME
617
+ /* Result#result_error_field argument constant
618
+ *
619
+ * If the error was associated with a specific database object, the name of the schema containing that object, if any. */
582
620
  rb_define_const(rb_mPGconstants, "PG_DIAG_SCHEMA_NAME", INT2FIX(PG_DIAG_SCHEMA_NAME));
583
621
 
584
- /* #result_error_field argument constant: If the error was associated with a
585
- *specific table, the name of the table. (When this field is present, the schema name
586
- * field provides the name of the table's schema.) */
622
+ /* Result#result_error_field argument constant
623
+ *
624
+ * If the error was associated with a specific table, the name of the table.
625
+ * (When this field is present, the schema name field provides the name of the table's schema.) */
587
626
  rb_define_const(rb_mPGconstants, "PG_DIAG_TABLE_NAME", INT2FIX(PG_DIAG_TABLE_NAME));
588
627
 
589
- /* #result_error_field argument constant: If the error was associated with a
590
- * specific table column, the name of the column. (When this field is present, the
591
- * schema and table name fields identify the table.) */
628
+ /* Result#result_error_field argument constant
629
+ *
630
+ * If the error was associated with a specific table column, the name of the column.
631
+ * (When this field is present, the schema and table name fields identify the table.) */
592
632
  rb_define_const(rb_mPGconstants, "PG_DIAG_COLUMN_NAME", INT2FIX(PG_DIAG_COLUMN_NAME));
593
633
 
594
- /* #result_error_field argument constant: If the error was associated with a
595
- * specific datatype, the name of the datatype. (When this field is present, the
596
- * schema name field provides the name of the datatype's schema.) */
634
+ /* Result#result_error_field argument constant
635
+ *
636
+ * If the error was associated with a specific datatype, the name of the datatype.
637
+ * (When this field is present, the schema name field provides the name of the datatype's schema.) */
597
638
  rb_define_const(rb_mPGconstants, "PG_DIAG_DATATYPE_NAME", INT2FIX(PG_DIAG_DATATYPE_NAME));
598
639
 
599
- /* #result_error_field argument constant: If the error was associated with a
600
- * specific constraint, the name of the constraint. The table or domain that the
601
- * constraint belongs to is reported using the fields listed above. (For this
602
- * purpose, indexes are treated as constraints, even if they weren't created with
603
- * constraint syntax.) */
640
+ /* Result#result_error_field argument constant
641
+ *
642
+ * If the error was associated with a specific constraint, the name of the constraint.
643
+ * The table or domain that the constraint belongs to is reported using the fields listed above.
644
+ * (For this purpose, indexes are treated as constraints, even if they weren't created with constraint syntax.) */
604
645
  rb_define_const(rb_mPGconstants, "PG_DIAG_CONSTRAINT_NAME", INT2FIX(PG_DIAG_CONSTRAINT_NAME));
605
646
  #endif
606
647
 
@@ -630,5 +671,7 @@ Init_pg_ext()
630
671
  init_pg_binary_encoder();
631
672
  init_pg_binary_decoder();
632
673
  init_pg_copycoder();
674
+ init_pg_recordcoder();
675
+ init_pg_tuple();
633
676
  }
634
677