pg 0.18.0 → 1.1.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/BSDL +2 -2
- data/ChangeLog +1221 -4
- data/History.rdoc +200 -0
- data/Manifest.txt +5 -18
- data/README-Windows.rdoc +15 -26
- data/README.rdoc +27 -10
- data/Rakefile +33 -24
- data/Rakefile.cross +57 -39
- data/ext/errorcodes.def +37 -0
- data/ext/errorcodes.rb +1 -1
- data/ext/errorcodes.txt +16 -1
- data/ext/extconf.rb +29 -35
- data/ext/gvl_wrappers.c +4 -0
- data/ext/gvl_wrappers.h +27 -39
- data/ext/pg.c +27 -53
- data/ext/pg.h +66 -83
- data/ext/pg_binary_decoder.c +75 -6
- data/ext/pg_binary_encoder.c +14 -12
- data/ext/pg_coder.c +83 -13
- data/ext/pg_connection.c +627 -351
- data/ext/pg_copy_coder.c +44 -9
- data/ext/pg_result.c +364 -134
- data/ext/pg_text_decoder.c +605 -46
- data/ext/pg_text_encoder.c +95 -76
- data/ext/pg_tuple.c +541 -0
- data/ext/pg_type_map.c +20 -13
- data/ext/pg_type_map_by_column.c +7 -7
- data/ext/pg_type_map_by_mri_type.c +2 -2
- data/ext/pg_type_map_in_ruby.c +4 -7
- data/ext/util.c +7 -7
- data/ext/util.h +3 -3
- data/lib/pg/basic_type_mapping.rb +105 -45
- data/lib/pg/binary_decoder.rb +22 -0
- data/lib/pg/coder.rb +1 -1
- data/lib/pg/connection.rb +109 -39
- data/lib/pg/constants.rb +1 -1
- data/lib/pg/exceptions.rb +1 -1
- data/lib/pg/result.rb +11 -6
- data/lib/pg/text_decoder.rb +25 -20
- data/lib/pg/text_encoder.rb +43 -1
- data/lib/pg/tuple.rb +30 -0
- data/lib/pg/type_map_by_column.rb +1 -1
- data/lib/pg.rb +21 -11
- data/spec/helpers.rb +50 -25
- data/spec/pg/basic_type_mapping_spec.rb +287 -30
- data/spec/pg/connection_spec.rb +695 -282
- data/spec/pg/connection_sync_spec.rb +41 -0
- data/spec/pg/result_spec.rb +59 -17
- data/spec/pg/tuple_spec.rb +280 -0
- data/spec/pg/type_map_by_class_spec.rb +3 -3
- data/spec/pg/type_map_by_column_spec.rb +1 -1
- data/spec/pg/type_map_by_mri_type_spec.rb +2 -2
- data/spec/pg/type_map_by_oid_spec.rb +1 -1
- 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 +319 -35
- data/spec/pg_spec.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +68 -68
- 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/Rakefile.cross
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# -*- rake -*-
|
2
2
|
|
3
3
|
require 'uri'
|
4
4
|
require 'tempfile'
|
@@ -21,17 +21,28 @@ end
|
|
21
21
|
class CrossLibrary < OpenStruct
|
22
22
|
include Rake::DSL
|
23
23
|
|
24
|
-
def initialize(for_platform, openssl_config)
|
24
|
+
def initialize(for_platform, openssl_config, toolchain)
|
25
25
|
super()
|
26
26
|
|
27
27
|
self.for_platform = for_platform
|
28
28
|
self.openssl_config = openssl_config
|
29
|
+
self.host_platform = toolchain
|
29
30
|
|
30
31
|
# Cross-compilation constants
|
31
|
-
self.openssl_version = ENV['OPENSSL_VERSION'] || '1.
|
32
|
-
self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '
|
33
|
-
|
34
|
-
|
32
|
+
self.openssl_version = ENV['OPENSSL_VERSION'] || '1.1.1a'
|
33
|
+
self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '11.1'
|
34
|
+
|
35
|
+
# Check if symlinks work in the current working directory.
|
36
|
+
# This fails, if rake-compiler-dock is running on a Windows box.
|
37
|
+
begin
|
38
|
+
FileUtils.rm_f '.test_symlink'
|
39
|
+
FileUtils.ln_s '/', '.test_symlink'
|
40
|
+
rescue SystemCallError
|
41
|
+
# Symlinks don't work -> use home directory instead
|
42
|
+
self.compile_home = Pathname( "~/.ruby-pg-build" ).expand_path
|
43
|
+
else
|
44
|
+
self.compile_home = Pathname( "./build" ).expand_path
|
45
|
+
end
|
35
46
|
self.static_sourcesdir = compile_home + 'sources'
|
36
47
|
self.static_builddir = compile_home + 'builds' + for_platform
|
37
48
|
|
@@ -43,8 +54,8 @@ class CrossLibrary < OpenStruct
|
|
43
54
|
self.openssl_tarball = static_sourcesdir + File.basename( openssl_source_uri.path )
|
44
55
|
self.openssl_makefile = static_openssl_builddir + 'Makefile'
|
45
56
|
|
46
|
-
self.
|
47
|
-
self.
|
57
|
+
self.libssl = static_openssl_builddir + 'libssl.a'
|
58
|
+
self.libcrypto = static_openssl_builddir + 'libcrypto.a'
|
48
59
|
|
49
60
|
self.openssl_patches = Rake::FileList[ (MISCDIR + "openssl-#{openssl_version}.*.patch").to_s ]
|
50
61
|
|
@@ -67,23 +78,10 @@ class CrossLibrary < OpenStruct
|
|
67
78
|
self.postgresql_lib = static_postgresql_libdir + 'libpq.dll'
|
68
79
|
self.postgresql_patches = Rake::FileList[ (MISCDIR + "postgresql-#{postgresql_version}.*.patch").to_s ]
|
69
80
|
|
70
|
-
# Use rake-compilers config.yml to determine the toolchain that was used
|
71
|
-
# to build Ruby for this platform.
|
72
|
-
self.host_platform = begin
|
73
|
-
config_file = YAML.load_file(File.expand_path("~/.rake-compiler/config.yml"))
|
74
|
-
_, rbfile = config_file.find{|key, fname| key.start_with?("rbconfig-#{for_platform}-") }
|
75
|
-
IO.read(rbfile).match(/CONFIG\["CC"\] = "(.*)"/)[1].sub(/\-gcc/, '')
|
76
|
-
rescue
|
77
|
-
nil
|
78
|
-
end
|
79
|
-
|
80
|
-
|
81
81
|
# clean intermediate files and folders
|
82
82
|
CLEAN.include( static_builddir.to_s )
|
83
83
|
|
84
84
|
|
85
|
-
ENV['RUBY_CC_VERSION'] ||= '1.9.3:2.0.0'
|
86
|
-
|
87
85
|
def download(url, save_to)
|
88
86
|
part = save_to+".part"
|
89
87
|
sh "wget #{url.to_s.inspect} -O #{part.inspect} || curl #{url.to_s.inspect} -o #{part.inspect}"
|
@@ -126,11 +124,9 @@ class CrossLibrary < OpenStruct
|
|
126
124
|
end
|
127
125
|
|
128
126
|
self.cmd_prelude = [
|
129
|
-
|
130
|
-
"
|
127
|
+
"env",
|
128
|
+
"CROSS_COMPILE=#{host_platform}-",
|
131
129
|
"CFLAGS=-DDSO_WIN32",
|
132
|
-
"AR=#{host_platform}-ar",
|
133
|
-
"RANLIB=#{host_platform}-ranlib"
|
134
130
|
]
|
135
131
|
|
136
132
|
|
@@ -145,7 +141,7 @@ class CrossLibrary < OpenStruct
|
|
145
141
|
end
|
146
142
|
|
147
143
|
desc "compile static openssl libraries"
|
148
|
-
task :openssl_libs => [
|
144
|
+
task :openssl_libs => [ libssl, libcrypto ]
|
149
145
|
|
150
146
|
task :compile_static_openssl => openssl_makefile do |t|
|
151
147
|
chdir( static_openssl_builddir ) do
|
@@ -156,14 +152,14 @@ class CrossLibrary < OpenStruct
|
|
156
152
|
end
|
157
153
|
end
|
158
154
|
|
159
|
-
desc "compile static #{
|
160
|
-
file
|
161
|
-
|
155
|
+
desc "compile static #{libssl}"
|
156
|
+
file libssl => :compile_static_openssl do |t|
|
157
|
+
rm t.name.gsub(/\.a$/, ".dll.a")
|
162
158
|
end
|
163
159
|
|
164
|
-
desc "compile static #{
|
165
|
-
file
|
166
|
-
|
160
|
+
desc "compile static #{libcrypto}"
|
161
|
+
file libcrypto => :compile_static_openssl do |t|
|
162
|
+
rm t.name.gsub(/\.a$/, ".dll.a")
|
167
163
|
end
|
168
164
|
|
169
165
|
|
@@ -207,7 +203,7 @@ class CrossLibrary < OpenStruct
|
|
207
203
|
cmd << "CFLAGS=-L#{static_openssl_builddir}"
|
208
204
|
cmd << "LDFLAGS=-L#{static_openssl_builddir}"
|
209
205
|
cmd << "LDFLAGS_SL=-L#{static_openssl_builddir}"
|
210
|
-
cmd << "LIBS=-lwsock32 -lgdi32"
|
206
|
+
cmd << "LIBS=-lwsock32 -lgdi32 -lws2_32"
|
211
207
|
cmd << "CPPFLAGS=-I#{static_openssl_builddir}/include"
|
212
208
|
|
213
209
|
run( *cmd )
|
@@ -217,11 +213,16 @@ class CrossLibrary < OpenStruct
|
|
217
213
|
|
218
214
|
# make libpq.dll
|
219
215
|
task postgresql_lib => [ postgresql_global_makefile ] do |t|
|
216
|
+
# Work around missing dependency to libcommon in PostgreSQL-9.4.0
|
217
|
+
chdir( static_postgresql_srcdir + "common" ) do
|
218
|
+
sh 'make', "-j#{NUM_CPUS}"
|
219
|
+
end
|
220
|
+
|
220
221
|
chdir( postgresql_lib.dirname ) do
|
221
222
|
sh 'make',
|
222
223
|
"-j#{NUM_CPUS}",
|
223
224
|
postgresql_lib.basename.to_s,
|
224
|
-
'SHLIB_LINK=-
|
225
|
+
'SHLIB_LINK=-lssl -lcrypto -lcrypt32 -lgdi32 -lsecur32 -lwsock32 -lws2_32'
|
225
226
|
end
|
226
227
|
end
|
227
228
|
|
@@ -230,7 +231,7 @@ class CrossLibrary < OpenStruct
|
|
230
231
|
task :libpq => postgresql_lib
|
231
232
|
|
232
233
|
# copy libpq.dll to lib dir
|
233
|
-
dest_libpq = "lib/#{
|
234
|
+
dest_libpq = "lib/#{postgresql_lib.basename}"
|
234
235
|
directory File.dirname(dest_libpq)
|
235
236
|
file dest_libpq => [postgresql_lib, File.dirname(dest_libpq)] do
|
236
237
|
cp postgresql_lib, dest_libpq
|
@@ -246,10 +247,10 @@ end
|
|
246
247
|
|
247
248
|
if File.exist?(File.expand_path("~/.rake-compiler/config.yml"))
|
248
249
|
CrossLibraries = [
|
249
|
-
['i386-mingw32', 'mingw'],
|
250
|
-
['x64-mingw32', 'mingw64'],
|
251
|
-
].map do |platform, openssl_config|
|
252
|
-
CrossLibrary.new platform, openssl_config
|
250
|
+
['i386-mingw32', 'mingw', 'i686-w64-mingw32'],
|
251
|
+
['x64-mingw32', 'mingw64', 'x86_64-w64-mingw32'],
|
252
|
+
].map do |platform, openssl_config, toolchain|
|
253
|
+
CrossLibrary.new platform, openssl_config, toolchain
|
253
254
|
end
|
254
255
|
else
|
255
256
|
$stderr.puts "Cross-compilation disabled -- rake-compiler not properly installed"
|
@@ -278,3 +279,20 @@ ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
|
|
278
279
|
sh "x86_64-w64-mingw32-strip -S tmp/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/pg_ext.so"
|
279
280
|
end
|
280
281
|
end
|
282
|
+
|
283
|
+
desc "Build the windows binary gems"
|
284
|
+
task 'gem:windows' => ['ChangeLog'] do
|
285
|
+
require 'rake_compiler_dock'
|
286
|
+
|
287
|
+
# Copy gem signing key and certs to be accessable from the docker container
|
288
|
+
mkdir_p 'build/gem'
|
289
|
+
sh "cp ~/.gem/gem-*.pem build/gem/ || true"
|
290
|
+
sh "bundle package"
|
291
|
+
|
292
|
+
RakeCompilerDock.sh <<-EOT
|
293
|
+
mkdir ~/.gem &&
|
294
|
+
(cp build/gem/gem-*.pem ~/.gem/ || true) &&
|
295
|
+
bundle install --local &&
|
296
|
+
rake cross native gem MAKE="make -j`nproc`"
|
297
|
+
EOT
|
298
|
+
end
|
data/ext/errorcodes.def
CHANGED
@@ -186,6 +186,10 @@
|
|
186
186
|
VALUE klass = define_error_class( "InvalidParameterValue", "22" );
|
187
187
|
register_error_class( "22023", klass );
|
188
188
|
}
|
189
|
+
{
|
190
|
+
VALUE klass = define_error_class( "InvalidPrecedingOrFollowingSize", "22" );
|
191
|
+
register_error_class( "22013", klass );
|
192
|
+
}
|
189
193
|
{
|
190
194
|
VALUE klass = define_error_class( "InvalidRegularExpression", "22" );
|
191
195
|
register_error_class( "2201B", klass );
|
@@ -198,6 +202,14 @@
|
|
198
202
|
VALUE klass = define_error_class( "InvalidRowCountInResultOffsetClause", "22" );
|
199
203
|
register_error_class( "2201X", klass );
|
200
204
|
}
|
205
|
+
{
|
206
|
+
VALUE klass = define_error_class( "InvalidTablesampleArgument", "22" );
|
207
|
+
register_error_class( "2202H", klass );
|
208
|
+
}
|
209
|
+
{
|
210
|
+
VALUE klass = define_error_class( "InvalidTablesampleRepeat", "22" );
|
211
|
+
register_error_class( "2202G", klass );
|
212
|
+
}
|
201
213
|
{
|
202
214
|
VALUE klass = define_error_class( "InvalidTimeZoneDisplacementValue", "22" );
|
203
215
|
register_error_class( "22009", klass );
|
@@ -222,6 +234,10 @@
|
|
222
234
|
VALUE klass = define_error_class( "NumericValueOutOfRange", "22" );
|
223
235
|
register_error_class( "22003", klass );
|
224
236
|
}
|
237
|
+
{
|
238
|
+
VALUE klass = define_error_class( "SequenceGeneratorLimitExceeded", "22" );
|
239
|
+
register_error_class( "2200H", klass );
|
240
|
+
}
|
225
241
|
{
|
226
242
|
VALUE klass = define_error_class( "StringDataLengthMismatch", "22" );
|
227
243
|
register_error_class( "22026", klass );
|
@@ -365,6 +381,10 @@
|
|
365
381
|
VALUE klass = define_error_class( "InFailedSqlTransaction", "25" );
|
366
382
|
register_error_class( "25P02", klass );
|
367
383
|
}
|
384
|
+
{
|
385
|
+
VALUE klass = define_error_class( "IdleInTransactionSessionTimeout", "25" );
|
386
|
+
register_error_class( "25P03", klass );
|
387
|
+
}
|
368
388
|
{
|
369
389
|
VALUE klass = define_error_class( "InvalidSqlStatementName", NULL );
|
370
390
|
register_error_class( "26000", klass );
|
@@ -466,6 +486,10 @@
|
|
466
486
|
VALUE klass = define_error_class( "ERIESrfProtocolViolated", "39" );
|
467
487
|
register_error_class( "39P02", klass );
|
468
488
|
}
|
489
|
+
{
|
490
|
+
VALUE klass = define_error_class( "ERIEEventTriggerProtocolViolated", "39" );
|
491
|
+
register_error_class( "39P03", klass );
|
492
|
+
}
|
469
493
|
{
|
470
494
|
VALUE klass = define_error_class( "SavepointException", NULL );
|
471
495
|
register_error_class( "3B000", klass );
|
@@ -571,6 +595,10 @@
|
|
571
595
|
VALUE klass = define_error_class( "WrongObjectType", "42" );
|
572
596
|
register_error_class( "42809", klass );
|
573
597
|
}
|
598
|
+
{
|
599
|
+
VALUE klass = define_error_class( "GeneratedAlways", "42" );
|
600
|
+
register_error_class( "428C9", klass );
|
601
|
+
}
|
574
602
|
{
|
575
603
|
VALUE klass = define_error_class( "UndefinedColumn", "42" );
|
576
604
|
register_error_class( "42703", klass );
|
@@ -781,6 +809,11 @@
|
|
781
809
|
VALUE klass = define_error_class( "DuplicateFile", "58" );
|
782
810
|
register_error_class( "58P02", klass );
|
783
811
|
}
|
812
|
+
{
|
813
|
+
VALUE klass = define_error_class( "SnapshotTooOld", NULL );
|
814
|
+
register_error_class( "72000", klass );
|
815
|
+
register_error_class( "72", klass );
|
816
|
+
}
|
784
817
|
{
|
785
818
|
VALUE klass = define_error_class( "ConfigFileError", NULL );
|
786
819
|
register_error_class( "F0000", klass );
|
@@ -916,6 +949,10 @@
|
|
916
949
|
VALUE klass = define_error_class( "TooManyRows", "P0" );
|
917
950
|
register_error_class( "P0003", klass );
|
918
951
|
}
|
952
|
+
{
|
953
|
+
VALUE klass = define_error_class( "AssertFailure", "P0" );
|
954
|
+
register_error_class( "P0004", klass );
|
955
|
+
}
|
919
956
|
{
|
920
957
|
VALUE klass = define_error_class( "InternalError", NULL );
|
921
958
|
register_error_class( "XX000", klass );
|
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-2018, 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,6 +15,9 @@
|
|
15
15
|
# src/pl/plpgsql/src/plerrcodes.h
|
16
16
|
# a list of PL/pgSQL condition names and their SQLSTATE codes
|
17
17
|
#
|
18
|
+
# src/pl/tcl/pltclerrcodes.h
|
19
|
+
# the same, for PL/Tcl
|
20
|
+
#
|
18
21
|
# doc/src/sgml/errcodes-list.sgml
|
19
22
|
# a SGML table of error codes for inclusion in the documentation
|
20
23
|
#
|
@@ -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
|
@@ -227,6 +234,7 @@ Section: Class 25 - Invalid Transaction State
|
|
227
234
|
25007 E ERRCODE_SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED schema_and_data_statement_mixing_not_supported
|
228
235
|
25P01 E ERRCODE_NO_ACTIVE_SQL_TRANSACTION no_active_sql_transaction
|
229
236
|
25P02 E ERRCODE_IN_FAILED_SQL_TRANSACTION in_failed_sql_transaction
|
237
|
+
25P03 E ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT idle_in_transaction_session_timeout
|
230
238
|
|
231
239
|
Section: Class 26 - Invalid SQL Statement Name
|
232
240
|
|
@@ -278,6 +286,7 @@ Section: Class 39 - External Routine Invocation Exception
|
|
278
286
|
39004 E ERRCODE_E_R_I_E_NULL_VALUE_NOT_ALLOWED null_value_not_allowed
|
279
287
|
39P01 E ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED trigger_protocol_violated
|
280
288
|
39P02 E ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED srf_protocol_violated
|
289
|
+
39P03 E ERRCODE_E_R_I_E_EVENT_TRIGGER_PROTOCOL_VIOLATED event_trigger_protocol_violated
|
281
290
|
|
282
291
|
Section: Class 3B - Savepoint Exception
|
283
292
|
|
@@ -319,6 +328,7 @@ Section: Class 42 - Syntax Error or Access Rule Violation
|
|
319
328
|
42P21 E ERRCODE_COLLATION_MISMATCH collation_mismatch
|
320
329
|
42P22 E ERRCODE_INDETERMINATE_COLLATION indeterminate_collation
|
321
330
|
42809 E ERRCODE_WRONG_OBJECT_TYPE wrong_object_type
|
331
|
+
428C9 E ERRCODE_GENERATED_ALWAYS generated_always
|
322
332
|
|
323
333
|
# Note: for ERRCODE purposes, we divide namable objects into these categories:
|
324
334
|
# databases, schemas, prepared statements, cursors, tables, columns,
|
@@ -410,6 +420,10 @@ Section: Class 58 - System Error (errors external to PostgreSQL itself)
|
|
410
420
|
58P01 E ERRCODE_UNDEFINED_FILE undefined_file
|
411
421
|
58P02 E ERRCODE_DUPLICATE_FILE duplicate_file
|
412
422
|
|
423
|
+
Section: Class 72 - Snapshot Failure
|
424
|
+
# (class borrowed from Oracle)
|
425
|
+
72000 E ERRCODE_SNAPSHOT_TOO_OLD snapshot_too_old
|
426
|
+
|
413
427
|
Section: Class F0 - Configuration File Error
|
414
428
|
|
415
429
|
# (PostgreSQL-specific error class)
|
@@ -454,6 +468,7 @@ P0000 E ERRCODE_PLPGSQL_ERROR plp
|
|
454
468
|
P0001 E ERRCODE_RAISE_EXCEPTION raise_exception
|
455
469
|
P0002 E ERRCODE_NO_DATA_FOUND no_data_found
|
456
470
|
P0003 E ERRCODE_TOO_MANY_ROWS too_many_rows
|
471
|
+
P0004 E ERRCODE_ASSERT_FAILURE assert_failure
|
457
472
|
|
458
473
|
Section: Class XX - Internal Error
|
459
474
|
|
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,34 @@ 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 'PQisthreadsafe'
|
61
|
-
have_func 'PQprepare'
|
62
|
-
have_func 'PQexecParams'
|
63
|
-
have_func 'PQescapeString'
|
64
|
-
have_func 'PQescapeStringConn'
|
65
|
-
have_func 'PQescapeLiteral'
|
66
|
-
have_func 'PQescapeIdentifier'
|
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
|
+
"of this gem or upgrade your database to at least PostgreSQL-9.2."
|
75
76
|
have_func 'PQconninfo'
|
76
|
-
have_func '
|
77
|
-
|
78
|
-
have_func '
|
79
|
-
have_func '
|
80
|
-
have_func 'rb_thread_call_without_gvl'
|
81
|
-
have_func 'rb_thread_call_with_gvl'
|
82
|
-
have_func 'rb_thread_fd_select'
|
83
|
-
have_func 'rb_w32_wrap_io_handle'
|
84
|
-
have_func 'rb_str_modify_expand'
|
85
|
-
have_func 'rb_hash_dup'
|
86
|
-
|
87
|
-
have_const 'PGRES_COPY_BOTH', 'libpq-fe.h'
|
88
|
-
have_const 'PGRES_SINGLE_TUPLE', 'libpq-fe.h'
|
89
|
-
have_const 'PG_DIAG_TABLE_NAME', 'libpq-fe.h'
|
77
|
+
have_func 'PQsslAttribute'
|
78
|
+
have_func 'PQencryptPasswordConn'
|
79
|
+
have_func 'timegm'
|
80
|
+
have_func 'rb_gc_adjust_memory_usage'
|
90
81
|
|
91
|
-
|
92
|
-
have_struct_member 'struct pgNotify', 'extra', 'libpq-fe.h'
|
82
|
+
have_const 'PG_DIAG_TABLE_NAME', 'libpq-fe.h'
|
93
83
|
|
94
84
|
# unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
|
95
85
|
have_header 'unistd.h'
|
96
|
-
have_header '
|
86
|
+
have_header 'inttypes.h'
|
87
|
+
|
88
|
+
checking_for "C99 variable length arrays" do
|
89
|
+
$defs.push( "-DHAVE_VARIABLE_LENGTH_ARRAYS" ) if try_compile('void test_vla(int l){ int vla[l]; }')
|
90
|
+
end
|
97
91
|
|
98
92
|
create_header()
|
99
93
|
create_makefile( "pg_ext" )
|
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
|
|