pg 0.21.0 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data/.appveyor.yml +36 -0
- data/.gems +6 -0
- data/.github/workflows/binary-gems.yml +86 -0
- data/.github/workflows/source-gem.yml +131 -0
- data/.gitignore +13 -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.rdoc +390 -4
- data/Manifest.txt +8 -4
- data/README-Windows.rdoc +4 -4
- data/README.ja.rdoc +1 -2
- data/README.rdoc +85 -20
- data/Rakefile +32 -142
- data/Rakefile.cross +71 -71
- data/certs/ged.pem +24 -0
- data/certs/larskanis-2022.pem +26 -0
- data/ext/errorcodes.def +84 -0
- data/ext/errorcodes.rb +1 -1
- data/ext/errorcodes.txt +23 -2
- data/ext/extconf.rb +111 -54
- data/ext/gvl_wrappers.c +8 -0
- data/ext/gvl_wrappers.h +40 -33
- data/ext/pg.c +211 -171
- data/ext/pg.h +87 -95
- data/ext/pg_binary_decoder.c +83 -16
- data/ext/pg_binary_encoder.c +14 -13
- data/ext/pg_coder.c +146 -31
- data/ext/pg_connection.c +1441 -1001
- data/ext/pg_copy_coder.c +61 -24
- data/ext/pg_errors.c +1 -1
- data/ext/pg_record_coder.c +521 -0
- data/ext/pg_result.c +623 -208
- data/ext/pg_text_decoder.c +607 -41
- data/ext/pg_text_encoder.c +191 -60
- data/ext/pg_tuple.c +569 -0
- data/ext/pg_type_map.c +43 -10
- data/ext/pg_type_map_all_strings.c +20 -6
- data/ext/pg_type_map_by_class.c +55 -25
- data/ext/pg_type_map_by_column.c +75 -36
- data/ext/pg_type_map_by_mri_type.c +49 -20
- data/ext/pg_type_map_by_oid.c +56 -26
- data/ext/pg_type_map_in_ruby.c +52 -21
- data/ext/{util.c → pg_util.c} +12 -12
- data/ext/{util.h → pg_util.h} +2 -2
- data/lib/pg/basic_type_map_based_on_result.rb +47 -0
- data/lib/pg/basic_type_map_for_queries.rb +193 -0
- data/lib/pg/basic_type_map_for_results.rb +81 -0
- data/lib/pg/basic_type_registry.rb +301 -0
- data/lib/pg/binary_decoder.rb +23 -0
- data/lib/pg/coder.rb +24 -3
- data/lib/pg/connection.rb +667 -57
- data/lib/pg/constants.rb +2 -1
- data/lib/pg/exceptions.rb +9 -2
- data/lib/pg/result.rb +14 -2
- data/lib/pg/text_decoder.rb +21 -26
- data/lib/pg/text_encoder.rb +32 -8
- data/lib/pg/tuple.rb +30 -0
- data/lib/pg/type_map_by_column.rb +3 -2
- data/lib/pg/version.rb +4 -0
- data/lib/pg.rb +51 -38
- 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 +32 -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.tar.gz.sig +0 -0
- metadata +91 -229
- metadata.gz.sig +0 -0
- data/ChangeLog +0 -6595
- data/lib/pg/basic_type_mapping.rb +0 -426
- data/lib/pg/deprecated_constants.rb +0 -21
- data/spec/data/expected_trace.out +0 -26
- data/spec/data/random_binary_data +0 -0
- data/spec/helpers.rb +0 -352
- data/spec/pg/basic_type_mapping_spec.rb +0 -305
- data/spec/pg/connection_spec.rb +0 -1676
- data/spec/pg/result_spec.rb +0 -456
- 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 -777
- data/spec/pg_spec.rb +0 -50
data/ext/pg.c
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* pg.c - Toplevel extension
|
|
3
|
-
* $Id
|
|
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
|
|
@@ -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
|
|
|
@@ -69,7 +70,6 @@ VALUE rb_mPGconstants;
|
|
|
69
70
|
* M17n functions
|
|
70
71
|
*/
|
|
71
72
|
|
|
72
|
-
#ifdef M17N_SUPPORTED
|
|
73
73
|
/**
|
|
74
74
|
* The mapping from canonical encoding names in PostgreSQL to ones in Ruby.
|
|
75
75
|
*/
|
|
@@ -126,29 +126,6 @@ const char * const (pg_enc_pg2ruby_mapping[][2]) = {
|
|
|
126
126
|
static struct st_table *enc_pg2ruby;
|
|
127
127
|
|
|
128
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
|
-
for (i = 1; i < sizeof(aliases)/sizeof(aliases[0]); ++i) {
|
|
147
|
-
ENC_ALIAS(aliases[i], aliases[0]);
|
|
148
|
-
}
|
|
149
|
-
return rb_enc_from_index(enc_index);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
129
|
/*
|
|
153
130
|
* Return the given PostgreSQL encoding ID as an rb_encoding.
|
|
154
131
|
*
|
|
@@ -189,10 +166,6 @@ pg_get_pg_encname_as_rb_encoding( const char *pg_encname )
|
|
|
189
166
|
return rb_enc_find( pg_enc_pg2ruby_mapping[i][1] );
|
|
190
167
|
}
|
|
191
168
|
|
|
192
|
-
/* JOHAB isn't a builtin encoding, so make up a dummy encoding if it's seen */
|
|
193
|
-
if ( strncmp(pg_encname, "JOHAB", 5) == 0 )
|
|
194
|
-
return pg_find_or_create_johab();
|
|
195
|
-
|
|
196
169
|
/* Fallthrough to ASCII-8BIT */
|
|
197
170
|
return rb_ascii8bit_encoding();
|
|
198
171
|
}
|
|
@@ -229,8 +202,6 @@ pg_get_rb_encoding_as_pg_encoding( rb_encoding *enc )
|
|
|
229
202
|
return encname;
|
|
230
203
|
}
|
|
231
204
|
|
|
232
|
-
#endif /* M17N_SUPPORTED */
|
|
233
|
-
|
|
234
205
|
|
|
235
206
|
/*
|
|
236
207
|
* Ensures that the given string has enough capacity to take expand_len
|
|
@@ -260,45 +231,26 @@ pg_get_rb_encoding_as_pg_encoding( rb_encoding *enc )
|
|
|
260
231
|
* rb_str_set_len( string, current_out - RSTRING_PTR(string) );
|
|
261
232
|
*
|
|
262
233
|
*/
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
rb_str_modify_expand( str, (curr_len + expand_len) * 2 - curr_capa );
|
|
273
|
-
curr_ptr = RSTRING_PTR(str) + curr_len;
|
|
274
|
-
}
|
|
275
|
-
if( end_ptr )
|
|
276
|
-
*end_ptr = RSTRING_PTR(str) + rb_str_capacity( str );
|
|
277
|
-
return curr_ptr;
|
|
278
|
-
}
|
|
279
|
-
#else
|
|
280
|
-
/* Use the more portable version */
|
|
281
|
-
char *
|
|
282
|
-
pg_rb_str_ensure_capa( VALUE str, long expand_len, char *curr_ptr, char **end_ptr )
|
|
283
|
-
{
|
|
284
|
-
long curr_len = curr_ptr - RSTRING_PTR(str);
|
|
285
|
-
long curr_capa = RSTRING_LEN( str );
|
|
286
|
-
if( curr_capa < curr_len + expand_len ){
|
|
287
|
-
rb_str_resize( str, (curr_len + expand_len) * 2 - curr_capa );
|
|
288
|
-
curr_ptr = RSTRING_PTR(str) + curr_len;
|
|
289
|
-
}
|
|
290
|
-
if( end_ptr )
|
|
291
|
-
*end_ptr = RSTRING_PTR(str) + RSTRING_LEN(str);
|
|
292
|
-
return curr_ptr;
|
|
234
|
+
char *
|
|
235
|
+
pg_rb_str_ensure_capa( VALUE str, long expand_len, char *curr_ptr, char **end_ptr )
|
|
236
|
+
{
|
|
237
|
+
long curr_len = curr_ptr - RSTRING_PTR(str);
|
|
238
|
+
long curr_capa = rb_str_capacity( str );
|
|
239
|
+
if( curr_capa < curr_len + expand_len ){
|
|
240
|
+
rb_str_set_len( str, curr_len );
|
|
241
|
+
rb_str_modify_expand( str, (curr_len + expand_len) * 2 - curr_capa );
|
|
242
|
+
curr_ptr = RSTRING_PTR(str) + curr_len;
|
|
293
243
|
}
|
|
294
|
-
|
|
244
|
+
if( end_ptr )
|
|
245
|
+
*end_ptr = RSTRING_PTR(str) + rb_str_capacity( str );
|
|
246
|
+
return curr_ptr;
|
|
247
|
+
}
|
|
295
248
|
|
|
296
249
|
|
|
297
250
|
/**************************************************************************
|
|
298
251
|
* Module Methods
|
|
299
252
|
**************************************************************************/
|
|
300
253
|
|
|
301
|
-
#ifdef HAVE_PQLIBVERSION
|
|
302
254
|
/*
|
|
303
255
|
* call-seq:
|
|
304
256
|
* PG.library_version -> Integer
|
|
@@ -316,7 +268,6 @@ pg_s_library_version(VALUE self)
|
|
|
316
268
|
UNUSED( self );
|
|
317
269
|
return INT2NUM(PQlibVersion());
|
|
318
270
|
}
|
|
319
|
-
#endif
|
|
320
271
|
|
|
321
272
|
|
|
322
273
|
/*
|
|
@@ -356,8 +307,7 @@ pg_to_bool_int(VALUE value)
|
|
|
356
307
|
* If your application initializes libssl and/or libcrypto libraries and libpq is
|
|
357
308
|
* built with SSL support, you should call PG.init_openssl() to tell libpq that the
|
|
358
309
|
* libssl and/or libcrypto libraries have been initialized by your application,
|
|
359
|
-
* so that libpq will not also initialize those libraries.
|
|
360
|
-
* http://h71000.www7.hp.com/doc/83final/BA554_90007/ch04.html for details on the SSL API.
|
|
310
|
+
* so that libpq will not also initialize those libraries.
|
|
361
311
|
*
|
|
362
312
|
* When do_ssl is +true+, libpq will initialize the OpenSSL library before first
|
|
363
313
|
* opening a database connection. When do_crypto is +true+, the libcrypto library
|
|
@@ -402,17 +352,22 @@ pg_s_init_ssl(VALUE self, VALUE do_ssl)
|
|
|
402
352
|
**************************************************************************/
|
|
403
353
|
|
|
404
354
|
void
|
|
405
|
-
Init_pg_ext()
|
|
355
|
+
Init_pg_ext(void)
|
|
406
356
|
{
|
|
357
|
+
if( RTEST(rb_eval_string("ENV['PG_SKIP_DEPRECATION_WARNING']")) ){
|
|
358
|
+
/* Set all bits to disable all deprecation warnings. */
|
|
359
|
+
pg_skip_deprecation_warning = 0xFFFF;
|
|
360
|
+
} else {
|
|
361
|
+
pg_skip_deprecation_warning = 0;
|
|
362
|
+
}
|
|
363
|
+
|
|
407
364
|
rb_mPG = rb_define_module( "PG" );
|
|
408
365
|
rb_mPGconstants = rb_define_module_under( rb_mPG, "Constants" );
|
|
409
366
|
|
|
410
367
|
/*************************
|
|
411
368
|
* PG module methods
|
|
412
369
|
*************************/
|
|
413
|
-
#ifdef HAVE_PQLIBVERSION
|
|
414
370
|
rb_define_singleton_method( rb_mPG, "library_version", pg_s_library_version, 0 );
|
|
415
|
-
#endif
|
|
416
371
|
rb_define_singleton_method( rb_mPG, "isthreadsafe", pg_s_threadsafe_p, 0 );
|
|
417
372
|
SINGLETON_ALIAS( rb_mPG, "is_threadsafe?", "isthreadsafe" );
|
|
418
373
|
SINGLETON_ALIAS( rb_mPG, "threadsafe?", "isthreadsafe" );
|
|
@@ -436,14 +391,34 @@ Init_pg_ext()
|
|
|
436
391
|
rb_define_const(rb_mPGconstants, "CONNECTION_MADE", INT2FIX(CONNECTION_MADE));
|
|
437
392
|
/* Waiting for a response from the server. */
|
|
438
393
|
rb_define_const(rb_mPGconstants, "CONNECTION_AWAITING_RESPONSE", INT2FIX(CONNECTION_AWAITING_RESPONSE));
|
|
439
|
-
/* Received authentication; waiting for backend
|
|
394
|
+
/* Received authentication; waiting for backend startup. */
|
|
440
395
|
rb_define_const(rb_mPGconstants, "CONNECTION_AUTH_OK", INT2FIX(CONNECTION_AUTH_OK));
|
|
396
|
+
/* This state is no longer used. */
|
|
397
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_SETENV", INT2FIX(CONNECTION_SETENV));
|
|
441
398
|
/* Negotiating SSL encryption. */
|
|
442
399
|
rb_define_const(rb_mPGconstants, "CONNECTION_SSL_STARTUP", INT2FIX(CONNECTION_SSL_STARTUP));
|
|
443
|
-
/*
|
|
444
|
-
rb_define_const(rb_mPGconstants, "CONNECTION_SETENV", INT2FIX(CONNECTION_SETENV));
|
|
445
|
-
/* Internal state: connect() needed. */
|
|
400
|
+
/* Internal state - PG.connect() needed. */
|
|
446
401
|
rb_define_const(rb_mPGconstants, "CONNECTION_NEEDED", INT2FIX(CONNECTION_NEEDED));
|
|
402
|
+
#if PG_MAJORVERSION_NUM >= 10
|
|
403
|
+
/* Checking if session is read-write. Available since PostgreSQL-10. */
|
|
404
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_CHECK_WRITABLE", INT2FIX(CONNECTION_CHECK_WRITABLE));
|
|
405
|
+
#endif
|
|
406
|
+
#if PG_MAJORVERSION_NUM >= 10
|
|
407
|
+
/* Consuming any extra messages. Available since PostgreSQL-10. */
|
|
408
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_CONSUME", INT2FIX(CONNECTION_CONSUME));
|
|
409
|
+
#endif
|
|
410
|
+
#if PG_MAJORVERSION_NUM >= 12
|
|
411
|
+
/* Negotiating GSSAPI. Available since PostgreSQL-12. */
|
|
412
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_GSS_STARTUP", INT2FIX(CONNECTION_GSS_STARTUP));
|
|
413
|
+
#endif
|
|
414
|
+
#if PG_MAJORVERSION_NUM >= 13
|
|
415
|
+
/* Checking target server properties. Available since PostgreSQL-13. */
|
|
416
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_CHECK_TARGET", INT2FIX(CONNECTION_CHECK_TARGET));
|
|
417
|
+
#endif
|
|
418
|
+
#if PG_MAJORVERSION_NUM >= 14
|
|
419
|
+
/* Checking if server is in standby mode. Available since PostgreSQL-14. */
|
|
420
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_CHECK_STANDBY", INT2FIX(CONNECTION_CHECK_STANDBY));
|
|
421
|
+
#endif
|
|
447
422
|
|
|
448
423
|
/****** PG::Connection CLASS CONSTANTS: Nonblocking connection polling status ******/
|
|
449
424
|
|
|
@@ -458,27 +433,48 @@ Init_pg_ext()
|
|
|
458
433
|
|
|
459
434
|
/****** PG::Connection CLASS CONSTANTS: Transaction Status ******/
|
|
460
435
|
|
|
461
|
-
/* Transaction is currently idle (#transaction_status) */
|
|
436
|
+
/* Transaction is currently idle ( Connection#transaction_status ) */
|
|
462
437
|
rb_define_const(rb_mPGconstants, "PQTRANS_IDLE", INT2FIX(PQTRANS_IDLE));
|
|
463
|
-
/* Transaction is currently active; query has been sent to the server, but not yet completed. (#transaction_status) */
|
|
438
|
+
/* Transaction is currently active; query has been sent to the server, but not yet completed. ( Connection#transaction_status ) */
|
|
464
439
|
rb_define_const(rb_mPGconstants, "PQTRANS_ACTIVE", INT2FIX(PQTRANS_ACTIVE));
|
|
465
|
-
/* Transaction is currently idle, in a valid transaction block (#transaction_status) */
|
|
440
|
+
/* Transaction is currently idle, in a valid transaction block ( Connection#transaction_status ) */
|
|
466
441
|
rb_define_const(rb_mPGconstants, "PQTRANS_INTRANS", INT2FIX(PQTRANS_INTRANS));
|
|
467
|
-
/* Transaction is currently idle, in a failed transaction block (#transaction_status) */
|
|
442
|
+
/* Transaction is currently idle, in a failed transaction block ( Connection#transaction_status ) */
|
|
468
443
|
rb_define_const(rb_mPGconstants, "PQTRANS_INERROR", INT2FIX(PQTRANS_INERROR));
|
|
469
|
-
/* Transaction's connection is bad (#transaction_status) */
|
|
444
|
+
/* Transaction's connection is bad ( Connection#transaction_status ) */
|
|
470
445
|
rb_define_const(rb_mPGconstants, "PQTRANS_UNKNOWN", INT2FIX(PQTRANS_UNKNOWN));
|
|
471
446
|
|
|
472
447
|
/****** PG::Connection CLASS CONSTANTS: Error Verbosity ******/
|
|
473
448
|
|
|
474
|
-
/*
|
|
449
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
|
450
|
+
* In TERSE mode, returned messages include severity, primary text, and position only; this will normally fit on a single line. */
|
|
475
451
|
rb_define_const(rb_mPGconstants, "PQERRORS_TERSE", INT2FIX(PQERRORS_TERSE));
|
|
476
|
-
/*
|
|
452
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
|
453
|
+
* The DEFAULT mode produces messages that include the above plus any detail, hint, or context fields (these might span multiple lines). */
|
|
477
454
|
rb_define_const(rb_mPGconstants, "PQERRORS_DEFAULT", INT2FIX(PQERRORS_DEFAULT));
|
|
478
|
-
/*
|
|
455
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
|
456
|
+
* The VERBOSE mode includes all available fields. */
|
|
479
457
|
rb_define_const(rb_mPGconstants, "PQERRORS_VERBOSE", INT2FIX(PQERRORS_VERBOSE));
|
|
480
458
|
|
|
481
|
-
|
|
459
|
+
/* PQERRORS_SQLSTATE was introduced in PG-12 together with PQresultMemorySize() */
|
|
460
|
+
#ifdef HAVE_PQRESULTMEMORYSIZE
|
|
461
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
|
462
|
+
* 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).
|
|
463
|
+
*
|
|
464
|
+
* Available since PostgreSQL-12.
|
|
465
|
+
*/
|
|
466
|
+
rb_define_const(rb_mPGconstants, "PQERRORS_SQLSTATE", INT2FIX(PQERRORS_SQLSTATE));
|
|
467
|
+
#endif
|
|
468
|
+
|
|
469
|
+
#ifdef HAVE_PQRESULTVERBOSEERRORMESSAGE
|
|
470
|
+
/* See Connection#set_error_context_visibility */
|
|
471
|
+
rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_NEVER", INT2FIX(PQSHOW_CONTEXT_NEVER));
|
|
472
|
+
/* See Connection#set_error_context_visibility */
|
|
473
|
+
rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_ERRORS", INT2FIX(PQSHOW_CONTEXT_ERRORS));
|
|
474
|
+
/* See Connection#set_error_context_visibility */
|
|
475
|
+
rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_ALWAYS", INT2FIX(PQSHOW_CONTEXT_ALWAYS));
|
|
476
|
+
#endif
|
|
477
|
+
|
|
482
478
|
/****** PG::Connection CLASS CONSTANTS: Check Server Status ******/
|
|
483
479
|
|
|
484
480
|
/* Server is accepting connections. */
|
|
@@ -489,152 +485,196 @@ Init_pg_ext()
|
|
|
489
485
|
rb_define_const(rb_mPGconstants, "PQPING_NO_RESPONSE", INT2FIX(PQPING_NO_RESPONSE));
|
|
490
486
|
/* Connection not attempted (bad params). */
|
|
491
487
|
rb_define_const(rb_mPGconstants, "PQPING_NO_ATTEMPT", INT2FIX(PQPING_NO_ATTEMPT));
|
|
492
|
-
#endif
|
|
493
488
|
|
|
494
489
|
/****** PG::Connection CLASS CONSTANTS: Large Objects ******/
|
|
495
490
|
|
|
496
|
-
/* Flag for #lo_creat, #lo_open -- open for writing */
|
|
491
|
+
/* Flag for Connection#lo_creat, Connection#lo_open -- open for writing */
|
|
497
492
|
rb_define_const(rb_mPGconstants, "INV_WRITE", INT2FIX(INV_WRITE));
|
|
498
|
-
/* Flag for #lo_creat, #lo_open -- open for reading */
|
|
493
|
+
/* Flag for Connection#lo_creat, Connection#lo_open -- open for reading */
|
|
499
494
|
rb_define_const(rb_mPGconstants, "INV_READ", INT2FIX(INV_READ));
|
|
500
|
-
/* Flag for #lo_lseek -- seek from object start */
|
|
495
|
+
/* Flag for Connection#lo_lseek -- seek from object start */
|
|
501
496
|
rb_define_const(rb_mPGconstants, "SEEK_SET", INT2FIX(SEEK_SET));
|
|
502
|
-
/* Flag for #lo_lseek -- seek from current position */
|
|
497
|
+
/* Flag for Connection#lo_lseek -- seek from current position */
|
|
503
498
|
rb_define_const(rb_mPGconstants, "SEEK_CUR", INT2FIX(SEEK_CUR));
|
|
504
|
-
/* Flag for #lo_lseek -- seek from object end */
|
|
499
|
+
/* Flag for Connection#lo_lseek -- seek from object end */
|
|
505
500
|
rb_define_const(rb_mPGconstants, "SEEK_END", INT2FIX(SEEK_END));
|
|
506
501
|
|
|
507
502
|
/****** PG::Result CONSTANTS: result status ******/
|
|
508
503
|
|
|
509
|
-
/* #result_status constant
|
|
504
|
+
/* Result#result_status constant - The string sent to the server was empty. */
|
|
510
505
|
rb_define_const(rb_mPGconstants, "PGRES_EMPTY_QUERY", INT2FIX(PGRES_EMPTY_QUERY));
|
|
511
|
-
/* #result_status constant
|
|
506
|
+
/* Result#result_status constant - Successful completion of a command returning no data. */
|
|
512
507
|
rb_define_const(rb_mPGconstants, "PGRES_COMMAND_OK", INT2FIX(PGRES_COMMAND_OK));
|
|
513
|
-
|
|
514
|
-
(such as a SELECT or SHOW). */
|
|
508
|
+
/* Result#result_status constant - Successful completion of a command returning data (such as a SELECT or SHOW). */
|
|
515
509
|
rb_define_const(rb_mPGconstants, "PGRES_TUPLES_OK", INT2FIX(PGRES_TUPLES_OK));
|
|
516
|
-
/* #result_status constant
|
|
510
|
+
/* Result#result_status constant - Copy Out (from server) data transfer started. */
|
|
517
511
|
rb_define_const(rb_mPGconstants, "PGRES_COPY_OUT", INT2FIX(PGRES_COPY_OUT));
|
|
518
|
-
/* #result_status constant
|
|
512
|
+
/* Result#result_status constant - Copy In (to server) data transfer started. */
|
|
519
513
|
rb_define_const(rb_mPGconstants, "PGRES_COPY_IN", INT2FIX(PGRES_COPY_IN));
|
|
520
|
-
/* #result_status constant
|
|
514
|
+
/* Result#result_status constant - The server’s response was not understood. */
|
|
521
515
|
rb_define_const(rb_mPGconstants, "PGRES_BAD_RESPONSE", INT2FIX(PGRES_BAD_RESPONSE));
|
|
522
|
-
/* #result_status constant
|
|
516
|
+
/* Result#result_status constant - A nonfatal error (a notice or warning) occurred. */
|
|
523
517
|
rb_define_const(rb_mPGconstants, "PGRES_NONFATAL_ERROR",INT2FIX(PGRES_NONFATAL_ERROR));
|
|
524
|
-
/* #result_status constant
|
|
518
|
+
/* Result#result_status constant - A fatal error occurred. */
|
|
525
519
|
rb_define_const(rb_mPGconstants, "PGRES_FATAL_ERROR", INT2FIX(PGRES_FATAL_ERROR));
|
|
526
|
-
/* #result_status constant
|
|
527
|
-
#ifdef HAVE_CONST_PGRES_COPY_BOTH
|
|
520
|
+
/* Result#result_status constant - Copy In/Out data transfer in progress. */
|
|
528
521
|
rb_define_const(rb_mPGconstants, "PGRES_COPY_BOTH", INT2FIX(PGRES_COPY_BOTH));
|
|
529
|
-
#
|
|
530
|
-
/* #result_status constant: Single tuple from larger resultset. */
|
|
531
|
-
#ifdef HAVE_CONST_PGRES_SINGLE_TUPLE
|
|
522
|
+
/* Result#result_status constant - Single tuple from larger resultset. */
|
|
532
523
|
rb_define_const(rb_mPGconstants, "PGRES_SINGLE_TUPLE", INT2FIX(PGRES_SINGLE_TUPLE));
|
|
524
|
+
|
|
525
|
+
#ifdef HAVE_PQENTERPIPELINEMODE
|
|
526
|
+
/* Result#result_status constant - The PG::Result represents a synchronization point in pipeline mode, requested by Connection#pipeline_sync.
|
|
527
|
+
*
|
|
528
|
+
* This status occurs only when pipeline mode has been selected. */
|
|
529
|
+
rb_define_const(rb_mPGconstants, "PGRES_PIPELINE_SYNC", INT2FIX(PGRES_PIPELINE_SYNC));
|
|
530
|
+
|
|
531
|
+
/* Result#result_status constant - The PG::Result represents a pipeline that has received an error from the server.
|
|
532
|
+
*
|
|
533
|
+
* 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.
|
|
534
|
+
*/
|
|
535
|
+
rb_define_const(rb_mPGconstants, "PGRES_PIPELINE_ABORTED", INT2FIX(PGRES_PIPELINE_ABORTED));
|
|
533
536
|
#endif
|
|
534
537
|
|
|
535
538
|
/****** Result CONSTANTS: result error field codes ******/
|
|
536
539
|
|
|
537
|
-
/* #result_error_field argument constant
|
|
538
|
-
*
|
|
539
|
-
* DEBUG, INFO, or LOG (in a notice message), or a localized translation
|
|
540
|
-
* of one of these.
|
|
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), or a localized translation
|
|
543
|
+
* of one of these.
|
|
544
|
+
* Always present.
|
|
541
545
|
*/
|
|
542
546
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY", INT2FIX(PG_DIAG_SEVERITY));
|
|
543
547
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
*
|
|
548
|
+
#ifdef PG_DIAG_SEVERITY_NONLOCALIZED
|
|
549
|
+
/* Result#result_error_field argument constant
|
|
550
|
+
*
|
|
551
|
+
* 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).
|
|
552
|
+
* This is identical to the PG_DIAG_SEVERITY field except that the contents are never localized.
|
|
553
|
+
*
|
|
554
|
+
* Available since PostgreSQL-9.6
|
|
555
|
+
*/
|
|
556
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY_NONLOCALIZED", INT2FIX(PG_DIAG_SEVERITY_NONLOCALIZED));
|
|
557
|
+
#endif
|
|
558
|
+
/* Result#result_error_field argument constant
|
|
559
|
+
*
|
|
560
|
+
* The SQLSTATE code for the error.
|
|
561
|
+
* 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.
|
|
562
|
+
* For a list of the possible SQLSTATE codes, see Appendix A.
|
|
563
|
+
* This field is not localizable, and is always present.
|
|
550
564
|
*/
|
|
551
565
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SQLSTATE", INT2FIX(PG_DIAG_SQLSTATE));
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
* error message (typically one line).
|
|
566
|
+
/* Result#result_error_field argument constant
|
|
567
|
+
*
|
|
568
|
+
* The primary human-readable error message (typically one line).
|
|
569
|
+
* Always present. */
|
|
555
570
|
rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_PRIMARY", INT2FIX(PG_DIAG_MESSAGE_PRIMARY));
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
* error message carrying more detail about the problem.
|
|
559
|
-
* multiple lines.
|
|
571
|
+
/* Result#result_error_field argument constant
|
|
572
|
+
*
|
|
573
|
+
* Detail: an optional secondary error message carrying more detail about the problem.
|
|
574
|
+
* Might run to multiple lines.
|
|
560
575
|
*/
|
|
561
576
|
rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_DETAIL", INT2FIX(PG_DIAG_MESSAGE_DETAIL));
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
* what to do about the problem.
|
|
565
|
-
* in that it offers advice (potentially inappropriate) rather than
|
|
566
|
-
*
|
|
577
|
+
/* Result#result_error_field argument constant
|
|
578
|
+
*
|
|
579
|
+
* Hint: an optional suggestion what to do about the problem.
|
|
580
|
+
* This is intended to differ from detail in that it offers advice (potentially inappropriate) rather than hard facts.
|
|
581
|
+
* Might run to multiple lines.
|
|
567
582
|
*/
|
|
568
|
-
|
|
569
583
|
rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_HINT", INT2FIX(PG_DIAG_MESSAGE_HINT));
|
|
570
|
-
/* #result_error_field argument constant
|
|
571
|
-
*
|
|
572
|
-
*
|
|
573
|
-
*
|
|
584
|
+
/* Result#result_error_field argument constant
|
|
585
|
+
*
|
|
586
|
+
* A string containing a decimal integer indicating an error cursor position as an index into the original statement string.
|
|
587
|
+
*
|
|
588
|
+
* The first character has index 1, and positions are measured in characters not bytes.
|
|
574
589
|
*/
|
|
575
|
-
|
|
576
590
|
rb_define_const(rb_mPGconstants, "PG_DIAG_STATEMENT_POSITION", INT2FIX(PG_DIAG_STATEMENT_POSITION));
|
|
577
|
-
/* #result_error_field argument constant
|
|
578
|
-
*
|
|
579
|
-
* position refers to an internally generated command rather than the
|
|
580
|
-
*
|
|
581
|
-
* always appear when this eld appears.
|
|
591
|
+
/* Result#result_error_field argument constant
|
|
592
|
+
*
|
|
593
|
+
* 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.
|
|
594
|
+
* The PG_DIAG_INTERNAL_QUERY field will always appear when this field appears.
|
|
582
595
|
*/
|
|
583
|
-
|
|
584
596
|
rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_POSITION", INT2FIX(PG_DIAG_INTERNAL_POSITION));
|
|
585
|
-
/* #result_error_field argument constant
|
|
586
|
-
*
|
|
587
|
-
*
|
|
597
|
+
/* Result#result_error_field argument constant
|
|
598
|
+
*
|
|
599
|
+
* The text of a failed internally-generated command.
|
|
600
|
+
* This could be, for example, a SQL query issued by a PL/pgSQL function.
|
|
588
601
|
*/
|
|
589
|
-
|
|
590
602
|
rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_QUERY", INT2FIX(PG_DIAG_INTERNAL_QUERY));
|
|
591
|
-
/* #result_error_field argument constant
|
|
592
|
-
*
|
|
593
|
-
*
|
|
594
|
-
*
|
|
603
|
+
/* Result#result_error_field argument constant
|
|
604
|
+
*
|
|
605
|
+
* An indication of the context in which the error occurred.
|
|
606
|
+
* Presently this includes a call stack traceback of active procedural language functions and internally-generated queries.
|
|
607
|
+
* The trace is one entry per line, most recent first.
|
|
595
608
|
*/
|
|
596
|
-
|
|
597
609
|
rb_define_const(rb_mPGconstants, "PG_DIAG_CONTEXT", INT2FIX(PG_DIAG_CONTEXT));
|
|
598
|
-
/* #result_error_field argument constant
|
|
599
|
-
*
|
|
610
|
+
/* Result#result_error_field argument constant
|
|
611
|
+
*
|
|
612
|
+
* The file name of the source-code location where the error was reported. */
|
|
600
613
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FILE", INT2FIX(PG_DIAG_SOURCE_FILE));
|
|
601
614
|
|
|
602
|
-
/* #result_error_field argument constant
|
|
603
|
-
*
|
|
615
|
+
/* Result#result_error_field argument constant
|
|
616
|
+
*
|
|
617
|
+
* The line number of the source-code location where the error was reported. */
|
|
604
618
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_LINE", INT2FIX(PG_DIAG_SOURCE_LINE));
|
|
605
619
|
|
|
606
|
-
/* #result_error_field argument constant
|
|
607
|
-
*
|
|
620
|
+
/* Result#result_error_field argument constant
|
|
621
|
+
*
|
|
622
|
+
* The name of the source-code function reporting the error. */
|
|
608
623
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FUNCTION", INT2FIX(PG_DIAG_SOURCE_FUNCTION));
|
|
609
624
|
|
|
610
|
-
#ifdef
|
|
611
|
-
/* #result_error_field argument constant
|
|
612
|
-
*
|
|
625
|
+
#ifdef PG_DIAG_TABLE_NAME
|
|
626
|
+
/* Result#result_error_field argument constant
|
|
627
|
+
*
|
|
628
|
+
* If the error was associated with a specific database object, the name of the schema containing that object, if any. */
|
|
613
629
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SCHEMA_NAME", INT2FIX(PG_DIAG_SCHEMA_NAME));
|
|
614
630
|
|
|
615
|
-
/* #result_error_field argument constant
|
|
616
|
-
*
|
|
617
|
-
*
|
|
631
|
+
/* Result#result_error_field argument constant
|
|
632
|
+
*
|
|
633
|
+
* If the error was associated with a specific table, the name of the table.
|
|
634
|
+
* (When this field is present, the schema name field provides the name of the table's schema.) */
|
|
618
635
|
rb_define_const(rb_mPGconstants, "PG_DIAG_TABLE_NAME", INT2FIX(PG_DIAG_TABLE_NAME));
|
|
619
636
|
|
|
620
|
-
/* #result_error_field argument constant
|
|
621
|
-
*
|
|
622
|
-
*
|
|
637
|
+
/* Result#result_error_field argument constant
|
|
638
|
+
*
|
|
639
|
+
* If the error was associated with a specific table column, the name of the column.
|
|
640
|
+
* (When this field is present, the schema and table name fields identify the table.) */
|
|
623
641
|
rb_define_const(rb_mPGconstants, "PG_DIAG_COLUMN_NAME", INT2FIX(PG_DIAG_COLUMN_NAME));
|
|
624
642
|
|
|
625
|
-
/* #result_error_field argument constant
|
|
626
|
-
*
|
|
627
|
-
*
|
|
643
|
+
/* Result#result_error_field argument constant
|
|
644
|
+
*
|
|
645
|
+
* If the error was associated with a specific datatype, the name of the datatype.
|
|
646
|
+
* (When this field is present, the schema name field provides the name of the datatype's schema.) */
|
|
628
647
|
rb_define_const(rb_mPGconstants, "PG_DIAG_DATATYPE_NAME", INT2FIX(PG_DIAG_DATATYPE_NAME));
|
|
629
648
|
|
|
630
|
-
/* #result_error_field argument constant
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
* constraint syntax.) */
|
|
649
|
+
/* Result#result_error_field argument constant
|
|
650
|
+
*
|
|
651
|
+
* If the error was associated with a specific constraint, the name of the constraint.
|
|
652
|
+
* The table or domain that the constraint belongs to is reported using the fields listed above.
|
|
653
|
+
* (For this purpose, indexes are treated as constraints, even if they weren't created with constraint syntax.) */
|
|
635
654
|
rb_define_const(rb_mPGconstants, "PG_DIAG_CONSTRAINT_NAME", INT2FIX(PG_DIAG_CONSTRAINT_NAME));
|
|
636
655
|
#endif
|
|
637
656
|
|
|
657
|
+
#ifdef HAVE_PQENTERPIPELINEMODE
|
|
658
|
+
/* Connection#pipeline_status constant
|
|
659
|
+
*
|
|
660
|
+
* The libpq connection is in pipeline mode.
|
|
661
|
+
*/
|
|
662
|
+
rb_define_const(rb_mPGconstants, "PQ_PIPELINE_ON", INT2FIX(PQ_PIPELINE_ON));
|
|
663
|
+
|
|
664
|
+
/* Connection#pipeline_status constant
|
|
665
|
+
*
|
|
666
|
+
* The libpq connection is not in pipeline mode.
|
|
667
|
+
*/
|
|
668
|
+
rb_define_const(rb_mPGconstants, "PQ_PIPELINE_OFF", INT2FIX(PQ_PIPELINE_OFF));
|
|
669
|
+
|
|
670
|
+
/* Connection#pipeline_status constant
|
|
671
|
+
*
|
|
672
|
+
* The libpq connection is in pipeline mode and an error occurred while processing the current pipeline.
|
|
673
|
+
* The aborted flag is cleared when PQgetResult returns a result of type PGRES_PIPELINE_SYNC.
|
|
674
|
+
*/
|
|
675
|
+
rb_define_const(rb_mPGconstants, "PQ_PIPELINE_ABORTED", INT2FIX(PQ_PIPELINE_ABORTED));
|
|
676
|
+
#endif
|
|
677
|
+
|
|
638
678
|
/* Invalid OID constant */
|
|
639
679
|
rb_define_const(rb_mPGconstants, "INVALID_OID", INT2FIX(InvalidOid));
|
|
640
680
|
rb_define_const(rb_mPGconstants, "InvalidOid", INT2FIX(InvalidOid));
|
|
@@ -642,9 +682,7 @@ Init_pg_ext()
|
|
|
642
682
|
/* Add the constants to the toplevel namespace */
|
|
643
683
|
rb_include_module( rb_mPG, rb_mPGconstants );
|
|
644
684
|
|
|
645
|
-
#ifdef M17N_SUPPORTED
|
|
646
685
|
enc_pg2ruby = st_init_numtable();
|
|
647
|
-
#endif
|
|
648
686
|
|
|
649
687
|
/* Initialize the main extension classes */
|
|
650
688
|
init_pg_connection();
|
|
@@ -663,5 +701,7 @@ Init_pg_ext()
|
|
|
663
701
|
init_pg_binary_encoder();
|
|
664
702
|
init_pg_binary_decoder();
|
|
665
703
|
init_pg_copycoder();
|
|
704
|
+
init_pg_recordcoder();
|
|
705
|
+
init_pg_tuple();
|
|
666
706
|
}
|
|
667
707
|
|