pg 1.1.4 → 1.5.3
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/.appveyor.yml +42 -0
- data/.gems +6 -0
- data/.github/workflows/binary-gems.yml +117 -0
- data/.github/workflows/source-gem.yml +137 -0
- data/.gitignore +22 -0
- data/.hgsigs +34 -0
- data/.hgtags +41 -0
- data/.irbrc +23 -0
- data/.pryrc +23 -0
- data/.tm_properties +21 -0
- data/.travis.yml +49 -0
- data/Gemfile +14 -0
- data/History.md +876 -0
- data/Manifest.txt +3 -3
- data/README-Windows.rdoc +4 -4
- data/README.ja.md +276 -0
- data/README.md +286 -0
- data/Rakefile +37 -137
- data/Rakefile.cross +62 -62
- data/certs/ged.pem +24 -0
- data/certs/larskanis-2022.pem +26 -0
- data/certs/larskanis-2023.pem +24 -0
- data/ext/errorcodes.def +76 -0
- data/ext/errorcodes.rb +0 -0
- data/ext/errorcodes.txt +21 -2
- data/ext/extconf.rb +101 -26
- data/ext/gvl_wrappers.c +4 -0
- data/ext/gvl_wrappers.h +23 -0
- data/ext/pg.c +203 -151
- data/ext/pg.h +48 -21
- data/ext/pg_binary_decoder.c +89 -10
- data/ext/pg_binary_encoder.c +238 -13
- data/ext/pg_coder.c +109 -34
- data/ext/pg_connection.c +1365 -976
- data/ext/pg_copy_coder.c +356 -35
- data/ext/pg_errors.c +1 -1
- data/ext/pg_record_coder.c +522 -0
- data/ext/pg_result.c +436 -171
- data/ext/pg_text_decoder.c +42 -18
- data/ext/pg_text_encoder.c +201 -56
- data/ext/pg_tuple.c +97 -66
- data/ext/pg_type_map.c +45 -11
- data/ext/pg_type_map_all_strings.c +21 -7
- data/ext/pg_type_map_by_class.c +59 -27
- data/ext/pg_type_map_by_column.c +80 -37
- data/ext/pg_type_map_by_mri_type.c +49 -20
- data/ext/pg_type_map_by_oid.c +62 -29
- data/ext/pg_type_map_in_ruby.c +56 -22
- data/ext/{util.c → pg_util.c} +7 -7
- data/lib/pg/basic_type_map_based_on_result.rb +67 -0
- data/lib/pg/basic_type_map_for_queries.rb +198 -0
- data/lib/pg/basic_type_map_for_results.rb +104 -0
- data/lib/pg/basic_type_registry.rb +299 -0
- data/lib/pg/binary_decoder/date.rb +9 -0
- data/lib/pg/binary_decoder/timestamp.rb +26 -0
- data/lib/pg/binary_encoder/timestamp.rb +20 -0
- data/lib/pg/coder.rb +35 -12
- data/lib/pg/connection.rb +744 -84
- data/lib/pg/exceptions.rb +15 -1
- data/lib/pg/result.rb +13 -1
- data/lib/pg/text_decoder/date.rb +18 -0
- data/lib/pg/text_decoder/inet.rb +9 -0
- data/lib/pg/text_decoder/json.rb +14 -0
- data/lib/pg/text_decoder/numeric.rb +9 -0
- data/lib/pg/text_decoder/timestamp.rb +30 -0
- data/lib/pg/text_encoder/date.rb +12 -0
- data/lib/pg/text_encoder/inet.rb +28 -0
- data/lib/pg/text_encoder/json.rb +14 -0
- data/lib/pg/text_encoder/numeric.rb +9 -0
- data/lib/pg/text_encoder/timestamp.rb +24 -0
- data/lib/pg/type_map_by_column.rb +2 -1
- data/lib/pg/version.rb +4 -0
- data/lib/pg.rb +94 -39
- data/misc/openssl-pg-segfault.rb +31 -0
- data/misc/postgres/History.txt +9 -0
- data/misc/postgres/Manifest.txt +5 -0
- data/misc/postgres/README.txt +21 -0
- data/misc/postgres/Rakefile +21 -0
- data/misc/postgres/lib/postgres.rb +16 -0
- data/misc/ruby-pg/History.txt +9 -0
- data/misc/ruby-pg/Manifest.txt +5 -0
- data/misc/ruby-pg/README.txt +21 -0
- data/misc/ruby-pg/Rakefile +21 -0
- data/misc/ruby-pg/lib/ruby/pg.rb +16 -0
- data/pg.gemspec +34 -0
- data/rakelib/task_extension.rb +46 -0
- data/sample/array_insert.rb +20 -0
- data/sample/async_api.rb +102 -0
- data/sample/async_copyto.rb +39 -0
- data/sample/async_mixed.rb +56 -0
- data/sample/check_conn.rb +21 -0
- data/sample/copydata.rb +71 -0
- data/sample/copyfrom.rb +81 -0
- data/sample/copyto.rb +19 -0
- data/sample/cursor.rb +21 -0
- data/sample/disk_usage_report.rb +177 -0
- data/sample/issue-119.rb +94 -0
- data/sample/losample.rb +69 -0
- data/sample/minimal-testcase.rb +17 -0
- data/sample/notify_wait.rb +72 -0
- data/sample/pg_statistics.rb +285 -0
- data/sample/replication_monitor.rb +222 -0
- data/sample/test_binary_values.rb +33 -0
- data/sample/wal_shipper.rb +434 -0
- data/sample/warehouse_partitions.rb +311 -0
- data/translation/.po4a-version +7 -0
- data/translation/po/all.pot +910 -0
- data/translation/po/ja.po +1047 -0
- data/translation/po4a.cfg +12 -0
- data.tar.gz.sig +0 -0
- metadata +151 -218
- metadata.gz.sig +0 -0
- data/ChangeLog +0 -6595
- data/History.rdoc +0 -492
- data/README.ja.rdoc +0 -14
- data/README.rdoc +0 -178
- data/lib/pg/basic_type_mapping.rb +0 -459
- data/lib/pg/binary_decoder.rb +0 -22
- data/lib/pg/constants.rb +0 -11
- data/lib/pg/text_decoder.rb +0 -47
- data/lib/pg/text_encoder.rb +0 -69
- data/spec/data/expected_trace.out +0 -26
- data/spec/data/random_binary_data +0 -0
- data/spec/helpers.rb +0 -380
- data/spec/pg/basic_type_mapping_spec.rb +0 -508
- data/spec/pg/connection_spec.rb +0 -1872
- data/spec/pg/connection_sync_spec.rb +0 -41
- data/spec/pg/result_spec.rb +0 -491
- data/spec/pg/tuple_spec.rb +0 -280
- data/spec/pg/type_map_by_class_spec.rb +0 -138
- data/spec/pg/type_map_by_column_spec.rb +0 -222
- data/spec/pg/type_map_by_mri_type_spec.rb +0 -136
- data/spec/pg/type_map_by_oid_spec.rb +0 -149
- data/spec/pg/type_map_in_ruby_spec.rb +0 -164
- data/spec/pg/type_map_spec.rb +0 -22
- data/spec/pg/type_spec.rb +0 -949
- data/spec/pg_spec.rb +0 -50
- /data/ext/{util.h → pg_util.h} +0 -0
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
|
@@ -33,7 +33,6 @@
|
|
33
33
|
*
|
34
34
|
* - PQfreemem -- unnecessary: copied to ruby object, then freed. Ruby object's
|
35
35
|
* memory is freed when it is garbage collected.
|
36
|
-
* - PQbinaryTuples -- better to use PQfformat
|
37
36
|
* - PQprint -- not very useful
|
38
37
|
* - PQsetdb -- not very useful
|
39
38
|
* - PQoidStatus -- deprecated, use PQoidValue
|
@@ -74,6 +73,7 @@ VALUE rb_mPGconstants;
|
|
74
73
|
* The mapping from canonical encoding names in PostgreSQL to ones in Ruby.
|
75
74
|
*/
|
76
75
|
const char * const (pg_enc_pg2ruby_mapping[][2]) = {
|
76
|
+
{"UTF8", "UTF-8" },
|
77
77
|
{"BIG5", "Big5" },
|
78
78
|
{"EUC_CN", "GB2312" },
|
79
79
|
{"EUC_JP", "EUC-JP" },
|
@@ -105,7 +105,6 @@ const char * const (pg_enc_pg2ruby_mapping[][2]) = {
|
|
105
105
|
{"SHIFT_JIS_2004","Windows-31J" },
|
106
106
|
/* {"SQL_ASCII", NULL }, special case*/
|
107
107
|
{"UHC", "CP949" },
|
108
|
-
{"UTF8", "UTF-8" },
|
109
108
|
{"WIN866", "IBM866" },
|
110
109
|
{"WIN874", "Windows-874" },
|
111
110
|
{"WIN1250", "Windows-1250"},
|
@@ -120,32 +119,6 @@ const char * const (pg_enc_pg2ruby_mapping[][2]) = {
|
|
120
119
|
};
|
121
120
|
|
122
121
|
|
123
|
-
/*
|
124
|
-
* A cache of mapping from PostgreSQL's encoding indices to Ruby's rb_encoding*s.
|
125
|
-
*/
|
126
|
-
static struct st_table *enc_pg2ruby;
|
127
|
-
|
128
|
-
|
129
|
-
/*
|
130
|
-
* Look up the JOHAB encoding, creating it as a dummy encoding if it's not
|
131
|
-
* already defined.
|
132
|
-
*/
|
133
|
-
static rb_encoding *
|
134
|
-
pg_find_or_create_johab(void)
|
135
|
-
{
|
136
|
-
static const char * const aliases[] = { "JOHAB", "Windows-1361", "CP1361" };
|
137
|
-
int enc_index;
|
138
|
-
size_t i;
|
139
|
-
|
140
|
-
for (i = 0; i < sizeof(aliases)/sizeof(aliases[0]); ++i) {
|
141
|
-
enc_index = rb_enc_find_index(aliases[i]);
|
142
|
-
if (enc_index > 0) return rb_enc_from_index(enc_index);
|
143
|
-
}
|
144
|
-
|
145
|
-
enc_index = rb_define_dummy_encoding(aliases[0]);
|
146
|
-
return rb_enc_from_index(enc_index);
|
147
|
-
}
|
148
|
-
|
149
122
|
/*
|
150
123
|
* Return the given PostgreSQL encoding ID as an rb_encoding.
|
151
124
|
*
|
@@ -155,21 +128,8 @@ pg_find_or_create_johab(void)
|
|
155
128
|
rb_encoding *
|
156
129
|
pg_get_pg_encoding_as_rb_encoding( int enc_id )
|
157
130
|
{
|
158
|
-
|
159
|
-
|
160
|
-
/* Use the cached value if it exists */
|
161
|
-
if ( st_lookup(enc_pg2ruby, (st_data_t)enc_id, (st_data_t*)&enc) ) {
|
162
|
-
return enc;
|
163
|
-
}
|
164
|
-
else {
|
165
|
-
const char *name = pg_encoding_to_char( enc_id );
|
166
|
-
|
167
|
-
enc = pg_get_pg_encname_as_rb_encoding( name );
|
168
|
-
st_insert( enc_pg2ruby, (st_data_t)enc_id, (st_data_t)enc );
|
169
|
-
|
170
|
-
return enc;
|
171
|
-
}
|
172
|
-
|
131
|
+
const char *name = pg_encoding_to_char( enc_id );
|
132
|
+
return pg_get_pg_encname_as_rb_encoding( name );
|
173
133
|
}
|
174
134
|
|
175
135
|
/*
|
@@ -186,10 +146,6 @@ pg_get_pg_encname_as_rb_encoding( const char *pg_encname )
|
|
186
146
|
return rb_enc_find( pg_enc_pg2ruby_mapping[i][1] );
|
187
147
|
}
|
188
148
|
|
189
|
-
/* JOHAB isn't a builtin encoding, so make up a dummy encoding if it's seen */
|
190
|
-
if ( strncmp(pg_encname, "JOHAB", 5) == 0 )
|
191
|
-
return pg_find_or_create_johab();
|
192
|
-
|
193
149
|
/* Fallthrough to ASCII-8BIT */
|
194
150
|
return rb_ascii8bit_encoding();
|
195
151
|
}
|
@@ -331,8 +287,7 @@ pg_to_bool_int(VALUE value)
|
|
331
287
|
* If your application initializes libssl and/or libcrypto libraries and libpq is
|
332
288
|
* built with SSL support, you should call PG.init_openssl() to tell libpq that the
|
333
289
|
* libssl and/or libcrypto libraries have been initialized by your application,
|
334
|
-
* so that libpq will not also initialize those libraries.
|
335
|
-
* http://h71000.www7.hp.com/doc/83final/BA554_90007/ch04.html for details on the SSL API.
|
290
|
+
* so that libpq will not also initialize those libraries.
|
336
291
|
*
|
337
292
|
* When do_ssl is +true+, libpq will initialize the OpenSSL library before first
|
338
293
|
* opening a database connection. When do_crypto is +true+, the libcrypto library
|
@@ -377,8 +332,13 @@ pg_s_init_ssl(VALUE self, VALUE do_ssl)
|
|
377
332
|
**************************************************************************/
|
378
333
|
|
379
334
|
void
|
380
|
-
Init_pg_ext()
|
335
|
+
Init_pg_ext(void)
|
381
336
|
{
|
337
|
+
|
338
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
339
|
+
rb_ext_ractor_safe(PQisthreadsafe());
|
340
|
+
#endif
|
341
|
+
|
382
342
|
if( RTEST(rb_eval_string("ENV['PG_SKIP_DEPRECATION_WARNING']")) ){
|
383
343
|
/* Set all bits to disable all deprecation warnings. */
|
384
344
|
pg_skip_deprecation_warning = 0xFFFF;
|
@@ -397,8 +357,8 @@ Init_pg_ext()
|
|
397
357
|
SINGLETON_ALIAS( rb_mPG, "is_threadsafe?", "isthreadsafe" );
|
398
358
|
SINGLETON_ALIAS( rb_mPG, "threadsafe?", "isthreadsafe" );
|
399
359
|
|
400
|
-
|
401
|
-
|
360
|
+
rb_define_singleton_method( rb_mPG, "init_openssl", pg_s_init_openssl, 2 );
|
361
|
+
rb_define_singleton_method( rb_mPG, "init_ssl", pg_s_init_ssl, 1 );
|
402
362
|
|
403
363
|
|
404
364
|
/****** PG::Connection CLASS CONSTANTS: Connection Status ******/
|
@@ -416,14 +376,34 @@ Init_pg_ext()
|
|
416
376
|
rb_define_const(rb_mPGconstants, "CONNECTION_MADE", INT2FIX(CONNECTION_MADE));
|
417
377
|
/* Waiting for a response from the server. */
|
418
378
|
rb_define_const(rb_mPGconstants, "CONNECTION_AWAITING_RESPONSE", INT2FIX(CONNECTION_AWAITING_RESPONSE));
|
419
|
-
/* Received authentication; waiting for backend
|
379
|
+
/* Received authentication; waiting for backend startup. */
|
420
380
|
rb_define_const(rb_mPGconstants, "CONNECTION_AUTH_OK", INT2FIX(CONNECTION_AUTH_OK));
|
381
|
+
/* This state is no longer used. */
|
382
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_SETENV", INT2FIX(CONNECTION_SETENV));
|
421
383
|
/* Negotiating SSL encryption. */
|
422
384
|
rb_define_const(rb_mPGconstants, "CONNECTION_SSL_STARTUP", INT2FIX(CONNECTION_SSL_STARTUP));
|
423
|
-
/*
|
424
|
-
rb_define_const(rb_mPGconstants, "CONNECTION_SETENV", INT2FIX(CONNECTION_SETENV));
|
425
|
-
/* Internal state: connect() needed. */
|
385
|
+
/* Internal state - PG.connect() needed. */
|
426
386
|
rb_define_const(rb_mPGconstants, "CONNECTION_NEEDED", INT2FIX(CONNECTION_NEEDED));
|
387
|
+
#if PG_MAJORVERSION_NUM >= 10
|
388
|
+
/* Checking if session is read-write. Available since PostgreSQL-10. */
|
389
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_CHECK_WRITABLE", INT2FIX(CONNECTION_CHECK_WRITABLE));
|
390
|
+
#endif
|
391
|
+
#if PG_MAJORVERSION_NUM >= 10
|
392
|
+
/* Consuming any extra messages. Available since PostgreSQL-10. */
|
393
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_CONSUME", INT2FIX(CONNECTION_CONSUME));
|
394
|
+
#endif
|
395
|
+
#if PG_MAJORVERSION_NUM >= 12
|
396
|
+
/* Negotiating GSSAPI. Available since PostgreSQL-12. */
|
397
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_GSS_STARTUP", INT2FIX(CONNECTION_GSS_STARTUP));
|
398
|
+
#endif
|
399
|
+
#if PG_MAJORVERSION_NUM >= 13
|
400
|
+
/* Checking target server properties. Available since PostgreSQL-13. */
|
401
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_CHECK_TARGET", INT2FIX(CONNECTION_CHECK_TARGET));
|
402
|
+
#endif
|
403
|
+
#if PG_MAJORVERSION_NUM >= 14
|
404
|
+
/* Checking if server is in standby mode. Available since PostgreSQL-14. */
|
405
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_CHECK_STANDBY", INT2FIX(CONNECTION_CHECK_STANDBY));
|
406
|
+
#endif
|
427
407
|
|
428
408
|
/****** PG::Connection CLASS CONSTANTS: Nonblocking connection polling status ******/
|
429
409
|
|
@@ -438,26 +418,48 @@ Init_pg_ext()
|
|
438
418
|
|
439
419
|
/****** PG::Connection CLASS CONSTANTS: Transaction Status ******/
|
440
420
|
|
441
|
-
/* Transaction is currently idle (#transaction_status) */
|
421
|
+
/* Transaction is currently idle ( Connection#transaction_status ) */
|
442
422
|
rb_define_const(rb_mPGconstants, "PQTRANS_IDLE", INT2FIX(PQTRANS_IDLE));
|
443
|
-
/* Transaction is currently active; query has been sent to the server, but not yet completed. (#transaction_status) */
|
423
|
+
/* Transaction is currently active; query has been sent to the server, but not yet completed. ( Connection#transaction_status ) */
|
444
424
|
rb_define_const(rb_mPGconstants, "PQTRANS_ACTIVE", INT2FIX(PQTRANS_ACTIVE));
|
445
|
-
/* Transaction is currently idle, in a valid transaction block (#transaction_status) */
|
425
|
+
/* Transaction is currently idle, in a valid transaction block ( Connection#transaction_status ) */
|
446
426
|
rb_define_const(rb_mPGconstants, "PQTRANS_INTRANS", INT2FIX(PQTRANS_INTRANS));
|
447
|
-
/* Transaction is currently idle, in a failed transaction block (#transaction_status) */
|
427
|
+
/* Transaction is currently idle, in a failed transaction block ( Connection#transaction_status ) */
|
448
428
|
rb_define_const(rb_mPGconstants, "PQTRANS_INERROR", INT2FIX(PQTRANS_INERROR));
|
449
|
-
/* Transaction's connection is bad (#transaction_status) */
|
429
|
+
/* Transaction's connection is bad ( Connection#transaction_status ) */
|
450
430
|
rb_define_const(rb_mPGconstants, "PQTRANS_UNKNOWN", INT2FIX(PQTRANS_UNKNOWN));
|
451
431
|
|
452
432
|
/****** PG::Connection CLASS CONSTANTS: Error Verbosity ******/
|
453
433
|
|
454
|
-
/*
|
434
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
435
|
+
* In TERSE mode, returned messages include severity, primary text, and position only; this will normally fit on a single line. */
|
455
436
|
rb_define_const(rb_mPGconstants, "PQERRORS_TERSE", INT2FIX(PQERRORS_TERSE));
|
456
|
-
/*
|
437
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
438
|
+
* The DEFAULT mode produces messages that include the above plus any detail, hint, or context fields (these might span multiple lines). */
|
457
439
|
rb_define_const(rb_mPGconstants, "PQERRORS_DEFAULT", INT2FIX(PQERRORS_DEFAULT));
|
458
|
-
/*
|
440
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
441
|
+
* The VERBOSE mode includes all available fields. */
|
459
442
|
rb_define_const(rb_mPGconstants, "PQERRORS_VERBOSE", INT2FIX(PQERRORS_VERBOSE));
|
460
443
|
|
444
|
+
/* PQERRORS_SQLSTATE was introduced in PG-12 together with PQresultMemorySize() */
|
445
|
+
#ifdef HAVE_PQRESULTMEMORYSIZE
|
446
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
447
|
+
* 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).
|
448
|
+
*
|
449
|
+
* Available since PostgreSQL-12.
|
450
|
+
*/
|
451
|
+
rb_define_const(rb_mPGconstants, "PQERRORS_SQLSTATE", INT2FIX(PQERRORS_SQLSTATE));
|
452
|
+
#endif
|
453
|
+
|
454
|
+
#ifdef HAVE_PQRESULTVERBOSEERRORMESSAGE
|
455
|
+
/* See Connection#set_error_context_visibility */
|
456
|
+
rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_NEVER", INT2FIX(PQSHOW_CONTEXT_NEVER));
|
457
|
+
/* See Connection#set_error_context_visibility */
|
458
|
+
rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_ERRORS", INT2FIX(PQSHOW_CONTEXT_ERRORS));
|
459
|
+
/* See Connection#set_error_context_visibility */
|
460
|
+
rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_ALWAYS", INT2FIX(PQSHOW_CONTEXT_ALWAYS));
|
461
|
+
#endif
|
462
|
+
|
461
463
|
/****** PG::Connection CLASS CONSTANTS: Check Server Status ******/
|
462
464
|
|
463
465
|
/* Server is accepting connections. */
|
@@ -471,153 +473,203 @@ Init_pg_ext()
|
|
471
473
|
|
472
474
|
/****** PG::Connection CLASS CONSTANTS: Large Objects ******/
|
473
475
|
|
474
|
-
/* Flag for #lo_creat, #lo_open -- open for writing */
|
476
|
+
/* Flag for Connection#lo_creat, Connection#lo_open -- open for writing */
|
475
477
|
rb_define_const(rb_mPGconstants, "INV_WRITE", INT2FIX(INV_WRITE));
|
476
|
-
/* Flag for #lo_creat, #lo_open -- open for reading */
|
478
|
+
/* Flag for Connection#lo_creat, Connection#lo_open -- open for reading */
|
477
479
|
rb_define_const(rb_mPGconstants, "INV_READ", INT2FIX(INV_READ));
|
478
|
-
/* Flag for #lo_lseek -- seek from object start */
|
480
|
+
/* Flag for Connection#lo_lseek -- seek from object start */
|
479
481
|
rb_define_const(rb_mPGconstants, "SEEK_SET", INT2FIX(SEEK_SET));
|
480
|
-
/* Flag for #lo_lseek -- seek from current position */
|
482
|
+
/* Flag for Connection#lo_lseek -- seek from current position */
|
481
483
|
rb_define_const(rb_mPGconstants, "SEEK_CUR", INT2FIX(SEEK_CUR));
|
482
|
-
/* Flag for #lo_lseek -- seek from object end */
|
484
|
+
/* Flag for Connection#lo_lseek -- seek from object end */
|
483
485
|
rb_define_const(rb_mPGconstants, "SEEK_END", INT2FIX(SEEK_END));
|
484
486
|
|
485
487
|
/****** PG::Result CONSTANTS: result status ******/
|
486
488
|
|
487
|
-
/* #result_status constant
|
489
|
+
/* Result#result_status constant - The string sent to the server was empty. */
|
488
490
|
rb_define_const(rb_mPGconstants, "PGRES_EMPTY_QUERY", INT2FIX(PGRES_EMPTY_QUERY));
|
489
|
-
/* #result_status constant
|
491
|
+
/* Result#result_status constant - Successful completion of a command returning no data. */
|
490
492
|
rb_define_const(rb_mPGconstants, "PGRES_COMMAND_OK", INT2FIX(PGRES_COMMAND_OK));
|
491
|
-
|
492
|
-
(such as a SELECT or SHOW). */
|
493
|
+
/* Result#result_status constant - Successful completion of a command returning data (such as a SELECT or SHOW). */
|
493
494
|
rb_define_const(rb_mPGconstants, "PGRES_TUPLES_OK", INT2FIX(PGRES_TUPLES_OK));
|
494
|
-
/* #result_status constant
|
495
|
+
/* Result#result_status constant - Copy Out (from server) data transfer started. */
|
495
496
|
rb_define_const(rb_mPGconstants, "PGRES_COPY_OUT", INT2FIX(PGRES_COPY_OUT));
|
496
|
-
/* #result_status constant
|
497
|
+
/* Result#result_status constant - Copy In (to server) data transfer started. */
|
497
498
|
rb_define_const(rb_mPGconstants, "PGRES_COPY_IN", INT2FIX(PGRES_COPY_IN));
|
498
|
-
/* #result_status constant
|
499
|
+
/* Result#result_status constant - The server’s response was not understood. */
|
499
500
|
rb_define_const(rb_mPGconstants, "PGRES_BAD_RESPONSE", INT2FIX(PGRES_BAD_RESPONSE));
|
500
|
-
/* #result_status constant
|
501
|
+
/* Result#result_status constant - A nonfatal error (a notice or warning) occurred. */
|
501
502
|
rb_define_const(rb_mPGconstants, "PGRES_NONFATAL_ERROR",INT2FIX(PGRES_NONFATAL_ERROR));
|
502
|
-
/* #result_status constant
|
503
|
+
/* Result#result_status constant - A fatal error occurred. */
|
503
504
|
rb_define_const(rb_mPGconstants, "PGRES_FATAL_ERROR", INT2FIX(PGRES_FATAL_ERROR));
|
504
|
-
/* #result_status constant
|
505
|
+
/* Result#result_status constant - Copy In/Out data transfer in progress. */
|
505
506
|
rb_define_const(rb_mPGconstants, "PGRES_COPY_BOTH", INT2FIX(PGRES_COPY_BOTH));
|
506
|
-
/* #result_status constant
|
507
|
+
/* Result#result_status constant - Single tuple from larger resultset. */
|
507
508
|
rb_define_const(rb_mPGconstants, "PGRES_SINGLE_TUPLE", INT2FIX(PGRES_SINGLE_TUPLE));
|
508
509
|
|
510
|
+
#ifdef HAVE_PQENTERPIPELINEMODE
|
511
|
+
/* Result#result_status constant - The PG::Result represents a synchronization point in pipeline mode, requested by Connection#pipeline_sync.
|
512
|
+
*
|
513
|
+
* This status occurs only when pipeline mode has been selected. */
|
514
|
+
rb_define_const(rb_mPGconstants, "PGRES_PIPELINE_SYNC", INT2FIX(PGRES_PIPELINE_SYNC));
|
515
|
+
|
516
|
+
/* Result#result_status constant - The PG::Result represents a pipeline that has received an error from the server.
|
517
|
+
*
|
518
|
+
* 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.
|
519
|
+
*/
|
520
|
+
rb_define_const(rb_mPGconstants, "PGRES_PIPELINE_ABORTED", INT2FIX(PGRES_PIPELINE_ABORTED));
|
521
|
+
#endif
|
522
|
+
|
509
523
|
/****** Result CONSTANTS: result error field codes ******/
|
510
524
|
|
511
|
-
/* #result_error_field argument constant
|
512
|
-
*
|
513
|
-
* DEBUG, INFO, or LOG (in a notice message), or a localized translation
|
514
|
-
* of one of these.
|
525
|
+
/* Result#result_error_field argument constant
|
526
|
+
*
|
527
|
+
* 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
|
528
|
+
* of one of these.
|
529
|
+
* Always present.
|
515
530
|
*/
|
516
531
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY", INT2FIX(PG_DIAG_SEVERITY));
|
517
532
|
|
518
|
-
|
519
|
-
|
520
|
-
*
|
521
|
-
*
|
522
|
-
*
|
523
|
-
*
|
533
|
+
#ifdef PG_DIAG_SEVERITY_NONLOCALIZED
|
534
|
+
/* Result#result_error_field argument constant
|
535
|
+
*
|
536
|
+
* 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).
|
537
|
+
* This is identical to the PG_DIAG_SEVERITY field except that the contents are never localized.
|
538
|
+
*
|
539
|
+
* Available since PostgreSQL-9.6
|
540
|
+
*/
|
541
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY_NONLOCALIZED", INT2FIX(PG_DIAG_SEVERITY_NONLOCALIZED));
|
542
|
+
#endif
|
543
|
+
/* Result#result_error_field argument constant
|
544
|
+
*
|
545
|
+
* The SQLSTATE code for the error.
|
546
|
+
* 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.
|
547
|
+
* For a list of the possible SQLSTATE codes, see Appendix A.
|
548
|
+
* This field is not localizable, and is always present.
|
524
549
|
*/
|
525
550
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SQLSTATE", INT2FIX(PG_DIAG_SQLSTATE));
|
526
|
-
|
527
|
-
|
528
|
-
* error message (typically one line).
|
551
|
+
/* Result#result_error_field argument constant
|
552
|
+
*
|
553
|
+
* The primary human-readable error message (typically one line).
|
554
|
+
* Always present. */
|
529
555
|
rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_PRIMARY", INT2FIX(PG_DIAG_MESSAGE_PRIMARY));
|
530
|
-
|
531
|
-
|
532
|
-
* error message carrying more detail about the problem.
|
533
|
-
* multiple lines.
|
556
|
+
/* Result#result_error_field argument constant
|
557
|
+
*
|
558
|
+
* Detail: an optional secondary error message carrying more detail about the problem.
|
559
|
+
* Might run to multiple lines.
|
534
560
|
*/
|
535
561
|
rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_DETAIL", INT2FIX(PG_DIAG_MESSAGE_DETAIL));
|
536
|
-
|
537
|
-
|
538
|
-
* what to do about the problem.
|
539
|
-
* in that it offers advice (potentially inappropriate) rather than
|
540
|
-
*
|
562
|
+
/* Result#result_error_field argument constant
|
563
|
+
*
|
564
|
+
* Hint: an optional suggestion what to do about the problem.
|
565
|
+
* This is intended to differ from detail in that it offers advice (potentially inappropriate) rather than hard facts.
|
566
|
+
* Might run to multiple lines.
|
541
567
|
*/
|
542
|
-
|
543
568
|
rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_HINT", INT2FIX(PG_DIAG_MESSAGE_HINT));
|
544
|
-
/* #result_error_field argument constant
|
545
|
-
*
|
546
|
-
*
|
547
|
-
*
|
569
|
+
/* Result#result_error_field argument constant
|
570
|
+
*
|
571
|
+
* A string containing a decimal integer indicating an error cursor position as an index into the original statement string.
|
572
|
+
*
|
573
|
+
* The first character has index 1, and positions are measured in characters not bytes.
|
548
574
|
*/
|
549
|
-
|
550
575
|
rb_define_const(rb_mPGconstants, "PG_DIAG_STATEMENT_POSITION", INT2FIX(PG_DIAG_STATEMENT_POSITION));
|
551
|
-
/* #result_error_field argument constant
|
552
|
-
*
|
553
|
-
* position refers to an internally generated command rather than the
|
554
|
-
*
|
555
|
-
* always appear when this eld appears.
|
576
|
+
/* Result#result_error_field argument constant
|
577
|
+
*
|
578
|
+
* 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.
|
579
|
+
* The PG_DIAG_INTERNAL_QUERY field will always appear when this field appears.
|
556
580
|
*/
|
557
|
-
|
558
581
|
rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_POSITION", INT2FIX(PG_DIAG_INTERNAL_POSITION));
|
559
|
-
/* #result_error_field argument constant
|
560
|
-
*
|
561
|
-
*
|
582
|
+
/* Result#result_error_field argument constant
|
583
|
+
*
|
584
|
+
* The text of a failed internally-generated command.
|
585
|
+
* This could be, for example, a SQL query issued by a PL/pgSQL function.
|
562
586
|
*/
|
563
|
-
|
564
587
|
rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_QUERY", INT2FIX(PG_DIAG_INTERNAL_QUERY));
|
565
|
-
/* #result_error_field argument constant
|
566
|
-
*
|
567
|
-
*
|
568
|
-
*
|
588
|
+
/* Result#result_error_field argument constant
|
589
|
+
*
|
590
|
+
* An indication of the context in which the error occurred.
|
591
|
+
* Presently this includes a call stack traceback of active procedural language functions and internally-generated queries.
|
592
|
+
* The trace is one entry per line, most recent first.
|
569
593
|
*/
|
570
|
-
|
571
594
|
rb_define_const(rb_mPGconstants, "PG_DIAG_CONTEXT", INT2FIX(PG_DIAG_CONTEXT));
|
572
|
-
/* #result_error_field argument constant
|
573
|
-
*
|
595
|
+
/* Result#result_error_field argument constant
|
596
|
+
*
|
597
|
+
* The file name of the source-code location where the error was reported. */
|
574
598
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FILE", INT2FIX(PG_DIAG_SOURCE_FILE));
|
575
599
|
|
576
|
-
/* #result_error_field argument constant
|
577
|
-
*
|
600
|
+
/* Result#result_error_field argument constant
|
601
|
+
*
|
602
|
+
* The line number of the source-code location where the error was reported. */
|
578
603
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_LINE", INT2FIX(PG_DIAG_SOURCE_LINE));
|
579
604
|
|
580
|
-
/* #result_error_field argument constant
|
581
|
-
*
|
605
|
+
/* Result#result_error_field argument constant
|
606
|
+
*
|
607
|
+
* The name of the source-code function reporting the error. */
|
582
608
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FUNCTION", INT2FIX(PG_DIAG_SOURCE_FUNCTION));
|
583
609
|
|
584
|
-
#ifdef
|
585
|
-
/* #result_error_field argument constant
|
586
|
-
*
|
610
|
+
#ifdef PG_DIAG_TABLE_NAME
|
611
|
+
/* Result#result_error_field argument constant
|
612
|
+
*
|
613
|
+
* If the error was associated with a specific database object, the name of the schema containing that object, if any. */
|
587
614
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SCHEMA_NAME", INT2FIX(PG_DIAG_SCHEMA_NAME));
|
588
615
|
|
589
|
-
/* #result_error_field argument constant
|
590
|
-
*
|
591
|
-
*
|
616
|
+
/* Result#result_error_field argument constant
|
617
|
+
*
|
618
|
+
* If the error was associated with a specific table, the name of the table.
|
619
|
+
* (When this field is present, the schema name field provides the name of the table's schema.) */
|
592
620
|
rb_define_const(rb_mPGconstants, "PG_DIAG_TABLE_NAME", INT2FIX(PG_DIAG_TABLE_NAME));
|
593
621
|
|
594
|
-
/* #result_error_field argument constant
|
595
|
-
*
|
596
|
-
*
|
622
|
+
/* Result#result_error_field argument constant
|
623
|
+
*
|
624
|
+
* If the error was associated with a specific table column, the name of the column.
|
625
|
+
* (When this field is present, the schema and table name fields identify the table.) */
|
597
626
|
rb_define_const(rb_mPGconstants, "PG_DIAG_COLUMN_NAME", INT2FIX(PG_DIAG_COLUMN_NAME));
|
598
627
|
|
599
|
-
/* #result_error_field argument constant
|
600
|
-
*
|
601
|
-
*
|
628
|
+
/* Result#result_error_field argument constant
|
629
|
+
*
|
630
|
+
* If the error was associated with a specific datatype, the name of the datatype.
|
631
|
+
* (When this field is present, the schema name field provides the name of the datatype's schema.) */
|
602
632
|
rb_define_const(rb_mPGconstants, "PG_DIAG_DATATYPE_NAME", INT2FIX(PG_DIAG_DATATYPE_NAME));
|
603
633
|
|
604
|
-
/* #result_error_field argument constant
|
605
|
-
*
|
606
|
-
*
|
607
|
-
*
|
608
|
-
* constraint syntax.) */
|
634
|
+
/* Result#result_error_field argument constant
|
635
|
+
*
|
636
|
+
* If the error was associated with a specific constraint, the name of the constraint.
|
637
|
+
* The table or domain that the constraint belongs to is reported using the fields listed above.
|
638
|
+
* (For this purpose, indexes are treated as constraints, even if they weren't created with constraint syntax.) */
|
609
639
|
rb_define_const(rb_mPGconstants, "PG_DIAG_CONSTRAINT_NAME", INT2FIX(PG_DIAG_CONSTRAINT_NAME));
|
610
640
|
#endif
|
611
641
|
|
642
|
+
#ifdef HAVE_PQENTERPIPELINEMODE
|
643
|
+
/* Connection#pipeline_status constant
|
644
|
+
*
|
645
|
+
* The libpq connection is in pipeline mode.
|
646
|
+
*/
|
647
|
+
rb_define_const(rb_mPGconstants, "PQ_PIPELINE_ON", INT2FIX(PQ_PIPELINE_ON));
|
648
|
+
|
649
|
+
/* Connection#pipeline_status constant
|
650
|
+
*
|
651
|
+
* The libpq connection is not in pipeline mode.
|
652
|
+
*/
|
653
|
+
rb_define_const(rb_mPGconstants, "PQ_PIPELINE_OFF", INT2FIX(PQ_PIPELINE_OFF));
|
654
|
+
|
655
|
+
/* Connection#pipeline_status constant
|
656
|
+
*
|
657
|
+
* The libpq connection is in pipeline mode and an error occurred while processing the current pipeline.
|
658
|
+
* The aborted flag is cleared when PQgetResult returns a result of type PGRES_PIPELINE_SYNC.
|
659
|
+
*/
|
660
|
+
rb_define_const(rb_mPGconstants, "PQ_PIPELINE_ABORTED", INT2FIX(PQ_PIPELINE_ABORTED));
|
661
|
+
#endif
|
662
|
+
|
612
663
|
/* Invalid OID constant */
|
613
664
|
rb_define_const(rb_mPGconstants, "INVALID_OID", INT2FIX(InvalidOid));
|
614
665
|
rb_define_const(rb_mPGconstants, "InvalidOid", INT2FIX(InvalidOid));
|
615
666
|
|
667
|
+
/* PostgreSQL compiled in default port */
|
668
|
+
rb_define_const(rb_mPGconstants, "DEF_PGPORT", INT2FIX(DEF_PGPORT));
|
669
|
+
|
616
670
|
/* Add the constants to the toplevel namespace */
|
617
671
|
rb_include_module( rb_mPG, rb_mPGconstants );
|
618
672
|
|
619
|
-
enc_pg2ruby = st_init_numtable();
|
620
|
-
|
621
673
|
/* Initialize the main extension classes */
|
622
674
|
init_pg_connection();
|
623
675
|
init_pg_result();
|
@@ -635,6 +687,6 @@ Init_pg_ext()
|
|
635
687
|
init_pg_binary_encoder();
|
636
688
|
init_pg_binary_decoder();
|
637
689
|
init_pg_copycoder();
|
690
|
+
init_pg_recordcoder();
|
638
691
|
init_pg_tuple();
|
639
692
|
}
|
640
|
-
|