pg 1.1.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/ChangeLog +0 -6595
- data/History.rdoc +101 -1
- data/Manifest.txt +3 -2
- data/README-Windows.rdoc +4 -4
- data/README.ja.rdoc +1 -2
- data/README.rdoc +43 -8
- data/Rakefile +7 -5
- data/Rakefile.cross +46 -44
- data/ext/errorcodes.def +68 -0
- data/ext/errorcodes.txt +19 -2
- data/ext/extconf.rb +6 -6
- data/ext/pg.c +138 -99
- data/ext/pg.h +33 -26
- data/ext/pg_binary_decoder.c +20 -16
- data/ext/pg_binary_encoder.c +13 -12
- data/ext/pg_coder.c +5 -5
- data/ext/pg_connection.c +413 -321
- data/ext/pg_copy_coder.c +5 -3
- data/ext/pg_record_coder.c +490 -0
- data/ext/pg_result.c +282 -128
- data/ext/pg_text_decoder.c +14 -8
- data/ext/pg_text_encoder.c +180 -48
- data/ext/pg_tuple.c +14 -6
- data/ext/pg_type_map.c +1 -1
- data/ext/pg_type_map_all_strings.c +4 -4
- data/ext/pg_type_map_by_class.c +4 -3
- data/ext/pg_type_map_by_column.c +7 -6
- data/ext/pg_type_map_by_mri_type.c +1 -1
- data/ext/pg_type_map_by_oid.c +3 -2
- data/ext/pg_type_map_in_ruby.c +1 -1
- data/ext/{util.c → pg_util.c} +5 -5
- data/ext/{util.h → pg_util.h} +0 -0
- data/lib/pg.rb +5 -5
- data/lib/pg/basic_type_mapping.rb +79 -16
- data/lib/pg/binary_decoder.rb +1 -0
- data/lib/pg/coder.rb +22 -1
- data/lib/pg/connection.rb +2 -2
- data/lib/pg/constants.rb +1 -0
- data/lib/pg/exceptions.rb +1 -0
- data/lib/pg/result.rb +13 -1
- data/lib/pg/text_decoder.rb +2 -3
- data/lib/pg/text_encoder.rb +8 -18
- data/lib/pg/type_map_by_column.rb +2 -1
- data/spec/helpers.rb +18 -16
- data/spec/pg/basic_type_mapping_spec.rb +151 -14
- data/spec/pg/connection_spec.rb +162 -54
- data/spec/pg/result_spec.rb +193 -3
- data/spec/pg/tuple_spec.rb +55 -2
- data/spec/pg/type_map_by_column_spec.rb +5 -1
- data/spec/pg/type_spec.rb +180 -6
- metadata +39 -45
- metadata.gz.sig +0 -0
data/ext/errorcodes.def
CHANGED
@@ -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 );
|
data/ext/errorcodes.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# errcodes.txt
|
3
3
|
# PostgreSQL error codes
|
4
4
|
#
|
5
|
-
# Copyright (c) 2003-
|
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-
|
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
|
|
data/ext/extconf.rb
CHANGED
@@ -73,13 +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 '
|
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
|
79
81
|
have_func 'timegm'
|
80
|
-
have_func 'rb_gc_adjust_memory_usage'
|
81
|
-
|
82
|
-
have_const 'PG_DIAG_TABLE_NAME', 'libpq-fe.h'
|
82
|
+
have_func 'rb_gc_adjust_memory_usage' # since ruby-2.4
|
83
83
|
|
84
84
|
# unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
|
85
85
|
have_header 'unistd.h'
|
data/ext/pg.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* pg.c - Toplevel extension
|
3
|
-
* $Id
|
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-
|
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
|
@@ -143,9 +143,6 @@ pg_find_or_create_johab(void)
|
|
143
143
|
}
|
144
144
|
|
145
145
|
enc_index = rb_define_dummy_encoding(aliases[0]);
|
146
|
-
for (i = 1; i < sizeof(aliases)/sizeof(aliases[0]); ++i) {
|
147
|
-
rb_enc_alias(aliases[i], aliases[0]);
|
148
|
-
}
|
149
146
|
return rb_enc_from_index(enc_index);
|
150
147
|
}
|
151
148
|
|
@@ -334,8 +331,7 @@ pg_to_bool_int(VALUE value)
|
|
334
331
|
* If your application initializes libssl and/or libcrypto libraries and libpq is
|
335
332
|
* built with SSL support, you should call PG.init_openssl() to tell libpq that the
|
336
333
|
* libssl and/or libcrypto libraries have been initialized by your application,
|
337
|
-
* so that libpq will not also initialize those libraries.
|
338
|
-
* 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.
|
339
335
|
*
|
340
336
|
* When do_ssl is +true+, libpq will initialize the OpenSSL library before first
|
341
337
|
* opening a database connection. When do_crypto is +true+, the libcrypto library
|
@@ -382,7 +378,12 @@ pg_s_init_ssl(VALUE self, VALUE do_ssl)
|
|
382
378
|
void
|
383
379
|
Init_pg_ext()
|
384
380
|
{
|
385
|
-
|
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
|
+
}
|
386
387
|
|
387
388
|
rb_mPG = rb_define_module( "PG" );
|
388
389
|
rb_mPGconstants = rb_define_module_under( rb_mPG, "Constants" );
|
@@ -420,7 +421,7 @@ Init_pg_ext()
|
|
420
421
|
rb_define_const(rb_mPGconstants, "CONNECTION_SSL_STARTUP", INT2FIX(CONNECTION_SSL_STARTUP));
|
421
422
|
/* Negotiating environment-driven parameter settings. */
|
422
423
|
rb_define_const(rb_mPGconstants, "CONNECTION_SETENV", INT2FIX(CONNECTION_SETENV));
|
423
|
-
/* Internal state
|
424
|
+
/* Internal state - PG.connect() needed. */
|
424
425
|
rb_define_const(rb_mPGconstants, "CONNECTION_NEEDED", INT2FIX(CONNECTION_NEEDED));
|
425
426
|
|
426
427
|
/****** PG::Connection CLASS CONSTANTS: Nonblocking connection polling status ******/
|
@@ -436,26 +437,48 @@ Init_pg_ext()
|
|
436
437
|
|
437
438
|
/****** PG::Connection CLASS CONSTANTS: Transaction Status ******/
|
438
439
|
|
439
|
-
/* Transaction is currently idle (#transaction_status) */
|
440
|
+
/* Transaction is currently idle ( Connection#transaction_status ) */
|
440
441
|
rb_define_const(rb_mPGconstants, "PQTRANS_IDLE", INT2FIX(PQTRANS_IDLE));
|
441
|
-
/* 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 ) */
|
442
443
|
rb_define_const(rb_mPGconstants, "PQTRANS_ACTIVE", INT2FIX(PQTRANS_ACTIVE));
|
443
|
-
/* Transaction is currently idle, in a valid transaction block (#transaction_status) */
|
444
|
+
/* Transaction is currently idle, in a valid transaction block ( Connection#transaction_status ) */
|
444
445
|
rb_define_const(rb_mPGconstants, "PQTRANS_INTRANS", INT2FIX(PQTRANS_INTRANS));
|
445
|
-
/* Transaction is currently idle, in a failed transaction block (#transaction_status) */
|
446
|
+
/* Transaction is currently idle, in a failed transaction block ( Connection#transaction_status ) */
|
446
447
|
rb_define_const(rb_mPGconstants, "PQTRANS_INERROR", INT2FIX(PQTRANS_INERROR));
|
447
|
-
/* Transaction's connection is bad (#transaction_status) */
|
448
|
+
/* Transaction's connection is bad ( Connection#transaction_status ) */
|
448
449
|
rb_define_const(rb_mPGconstants, "PQTRANS_UNKNOWN", INT2FIX(PQTRANS_UNKNOWN));
|
449
450
|
|
450
451
|
/****** PG::Connection CLASS CONSTANTS: Error Verbosity ******/
|
451
452
|
|
452
|
-
/*
|
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. */
|
453
455
|
rb_define_const(rb_mPGconstants, "PQERRORS_TERSE", INT2FIX(PQERRORS_TERSE));
|
454
|
-
/*
|
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). */
|
455
458
|
rb_define_const(rb_mPGconstants, "PQERRORS_DEFAULT", INT2FIX(PQERRORS_DEFAULT));
|
456
|
-
/*
|
459
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
460
|
+
* The VERBOSE mode includes all available fields. */
|
457
461
|
rb_define_const(rb_mPGconstants, "PQERRORS_VERBOSE", INT2FIX(PQERRORS_VERBOSE));
|
458
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
|
+
|
459
482
|
/****** PG::Connection CLASS CONSTANTS: Check Server Status ******/
|
460
483
|
|
461
484
|
/* Server is accepting connections. */
|
@@ -469,141 +492,156 @@ Init_pg_ext()
|
|
469
492
|
|
470
493
|
/****** PG::Connection CLASS CONSTANTS: Large Objects ******/
|
471
494
|
|
472
|
-
/* Flag for #lo_creat, #lo_open -- open for writing */
|
495
|
+
/* Flag for Connection#lo_creat, Connection#lo_open -- open for writing */
|
473
496
|
rb_define_const(rb_mPGconstants, "INV_WRITE", INT2FIX(INV_WRITE));
|
474
|
-
/* Flag for #lo_creat, #lo_open -- open for reading */
|
497
|
+
/* Flag for Connection#lo_creat, Connection#lo_open -- open for reading */
|
475
498
|
rb_define_const(rb_mPGconstants, "INV_READ", INT2FIX(INV_READ));
|
476
|
-
/* Flag for #lo_lseek -- seek from object start */
|
499
|
+
/* Flag for Connection#lo_lseek -- seek from object start */
|
477
500
|
rb_define_const(rb_mPGconstants, "SEEK_SET", INT2FIX(SEEK_SET));
|
478
|
-
/* Flag for #lo_lseek -- seek from current position */
|
501
|
+
/* Flag for Connection#lo_lseek -- seek from current position */
|
479
502
|
rb_define_const(rb_mPGconstants, "SEEK_CUR", INT2FIX(SEEK_CUR));
|
480
|
-
/* Flag for #lo_lseek -- seek from object end */
|
503
|
+
/* Flag for Connection#lo_lseek -- seek from object end */
|
481
504
|
rb_define_const(rb_mPGconstants, "SEEK_END", INT2FIX(SEEK_END));
|
482
505
|
|
483
506
|
/****** PG::Result CONSTANTS: result status ******/
|
484
507
|
|
485
|
-
/* #result_status constant
|
508
|
+
/* Result#result_status constant - The string sent to the server was empty. */
|
486
509
|
rb_define_const(rb_mPGconstants, "PGRES_EMPTY_QUERY", INT2FIX(PGRES_EMPTY_QUERY));
|
487
|
-
/* #result_status constant
|
510
|
+
/* Result#result_status constant - Successful completion of a command returning no data. */
|
488
511
|
rb_define_const(rb_mPGconstants, "PGRES_COMMAND_OK", INT2FIX(PGRES_COMMAND_OK));
|
489
|
-
|
490
|
-
(such as a SELECT or SHOW). */
|
512
|
+
/* Result#result_status constant - Successful completion of a command returning data (such as a SELECT or SHOW). */
|
491
513
|
rb_define_const(rb_mPGconstants, "PGRES_TUPLES_OK", INT2FIX(PGRES_TUPLES_OK));
|
492
|
-
/* #result_status constant
|
514
|
+
/* Result#result_status constant - Copy Out (from server) data transfer started. */
|
493
515
|
rb_define_const(rb_mPGconstants, "PGRES_COPY_OUT", INT2FIX(PGRES_COPY_OUT));
|
494
|
-
/* #result_status constant
|
516
|
+
/* Result#result_status constant - Copy In (to server) data transfer started. */
|
495
517
|
rb_define_const(rb_mPGconstants, "PGRES_COPY_IN", INT2FIX(PGRES_COPY_IN));
|
496
|
-
/* #result_status constant
|
518
|
+
/* Result#result_status constant - The server’s response was not understood. */
|
497
519
|
rb_define_const(rb_mPGconstants, "PGRES_BAD_RESPONSE", INT2FIX(PGRES_BAD_RESPONSE));
|
498
|
-
/* #result_status constant
|
520
|
+
/* Result#result_status constant - A nonfatal error (a notice or warning) occurred. */
|
499
521
|
rb_define_const(rb_mPGconstants, "PGRES_NONFATAL_ERROR",INT2FIX(PGRES_NONFATAL_ERROR));
|
500
|
-
/* #result_status constant
|
522
|
+
/* Result#result_status constant - A fatal error occurred. */
|
501
523
|
rb_define_const(rb_mPGconstants, "PGRES_FATAL_ERROR", INT2FIX(PGRES_FATAL_ERROR));
|
502
|
-
/* #result_status constant
|
524
|
+
/* Result#result_status constant - Copy In/Out data transfer in progress. */
|
503
525
|
rb_define_const(rb_mPGconstants, "PGRES_COPY_BOTH", INT2FIX(PGRES_COPY_BOTH));
|
504
|
-
/* #result_status constant
|
526
|
+
/* Result#result_status constant - Single tuple from larger resultset. */
|
505
527
|
rb_define_const(rb_mPGconstants, "PGRES_SINGLE_TUPLE", INT2FIX(PGRES_SINGLE_TUPLE));
|
506
528
|
|
507
529
|
/****** Result CONSTANTS: result error field codes ******/
|
508
530
|
|
509
|
-
/* #result_error_field argument constant
|
510
|
-
*
|
511
|
-
* DEBUG, INFO, or LOG (in a notice message), or a localized translation
|
512
|
-
* of one of these.
|
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.
|
513
536
|
*/
|
514
537
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY", INT2FIX(PG_DIAG_SEVERITY));
|
515
538
|
|
516
|
-
|
517
|
-
|
518
|
-
*
|
519
|
-
*
|
520
|
-
*
|
521
|
-
*
|
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.
|
522
555
|
*/
|
523
556
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SQLSTATE", INT2FIX(PG_DIAG_SQLSTATE));
|
524
|
-
|
525
|
-
|
526
|
-
* error message (typically one line).
|
557
|
+
/* Result#result_error_field argument constant
|
558
|
+
*
|
559
|
+
* The primary human-readable error message (typically one line).
|
560
|
+
* Always present. */
|
527
561
|
rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_PRIMARY", INT2FIX(PG_DIAG_MESSAGE_PRIMARY));
|
528
|
-
|
529
|
-
|
530
|
-
* error message carrying more detail about the problem.
|
531
|
-
* 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.
|
532
566
|
*/
|
533
567
|
rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_DETAIL", INT2FIX(PG_DIAG_MESSAGE_DETAIL));
|
534
|
-
|
535
|
-
|
536
|
-
* what to do about the problem.
|
537
|
-
* in that it offers advice (potentially inappropriate) rather than
|
538
|
-
*
|
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.
|
539
573
|
*/
|
540
|
-
|
541
574
|
rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_HINT", INT2FIX(PG_DIAG_MESSAGE_HINT));
|
542
|
-
/* #result_error_field argument constant
|
543
|
-
*
|
544
|
-
*
|
545
|
-
*
|
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.
|
546
580
|
*/
|
547
|
-
|
548
581
|
rb_define_const(rb_mPGconstants, "PG_DIAG_STATEMENT_POSITION", INT2FIX(PG_DIAG_STATEMENT_POSITION));
|
549
|
-
/* #result_error_field argument constant
|
550
|
-
*
|
551
|
-
* position refers to an internally generated command rather than the
|
552
|
-
*
|
553
|
-
* 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.
|
554
586
|
*/
|
555
|
-
|
556
587
|
rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_POSITION", INT2FIX(PG_DIAG_INTERNAL_POSITION));
|
557
|
-
/* #result_error_field argument constant
|
558
|
-
*
|
559
|
-
*
|
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.
|
560
592
|
*/
|
561
|
-
|
562
593
|
rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_QUERY", INT2FIX(PG_DIAG_INTERNAL_QUERY));
|
563
|
-
/* #result_error_field argument constant
|
564
|
-
*
|
565
|
-
*
|
566
|
-
*
|
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.
|
567
599
|
*/
|
568
|
-
|
569
600
|
rb_define_const(rb_mPGconstants, "PG_DIAG_CONTEXT", INT2FIX(PG_DIAG_CONTEXT));
|
570
|
-
/* #result_error_field argument constant
|
571
|
-
*
|
601
|
+
/* Result#result_error_field argument constant
|
602
|
+
*
|
603
|
+
* The file name of the source-code location where the error was reported. */
|
572
604
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FILE", INT2FIX(PG_DIAG_SOURCE_FILE));
|
573
605
|
|
574
|
-
/* #result_error_field argument constant
|
575
|
-
*
|
606
|
+
/* Result#result_error_field argument constant
|
607
|
+
*
|
608
|
+
* The line number of the source-code location where the error was reported. */
|
576
609
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_LINE", INT2FIX(PG_DIAG_SOURCE_LINE));
|
577
610
|
|
578
|
-
/* #result_error_field argument constant
|
579
|
-
*
|
611
|
+
/* Result#result_error_field argument constant
|
612
|
+
*
|
613
|
+
* The name of the source-code function reporting the error. */
|
580
614
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FUNCTION", INT2FIX(PG_DIAG_SOURCE_FUNCTION));
|
581
615
|
|
582
|
-
#ifdef
|
583
|
-
/* #result_error_field argument constant
|
584
|
-
*
|
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. */
|
585
620
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SCHEMA_NAME", INT2FIX(PG_DIAG_SCHEMA_NAME));
|
586
621
|
|
587
|
-
/* #result_error_field argument constant
|
588
|
-
*
|
589
|
-
*
|
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.) */
|
590
626
|
rb_define_const(rb_mPGconstants, "PG_DIAG_TABLE_NAME", INT2FIX(PG_DIAG_TABLE_NAME));
|
591
627
|
|
592
|
-
/* #result_error_field argument constant
|
593
|
-
*
|
594
|
-
*
|
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.) */
|
595
632
|
rb_define_const(rb_mPGconstants, "PG_DIAG_COLUMN_NAME", INT2FIX(PG_DIAG_COLUMN_NAME));
|
596
633
|
|
597
|
-
/* #result_error_field argument constant
|
598
|
-
*
|
599
|
-
*
|
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.) */
|
600
638
|
rb_define_const(rb_mPGconstants, "PG_DIAG_DATATYPE_NAME", INT2FIX(PG_DIAG_DATATYPE_NAME));
|
601
639
|
|
602
|
-
/* #result_error_field argument constant
|
603
|
-
*
|
604
|
-
*
|
605
|
-
*
|
606
|
-
* 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.) */
|
607
645
|
rb_define_const(rb_mPGconstants, "PG_DIAG_CONSTRAINT_NAME", INT2FIX(PG_DIAG_CONSTRAINT_NAME));
|
608
646
|
#endif
|
609
647
|
|
@@ -633,6 +671,7 @@ Init_pg_ext()
|
|
633
671
|
init_pg_binary_encoder();
|
634
672
|
init_pg_binary_decoder();
|
635
673
|
init_pg_copycoder();
|
674
|
+
init_pg_recordcoder();
|
636
675
|
init_pg_tuple();
|
637
676
|
}
|
638
677
|
|