pg 1.3.0.rc2-x64-mingw-ucrt
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +3 -0
- data/.appveyor.yml +36 -0
- data/.gems +6 -0
- data/.gemtest +0 -0
- data/.github/workflows/binary-gems.yml +85 -0
- data/.github/workflows/source-gem.yml +130 -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/BSDL +22 -0
- data/Contributors.rdoc +46 -0
- data/Gemfile +14 -0
- data/History.rdoc +648 -0
- data/LICENSE +56 -0
- data/Manifest.txt +72 -0
- data/POSTGRES +23 -0
- data/README-OS_X.rdoc +68 -0
- data/README-Windows.rdoc +56 -0
- data/README.ja.rdoc +13 -0
- data/README.rdoc +214 -0
- data/Rakefile +106 -0
- data/Rakefile.cross +300 -0
- data/certs/ged.pem +24 -0
- data/ext/errorcodes.def +1040 -0
- data/ext/errorcodes.rb +45 -0
- data/ext/errorcodes.txt +496 -0
- data/ext/extconf.rb +165 -0
- data/ext/gvl_wrappers.c +21 -0
- data/ext/gvl_wrappers.h +264 -0
- data/ext/pg.c +732 -0
- data/ext/pg.h +385 -0
- data/ext/pg_binary_decoder.c +229 -0
- data/ext/pg_binary_encoder.c +163 -0
- data/ext/pg_coder.c +615 -0
- data/ext/pg_connection.c +4415 -0
- data/ext/pg_copy_coder.c +628 -0
- data/ext/pg_errors.c +95 -0
- data/ext/pg_record_coder.c +519 -0
- data/ext/pg_result.c +1683 -0
- data/ext/pg_text_decoder.c +987 -0
- data/ext/pg_text_encoder.c +814 -0
- data/ext/pg_tuple.c +575 -0
- data/ext/pg_type_map.c +199 -0
- data/ext/pg_type_map_all_strings.c +129 -0
- data/ext/pg_type_map_by_class.c +269 -0
- data/ext/pg_type_map_by_column.c +349 -0
- data/ext/pg_type_map_by_mri_type.c +313 -0
- data/ext/pg_type_map_by_oid.c +385 -0
- data/ext/pg_type_map_in_ruby.c +330 -0
- data/ext/pg_util.c +149 -0
- data/ext/pg_util.h +65 -0
- data/ext/vc/pg.sln +26 -0
- data/ext/vc/pg_18/pg.vcproj +216 -0
- data/ext/vc/pg_19/pg_19.vcproj +209 -0
- data/lib/3.1/pg_ext.so +0 -0
- 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 +296 -0
- data/lib/pg/binary_decoder.rb +23 -0
- data/lib/pg/coder.rb +104 -0
- data/lib/pg/connection.rb +813 -0
- data/lib/pg/constants.rb +12 -0
- data/lib/pg/exceptions.rb +12 -0
- data/lib/pg/result.rb +43 -0
- data/lib/pg/text_decoder.rb +46 -0
- data/lib/pg/text_encoder.rb +59 -0
- data/lib/pg/tuple.rb +30 -0
- data/lib/pg/type_map_by_column.rb +16 -0
- data/lib/pg/version.rb +4 -0
- data/lib/pg.rb +87 -0
- data/lib/x64-mingw-ucrt/libpq.dll +0 -0
- 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/sample/array_insert.rb +20 -0
- data/sample/async_api.rb +106 -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 +188 -0
- metadata.gz.sig +0 -0
data/ext/pg.c
ADDED
@@ -0,0 +1,732 @@
|
|
1
|
+
/*
|
2
|
+
* pg.c - Toplevel extension
|
3
|
+
* $Id$
|
4
|
+
*
|
5
|
+
* Author/s:
|
6
|
+
*
|
7
|
+
* - Jeff Davis <ruby-pg@j-davis.com>
|
8
|
+
* - Guy Decoux (ts) <decoux@moulon.inra.fr>
|
9
|
+
* - Michael Granger <ged@FaerieMUD.org>
|
10
|
+
* - Lars Kanis <lars@greiz-reinsdorf.de>
|
11
|
+
* - Dave Lee
|
12
|
+
* - Eiji Matsumoto <usagi@ruby.club.or.jp>
|
13
|
+
* - Yukihiro Matsumoto <matz@ruby-lang.org>
|
14
|
+
* - Noboru Saitou <noborus@netlab.jp>
|
15
|
+
*
|
16
|
+
* See Contributors.rdoc for the many additional fine people that have contributed
|
17
|
+
* to this library over the years.
|
18
|
+
*
|
19
|
+
* Copyright (c) 1997-2019 by the authors.
|
20
|
+
*
|
21
|
+
* You may redistribute this software under the same terms as Ruby itself; see
|
22
|
+
* https://www.ruby-lang.org/en/about/license.txt or the BSDL file in the source
|
23
|
+
* for details.
|
24
|
+
*
|
25
|
+
* Portions of the code are from the PostgreSQL project, and are distributed
|
26
|
+
* under the terms of the PostgreSQL license, included in the file "POSTGRES".
|
27
|
+
*
|
28
|
+
* Portions copyright LAIKA, Inc.
|
29
|
+
*
|
30
|
+
*
|
31
|
+
* The following functions are part of libpq, but not available from ruby-pg,
|
32
|
+
* because they are deprecated, obsolete, or generally not useful:
|
33
|
+
*
|
34
|
+
* - PQfreemem -- unnecessary: copied to ruby object, then freed. Ruby object's
|
35
|
+
* memory is freed when it is garbage collected.
|
36
|
+
* - PQbinaryTuples -- better to use PQfformat
|
37
|
+
* - PQprint -- not very useful
|
38
|
+
* - PQsetdb -- not very useful
|
39
|
+
* - PQoidStatus -- deprecated, use PQoidValue
|
40
|
+
* - PQrequestCancel -- deprecated, use PQcancel
|
41
|
+
* - PQfn -- use a prepared statement instead
|
42
|
+
* - PQgetline -- deprecated, use PQgetCopyData
|
43
|
+
* - PQgetlineAsync -- deprecated, use PQgetCopyData
|
44
|
+
* - PQputline -- deprecated, use PQputCopyData
|
45
|
+
* - PQputnbytes -- deprecated, use PQputCopyData
|
46
|
+
* - PQendcopy -- deprecated, use PQputCopyEnd
|
47
|
+
*/
|
48
|
+
|
49
|
+
#include "pg.h"
|
50
|
+
#include "pg_config.h"
|
51
|
+
|
52
|
+
int pg_skip_deprecation_warning;
|
53
|
+
VALUE rb_mPG;
|
54
|
+
VALUE rb_mPGconstants;
|
55
|
+
|
56
|
+
|
57
|
+
/*
|
58
|
+
* Document-class: PG::Error
|
59
|
+
*
|
60
|
+
* This is the exception class raised when an error is returned from
|
61
|
+
* a libpq API call.
|
62
|
+
*
|
63
|
+
* The attributes +connection+ and +result+ are set to the connection
|
64
|
+
* object and result set object, respectively.
|
65
|
+
*
|
66
|
+
* If the connection object or result set object is not available from
|
67
|
+
* the context in which the error was encountered, it is +nil+.
|
68
|
+
*/
|
69
|
+
|
70
|
+
/*
|
71
|
+
* M17n functions
|
72
|
+
*/
|
73
|
+
|
74
|
+
/**
|
75
|
+
* The mapping from canonical encoding names in PostgreSQL to ones in Ruby.
|
76
|
+
*/
|
77
|
+
const char * const (pg_enc_pg2ruby_mapping[][2]) = {
|
78
|
+
{"BIG5", "Big5" },
|
79
|
+
{"EUC_CN", "GB2312" },
|
80
|
+
{"EUC_JP", "EUC-JP" },
|
81
|
+
{"EUC_JIS_2004", "EUC-JP" },
|
82
|
+
{"EUC_KR", "EUC-KR" },
|
83
|
+
{"EUC_TW", "EUC-TW" },
|
84
|
+
{"GB18030", "GB18030" },
|
85
|
+
{"GBK", "GBK" },
|
86
|
+
{"ISO_8859_5", "ISO-8859-5" },
|
87
|
+
{"ISO_8859_6", "ISO-8859-6" },
|
88
|
+
{"ISO_8859_7", "ISO-8859-7" },
|
89
|
+
{"ISO_8859_8", "ISO-8859-8" },
|
90
|
+
/* {"JOHAB", "JOHAB" }, dummy */
|
91
|
+
{"KOI8", "KOI8-R" },
|
92
|
+
{"KOI8R", "KOI8-R" },
|
93
|
+
{"KOI8U", "KOI8-U" },
|
94
|
+
{"LATIN1", "ISO-8859-1" },
|
95
|
+
{"LATIN2", "ISO-8859-2" },
|
96
|
+
{"LATIN3", "ISO-8859-3" },
|
97
|
+
{"LATIN4", "ISO-8859-4" },
|
98
|
+
{"LATIN5", "ISO-8859-9" },
|
99
|
+
{"LATIN6", "ISO-8859-10" },
|
100
|
+
{"LATIN7", "ISO-8859-13" },
|
101
|
+
{"LATIN8", "ISO-8859-14" },
|
102
|
+
{"LATIN9", "ISO-8859-15" },
|
103
|
+
{"LATIN10", "ISO-8859-16" },
|
104
|
+
{"MULE_INTERNAL", "Emacs-Mule" },
|
105
|
+
{"SJIS", "Windows-31J" },
|
106
|
+
{"SHIFT_JIS_2004","Windows-31J" },
|
107
|
+
/* {"SQL_ASCII", NULL }, special case*/
|
108
|
+
{"UHC", "CP949" },
|
109
|
+
{"UTF8", "UTF-8" },
|
110
|
+
{"WIN866", "IBM866" },
|
111
|
+
{"WIN874", "Windows-874" },
|
112
|
+
{"WIN1250", "Windows-1250"},
|
113
|
+
{"WIN1251", "Windows-1251"},
|
114
|
+
{"WIN1252", "Windows-1252"},
|
115
|
+
{"WIN1253", "Windows-1253"},
|
116
|
+
{"WIN1254", "Windows-1254"},
|
117
|
+
{"WIN1255", "Windows-1255"},
|
118
|
+
{"WIN1256", "Windows-1256"},
|
119
|
+
{"WIN1257", "Windows-1257"},
|
120
|
+
{"WIN1258", "Windows-1258"}
|
121
|
+
};
|
122
|
+
|
123
|
+
|
124
|
+
/*
|
125
|
+
* A cache of mapping from PostgreSQL's encoding indices to Ruby's rb_encoding*s.
|
126
|
+
*/
|
127
|
+
static struct st_table *enc_pg2ruby;
|
128
|
+
|
129
|
+
|
130
|
+
/*
|
131
|
+
* Look up the JOHAB encoding, creating it as a dummy encoding if it's not
|
132
|
+
* already defined.
|
133
|
+
*/
|
134
|
+
static rb_encoding *
|
135
|
+
pg_find_or_create_johab(void)
|
136
|
+
{
|
137
|
+
static const char * const aliases[] = { "JOHAB", "Windows-1361", "CP1361" };
|
138
|
+
int enc_index;
|
139
|
+
size_t i;
|
140
|
+
|
141
|
+
for (i = 0; i < sizeof(aliases)/sizeof(aliases[0]); ++i) {
|
142
|
+
enc_index = rb_enc_find_index(aliases[i]);
|
143
|
+
if (enc_index > 0) return rb_enc_from_index(enc_index);
|
144
|
+
}
|
145
|
+
|
146
|
+
enc_index = rb_define_dummy_encoding(aliases[0]);
|
147
|
+
return rb_enc_from_index(enc_index);
|
148
|
+
}
|
149
|
+
|
150
|
+
/*
|
151
|
+
* Return the given PostgreSQL encoding ID as an rb_encoding.
|
152
|
+
*
|
153
|
+
* - returns NULL if the client encoding is 'SQL_ASCII'.
|
154
|
+
* - returns ASCII-8BIT if the client encoding is unknown.
|
155
|
+
*/
|
156
|
+
rb_encoding *
|
157
|
+
pg_get_pg_encoding_as_rb_encoding( int enc_id )
|
158
|
+
{
|
159
|
+
rb_encoding *enc;
|
160
|
+
|
161
|
+
/* Use the cached value if it exists */
|
162
|
+
if ( st_lookup(enc_pg2ruby, (st_data_t)enc_id, (st_data_t*)&enc) ) {
|
163
|
+
return enc;
|
164
|
+
}
|
165
|
+
else {
|
166
|
+
const char *name = pg_encoding_to_char( enc_id );
|
167
|
+
|
168
|
+
enc = pg_get_pg_encname_as_rb_encoding( name );
|
169
|
+
st_insert( enc_pg2ruby, (st_data_t)enc_id, (st_data_t)enc );
|
170
|
+
|
171
|
+
return enc;
|
172
|
+
}
|
173
|
+
|
174
|
+
}
|
175
|
+
|
176
|
+
/*
|
177
|
+
* Return the given PostgreSQL encoding name as an rb_encoding.
|
178
|
+
*/
|
179
|
+
rb_encoding *
|
180
|
+
pg_get_pg_encname_as_rb_encoding( const char *pg_encname )
|
181
|
+
{
|
182
|
+
size_t i;
|
183
|
+
|
184
|
+
/* Trying looking it up in the conversion table */
|
185
|
+
for ( i = 0; i < sizeof(pg_enc_pg2ruby_mapping)/sizeof(pg_enc_pg2ruby_mapping[0]); ++i ) {
|
186
|
+
if ( strcmp(pg_encname, pg_enc_pg2ruby_mapping[i][0]) == 0 )
|
187
|
+
return rb_enc_find( pg_enc_pg2ruby_mapping[i][1] );
|
188
|
+
}
|
189
|
+
|
190
|
+
/* JOHAB isn't a builtin encoding, so make up a dummy encoding if it's seen */
|
191
|
+
if ( strncmp(pg_encname, "JOHAB", 5) == 0 )
|
192
|
+
return pg_find_or_create_johab();
|
193
|
+
|
194
|
+
/* Fallthrough to ASCII-8BIT */
|
195
|
+
return rb_ascii8bit_encoding();
|
196
|
+
}
|
197
|
+
|
198
|
+
/*
|
199
|
+
* Get the client encoding of the specified connection handle and return it as a rb_encoding.
|
200
|
+
*/
|
201
|
+
rb_encoding *
|
202
|
+
pg_conn_enc_get( PGconn *conn )
|
203
|
+
{
|
204
|
+
int enc_id = PQclientEncoding( conn );
|
205
|
+
return pg_get_pg_encoding_as_rb_encoding( enc_id );
|
206
|
+
}
|
207
|
+
|
208
|
+
|
209
|
+
/*
|
210
|
+
* Returns the given rb_encoding as the equivalent PostgreSQL encoding string.
|
211
|
+
*/
|
212
|
+
const char *
|
213
|
+
pg_get_rb_encoding_as_pg_encoding( rb_encoding *enc )
|
214
|
+
{
|
215
|
+
const char *rb_encname = rb_enc_name( enc );
|
216
|
+
const char *encname = NULL;
|
217
|
+
size_t i;
|
218
|
+
|
219
|
+
for (i = 0; i < sizeof(pg_enc_pg2ruby_mapping)/sizeof(pg_enc_pg2ruby_mapping[0]); ++i) {
|
220
|
+
if (strcmp(rb_encname, pg_enc_pg2ruby_mapping[i][1]) == 0) {
|
221
|
+
encname = pg_enc_pg2ruby_mapping[i][0];
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
if ( !encname ) encname = "SQL_ASCII";
|
226
|
+
|
227
|
+
return encname;
|
228
|
+
}
|
229
|
+
|
230
|
+
|
231
|
+
/*
|
232
|
+
* Ensures that the given string has enough capacity to take expand_len
|
233
|
+
* more data bytes. The new data part of the String is not initialized.
|
234
|
+
*
|
235
|
+
* current_out must be a pointer within the data part of the String object.
|
236
|
+
* This pointer is returned and possibly adjusted, because the location of the data
|
237
|
+
* part of the String can change through this function.
|
238
|
+
*
|
239
|
+
* PG_RB_STR_ENSURE_CAPA can be used to do fast inline checks of the remaining capacity.
|
240
|
+
* end_capa it is then set to the first byte after the currently reserved memory,
|
241
|
+
* if not NULL.
|
242
|
+
*
|
243
|
+
* Before the String can be used with other string functions or returned to Ruby space,
|
244
|
+
* the string length has to be set with rb_str_set_len().
|
245
|
+
*
|
246
|
+
* Usage example:
|
247
|
+
*
|
248
|
+
* VALUE string;
|
249
|
+
* char *current_out, *end_capa;
|
250
|
+
* PG_RB_STR_NEW( string, current_out, end_capa );
|
251
|
+
* while( data_is_going_to_be_processed ){
|
252
|
+
* PG_RB_STR_ENSURE_CAPA( string, 2, current_out, end_capa );
|
253
|
+
* *current_out++ = databyte1;
|
254
|
+
* *current_out++ = databyte2;
|
255
|
+
* }
|
256
|
+
* rb_str_set_len( string, current_out - RSTRING_PTR(string) );
|
257
|
+
*
|
258
|
+
*/
|
259
|
+
char *
|
260
|
+
pg_rb_str_ensure_capa( VALUE str, long expand_len, char *curr_ptr, char **end_ptr )
|
261
|
+
{
|
262
|
+
long curr_len = curr_ptr - RSTRING_PTR(str);
|
263
|
+
long curr_capa = rb_str_capacity( str );
|
264
|
+
if( curr_capa < curr_len + expand_len ){
|
265
|
+
rb_str_set_len( str, curr_len );
|
266
|
+
rb_str_modify_expand( str, (curr_len + expand_len) * 2 - curr_capa );
|
267
|
+
curr_ptr = RSTRING_PTR(str) + curr_len;
|
268
|
+
}
|
269
|
+
if( end_ptr )
|
270
|
+
*end_ptr = RSTRING_PTR(str) + rb_str_capacity( str );
|
271
|
+
return curr_ptr;
|
272
|
+
}
|
273
|
+
|
274
|
+
|
275
|
+
/**************************************************************************
|
276
|
+
* Module Methods
|
277
|
+
**************************************************************************/
|
278
|
+
|
279
|
+
/*
|
280
|
+
* call-seq:
|
281
|
+
* PG.library_version -> Integer
|
282
|
+
*
|
283
|
+
* Get the version of the libpq library in use. The number is formed by
|
284
|
+
* converting the major, minor, and revision numbers into two-decimal-
|
285
|
+
* digit numbers and appending them together.
|
286
|
+
* For example, version 7.4.2 will be returned as 70402, and version
|
287
|
+
* 8.1 will be returned as 80100 (leading zeroes are not shown). Zero
|
288
|
+
* is returned if the connection is bad.
|
289
|
+
*/
|
290
|
+
static VALUE
|
291
|
+
pg_s_library_version(VALUE self)
|
292
|
+
{
|
293
|
+
UNUSED( self );
|
294
|
+
return INT2NUM(PQlibVersion());
|
295
|
+
}
|
296
|
+
|
297
|
+
|
298
|
+
/*
|
299
|
+
* call-seq:
|
300
|
+
* PG.isthreadsafe -> Boolean
|
301
|
+
* PG.is_threadsafe? -> Boolean
|
302
|
+
* PG.threadsafe? -> Boolean
|
303
|
+
*
|
304
|
+
* Returns +true+ if libpq is thread-safe, +false+ otherwise.
|
305
|
+
*/
|
306
|
+
static VALUE
|
307
|
+
pg_s_threadsafe_p(VALUE self)
|
308
|
+
{
|
309
|
+
UNUSED( self );
|
310
|
+
return PQisthreadsafe() ? Qtrue : Qfalse;
|
311
|
+
}
|
312
|
+
|
313
|
+
static int
|
314
|
+
pg_to_bool_int(VALUE value)
|
315
|
+
{
|
316
|
+
switch( TYPE(value) ){
|
317
|
+
case T_FALSE:
|
318
|
+
return 0;
|
319
|
+
case T_TRUE:
|
320
|
+
return 1;
|
321
|
+
default:
|
322
|
+
return NUM2INT(value);
|
323
|
+
}
|
324
|
+
}
|
325
|
+
|
326
|
+
/*
|
327
|
+
* call-seq:
|
328
|
+
* PG.init_openssl(do_ssl, do_crypto) -> nil
|
329
|
+
*
|
330
|
+
* Allows applications to select which security libraries to initialize.
|
331
|
+
*
|
332
|
+
* If your application initializes libssl and/or libcrypto libraries and libpq is
|
333
|
+
* built with SSL support, you should call PG.init_openssl() to tell libpq that the
|
334
|
+
* libssl and/or libcrypto libraries have been initialized by your application,
|
335
|
+
* so that libpq will not also initialize those libraries.
|
336
|
+
*
|
337
|
+
* When do_ssl is +true+, libpq will initialize the OpenSSL library before first
|
338
|
+
* opening a database connection. When do_crypto is +true+, the libcrypto library
|
339
|
+
* will be initialized. By default (if PG.init_openssl() is not called), both libraries
|
340
|
+
* are initialized. When SSL support is not compiled in, this function is present but does nothing.
|
341
|
+
*
|
342
|
+
* If your application uses and initializes either OpenSSL or its underlying libcrypto library,
|
343
|
+
* you must call this function with +false+ for the appropriate parameter(s) before first opening
|
344
|
+
* a database connection. Also be sure that you have done that initialization before opening a
|
345
|
+
* database connection.
|
346
|
+
*
|
347
|
+
*/
|
348
|
+
static VALUE
|
349
|
+
pg_s_init_openssl(VALUE self, VALUE do_ssl, VALUE do_crypto)
|
350
|
+
{
|
351
|
+
UNUSED( self );
|
352
|
+
PQinitOpenSSL(pg_to_bool_int(do_ssl), pg_to_bool_int(do_crypto));
|
353
|
+
return Qnil;
|
354
|
+
}
|
355
|
+
|
356
|
+
|
357
|
+
/*
|
358
|
+
* call-seq:
|
359
|
+
* PG.init_ssl(do_ssl) -> nil
|
360
|
+
*
|
361
|
+
* Allows applications to select which security libraries to initialize.
|
362
|
+
*
|
363
|
+
* This function is equivalent to <tt>PG.init_openssl(do_ssl, do_ssl)</tt> . It is sufficient for
|
364
|
+
* applications that initialize both or neither of OpenSSL and libcrypto.
|
365
|
+
*/
|
366
|
+
static VALUE
|
367
|
+
pg_s_init_ssl(VALUE self, VALUE do_ssl)
|
368
|
+
{
|
369
|
+
UNUSED( self );
|
370
|
+
PQinitSSL(pg_to_bool_int(do_ssl));
|
371
|
+
return Qnil;
|
372
|
+
}
|
373
|
+
|
374
|
+
|
375
|
+
/**************************************************************************
|
376
|
+
* Initializer
|
377
|
+
**************************************************************************/
|
378
|
+
|
379
|
+
void
|
380
|
+
Init_pg_ext()
|
381
|
+
{
|
382
|
+
if( RTEST(rb_eval_string("ENV['PG_SKIP_DEPRECATION_WARNING']")) ){
|
383
|
+
/* Set all bits to disable all deprecation warnings. */
|
384
|
+
pg_skip_deprecation_warning = 0xFFFF;
|
385
|
+
} else {
|
386
|
+
pg_skip_deprecation_warning = 0;
|
387
|
+
}
|
388
|
+
|
389
|
+
rb_mPG = rb_define_module( "PG" );
|
390
|
+
rb_mPGconstants = rb_define_module_under( rb_mPG, "Constants" );
|
391
|
+
|
392
|
+
/*************************
|
393
|
+
* PG module methods
|
394
|
+
*************************/
|
395
|
+
rb_define_singleton_method( rb_mPG, "library_version", pg_s_library_version, 0 );
|
396
|
+
rb_define_singleton_method( rb_mPG, "isthreadsafe", pg_s_threadsafe_p, 0 );
|
397
|
+
SINGLETON_ALIAS( rb_mPG, "is_threadsafe?", "isthreadsafe" );
|
398
|
+
SINGLETON_ALIAS( rb_mPG, "threadsafe?", "isthreadsafe" );
|
399
|
+
|
400
|
+
rb_define_singleton_method( rb_mPG, "init_openssl", pg_s_init_openssl, 2 );
|
401
|
+
rb_define_singleton_method( rb_mPG, "init_ssl", pg_s_init_ssl, 1 );
|
402
|
+
|
403
|
+
|
404
|
+
/****** PG::Connection CLASS CONSTANTS: Connection Status ******/
|
405
|
+
|
406
|
+
/* Connection succeeded */
|
407
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_OK", INT2FIX(CONNECTION_OK));
|
408
|
+
/* Connection failed */
|
409
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_BAD", INT2FIX(CONNECTION_BAD));
|
410
|
+
|
411
|
+
/****** PG::Connection CLASS CONSTANTS: Nonblocking connection status ******/
|
412
|
+
|
413
|
+
/* Waiting for connection to be made. */
|
414
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_STARTED", INT2FIX(CONNECTION_STARTED));
|
415
|
+
/* Connection OK; waiting to send. */
|
416
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_MADE", INT2FIX(CONNECTION_MADE));
|
417
|
+
/* Waiting for a response from the server. */
|
418
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_AWAITING_RESPONSE", INT2FIX(CONNECTION_AWAITING_RESPONSE));
|
419
|
+
/* Received authentication; waiting for backend startup. */
|
420
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_AUTH_OK", INT2FIX(CONNECTION_AUTH_OK));
|
421
|
+
/* This state is no longer used. */
|
422
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_SETENV", INT2FIX(CONNECTION_SETENV));
|
423
|
+
/* Negotiating SSL encryption. */
|
424
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_SSL_STARTUP", INT2FIX(CONNECTION_SSL_STARTUP));
|
425
|
+
/* Internal state - PG.connect() needed. */
|
426
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_NEEDED", INT2FIX(CONNECTION_NEEDED));
|
427
|
+
#if PG_MAJORVERSION_NUM >= 10
|
428
|
+
/* Checking if session is read-write. Available since PostgreSQL-10. */
|
429
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_CHECK_WRITABLE", INT2FIX(CONNECTION_CHECK_WRITABLE));
|
430
|
+
#endif
|
431
|
+
#if PG_MAJORVERSION_NUM >= 10
|
432
|
+
/* Consuming any extra messages. Available since PostgreSQL-10. */
|
433
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_CONSUME", INT2FIX(CONNECTION_CONSUME));
|
434
|
+
#endif
|
435
|
+
#if PG_MAJORVERSION_NUM >= 12
|
436
|
+
/* Negotiating GSSAPI. Available since PostgreSQL-12. */
|
437
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_GSS_STARTUP", INT2FIX(CONNECTION_GSS_STARTUP));
|
438
|
+
#endif
|
439
|
+
#if PG_MAJORVERSION_NUM >= 13
|
440
|
+
/* Checking target server properties. Available since PostgreSQL-13. */
|
441
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_CHECK_TARGET", INT2FIX(CONNECTION_CHECK_TARGET));
|
442
|
+
#endif
|
443
|
+
#if PG_MAJORVERSION_NUM >= 14
|
444
|
+
/* Checking if server is in standby mode. Available since PostgreSQL-14. */
|
445
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_CHECK_STANDBY", INT2FIX(CONNECTION_CHECK_STANDBY));
|
446
|
+
#endif
|
447
|
+
|
448
|
+
/****** PG::Connection CLASS CONSTANTS: Nonblocking connection polling status ******/
|
449
|
+
|
450
|
+
/* Async connection is waiting to read */
|
451
|
+
rb_define_const(rb_mPGconstants, "PGRES_POLLING_READING", INT2FIX(PGRES_POLLING_READING));
|
452
|
+
/* Async connection is waiting to write */
|
453
|
+
rb_define_const(rb_mPGconstants, "PGRES_POLLING_WRITING", INT2FIX(PGRES_POLLING_WRITING));
|
454
|
+
/* Async connection failed or was reset */
|
455
|
+
rb_define_const(rb_mPGconstants, "PGRES_POLLING_FAILED", INT2FIX(PGRES_POLLING_FAILED));
|
456
|
+
/* Async connection succeeded */
|
457
|
+
rb_define_const(rb_mPGconstants, "PGRES_POLLING_OK", INT2FIX(PGRES_POLLING_OK));
|
458
|
+
|
459
|
+
/****** PG::Connection CLASS CONSTANTS: Transaction Status ******/
|
460
|
+
|
461
|
+
/* Transaction is currently idle ( Connection#transaction_status ) */
|
462
|
+
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. ( Connection#transaction_status ) */
|
464
|
+
rb_define_const(rb_mPGconstants, "PQTRANS_ACTIVE", INT2FIX(PQTRANS_ACTIVE));
|
465
|
+
/* Transaction is currently idle, in a valid transaction block ( Connection#transaction_status ) */
|
466
|
+
rb_define_const(rb_mPGconstants, "PQTRANS_INTRANS", INT2FIX(PQTRANS_INTRANS));
|
467
|
+
/* Transaction is currently idle, in a failed transaction block ( Connection#transaction_status ) */
|
468
|
+
rb_define_const(rb_mPGconstants, "PQTRANS_INERROR", INT2FIX(PQTRANS_INERROR));
|
469
|
+
/* Transaction's connection is bad ( Connection#transaction_status ) */
|
470
|
+
rb_define_const(rb_mPGconstants, "PQTRANS_UNKNOWN", INT2FIX(PQTRANS_UNKNOWN));
|
471
|
+
|
472
|
+
/****** PG::Connection CLASS CONSTANTS: Error Verbosity ******/
|
473
|
+
|
474
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
475
|
+
* In TERSE mode, returned messages include severity, primary text, and position only; this will normally fit on a single line. */
|
476
|
+
rb_define_const(rb_mPGconstants, "PQERRORS_TERSE", INT2FIX(PQERRORS_TERSE));
|
477
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
478
|
+
* The DEFAULT mode produces messages that include the above plus any detail, hint, or context fields (these might span multiple lines). */
|
479
|
+
rb_define_const(rb_mPGconstants, "PQERRORS_DEFAULT", INT2FIX(PQERRORS_DEFAULT));
|
480
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
481
|
+
* The VERBOSE mode includes all available fields. */
|
482
|
+
rb_define_const(rb_mPGconstants, "PQERRORS_VERBOSE", INT2FIX(PQERRORS_VERBOSE));
|
483
|
+
|
484
|
+
/* PQERRORS_SQLSTATE was introduced in PG-12 together with PQresultMemorySize() */
|
485
|
+
#ifdef HAVE_PQRESULTMEMORYSIZE
|
486
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
487
|
+
* 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).
|
488
|
+
*
|
489
|
+
* Available since PostgreSQL-12.
|
490
|
+
*/
|
491
|
+
rb_define_const(rb_mPGconstants, "PQERRORS_SQLSTATE", INT2FIX(PQERRORS_SQLSTATE));
|
492
|
+
#endif
|
493
|
+
|
494
|
+
#ifdef HAVE_PQRESULTVERBOSEERRORMESSAGE
|
495
|
+
/* See Connection#set_error_context_visibility */
|
496
|
+
rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_NEVER", INT2FIX(PQSHOW_CONTEXT_NEVER));
|
497
|
+
/* See Connection#set_error_context_visibility */
|
498
|
+
rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_ERRORS", INT2FIX(PQSHOW_CONTEXT_ERRORS));
|
499
|
+
/* See Connection#set_error_context_visibility */
|
500
|
+
rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_ALWAYS", INT2FIX(PQSHOW_CONTEXT_ALWAYS));
|
501
|
+
#endif
|
502
|
+
|
503
|
+
/****** PG::Connection CLASS CONSTANTS: Check Server Status ******/
|
504
|
+
|
505
|
+
/* Server is accepting connections. */
|
506
|
+
rb_define_const(rb_mPGconstants, "PQPING_OK", INT2FIX(PQPING_OK));
|
507
|
+
/* Server is alive but rejecting connections. */
|
508
|
+
rb_define_const(rb_mPGconstants, "PQPING_REJECT", INT2FIX(PQPING_REJECT));
|
509
|
+
/* Could not establish connection. */
|
510
|
+
rb_define_const(rb_mPGconstants, "PQPING_NO_RESPONSE", INT2FIX(PQPING_NO_RESPONSE));
|
511
|
+
/* Connection not attempted (bad params). */
|
512
|
+
rb_define_const(rb_mPGconstants, "PQPING_NO_ATTEMPT", INT2FIX(PQPING_NO_ATTEMPT));
|
513
|
+
|
514
|
+
/****** PG::Connection CLASS CONSTANTS: Large Objects ******/
|
515
|
+
|
516
|
+
/* Flag for Connection#lo_creat, Connection#lo_open -- open for writing */
|
517
|
+
rb_define_const(rb_mPGconstants, "INV_WRITE", INT2FIX(INV_WRITE));
|
518
|
+
/* Flag for Connection#lo_creat, Connection#lo_open -- open for reading */
|
519
|
+
rb_define_const(rb_mPGconstants, "INV_READ", INT2FIX(INV_READ));
|
520
|
+
/* Flag for Connection#lo_lseek -- seek from object start */
|
521
|
+
rb_define_const(rb_mPGconstants, "SEEK_SET", INT2FIX(SEEK_SET));
|
522
|
+
/* Flag for Connection#lo_lseek -- seek from current position */
|
523
|
+
rb_define_const(rb_mPGconstants, "SEEK_CUR", INT2FIX(SEEK_CUR));
|
524
|
+
/* Flag for Connection#lo_lseek -- seek from object end */
|
525
|
+
rb_define_const(rb_mPGconstants, "SEEK_END", INT2FIX(SEEK_END));
|
526
|
+
|
527
|
+
/****** PG::Result CONSTANTS: result status ******/
|
528
|
+
|
529
|
+
/* Result#result_status constant - The string sent to the server was empty. */
|
530
|
+
rb_define_const(rb_mPGconstants, "PGRES_EMPTY_QUERY", INT2FIX(PGRES_EMPTY_QUERY));
|
531
|
+
/* Result#result_status constant - Successful completion of a command returning no data. */
|
532
|
+
rb_define_const(rb_mPGconstants, "PGRES_COMMAND_OK", INT2FIX(PGRES_COMMAND_OK));
|
533
|
+
/* Result#result_status constant - Successful completion of a command returning data (such as a SELECT or SHOW). */
|
534
|
+
rb_define_const(rb_mPGconstants, "PGRES_TUPLES_OK", INT2FIX(PGRES_TUPLES_OK));
|
535
|
+
/* Result#result_status constant - Copy Out (from server) data transfer started. */
|
536
|
+
rb_define_const(rb_mPGconstants, "PGRES_COPY_OUT", INT2FIX(PGRES_COPY_OUT));
|
537
|
+
/* Result#result_status constant - Copy In (to server) data transfer started. */
|
538
|
+
rb_define_const(rb_mPGconstants, "PGRES_COPY_IN", INT2FIX(PGRES_COPY_IN));
|
539
|
+
/* Result#result_status constant - The server’s response was not understood. */
|
540
|
+
rb_define_const(rb_mPGconstants, "PGRES_BAD_RESPONSE", INT2FIX(PGRES_BAD_RESPONSE));
|
541
|
+
/* Result#result_status constant - A nonfatal error (a notice or warning) occurred. */
|
542
|
+
rb_define_const(rb_mPGconstants, "PGRES_NONFATAL_ERROR",INT2FIX(PGRES_NONFATAL_ERROR));
|
543
|
+
/* Result#result_status constant - A fatal error occurred. */
|
544
|
+
rb_define_const(rb_mPGconstants, "PGRES_FATAL_ERROR", INT2FIX(PGRES_FATAL_ERROR));
|
545
|
+
/* Result#result_status constant - Copy In/Out data transfer in progress. */
|
546
|
+
rb_define_const(rb_mPGconstants, "PGRES_COPY_BOTH", INT2FIX(PGRES_COPY_BOTH));
|
547
|
+
/* Result#result_status constant - Single tuple from larger resultset. */
|
548
|
+
rb_define_const(rb_mPGconstants, "PGRES_SINGLE_TUPLE", INT2FIX(PGRES_SINGLE_TUPLE));
|
549
|
+
|
550
|
+
#ifdef HAVE_PQENTERPIPELINEMODE
|
551
|
+
/* Result#result_status constant - The PG::Result represents a synchronization point in pipeline mode, requested by Connection#pipeline_sync.
|
552
|
+
*
|
553
|
+
* This status occurs only when pipeline mode has been selected. */
|
554
|
+
rb_define_const(rb_mPGconstants, "PGRES_PIPELINE_SYNC", INT2FIX(PGRES_PIPELINE_SYNC));
|
555
|
+
|
556
|
+
/* Result#result_status constant - The PG::Result represents a pipeline that has received an error from the server.
|
557
|
+
*
|
558
|
+
* 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.
|
559
|
+
*/
|
560
|
+
rb_define_const(rb_mPGconstants, "PGRES_PIPELINE_ABORTED", INT2FIX(PGRES_PIPELINE_ABORTED));
|
561
|
+
#endif
|
562
|
+
|
563
|
+
/****** Result CONSTANTS: result error field codes ******/
|
564
|
+
|
565
|
+
/* Result#result_error_field argument constant
|
566
|
+
*
|
567
|
+
* 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
|
568
|
+
* of one of these.
|
569
|
+
* Always present.
|
570
|
+
*/
|
571
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY", INT2FIX(PG_DIAG_SEVERITY));
|
572
|
+
|
573
|
+
#ifdef PG_DIAG_SEVERITY_NONLOCALIZED
|
574
|
+
/* Result#result_error_field argument constant
|
575
|
+
*
|
576
|
+
* 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).
|
577
|
+
* This is identical to the PG_DIAG_SEVERITY field except that the contents are never localized.
|
578
|
+
*
|
579
|
+
* Available since PostgreSQL-9.6
|
580
|
+
*/
|
581
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY_NONLOCALIZED", INT2FIX(PG_DIAG_SEVERITY_NONLOCALIZED));
|
582
|
+
#endif
|
583
|
+
/* Result#result_error_field argument constant
|
584
|
+
*
|
585
|
+
* The SQLSTATE code for the error.
|
586
|
+
* 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.
|
587
|
+
* For a list of the possible SQLSTATE codes, see Appendix A.
|
588
|
+
* This field is not localizable, and is always present.
|
589
|
+
*/
|
590
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_SQLSTATE", INT2FIX(PG_DIAG_SQLSTATE));
|
591
|
+
/* Result#result_error_field argument constant
|
592
|
+
*
|
593
|
+
* The primary human-readable error message (typically one line).
|
594
|
+
* Always present. */
|
595
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_PRIMARY", INT2FIX(PG_DIAG_MESSAGE_PRIMARY));
|
596
|
+
/* Result#result_error_field argument constant
|
597
|
+
*
|
598
|
+
* Detail: an optional secondary error message carrying more detail about the problem.
|
599
|
+
* Might run to multiple lines.
|
600
|
+
*/
|
601
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_DETAIL", INT2FIX(PG_DIAG_MESSAGE_DETAIL));
|
602
|
+
/* Result#result_error_field argument constant
|
603
|
+
*
|
604
|
+
* Hint: an optional suggestion what to do about the problem.
|
605
|
+
* This is intended to differ from detail in that it offers advice (potentially inappropriate) rather than hard facts.
|
606
|
+
* Might run to multiple lines.
|
607
|
+
*/
|
608
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_HINT", INT2FIX(PG_DIAG_MESSAGE_HINT));
|
609
|
+
/* Result#result_error_field argument constant
|
610
|
+
*
|
611
|
+
* A string containing a decimal integer indicating an error cursor position as an index into the original statement string.
|
612
|
+
*
|
613
|
+
* The first character has index 1, and positions are measured in characters not bytes.
|
614
|
+
*/
|
615
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_STATEMENT_POSITION", INT2FIX(PG_DIAG_STATEMENT_POSITION));
|
616
|
+
/* Result#result_error_field argument constant
|
617
|
+
*
|
618
|
+
* 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.
|
619
|
+
* The PG_DIAG_INTERNAL_QUERY field will always appear when this field appears.
|
620
|
+
*/
|
621
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_POSITION", INT2FIX(PG_DIAG_INTERNAL_POSITION));
|
622
|
+
/* Result#result_error_field argument constant
|
623
|
+
*
|
624
|
+
* The text of a failed internally-generated command.
|
625
|
+
* This could be, for example, a SQL query issued by a PL/pgSQL function.
|
626
|
+
*/
|
627
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_QUERY", INT2FIX(PG_DIAG_INTERNAL_QUERY));
|
628
|
+
/* Result#result_error_field argument constant
|
629
|
+
*
|
630
|
+
* An indication of the context in which the error occurred.
|
631
|
+
* Presently this includes a call stack traceback of active procedural language functions and internally-generated queries.
|
632
|
+
* The trace is one entry per line, most recent first.
|
633
|
+
*/
|
634
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_CONTEXT", INT2FIX(PG_DIAG_CONTEXT));
|
635
|
+
/* Result#result_error_field argument constant
|
636
|
+
*
|
637
|
+
* The file name of the source-code location where the error was reported. */
|
638
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FILE", INT2FIX(PG_DIAG_SOURCE_FILE));
|
639
|
+
|
640
|
+
/* Result#result_error_field argument constant
|
641
|
+
*
|
642
|
+
* The line number of the source-code location where the error was reported. */
|
643
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_LINE", INT2FIX(PG_DIAG_SOURCE_LINE));
|
644
|
+
|
645
|
+
/* Result#result_error_field argument constant
|
646
|
+
*
|
647
|
+
* The name of the source-code function reporting the error. */
|
648
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FUNCTION", INT2FIX(PG_DIAG_SOURCE_FUNCTION));
|
649
|
+
|
650
|
+
#ifdef PG_DIAG_TABLE_NAME
|
651
|
+
/* Result#result_error_field argument constant
|
652
|
+
*
|
653
|
+
* If the error was associated with a specific database object, the name of the schema containing that object, if any. */
|
654
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_SCHEMA_NAME", INT2FIX(PG_DIAG_SCHEMA_NAME));
|
655
|
+
|
656
|
+
/* Result#result_error_field argument constant
|
657
|
+
*
|
658
|
+
* If the error was associated with a specific table, the name of the table.
|
659
|
+
* (When this field is present, the schema name field provides the name of the table's schema.) */
|
660
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_TABLE_NAME", INT2FIX(PG_DIAG_TABLE_NAME));
|
661
|
+
|
662
|
+
/* Result#result_error_field argument constant
|
663
|
+
*
|
664
|
+
* If the error was associated with a specific table column, the name of the column.
|
665
|
+
* (When this field is present, the schema and table name fields identify the table.) */
|
666
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_COLUMN_NAME", INT2FIX(PG_DIAG_COLUMN_NAME));
|
667
|
+
|
668
|
+
/* Result#result_error_field argument constant
|
669
|
+
*
|
670
|
+
* If the error was associated with a specific datatype, the name of the datatype.
|
671
|
+
* (When this field is present, the schema name field provides the name of the datatype's schema.) */
|
672
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_DATATYPE_NAME", INT2FIX(PG_DIAG_DATATYPE_NAME));
|
673
|
+
|
674
|
+
/* Result#result_error_field argument constant
|
675
|
+
*
|
676
|
+
* If the error was associated with a specific constraint, the name of the constraint.
|
677
|
+
* The table or domain that the constraint belongs to is reported using the fields listed above.
|
678
|
+
* (For this purpose, indexes are treated as constraints, even if they weren't created with constraint syntax.) */
|
679
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_CONSTRAINT_NAME", INT2FIX(PG_DIAG_CONSTRAINT_NAME));
|
680
|
+
#endif
|
681
|
+
|
682
|
+
#ifdef HAVE_PQENTERPIPELINEMODE
|
683
|
+
/* Connection#pipeline_status constant
|
684
|
+
*
|
685
|
+
* The libpq connection is in pipeline mode.
|
686
|
+
*/
|
687
|
+
rb_define_const(rb_mPGconstants, "PQ_PIPELINE_ON", INT2FIX(PQ_PIPELINE_ON));
|
688
|
+
|
689
|
+
/* Connection#pipeline_status constant
|
690
|
+
*
|
691
|
+
* The libpq connection is not in pipeline mode.
|
692
|
+
*/
|
693
|
+
rb_define_const(rb_mPGconstants, "PQ_PIPELINE_OFF", INT2FIX(PQ_PIPELINE_OFF));
|
694
|
+
|
695
|
+
/* Connection#pipeline_status constant
|
696
|
+
*
|
697
|
+
* The libpq connection is in pipeline mode and an error occurred while processing the current pipeline.
|
698
|
+
* The aborted flag is cleared when PQgetResult returns a result of type PGRES_PIPELINE_SYNC.
|
699
|
+
*/
|
700
|
+
rb_define_const(rb_mPGconstants, "PQ_PIPELINE_ABORTED", INT2FIX(PQ_PIPELINE_ABORTED));
|
701
|
+
#endif
|
702
|
+
|
703
|
+
/* Invalid OID constant */
|
704
|
+
rb_define_const(rb_mPGconstants, "INVALID_OID", INT2FIX(InvalidOid));
|
705
|
+
rb_define_const(rb_mPGconstants, "InvalidOid", INT2FIX(InvalidOid));
|
706
|
+
|
707
|
+
/* Add the constants to the toplevel namespace */
|
708
|
+
rb_include_module( rb_mPG, rb_mPGconstants );
|
709
|
+
|
710
|
+
enc_pg2ruby = st_init_numtable();
|
711
|
+
|
712
|
+
/* Initialize the main extension classes */
|
713
|
+
init_pg_connection();
|
714
|
+
init_pg_result();
|
715
|
+
init_pg_errors();
|
716
|
+
init_pg_type_map();
|
717
|
+
init_pg_type_map_all_strings();
|
718
|
+
init_pg_type_map_by_class();
|
719
|
+
init_pg_type_map_by_column();
|
720
|
+
init_pg_type_map_by_mri_type();
|
721
|
+
init_pg_type_map_by_oid();
|
722
|
+
init_pg_type_map_in_ruby();
|
723
|
+
init_pg_coder();
|
724
|
+
init_pg_text_encoder();
|
725
|
+
init_pg_text_decoder();
|
726
|
+
init_pg_binary_encoder();
|
727
|
+
init_pg_binary_decoder();
|
728
|
+
init_pg_copycoder();
|
729
|
+
init_pg_recordcoder();
|
730
|
+
init_pg_tuple();
|
731
|
+
}
|
732
|
+
|