pg 0.18.4 → 1.2.3
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.tar.gz.sig +0 -0
- data/BSDL +2 -2
- data/ChangeLog +0 -5911
- data/History.rdoc +240 -0
- data/Manifest.txt +8 -20
- data/README-Windows.rdoc +4 -4
- data/README.ja.rdoc +1 -2
- data/README.rdoc +64 -15
- data/Rakefile +20 -21
- data/Rakefile.cross +67 -69
- data/ext/errorcodes.def +101 -0
- data/ext/errorcodes.rb +1 -1
- data/ext/errorcodes.txt +33 -2
- data/ext/extconf.rb +26 -36
- data/ext/gvl_wrappers.c +4 -0
- data/ext/gvl_wrappers.h +27 -39
- data/ext/pg.c +156 -145
- data/ext/pg.h +74 -98
- data/ext/pg_binary_decoder.c +82 -15
- data/ext/pg_binary_encoder.c +20 -19
- data/ext/pg_coder.c +103 -21
- data/ext/pg_connection.c +917 -523
- data/ext/pg_copy_coder.c +50 -12
- data/ext/pg_record_coder.c +491 -0
- data/ext/pg_result.c +590 -208
- data/ext/pg_text_decoder.c +606 -40
- data/ext/pg_text_encoder.c +245 -94
- data/ext/pg_tuple.c +549 -0
- data/ext/pg_type_map.c +14 -7
- data/ext/pg_type_map_all_strings.c +4 -4
- data/ext/pg_type_map_by_class.c +9 -4
- data/ext/pg_type_map_by_column.c +7 -6
- data/ext/pg_type_map_by_mri_type.c +1 -1
- data/ext/pg_type_map_by_oid.c +3 -2
- data/ext/pg_type_map_in_ruby.c +1 -1
- data/ext/{util.c → pg_util.c} +10 -10
- data/ext/{util.h → pg_util.h} +2 -2
- data/lib/pg.rb +23 -13
- data/lib/pg/basic_type_mapping.rb +155 -32
- data/lib/pg/binary_decoder.rb +23 -0
- data/lib/pg/coder.rb +23 -2
- data/lib/pg/connection.rb +73 -13
- data/lib/pg/constants.rb +2 -1
- data/lib/pg/exceptions.rb +2 -1
- data/lib/pg/result.rb +24 -7
- data/lib/pg/text_decoder.rb +24 -22
- data/lib/pg/text_encoder.rb +40 -8
- data/lib/pg/tuple.rb +30 -0
- data/lib/pg/type_map_by_column.rb +3 -2
- data/spec/helpers.rb +61 -36
- data/spec/pg/basic_type_mapping_spec.rb +415 -36
- data/spec/pg/connection_spec.rb +732 -327
- data/spec/pg/connection_sync_spec.rb +41 -0
- data/spec/pg/result_spec.rb +253 -21
- data/spec/pg/tuple_spec.rb +333 -0
- data/spec/pg/type_map_by_class_spec.rb +4 -4
- data/spec/pg/type_map_by_column_spec.rb +6 -2
- data/spec/pg/type_map_by_mri_type_spec.rb +2 -2
- data/spec/pg/type_map_by_oid_spec.rb +3 -3
- data/spec/pg/type_map_in_ruby_spec.rb +1 -1
- data/spec/pg/type_map_spec.rb +1 -1
- data/spec/pg/type_spec.rb +446 -20
- data/spec/pg_spec.rb +2 -2
- metadata +63 -72
- metadata.gz.sig +0 -0
- data/sample/array_insert.rb +0 -20
- data/sample/async_api.rb +0 -106
- data/sample/async_copyto.rb +0 -39
- data/sample/async_mixed.rb +0 -56
- data/sample/check_conn.rb +0 -21
- data/sample/copyfrom.rb +0 -81
- data/sample/copyto.rb +0 -19
- data/sample/cursor.rb +0 -21
- data/sample/disk_usage_report.rb +0 -186
- data/sample/issue-119.rb +0 -94
- data/sample/losample.rb +0 -69
- data/sample/minimal-testcase.rb +0 -17
- data/sample/notify_wait.rb +0 -72
- data/sample/pg_statistics.rb +0 -294
- data/sample/replication_monitor.rb +0 -231
- data/sample/test_binary_values.rb +0 -33
- data/sample/wal_shipper.rb +0 -434
- data/sample/warehouse_partitions.rb +0 -320
data/ext/errorcodes.rb
CHANGED
data/ext/errorcodes.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# errcodes.txt
|
3
3
|
# PostgreSQL error codes
|
4
4
|
#
|
5
|
-
# Copyright (c) 2003-
|
5
|
+
# Copyright (c) 2003-2019, PostgreSQL Global Development Group
|
6
6
|
#
|
7
7
|
# This list serves as the basis for generating source files containing error
|
8
8
|
# codes. It is kept in a common format to make sure all these source files have
|
@@ -15,7 +15,10 @@
|
|
15
15
|
# src/pl/plpgsql/src/plerrcodes.h
|
16
16
|
# a list of PL/pgSQL condition names and their SQLSTATE codes
|
17
17
|
#
|
18
|
-
#
|
18
|
+
# src/pl/tcl/pltclerrcodes.h
|
19
|
+
# the same, for PL/Tcl
|
20
|
+
#
|
21
|
+
# doc/src/sgml/errcodes-table.sgml
|
19
22
|
# a SGML table of error codes for inclusion in the documentation
|
20
23
|
#
|
21
24
|
# The format of this file is one error code per line, with the following
|
@@ -174,15 +177,19 @@ Section: Class 22 - Data Exception
|
|
174
177
|
22P06 E ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER nonstandard_use_of_escape_character
|
175
178
|
22010 E ERRCODE_INVALID_INDICATOR_PARAMETER_VALUE invalid_indicator_parameter_value
|
176
179
|
22023 E ERRCODE_INVALID_PARAMETER_VALUE invalid_parameter_value
|
180
|
+
22013 E ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE invalid_preceding_or_following_size
|
177
181
|
2201B E ERRCODE_INVALID_REGULAR_EXPRESSION invalid_regular_expression
|
178
182
|
2201W E ERRCODE_INVALID_ROW_COUNT_IN_LIMIT_CLAUSE invalid_row_count_in_limit_clause
|
179
183
|
2201X E ERRCODE_INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE invalid_row_count_in_result_offset_clause
|
184
|
+
2202H E ERRCODE_INVALID_TABLESAMPLE_ARGUMENT invalid_tablesample_argument
|
185
|
+
2202G E ERRCODE_INVALID_TABLESAMPLE_REPEAT invalid_tablesample_repeat
|
180
186
|
22009 E ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE invalid_time_zone_displacement_value
|
181
187
|
2200C E ERRCODE_INVALID_USE_OF_ESCAPE_CHARACTER invalid_use_of_escape_character
|
182
188
|
2200G E ERRCODE_MOST_SPECIFIC_TYPE_MISMATCH most_specific_type_mismatch
|
183
189
|
22004 E ERRCODE_NULL_VALUE_NOT_ALLOWED null_value_not_allowed
|
184
190
|
22002 E ERRCODE_NULL_VALUE_NO_INDICATOR_PARAMETER null_value_no_indicator_parameter
|
185
191
|
22003 E ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE numeric_value_out_of_range
|
192
|
+
2200H E ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED sequence_generator_limit_exceeded
|
186
193
|
22026 E ERRCODE_STRING_DATA_LENGTH_MISMATCH string_data_length_mismatch
|
187
194
|
22001 E ERRCODE_STRING_DATA_RIGHT_TRUNCATION string_data_right_truncation
|
188
195
|
22011 E ERRCODE_SUBSTRING_ERROR substring_error
|
@@ -199,6 +206,21 @@ Section: Class 22 - Data Exception
|
|
199
206
|
2200N E ERRCODE_INVALID_XML_CONTENT invalid_xml_content
|
200
207
|
2200S E ERRCODE_INVALID_XML_COMMENT invalid_xml_comment
|
201
208
|
2200T E ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION invalid_xml_processing_instruction
|
209
|
+
22030 E ERRCODE_DUPLICATE_JSON_OBJECT_KEY_VALUE duplicate_json_object_key_value
|
210
|
+
22032 E ERRCODE_INVALID_JSON_TEXT invalid_json_text
|
211
|
+
22033 E ERRCODE_INVALID_SQL_JSON_SUBSCRIPT invalid_sql_json_subscript
|
212
|
+
22034 E ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM more_than_one_sql_json_item
|
213
|
+
22035 E ERRCODE_NO_SQL_JSON_ITEM no_sql_json_item
|
214
|
+
22036 E ERRCODE_NON_NUMERIC_SQL_JSON_ITEM non_numeric_sql_json_item
|
215
|
+
22037 E ERRCODE_NON_UNIQUE_KEYS_IN_A_JSON_OBJECT non_unique_keys_in_a_json_object
|
216
|
+
22038 E ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED singleton_sql_json_item_required
|
217
|
+
22039 E ERRCODE_SQL_JSON_ARRAY_NOT_FOUND sql_json_array_not_found
|
218
|
+
2203A E ERRCODE_SQL_JSON_MEMBER_NOT_FOUND sql_json_member_not_found
|
219
|
+
2203B E ERRCODE_SQL_JSON_NUMBER_NOT_FOUND sql_json_number_not_found
|
220
|
+
2203C E ERRCODE_SQL_JSON_OBJECT_NOT_FOUND sql_json_object_not_found
|
221
|
+
2203D E ERRCODE_TOO_MANY_JSON_ARRAY_ELEMENTS too_many_json_array_elements
|
222
|
+
2203E E ERRCODE_TOO_MANY_JSON_OBJECT_MEMBERS too_many_json_object_members
|
223
|
+
2203F E ERRCODE_SQL_JSON_SCALAR_REQUIRED sql_json_scalar_required
|
202
224
|
|
203
225
|
Section: Class 23 - Integrity Constraint Violation
|
204
226
|
|
@@ -227,6 +249,7 @@ Section: Class 25 - Invalid Transaction State
|
|
227
249
|
25007 E ERRCODE_SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED schema_and_data_statement_mixing_not_supported
|
228
250
|
25P01 E ERRCODE_NO_ACTIVE_SQL_TRANSACTION no_active_sql_transaction
|
229
251
|
25P02 E ERRCODE_IN_FAILED_SQL_TRANSACTION in_failed_sql_transaction
|
252
|
+
25P03 E ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT idle_in_transaction_session_timeout
|
230
253
|
|
231
254
|
Section: Class 26 - Invalid SQL Statement Name
|
232
255
|
|
@@ -278,6 +301,7 @@ Section: Class 39 - External Routine Invocation Exception
|
|
278
301
|
39004 E ERRCODE_E_R_I_E_NULL_VALUE_NOT_ALLOWED null_value_not_allowed
|
279
302
|
39P01 E ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED trigger_protocol_violated
|
280
303
|
39P02 E ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED srf_protocol_violated
|
304
|
+
39P03 E ERRCODE_E_R_I_E_EVENT_TRIGGER_PROTOCOL_VIOLATED event_trigger_protocol_violated
|
281
305
|
|
282
306
|
Section: Class 3B - Savepoint Exception
|
283
307
|
|
@@ -319,6 +343,7 @@ Section: Class 42 - Syntax Error or Access Rule Violation
|
|
319
343
|
42P21 E ERRCODE_COLLATION_MISMATCH collation_mismatch
|
320
344
|
42P22 E ERRCODE_INDETERMINATE_COLLATION indeterminate_collation
|
321
345
|
42809 E ERRCODE_WRONG_OBJECT_TYPE wrong_object_type
|
346
|
+
428C9 E ERRCODE_GENERATED_ALWAYS generated_always
|
322
347
|
|
323
348
|
# Note: for ERRCODE purposes, we divide namable objects into these categories:
|
324
349
|
# databases, schemas, prepared statements, cursors, tables, columns,
|
@@ -391,6 +416,7 @@ Section: Class 55 - Object Not In Prerequisite State
|
|
391
416
|
55006 E ERRCODE_OBJECT_IN_USE object_in_use
|
392
417
|
55P02 E ERRCODE_CANT_CHANGE_RUNTIME_PARAM cant_change_runtime_param
|
393
418
|
55P03 E ERRCODE_LOCK_NOT_AVAILABLE lock_not_available
|
419
|
+
55P04 E ERRCODE_UNSAFE_NEW_ENUM_VALUE_USAGE unsafe_new_enum_value_usage
|
394
420
|
|
395
421
|
Section: Class 57 - Operator Intervention
|
396
422
|
|
@@ -410,6 +436,10 @@ Section: Class 58 - System Error (errors external to PostgreSQL itself)
|
|
410
436
|
58P01 E ERRCODE_UNDEFINED_FILE undefined_file
|
411
437
|
58P02 E ERRCODE_DUPLICATE_FILE duplicate_file
|
412
438
|
|
439
|
+
Section: Class 72 - Snapshot Failure
|
440
|
+
# (class borrowed from Oracle)
|
441
|
+
72000 E ERRCODE_SNAPSHOT_TOO_OLD snapshot_too_old
|
442
|
+
|
413
443
|
Section: Class F0 - Configuration File Error
|
414
444
|
|
415
445
|
# (PostgreSQL-specific error class)
|
@@ -454,6 +484,7 @@ P0000 E ERRCODE_PLPGSQL_ERROR plp
|
|
454
484
|
P0001 E ERRCODE_RAISE_EXCEPTION raise_exception
|
455
485
|
P0002 E ERRCODE_NO_DATA_FOUND no_data_found
|
456
486
|
P0003 E ERRCODE_TOO_MANY_ROWS too_many_rows
|
487
|
+
P0004 E ERRCODE_ASSERT_FAILURE assert_failure
|
457
488
|
|
458
489
|
Section: Class XX - Internal Error
|
459
490
|
|
data/ext/extconf.rb
CHANGED
@@ -24,7 +24,11 @@ if enable_config("windows-cross")
|
|
24
24
|
else
|
25
25
|
# Native build
|
26
26
|
|
27
|
-
|
27
|
+
pgconfig = with_config('pg-config') ||
|
28
|
+
with_config('pg_config') ||
|
29
|
+
find_executable('pg_config')
|
30
|
+
|
31
|
+
if pgconfig && pgconfig != 'ignore'
|
28
32
|
$stderr.puts "Using config values from %s" % [ pgconfig ]
|
29
33
|
incdir = `"#{pgconfig}" --includedir`.chomp
|
30
34
|
libdir = `"#{pgconfig}" --libdir`.chomp
|
@@ -43,6 +47,9 @@ else
|
|
43
47
|
end
|
44
48
|
end
|
45
49
|
|
50
|
+
if RUBY_VERSION >= '2.3.0' && /solaris/ =~ RUBY_PLATFORM
|
51
|
+
append_cppflags( '-D__EXTENSIONS__' )
|
52
|
+
end
|
46
53
|
|
47
54
|
find_header( 'libpq-fe.h' ) or abort "Can't find the 'libpq-fe.h header"
|
48
55
|
find_header( 'libpq/libpq-fs.h' ) or abort "Can't find the 'libpq/libpq-fs.h header"
|
@@ -53,47 +60,30 @@ abort "Can't find the PostgreSQL client library (libpq)" unless
|
|
53
60
|
have_library( 'libpq', 'PQconnectdb', ['libpq-fe.h'] ) ||
|
54
61
|
have_library( 'ms/libpq', 'PQconnectdb', ['libpq-fe.h'] )
|
55
62
|
|
63
|
+
if /mingw/ =~ RUBY_PLATFORM && RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
|
64
|
+
# Work around: https://sourceware.org/bugzilla/show_bug.cgi?id=22504
|
65
|
+
checking_for "workaround gcc version with link issue" do
|
66
|
+
`#{RbConfig::MAKEFILE_CONFIG['CC']} --version`.chomp =~ /\s(\d+)\.\d+\.\d+(\s|$)/ &&
|
67
|
+
$1.to_i >= 6 &&
|
68
|
+
have_library(':libpq.lib') # Prefer linking to libpq.lib over libpq.dll if available
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
56
72
|
# optional headers/functions
|
57
|
-
have_func '
|
73
|
+
have_func 'PQsetSingleRowMode' or
|
58
74
|
abort "Your PostgreSQL is too old. Either install an older version " +
|
59
|
-
"of this gem or upgrade your database."
|
60
|
-
have_func '
|
61
|
-
have_func '
|
62
|
-
have_func '
|
63
|
-
have_func '
|
64
|
-
have_func '
|
65
|
-
have_func '
|
66
|
-
have_func '
|
67
|
-
have_func 'PQgetCancel'
|
68
|
-
have_func 'lo_create'
|
69
|
-
have_func 'pg_encoding_to_char'
|
70
|
-
have_func 'pg_char_to_encoding'
|
71
|
-
have_func 'PQsetClientEncoding'
|
72
|
-
have_func 'PQlibVersion'
|
73
|
-
have_func 'PQping'
|
74
|
-
have_func 'PQsetSingleRowMode'
|
75
|
-
have_func 'PQconninfo'
|
76
|
-
|
77
|
-
have_func 'rb_encdb_alias'
|
78
|
-
have_func 'rb_enc_alias'
|
79
|
-
have_func 'rb_thread_call_without_gvl'
|
80
|
-
have_func 'rb_thread_call_with_gvl'
|
81
|
-
have_func 'rb_thread_fd_select'
|
82
|
-
have_func 'rb_w32_wrap_io_handle'
|
83
|
-
have_func 'rb_str_modify_expand'
|
84
|
-
have_func 'rb_hash_dup'
|
85
|
-
|
86
|
-
have_const 'PGRES_COPY_BOTH', 'libpq-fe.h'
|
87
|
-
have_const 'PGRES_SINGLE_TUPLE', 'libpq-fe.h'
|
88
|
-
have_const 'PG_DIAG_TABLE_NAME', 'libpq-fe.h'
|
89
|
-
|
90
|
-
$defs.push( "-DHAVE_ST_NOTIFY_EXTRA" ) if
|
91
|
-
have_struct_member 'struct pgNotify', 'extra', 'libpq-fe.h'
|
75
|
+
"of this gem or upgrade your database to at least PostgreSQL-9.2."
|
76
|
+
have_func 'PQconninfo' # since PostgreSQL-9.3
|
77
|
+
have_func 'PQsslAttribute' # since PostgreSQL-9.5
|
78
|
+
have_func 'PQresultVerboseErrorMessage' # since PostgreSQL-9.6
|
79
|
+
have_func 'PQencryptPasswordConn' # since PostgreSQL-10
|
80
|
+
have_func 'PQresultMemorySize' # since PostgreSQL-12
|
81
|
+
have_func 'timegm'
|
82
|
+
have_func 'rb_gc_adjust_memory_usage' # since ruby-2.4
|
92
83
|
|
93
84
|
# unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
|
94
85
|
have_header 'unistd.h'
|
95
86
|
have_header 'inttypes.h'
|
96
|
-
have_header 'ruby/st.h' or have_header 'st.h' or abort "pg currently requires the ruby/st.h header"
|
97
87
|
|
98
88
|
checking_for "C99 variable length arrays" do
|
99
89
|
$defs.push( "-DHAVE_VARIABLE_LENGTH_ARRAYS" ) if try_compile('void test_vla(int l){ int vla[l]; }')
|
data/ext/gvl_wrappers.c
CHANGED
@@ -5,6 +5,10 @@
|
|
5
5
|
|
6
6
|
#include "pg.h"
|
7
7
|
|
8
|
+
#ifndef HAVE_PQENCRYPTPASSWORDCONN
|
9
|
+
char *PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm){return NULL;}
|
10
|
+
#endif
|
11
|
+
|
8
12
|
FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_WRAPPER_STRUCT );
|
9
13
|
FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_SKELETON );
|
10
14
|
FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_STUB );
|
data/ext/gvl_wrappers.h
CHANGED
@@ -15,14 +15,7 @@
|
|
15
15
|
#ifndef __gvl_wrappers_h
|
16
16
|
#define __gvl_wrappers_h
|
17
17
|
|
18
|
-
#
|
19
|
-
extern void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
|
20
|
-
#endif
|
21
|
-
|
22
|
-
#if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL)
|
23
|
-
extern void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1,
|
24
|
-
rb_unblock_function_t *ubf, void *data2);
|
25
|
-
#endif
|
18
|
+
#include <ruby/thread.h>
|
26
19
|
|
27
20
|
#define DEFINE_PARAM_LIST1(type, name) \
|
28
21
|
name,
|
@@ -53,21 +46,14 @@ extern void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1,
|
|
53
46
|
return NULL; \
|
54
47
|
}
|
55
48
|
|
56
|
-
#
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
}
|
65
|
-
#else
|
66
|
-
#define DEFINE_GVL_STUB(name, when_non_void, rettype, lastparamtype, lastparamname) \
|
67
|
-
rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname){ \
|
68
|
-
return name( FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST1) lastparamname ); \
|
69
|
-
}
|
70
|
-
#endif
|
49
|
+
#define DEFINE_GVL_STUB(name, when_non_void, rettype, lastparamtype, lastparamname) \
|
50
|
+
rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname){ \
|
51
|
+
struct gvl_wrapper_##name##_params params = { \
|
52
|
+
{FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST1) lastparamname}, when_non_void((rettype)0) \
|
53
|
+
}; \
|
54
|
+
rb_thread_call_without_gvl(gvl_##name##_skeleton, ¶ms, RUBY_UBF_IO, 0); \
|
55
|
+
when_non_void( return params.retval; ) \
|
56
|
+
}
|
71
57
|
|
72
58
|
#define DEFINE_GVL_STUB_DECL(name, when_non_void, rettype, lastparamtype, lastparamname) \
|
73
59
|
rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname);
|
@@ -80,21 +66,14 @@ extern void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1,
|
|
80
66
|
return NULL; \
|
81
67
|
}
|
82
68
|
|
83
|
-
#
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
}
|
92
|
-
#else
|
93
|
-
#define DEFINE_GVLCB_STUB(name, when_non_void, rettype, lastparamtype, lastparamname) \
|
94
|
-
rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname){ \
|
95
|
-
return name( FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST1) lastparamname ); \
|
96
|
-
}
|
97
|
-
#endif
|
69
|
+
#define DEFINE_GVLCB_STUB(name, when_non_void, rettype, lastparamtype, lastparamname) \
|
70
|
+
rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname){ \
|
71
|
+
struct gvl_wrapper_##name##_params params = { \
|
72
|
+
{FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST1) lastparamname}, when_non_void((rettype)0) \
|
73
|
+
}; \
|
74
|
+
rb_thread_call_with_gvl(gvl_##name##_skeleton, ¶ms); \
|
75
|
+
when_non_void( return params.retval; ) \
|
76
|
+
}
|
98
77
|
|
99
78
|
#define GVL_TYPE_VOID(string)
|
100
79
|
#define GVL_TYPE_NONVOID(string) string
|
@@ -195,8 +174,16 @@ extern void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1,
|
|
195
174
|
#define FOR_EACH_PARAM_OF_PQsendDescribePortal(param) \
|
196
175
|
param(PGconn *, conn)
|
197
176
|
|
177
|
+
#define FOR_EACH_PARAM_OF_PQsetClientEncoding(param) \
|
178
|
+
param(PGconn *, conn)
|
179
|
+
|
198
180
|
#define FOR_EACH_PARAM_OF_PQisBusy(param)
|
199
181
|
|
182
|
+
#define FOR_EACH_PARAM_OF_PQencryptPasswordConn(param) \
|
183
|
+
param(PGconn *, conn) \
|
184
|
+
param(const char *, passwd) \
|
185
|
+
param(const char *, user)
|
186
|
+
|
200
187
|
#define FOR_EACH_PARAM_OF_PQcancel(param) \
|
201
188
|
param(PGcancel *, cancel) \
|
202
189
|
param(char *, errbuf)
|
@@ -226,10 +213,11 @@ extern void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1,
|
|
226
213
|
function(PQsendQueryPrepared, GVL_TYPE_NONVOID, int, int, resultFormat) \
|
227
214
|
function(PQsendDescribePrepared, GVL_TYPE_NONVOID, int, const char *, stmt) \
|
228
215
|
function(PQsendDescribePortal, GVL_TYPE_NONVOID, int, const char *, portal) \
|
216
|
+
function(PQsetClientEncoding, GVL_TYPE_NONVOID, int, const char *, encoding) \
|
229
217
|
function(PQisBusy, GVL_TYPE_NONVOID, int, PGconn *, conn) \
|
218
|
+
function(PQencryptPasswordConn, GVL_TYPE_NONVOID, char *, const char *, algorithm) \
|
230
219
|
function(PQcancel, GVL_TYPE_NONVOID, int, int, errbufsize);
|
231
220
|
|
232
|
-
|
233
221
|
FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_STUB_DECL );
|
234
222
|
|
235
223
|
|
data/ext/pg.c
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
/*
|
2
2
|
* pg.c - Toplevel extension
|
3
|
-
* $Id
|
3
|
+
* $Id$
|
4
4
|
*
|
5
5
|
* Author/s:
|
6
6
|
*
|
7
7
|
* - Jeff Davis <ruby-pg@j-davis.com>
|
8
8
|
* - Guy Decoux (ts) <decoux@moulon.inra.fr>
|
9
9
|
* - Michael Granger <ged@FaerieMUD.org>
|
10
|
+
* - Lars Kanis <lars@greiz-reinsdorf.de>
|
10
11
|
* - Dave Lee
|
11
12
|
* - Eiji Matsumoto <usagi@ruby.club.or.jp>
|
12
13
|
* - Yukihiro Matsumoto <matz@ruby-lang.org>
|
@@ -15,10 +16,10 @@
|
|
15
16
|
* See Contributors.rdoc for the many additional fine people that have contributed
|
16
17
|
* to this library over the years.
|
17
18
|
*
|
18
|
-
* Copyright (c) 1997-
|
19
|
+
* Copyright (c) 1997-2019 by the authors.
|
19
20
|
*
|
20
21
|
* You may redistribute this software under the same terms as Ruby itself; see
|
21
|
-
*
|
22
|
+
* https://www.ruby-lang.org/en/about/license.txt or the BSDL file in the source
|
22
23
|
* for details.
|
23
24
|
*
|
24
25
|
* Portions of the code are from the PostgreSQL project, and are distributed
|
@@ -47,6 +48,7 @@
|
|
47
48
|
|
48
49
|
#include "pg.h"
|
49
50
|
|
51
|
+
int pg_skip_deprecation_warning;
|
50
52
|
VALUE rb_mPG;
|
51
53
|
VALUE rb_mPGconstants;
|
52
54
|
|
@@ -68,7 +70,6 @@ VALUE rb_mPGconstants;
|
|
68
70
|
* M17n functions
|
69
71
|
*/
|
70
72
|
|
71
|
-
#ifdef M17N_SUPPORTED
|
72
73
|
/**
|
73
74
|
* The mapping from canonical encoding names in PostgreSQL to ones in Ruby.
|
74
75
|
*/
|
@@ -142,9 +143,6 @@ pg_find_or_create_johab(void)
|
|
142
143
|
}
|
143
144
|
|
144
145
|
enc_index = rb_define_dummy_encoding(aliases[0]);
|
145
|
-
for (i = 1; i < sizeof(aliases)/sizeof(aliases[0]); ++i) {
|
146
|
-
ENC_ALIAS(aliases[i], aliases[0]);
|
147
|
-
}
|
148
146
|
return rb_enc_from_index(enc_index);
|
149
147
|
}
|
150
148
|
|
@@ -228,8 +226,6 @@ pg_get_rb_encoding_as_pg_encoding( rb_encoding *enc )
|
|
228
226
|
return encname;
|
229
227
|
}
|
230
228
|
|
231
|
-
#endif /* M17N_SUPPORTED */
|
232
|
-
|
233
229
|
|
234
230
|
/*
|
235
231
|
* Ensures that the given string has enough capacity to take expand_len
|
@@ -259,45 +255,26 @@ pg_get_rb_encoding_as_pg_encoding( rb_encoding *enc )
|
|
259
255
|
* rb_str_set_len( string, current_out - RSTRING_PTR(string) );
|
260
256
|
*
|
261
257
|
*/
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
rb_str_modify_expand( str, (curr_len + expand_len) * 2 - curr_capa );
|
272
|
-
curr_ptr = RSTRING_PTR(str) + curr_len;
|
273
|
-
}
|
274
|
-
if( end_ptr )
|
275
|
-
*end_ptr = RSTRING_PTR(str) + rb_str_capacity( str );
|
276
|
-
return curr_ptr;
|
277
|
-
}
|
278
|
-
#else
|
279
|
-
/* Use the more portable version */
|
280
|
-
char *
|
281
|
-
pg_rb_str_ensure_capa( VALUE str, long expand_len, char *curr_ptr, char **end_ptr )
|
282
|
-
{
|
283
|
-
long curr_len = curr_ptr - RSTRING_PTR(str);
|
284
|
-
long curr_capa = RSTRING_LEN( str );
|
285
|
-
if( curr_capa < curr_len + expand_len ){
|
286
|
-
rb_str_resize( str, (curr_len + expand_len) * 2 - curr_capa );
|
287
|
-
curr_ptr = RSTRING_PTR(str) + curr_len;
|
288
|
-
}
|
289
|
-
if( end_ptr )
|
290
|
-
*end_ptr = RSTRING_PTR(str) + RSTRING_LEN(str);
|
291
|
-
return curr_ptr;
|
258
|
+
char *
|
259
|
+
pg_rb_str_ensure_capa( VALUE str, long expand_len, char *curr_ptr, char **end_ptr )
|
260
|
+
{
|
261
|
+
long curr_len = curr_ptr - RSTRING_PTR(str);
|
262
|
+
long curr_capa = rb_str_capacity( str );
|
263
|
+
if( curr_capa < curr_len + expand_len ){
|
264
|
+
rb_str_set_len( str, curr_len );
|
265
|
+
rb_str_modify_expand( str, (curr_len + expand_len) * 2 - curr_capa );
|
266
|
+
curr_ptr = RSTRING_PTR(str) + curr_len;
|
292
267
|
}
|
293
|
-
|
268
|
+
if( end_ptr )
|
269
|
+
*end_ptr = RSTRING_PTR(str) + rb_str_capacity( str );
|
270
|
+
return curr_ptr;
|
271
|
+
}
|
294
272
|
|
295
273
|
|
296
274
|
/**************************************************************************
|
297
275
|
* Module Methods
|
298
276
|
**************************************************************************/
|
299
277
|
|
300
|
-
#ifdef HAVE_PQLIBVERSION
|
301
278
|
/*
|
302
279
|
* call-seq:
|
303
280
|
* PG.library_version -> Integer
|
@@ -315,7 +292,6 @@ pg_s_library_version(VALUE self)
|
|
315
292
|
UNUSED( self );
|
316
293
|
return INT2NUM(PQlibVersion());
|
317
294
|
}
|
318
|
-
#endif
|
319
295
|
|
320
296
|
|
321
297
|
/*
|
@@ -355,8 +331,7 @@ pg_to_bool_int(VALUE value)
|
|
355
331
|
* If your application initializes libssl and/or libcrypto libraries and libpq is
|
356
332
|
* built with SSL support, you should call PG.init_openssl() to tell libpq that the
|
357
333
|
* libssl and/or libcrypto libraries have been initialized by your application,
|
358
|
-
* so that libpq will not also initialize those libraries.
|
359
|
-
* http://h71000.www7.hp.com/doc/83final/BA554_90007/ch04.html for details on the SSL API.
|
334
|
+
* so that libpq will not also initialize those libraries.
|
360
335
|
*
|
361
336
|
* When do_ssl is +true+, libpq will initialize the OpenSSL library before first
|
362
337
|
* opening a database connection. When do_crypto is +true+, the libcrypto library
|
@@ -403,15 +378,20 @@ pg_s_init_ssl(VALUE self, VALUE do_ssl)
|
|
403
378
|
void
|
404
379
|
Init_pg_ext()
|
405
380
|
{
|
381
|
+
if( RTEST(rb_eval_string("ENV['PG_SKIP_DEPRECATION_WARNING']")) ){
|
382
|
+
/* Set all bits to disable all deprecation warnings. */
|
383
|
+
pg_skip_deprecation_warning = 0xFFFF;
|
384
|
+
} else {
|
385
|
+
pg_skip_deprecation_warning = 0;
|
386
|
+
}
|
387
|
+
|
406
388
|
rb_mPG = rb_define_module( "PG" );
|
407
389
|
rb_mPGconstants = rb_define_module_under( rb_mPG, "Constants" );
|
408
390
|
|
409
391
|
/*************************
|
410
392
|
* PG module methods
|
411
393
|
*************************/
|
412
|
-
#ifdef HAVE_PQLIBVERSION
|
413
394
|
rb_define_singleton_method( rb_mPG, "library_version", pg_s_library_version, 0 );
|
414
|
-
#endif
|
415
395
|
rb_define_singleton_method( rb_mPG, "isthreadsafe", pg_s_threadsafe_p, 0 );
|
416
396
|
SINGLETON_ALIAS( rb_mPG, "is_threadsafe?", "isthreadsafe" );
|
417
397
|
SINGLETON_ALIAS( rb_mPG, "threadsafe?", "isthreadsafe" );
|
@@ -441,7 +421,7 @@ Init_pg_ext()
|
|
441
421
|
rb_define_const(rb_mPGconstants, "CONNECTION_SSL_STARTUP", INT2FIX(CONNECTION_SSL_STARTUP));
|
442
422
|
/* Negotiating environment-driven parameter settings. */
|
443
423
|
rb_define_const(rb_mPGconstants, "CONNECTION_SETENV", INT2FIX(CONNECTION_SETENV));
|
444
|
-
/* Internal state
|
424
|
+
/* Internal state - PG.connect() needed. */
|
445
425
|
rb_define_const(rb_mPGconstants, "CONNECTION_NEEDED", INT2FIX(CONNECTION_NEEDED));
|
446
426
|
|
447
427
|
/****** PG::Connection CLASS CONSTANTS: Nonblocking connection polling status ******/
|
@@ -457,27 +437,48 @@ Init_pg_ext()
|
|
457
437
|
|
458
438
|
/****** PG::Connection CLASS CONSTANTS: Transaction Status ******/
|
459
439
|
|
460
|
-
/* Transaction is currently idle (#transaction_status) */
|
440
|
+
/* Transaction is currently idle ( Connection#transaction_status ) */
|
461
441
|
rb_define_const(rb_mPGconstants, "PQTRANS_IDLE", INT2FIX(PQTRANS_IDLE));
|
462
|
-
/* Transaction is currently active; query has been sent to the server, but not yet completed. (#transaction_status) */
|
442
|
+
/* Transaction is currently active; query has been sent to the server, but not yet completed. ( Connection#transaction_status ) */
|
463
443
|
rb_define_const(rb_mPGconstants, "PQTRANS_ACTIVE", INT2FIX(PQTRANS_ACTIVE));
|
464
|
-
/* Transaction is currently idle, in a valid transaction block (#transaction_status) */
|
444
|
+
/* Transaction is currently idle, in a valid transaction block ( Connection#transaction_status ) */
|
465
445
|
rb_define_const(rb_mPGconstants, "PQTRANS_INTRANS", INT2FIX(PQTRANS_INTRANS));
|
466
|
-
/* Transaction is currently idle, in a failed transaction block (#transaction_status) */
|
446
|
+
/* Transaction is currently idle, in a failed transaction block ( Connection#transaction_status ) */
|
467
447
|
rb_define_const(rb_mPGconstants, "PQTRANS_INERROR", INT2FIX(PQTRANS_INERROR));
|
468
|
-
/* Transaction's connection is bad (#transaction_status) */
|
448
|
+
/* Transaction's connection is bad ( Connection#transaction_status ) */
|
469
449
|
rb_define_const(rb_mPGconstants, "PQTRANS_UNKNOWN", INT2FIX(PQTRANS_UNKNOWN));
|
470
450
|
|
471
451
|
/****** PG::Connection CLASS CONSTANTS: Error Verbosity ******/
|
472
452
|
|
473
|
-
/*
|
453
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
454
|
+
* In TERSE mode, returned messages include severity, primary text, and position only; this will normally fit on a single line. */
|
474
455
|
rb_define_const(rb_mPGconstants, "PQERRORS_TERSE", INT2FIX(PQERRORS_TERSE));
|
475
|
-
/*
|
456
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
457
|
+
* The DEFAULT mode produces messages that include the above plus any detail, hint, or context fields (these might span multiple lines). */
|
476
458
|
rb_define_const(rb_mPGconstants, "PQERRORS_DEFAULT", INT2FIX(PQERRORS_DEFAULT));
|
477
|
-
/*
|
459
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
460
|
+
* The VERBOSE mode includes all available fields. */
|
478
461
|
rb_define_const(rb_mPGconstants, "PQERRORS_VERBOSE", INT2FIX(PQERRORS_VERBOSE));
|
479
462
|
|
480
|
-
|
463
|
+
/* PQERRORS_SQLSTATE was introduced in PG-12 together with PQresultMemorySize() */
|
464
|
+
#ifdef HAVE_PQRESULTMEMORYSIZE
|
465
|
+
/* Error verbosity level ( Connection#set_error_verbosity ).
|
466
|
+
* The SQLSTATE mode includes only the error severity and the SQLSTATE error code, if one is available (if not, the output is like TERSE mode).
|
467
|
+
*
|
468
|
+
* Available since PostgreSQL-12.
|
469
|
+
*/
|
470
|
+
rb_define_const(rb_mPGconstants, "PQERRORS_SQLSTATE", INT2FIX(PQERRORS_SQLSTATE));
|
471
|
+
#endif
|
472
|
+
|
473
|
+
#ifdef HAVE_PQRESULTVERBOSEERRORMESSAGE
|
474
|
+
/* See Connection#set_error_context_visibility */
|
475
|
+
rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_NEVER", INT2FIX(PQSHOW_CONTEXT_NEVER));
|
476
|
+
/* See Connection#set_error_context_visibility */
|
477
|
+
rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_ERRORS", INT2FIX(PQSHOW_CONTEXT_ERRORS));
|
478
|
+
/* See Connection#set_error_context_visibility */
|
479
|
+
rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_ALWAYS", INT2FIX(PQSHOW_CONTEXT_ALWAYS));
|
480
|
+
#endif
|
481
|
+
|
481
482
|
/****** PG::Connection CLASS CONSTANTS: Check Server Status ******/
|
482
483
|
|
483
484
|
/* Server is accepting connections. */
|
@@ -488,149 +489,159 @@ Init_pg_ext()
|
|
488
489
|
rb_define_const(rb_mPGconstants, "PQPING_NO_RESPONSE", INT2FIX(PQPING_NO_RESPONSE));
|
489
490
|
/* Connection not attempted (bad params). */
|
490
491
|
rb_define_const(rb_mPGconstants, "PQPING_NO_ATTEMPT", INT2FIX(PQPING_NO_ATTEMPT));
|
491
|
-
#endif
|
492
492
|
|
493
493
|
/****** PG::Connection CLASS CONSTANTS: Large Objects ******/
|
494
494
|
|
495
|
-
/* Flag for #lo_creat, #lo_open -- open for writing */
|
495
|
+
/* Flag for Connection#lo_creat, Connection#lo_open -- open for writing */
|
496
496
|
rb_define_const(rb_mPGconstants, "INV_WRITE", INT2FIX(INV_WRITE));
|
497
|
-
/* Flag for #lo_creat, #lo_open -- open for reading */
|
497
|
+
/* Flag for Connection#lo_creat, Connection#lo_open -- open for reading */
|
498
498
|
rb_define_const(rb_mPGconstants, "INV_READ", INT2FIX(INV_READ));
|
499
|
-
/* Flag for #lo_lseek -- seek from object start */
|
499
|
+
/* Flag for Connection#lo_lseek -- seek from object start */
|
500
500
|
rb_define_const(rb_mPGconstants, "SEEK_SET", INT2FIX(SEEK_SET));
|
501
|
-
/* Flag for #lo_lseek -- seek from current position */
|
501
|
+
/* Flag for Connection#lo_lseek -- seek from current position */
|
502
502
|
rb_define_const(rb_mPGconstants, "SEEK_CUR", INT2FIX(SEEK_CUR));
|
503
|
-
/* Flag for #lo_lseek -- seek from object end */
|
503
|
+
/* Flag for Connection#lo_lseek -- seek from object end */
|
504
504
|
rb_define_const(rb_mPGconstants, "SEEK_END", INT2FIX(SEEK_END));
|
505
505
|
|
506
506
|
/****** PG::Result CONSTANTS: result status ******/
|
507
507
|
|
508
|
-
/* #result_status constant
|
508
|
+
/* Result#result_status constant - The string sent to the server was empty. */
|
509
509
|
rb_define_const(rb_mPGconstants, "PGRES_EMPTY_QUERY", INT2FIX(PGRES_EMPTY_QUERY));
|
510
|
-
/* #result_status constant
|
510
|
+
/* Result#result_status constant - Successful completion of a command returning no data. */
|
511
511
|
rb_define_const(rb_mPGconstants, "PGRES_COMMAND_OK", INT2FIX(PGRES_COMMAND_OK));
|
512
|
-
|
513
|
-
(such as a SELECT or SHOW). */
|
512
|
+
/* Result#result_status constant - Successful completion of a command returning data (such as a SELECT or SHOW). */
|
514
513
|
rb_define_const(rb_mPGconstants, "PGRES_TUPLES_OK", INT2FIX(PGRES_TUPLES_OK));
|
515
|
-
/* #result_status constant
|
514
|
+
/* Result#result_status constant - Copy Out (from server) data transfer started. */
|
516
515
|
rb_define_const(rb_mPGconstants, "PGRES_COPY_OUT", INT2FIX(PGRES_COPY_OUT));
|
517
|
-
/* #result_status constant
|
516
|
+
/* Result#result_status constant - Copy In (to server) data transfer started. */
|
518
517
|
rb_define_const(rb_mPGconstants, "PGRES_COPY_IN", INT2FIX(PGRES_COPY_IN));
|
519
|
-
/* #result_status constant
|
518
|
+
/* Result#result_status constant - The server’s response was not understood. */
|
520
519
|
rb_define_const(rb_mPGconstants, "PGRES_BAD_RESPONSE", INT2FIX(PGRES_BAD_RESPONSE));
|
521
|
-
/* #result_status constant
|
520
|
+
/* Result#result_status constant - A nonfatal error (a notice or warning) occurred. */
|
522
521
|
rb_define_const(rb_mPGconstants, "PGRES_NONFATAL_ERROR",INT2FIX(PGRES_NONFATAL_ERROR));
|
523
|
-
/* #result_status constant
|
522
|
+
/* Result#result_status constant - A fatal error occurred. */
|
524
523
|
rb_define_const(rb_mPGconstants, "PGRES_FATAL_ERROR", INT2FIX(PGRES_FATAL_ERROR));
|
525
|
-
/* #result_status constant
|
526
|
-
#ifdef HAVE_CONST_PGRES_COPY_BOTH
|
524
|
+
/* Result#result_status constant - Copy In/Out data transfer in progress. */
|
527
525
|
rb_define_const(rb_mPGconstants, "PGRES_COPY_BOTH", INT2FIX(PGRES_COPY_BOTH));
|
528
|
-
#
|
529
|
-
/* #result_status constant: Single tuple from larger resultset. */
|
530
|
-
#ifdef HAVE_CONST_PGRES_SINGLE_TUPLE
|
526
|
+
/* Result#result_status constant - Single tuple from larger resultset. */
|
531
527
|
rb_define_const(rb_mPGconstants, "PGRES_SINGLE_TUPLE", INT2FIX(PGRES_SINGLE_TUPLE));
|
532
|
-
#endif
|
533
528
|
|
534
529
|
/****** Result CONSTANTS: result error field codes ******/
|
535
530
|
|
536
|
-
/* #result_error_field argument constant
|
537
|
-
*
|
538
|
-
* DEBUG, INFO, or LOG (in a notice message), or a localized translation
|
539
|
-
* of one of these.
|
531
|
+
/* Result#result_error_field argument constant
|
532
|
+
*
|
533
|
+
* The severity; the field contents are ERROR, FATAL, or PANIC (in an error message), or WARNING, NOTICE, DEBUG, INFO, or LOG (in a notice message), or a localized translation
|
534
|
+
* of one of these.
|
535
|
+
* Always present.
|
540
536
|
*/
|
541
537
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY", INT2FIX(PG_DIAG_SEVERITY));
|
542
538
|
|
543
|
-
|
544
|
-
|
545
|
-
*
|
546
|
-
*
|
547
|
-
*
|
548
|
-
*
|
539
|
+
#ifdef PG_DIAG_SEVERITY_NONLOCALIZED
|
540
|
+
/* Result#result_error_field argument constant
|
541
|
+
*
|
542
|
+
* The severity; the field contents are ERROR, FATAL, or PANIC (in an error message), or WARNING, NOTICE, DEBUG, INFO, or LOG (in a notice message).
|
543
|
+
* This is identical to the PG_DIAG_SEVERITY field except that the contents are never localized.
|
544
|
+
*
|
545
|
+
* Available since PostgreSQL-9.6
|
546
|
+
*/
|
547
|
+
rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY_NONLOCALIZED", INT2FIX(PG_DIAG_SEVERITY_NONLOCALIZED));
|
548
|
+
#endif
|
549
|
+
/* Result#result_error_field argument constant
|
550
|
+
*
|
551
|
+
* The SQLSTATE code for the error.
|
552
|
+
* The SQLSTATE code identies the type of error that has occurred; it can be used by front-end applications to perform specic operations (such as error handling) in response to a particular database error.
|
553
|
+
* For a list of the possible SQLSTATE codes, see Appendix A.
|
554
|
+
* This field is not localizable, and is always present.
|
549
555
|
*/
|
550
556
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SQLSTATE", INT2FIX(PG_DIAG_SQLSTATE));
|
551
|
-
|
552
|
-
|
553
|
-
* error message (typically one line).
|
557
|
+
/* Result#result_error_field argument constant
|
558
|
+
*
|
559
|
+
* The primary human-readable error message (typically one line).
|
560
|
+
* Always present. */
|
554
561
|
rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_PRIMARY", INT2FIX(PG_DIAG_MESSAGE_PRIMARY));
|
555
|
-
|
556
|
-
|
557
|
-
* error message carrying more detail about the problem.
|
558
|
-
* multiple lines.
|
562
|
+
/* Result#result_error_field argument constant
|
563
|
+
*
|
564
|
+
* Detail: an optional secondary error message carrying more detail about the problem.
|
565
|
+
* Might run to multiple lines.
|
559
566
|
*/
|
560
567
|
rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_DETAIL", INT2FIX(PG_DIAG_MESSAGE_DETAIL));
|
561
|
-
|
562
|
-
|
563
|
-
* what to do about the problem.
|
564
|
-
* in that it offers advice (potentially inappropriate) rather than
|
565
|
-
*
|
568
|
+
/* Result#result_error_field argument constant
|
569
|
+
*
|
570
|
+
* Hint: an optional suggestion what to do about the problem.
|
571
|
+
* This is intended to differ from detail in that it offers advice (potentially inappropriate) rather than hard facts.
|
572
|
+
* Might run to multiple lines.
|
566
573
|
*/
|
567
|
-
|
568
574
|
rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_HINT", INT2FIX(PG_DIAG_MESSAGE_HINT));
|
569
|
-
/* #result_error_field argument constant
|
570
|
-
*
|
571
|
-
*
|
572
|
-
*
|
575
|
+
/* Result#result_error_field argument constant
|
576
|
+
*
|
577
|
+
* A string containing a decimal integer indicating an error cursor position as an index into the original statement string.
|
578
|
+
*
|
579
|
+
* The first character has index 1, and positions are measured in characters not bytes.
|
573
580
|
*/
|
574
|
-
|
575
581
|
rb_define_const(rb_mPGconstants, "PG_DIAG_STATEMENT_POSITION", INT2FIX(PG_DIAG_STATEMENT_POSITION));
|
576
|
-
/* #result_error_field argument constant
|
577
|
-
*
|
578
|
-
* position refers to an internally generated command rather than the
|
579
|
-
*
|
580
|
-
* always appear when this eld appears.
|
582
|
+
/* Result#result_error_field argument constant
|
583
|
+
*
|
584
|
+
* This is defined the same as the PG_DIAG_STATEMENT_POSITION field, but it is used when the cursor position refers to an internally generated command rather than the one submitted by the client.
|
585
|
+
* The PG_DIAG_INTERNAL_QUERY field will always appear when this field appears.
|
581
586
|
*/
|
582
|
-
|
583
587
|
rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_POSITION", INT2FIX(PG_DIAG_INTERNAL_POSITION));
|
584
|
-
/* #result_error_field argument constant
|
585
|
-
*
|
586
|
-
*
|
588
|
+
/* Result#result_error_field argument constant
|
589
|
+
*
|
590
|
+
* The text of a failed internally-generated command.
|
591
|
+
* This could be, for example, a SQL query issued by a PL/pgSQL function.
|
587
592
|
*/
|
588
|
-
|
589
593
|
rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_QUERY", INT2FIX(PG_DIAG_INTERNAL_QUERY));
|
590
|
-
/* #result_error_field argument constant
|
591
|
-
*
|
592
|
-
*
|
593
|
-
*
|
594
|
+
/* Result#result_error_field argument constant
|
595
|
+
*
|
596
|
+
* An indication of the context in which the error occurred.
|
597
|
+
* Presently this includes a call stack traceback of active procedural language functions and internally-generated queries.
|
598
|
+
* The trace is one entry per line, most recent first.
|
594
599
|
*/
|
595
|
-
|
596
600
|
rb_define_const(rb_mPGconstants, "PG_DIAG_CONTEXT", INT2FIX(PG_DIAG_CONTEXT));
|
597
|
-
/* #result_error_field argument constant
|
598
|
-
*
|
601
|
+
/* Result#result_error_field argument constant
|
602
|
+
*
|
603
|
+
* The file name of the source-code location where the error was reported. */
|
599
604
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FILE", INT2FIX(PG_DIAG_SOURCE_FILE));
|
600
605
|
|
601
|
-
/* #result_error_field argument constant
|
602
|
-
*
|
606
|
+
/* Result#result_error_field argument constant
|
607
|
+
*
|
608
|
+
* The line number of the source-code location where the error was reported. */
|
603
609
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_LINE", INT2FIX(PG_DIAG_SOURCE_LINE));
|
604
610
|
|
605
|
-
/* #result_error_field argument constant
|
606
|
-
*
|
611
|
+
/* Result#result_error_field argument constant
|
612
|
+
*
|
613
|
+
* The name of the source-code function reporting the error. */
|
607
614
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FUNCTION", INT2FIX(PG_DIAG_SOURCE_FUNCTION));
|
608
615
|
|
609
|
-
#ifdef
|
610
|
-
/* #result_error_field argument constant
|
611
|
-
*
|
616
|
+
#ifdef PG_DIAG_TABLE_NAME
|
617
|
+
/* Result#result_error_field argument constant
|
618
|
+
*
|
619
|
+
* If the error was associated with a specific database object, the name of the schema containing that object, if any. */
|
612
620
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SCHEMA_NAME", INT2FIX(PG_DIAG_SCHEMA_NAME));
|
613
621
|
|
614
|
-
/* #result_error_field argument constant
|
615
|
-
*
|
616
|
-
*
|
622
|
+
/* Result#result_error_field argument constant
|
623
|
+
*
|
624
|
+
* If the error was associated with a specific table, the name of the table.
|
625
|
+
* (When this field is present, the schema name field provides the name of the table's schema.) */
|
617
626
|
rb_define_const(rb_mPGconstants, "PG_DIAG_TABLE_NAME", INT2FIX(PG_DIAG_TABLE_NAME));
|
618
627
|
|
619
|
-
/* #result_error_field argument constant
|
620
|
-
*
|
621
|
-
*
|
628
|
+
/* Result#result_error_field argument constant
|
629
|
+
*
|
630
|
+
* If the error was associated with a specific table column, the name of the column.
|
631
|
+
* (When this field is present, the schema and table name fields identify the table.) */
|
622
632
|
rb_define_const(rb_mPGconstants, "PG_DIAG_COLUMN_NAME", INT2FIX(PG_DIAG_COLUMN_NAME));
|
623
633
|
|
624
|
-
/* #result_error_field argument constant
|
625
|
-
*
|
626
|
-
*
|
634
|
+
/* Result#result_error_field argument constant
|
635
|
+
*
|
636
|
+
* If the error was associated with a specific datatype, the name of the datatype.
|
637
|
+
* (When this field is present, the schema name field provides the name of the datatype's schema.) */
|
627
638
|
rb_define_const(rb_mPGconstants, "PG_DIAG_DATATYPE_NAME", INT2FIX(PG_DIAG_DATATYPE_NAME));
|
628
639
|
|
629
|
-
/* #result_error_field argument constant
|
630
|
-
*
|
631
|
-
*
|
632
|
-
*
|
633
|
-
* constraint syntax.) */
|
640
|
+
/* Result#result_error_field argument constant
|
641
|
+
*
|
642
|
+
* If the error was associated with a specific constraint, the name of the constraint.
|
643
|
+
* The table or domain that the constraint belongs to is reported using the fields listed above.
|
644
|
+
* (For this purpose, indexes are treated as constraints, even if they weren't created with constraint syntax.) */
|
634
645
|
rb_define_const(rb_mPGconstants, "PG_DIAG_CONSTRAINT_NAME", INT2FIX(PG_DIAG_CONSTRAINT_NAME));
|
635
646
|
#endif
|
636
647
|
|
@@ -641,9 +652,7 @@ Init_pg_ext()
|
|
641
652
|
/* Add the constants to the toplevel namespace */
|
642
653
|
rb_include_module( rb_mPG, rb_mPGconstants );
|
643
654
|
|
644
|
-
#ifdef M17N_SUPPORTED
|
645
655
|
enc_pg2ruby = st_init_numtable();
|
646
|
-
#endif
|
647
656
|
|
648
657
|
/* Initialize the main extension classes */
|
649
658
|
init_pg_connection();
|
@@ -662,5 +671,7 @@ Init_pg_ext()
|
|
662
671
|
init_pg_binary_encoder();
|
663
672
|
init_pg_binary_decoder();
|
664
673
|
init_pg_copycoder();
|
674
|
+
init_pg_recordcoder();
|
675
|
+
init_pg_tuple();
|
665
676
|
}
|
666
677
|
|