pg 0.21.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d459edbf441a30095d92512f986194a7e183efe9
4
- data.tar.gz: 90ba3a4e5b506aa68d9addab7e8af76f5efcee8e
2
+ SHA256:
3
+ metadata.gz: 00baf07c6fd4d371d287ca8209c0db01b5de5477b62dd00e07c34b4000be3b20
4
+ data.tar.gz: 629daf0e7785a7cc67fdf41852462cb3e02946399b6bfb78dc63e889c28e2a72
5
5
  SHA512:
6
- metadata.gz: 0212d8cb8cd8a29ab8f120d6d1c4a90087107fd273785b53fa6b59e1583c48eb350420a53132a51ab6e9c1d10ccb821fa2924b850b14fbf8a759fe915d73251b
7
- data.tar.gz: b3bbd17f06fb3ab2a7864bbdeeead245c7f47348c618e39fb732f20b58f46591bac774844438fe410c96fbd460dbaa204c705e1617d62a4c74d3da18e425c001
6
+ metadata.gz: 608978950994657749109e344e33b83704a26c367bb551d8d2095b335e1a5102426e7d212a2213c19439d5fa3e6087d8fddd7401102e1e7f2ec3cf2fd32627ec
7
+ data.tar.gz: 863a7b7a83d245ab52a774769e295edb57a77e2811fb5bfda2c3fd067242696294d1b0d08216ef3dd9ad5e27ed539cad7ec2096d047c18dc949d4107a957b5e1
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,28 @@
1
+ == v1.0.0 [2018-01-10] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Deprecated:
4
+ - Deprecate Ruby older than 2.2.
5
+ - Deprecate Connection#socket in favor of #socket_io.
6
+
7
+ Removed:
8
+ - Remove compatibility code for Ruby < 2.0 and PostgreSQL < 9.2.
9
+ - Remove partial compatibility with Rubinius.
10
+
11
+ Enhancements:
12
+ - Update error codes to PostgreSQL-10
13
+ - Update Windows binary gems to Ruby-2.5, PostgreSQL 10.1 and
14
+ OpenSSL 1.1.0g.
15
+
16
+ Bugfixes:
17
+ - Fix URI detection for connection strings. #265 (thanks to jjoos)
18
+ - MINGW: Workaround segfault due to GCC linker error in conjunction with MSVC.
19
+ This happens when linking to PostgreSQL-10.0-x64 from EnterpriseDB.
20
+
21
+ Documentation fixes:
22
+ - Add PostgreSQL version since when the given function is supported. #263
23
+ - Better documentation to `encoder` and `decoder` arguments of COPY related methods.
24
+
25
+
1
26
  == v0.21.0 [2017-06-12] Michael Granger <ged@FaerieMUD.org>
2
27
 
3
28
  Enhancements:
@@ -10,6 +35,9 @@ Enhancements:
10
35
  Documentation fixes:
11
36
  - Update the docs for PG::Result#cmd_tuples
12
37
 
38
+ New Samples:
39
+ - Add an example of the nicer #copy_data way of doing `COPY`.
40
+
13
41
 
14
42
  == v0.20.0 [2017-03-10] Michael Granger <ged@FaerieMUD.org>
15
43
 
@@ -46,7 +46,6 @@ lib/pg/basic_type_mapping.rb
46
46
  lib/pg/coder.rb
47
47
  lib/pg/connection.rb
48
48
  lib/pg/constants.rb
49
- lib/pg/deprecated_constants.rb
50
49
  lib/pg/exceptions.rb
51
50
  lib/pg/result.rb
52
51
  lib/pg/text_decoder.rb
@@ -11,7 +11,7 @@ docs :: http://deveiate.org/code/pg
11
11
 
12
12
  Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
13
13
 
14
- It works with {PostgreSQL 9.1 and later}[http://www.postgresql.org/support/versioning/].
14
+ It works with {PostgreSQL 9.2 and later}[http://www.postgresql.org/support/versioning/].
15
15
 
16
16
  A small example usage:
17
17
 
@@ -37,8 +37,8 @@ A small example usage:
37
37
 
38
38
  == Requirements
39
39
 
40
- * Ruby 2.2
41
- * PostgreSQL 9.1.x or later (with headers, -dev packages, etc).
40
+ * Ruby 2.2 or newer
41
+ * PostgreSQL 9.2.x or later (with headers, -dev packages, etc).
42
42
 
43
43
  It usually work with earlier versions of Ruby/PostgreSQL as well, but those are
44
44
  not regularly tested.
@@ -165,4 +165,3 @@ to this library over the years.
165
165
 
166
166
  We are thankful to the people at the ruby-list and ruby-dev mailing lists.
167
167
  And to the people who developed PostgreSQL.
168
-
data/Rakefile CHANGED
@@ -61,7 +61,7 @@ $hoespec = Hoe.spec 'pg' do
61
61
  self.developer 'Lars Kanis', 'lars@greiz-reinsdorf.de'
62
62
 
63
63
  self.dependency 'rake-compiler', '~> 1.0', :developer
64
- self.dependency 'rake-compiler-dock', '~> 0.6', :developer
64
+ self.dependency 'rake-compiler-dock', ['~> 0.6', '>= 0.6.2'], :developer
65
65
  self.dependency 'hoe-deveiate', '~> 0.9', :developer
66
66
  self.dependency 'hoe-bundler', '~> 1.0', :developer
67
67
  self.dependency 'rspec', '~> 3.5', :developer
@@ -105,8 +105,6 @@ task :maint do
105
105
  ENV['MAINTAINER_MODE'] = 'yes'
106
106
  end
107
107
 
108
- ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.2:2.0.0'
109
-
110
108
  # Rake-compiler task
111
109
  Rake::ExtensionTask.new do |ext|
112
110
  ext.name = 'pg_ext'
@@ -155,6 +153,7 @@ end
155
153
  file '.hg/branch' do
156
154
  warn "WARNING: You need the Mercurial repo to update the ChangeLog"
157
155
  end
156
+ Rake::Task["ChangeLog"].clear
158
157
  file 'ChangeLog' do |task|
159
158
  if File.exist?('.hg/branch')
160
159
  $stderr.puts "Updating the changelog..."
@@ -185,7 +184,7 @@ end
185
184
 
186
185
  desc "Update list of server error codes"
187
186
  task :update_error_codes do
188
- URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL9_6_1"
187
+ URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL_10_1"
189
188
 
190
189
  ERRORCODES_TXT = "ext/errorcodes.txt"
191
190
  sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
@@ -29,8 +29,8 @@ class CrossLibrary < OpenStruct
29
29
  self.host_platform = toolchain
30
30
 
31
31
  # Cross-compilation constants
32
- self.openssl_version = ENV['OPENSSL_VERSION'] || '1.0.2j'
33
- self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '9.6.2'
32
+ self.openssl_version = ENV['OPENSSL_VERSION'] || '1.1.0g'
33
+ self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '10.1'
34
34
 
35
35
  # Check if symlinks work in the current working directory.
36
36
  # This fails, if rake-compiler-dock is running on a Windows box.
@@ -54,8 +54,8 @@ class CrossLibrary < OpenStruct
54
54
  self.openssl_tarball = static_sourcesdir + File.basename( openssl_source_uri.path )
55
55
  self.openssl_makefile = static_openssl_builddir + 'Makefile'
56
56
 
57
- self.libssleay32 = static_openssl_builddir + 'libssleay32.a'
58
- self.libeay32 = static_openssl_builddir + 'libeay32.a'
57
+ self.libssl = static_openssl_builddir + 'libssl.a'
58
+ self.libcrypto = static_openssl_builddir + 'libcrypto.a'
59
59
 
60
60
  self.openssl_patches = Rake::FileList[ (MISCDIR + "openssl-#{openssl_version}.*.patch").to_s ]
61
61
 
@@ -82,8 +82,6 @@ class CrossLibrary < OpenStruct
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
- 'env',
130
- "CC=#{host_platform}-gcc",
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 => [ libssleay32, libeay32 ]
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 #{libeay32}"
160
- file libeay32 => :compile_static_openssl do |t|
161
- FileUtils.cp( static_openssl_builddir + 'libcrypto.a', libeay32.to_s )
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 #{libssleay32}"
165
- file libssleay32 => :compile_static_openssl do |t|
166
- FileUtils.cp( static_openssl_builddir + 'libssl.a', libssleay32.to_s )
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 )
@@ -226,7 +222,7 @@ class CrossLibrary < OpenStruct
226
222
  sh 'make',
227
223
  "-j#{NUM_CPUS}",
228
224
  postgresql_lib.basename.to_s,
229
- 'SHLIB_LINK=-lssleay32 -leay32 -lcrypt32 -lgdi32 -lsecur32 -lwsock32 -lws2_32'
225
+ 'SHLIB_LINK=-lssl -lcrypto -lcrypt32 -lgdi32 -lsecur32 -lwsock32 -lws2_32'
230
226
  end
231
227
  end
232
228
 
@@ -297,6 +293,6 @@ task 'gem:windows' => ['ChangeLog'] do
297
293
  mkdir ~/.gem &&
298
294
  (cp build/gem/gem-*.pem ~/.gem/ || true) &&
299
295
  bundle install --local &&
300
- rake cross native gem RUBY_CC_VERSION=2.4.0:2.3.0:2.2.2:2.1.6:2.0.0
296
+ rake cross native gem RUBY_CC_VERSION=2.5.0:2.4.0:2.3.0:2.2.2:2.1.6:2.0.0
301
297
  EOT
302
298
  end
@@ -230,6 +230,10 @@
230
230
  VALUE klass = define_error_class( "NumericValueOutOfRange", "22" );
231
231
  register_error_class( "22003", klass );
232
232
  }
233
+ {
234
+ VALUE klass = define_error_class( "SequenceGeneratorLimitExceeded", "22" );
235
+ register_error_class( "2200H", klass );
236
+ }
233
237
  {
234
238
  VALUE klass = define_error_class( "StringDataLengthMismatch", "22" );
235
239
  register_error_class( "22026", klass );
@@ -587,6 +591,10 @@
587
591
  VALUE klass = define_error_class( "WrongObjectType", "42" );
588
592
  register_error_class( "42809", klass );
589
593
  }
594
+ {
595
+ VALUE klass = define_error_class( "GeneratedAlways", "42" );
596
+ register_error_class( "428C9", klass );
597
+ }
590
598
  {
591
599
  VALUE klass = define_error_class( "UndefinedColumn", "42" );
592
600
  register_error_class( "42703", klass );
@@ -2,7 +2,7 @@
2
2
  # errcodes.txt
3
3
  # PostgreSQL error codes
4
4
  #
5
- # Copyright (c) 2003-2016, PostgreSQL Global Development Group
5
+ # Copyright (c) 2003-2017, 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
@@ -188,6 +188,7 @@ Section: Class 22 - Data Exception
188
188
  22004 E ERRCODE_NULL_VALUE_NOT_ALLOWED null_value_not_allowed
189
189
  22002 E ERRCODE_NULL_VALUE_NO_INDICATOR_PARAMETER null_value_no_indicator_parameter
190
190
  22003 E ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE numeric_value_out_of_range
191
+ 2200H E ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED sequence_generator_limit_exceeded
191
192
  22026 E ERRCODE_STRING_DATA_LENGTH_MISMATCH string_data_length_mismatch
192
193
  22001 E ERRCODE_STRING_DATA_RIGHT_TRUNCATION string_data_right_truncation
193
194
  22011 E ERRCODE_SUBSTRING_ERROR substring_error
@@ -326,6 +327,7 @@ Section: Class 42 - Syntax Error or Access Rule Violation
326
327
  42P21 E ERRCODE_COLLATION_MISMATCH collation_mismatch
327
328
  42P22 E ERRCODE_INDETERMINATE_COLLATION indeterminate_collation
328
329
  42809 E ERRCODE_WRONG_OBJECT_TYPE wrong_object_type
330
+ 428C9 E ERRCODE_GENERATED_ALWAYS generated_always
329
331
 
330
332
  # Note: for ERRCODE purposes, we divide namable objects into these categories:
331
333
  # databases, schemas, prepared statements, cursors, tables, columns,
@@ -60,48 +60,28 @@ abort "Can't find the PostgreSQL client library (libpq)" unless
60
60
  have_library( 'libpq', 'PQconnectdb', ['libpq-fe.h'] ) ||
61
61
  have_library( 'ms/libpq', 'PQconnectdb', ['libpq-fe.h'] )
62
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
+
63
72
  # optional headers/functions
64
- have_func 'PQconnectionUsedPassword' or
73
+ have_func 'PQsetSingleRowMode' or
65
74
  abort "Your PostgreSQL is too old. Either install an older version " +
66
- "of this gem or upgrade your database."
67
- have_func 'PQisthreadsafe'
68
- have_func 'PQprepare'
69
- have_func 'PQexecParams'
70
- have_func 'PQescapeString'
71
- have_func 'PQescapeStringConn'
72
- have_func 'PQescapeLiteral'
73
- have_func 'PQescapeIdentifier'
74
- have_func 'PQgetCancel'
75
- have_func 'lo_create'
76
- have_func 'pg_encoding_to_char'
77
- have_func 'pg_char_to_encoding'
78
- have_func 'PQsetClientEncoding'
79
- have_func 'PQlibVersion'
80
- have_func 'PQping'
81
- have_func 'PQsetSingleRowMode'
75
+ "of this gem or upgrade your database to at least PostgreSQL-9.2."
82
76
  have_func 'PQconninfo'
83
77
  have_func 'PQsslAttribute'
78
+ have_func 'PQencryptPasswordConn'
84
79
 
85
- have_func 'rb_encdb_alias'
86
- have_func 'rb_enc_alias'
87
- have_func 'rb_thread_call_without_gvl'
88
- have_func 'rb_thread_call_with_gvl'
89
- have_func 'rb_thread_fd_select'
90
- have_func 'rb_w32_wrap_io_handle'
91
- have_func 'rb_str_modify_expand'
92
- have_func 'rb_hash_dup'
93
-
94
- have_const 'PGRES_COPY_BOTH', 'libpq-fe.h'
95
- have_const 'PGRES_SINGLE_TUPLE', 'libpq-fe.h'
96
80
  have_const 'PG_DIAG_TABLE_NAME', 'libpq-fe.h'
97
81
 
98
- $defs.push( "-DHAVE_ST_NOTIFY_EXTRA" ) if
99
- have_struct_member 'struct pgNotify', 'extra', 'libpq-fe.h'
100
-
101
82
  # unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
102
83
  have_header 'unistd.h'
103
84
  have_header 'inttypes.h'
104
- have_header 'ruby/st.h' or have_header 'st.h' or abort "pg currently requires the ruby/st.h header"
105
85
 
106
86
  checking_for "C99 variable length arrays" do
107
87
  $defs.push( "-DHAVE_VARIABLE_LENGTH_ARRAYS" ) if try_compile('void test_vla(int l){ int vla[l]; }')
@@ -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 );
@@ -15,14 +15,7 @@
15
15
  #ifndef __gvl_wrappers_h
16
16
  #define __gvl_wrappers_h
17
17
 
18
- #if defined(HAVE_RB_THREAD_CALL_WITH_GVL)
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
- #if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL)
57
- #define DEFINE_GVL_STUB(name, when_non_void, rettype, lastparamtype, lastparamname) \
58
- rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname){ \
59
- struct gvl_wrapper_##name##_params params = { \
60
- {FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST1) lastparamname}, when_non_void((rettype)0) \
61
- }; \
62
- rb_thread_call_without_gvl(gvl_##name##_skeleton, &params, RUBY_UBF_IO, 0); \
63
- when_non_void( return params.retval; ) \
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, &params, 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
- #if defined(HAVE_RB_THREAD_CALL_WITH_GVL)
84
- #define DEFINE_GVLCB_STUB(name, when_non_void, rettype, lastparamtype, lastparamname) \
85
- rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname){ \
86
- struct gvl_wrapper_##name##_params params = { \
87
- {FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST1) lastparamname}, when_non_void((rettype)0) \
88
- }; \
89
- rb_thread_call_with_gvl(gvl_##name##_skeleton, &params); \
90
- when_non_void( return params.retval; ) \
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, &params); \
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
@@ -200,6 +179,11 @@ extern void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1,
200
179
 
201
180
  #define FOR_EACH_PARAM_OF_PQisBusy(param)
202
181
 
182
+ #define FOR_EACH_PARAM_OF_PQencryptPasswordConn(param) \
183
+ param(PGconn *, conn) \
184
+ param(const char *, passwd) \
185
+ param(const char *, user)
186
+
203
187
  #define FOR_EACH_PARAM_OF_PQcancel(param) \
204
188
  param(PGcancel *, cancel) \
205
189
  param(char *, errbuf)
@@ -231,9 +215,9 @@ extern void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1,
231
215
  function(PQsendDescribePortal, GVL_TYPE_NONVOID, int, const char *, portal) \
232
216
  function(PQsetClientEncoding, GVL_TYPE_NONVOID, int, const char *, encoding) \
233
217
  function(PQisBusy, GVL_TYPE_NONVOID, int, PGconn *, conn) \
218
+ function(PQencryptPasswordConn, GVL_TYPE_NONVOID, char *, const char *, algorithm) \
234
219
  function(PQcancel, GVL_TYPE_NONVOID, int, int, errbufsize);
235
220
 
236
-
237
221
  FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_STUB_DECL );
238
222
 
239
223
 
data/ext/pg.c CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * pg.c - Toplevel extension
3
- * $Id: pg.c,v c77d0997b4e4 2016/08/20 17:30:03 ged $
3
+ * $Id: pg.c,v 1f0926bfa9a5 2018/01/04 18:14:32 lars $
4
4
  *
5
5
  * Author/s:
6
6
  *
@@ -69,7 +69,6 @@ VALUE rb_mPGconstants;
69
69
  * M17n functions
70
70
  */
71
71
 
72
- #ifdef M17N_SUPPORTED
73
72
  /**
74
73
  * The mapping from canonical encoding names in PostgreSQL to ones in Ruby.
75
74
  */
@@ -144,7 +143,7 @@ pg_find_or_create_johab(void)
144
143
 
145
144
  enc_index = rb_define_dummy_encoding(aliases[0]);
146
145
  for (i = 1; i < sizeof(aliases)/sizeof(aliases[0]); ++i) {
147
- ENC_ALIAS(aliases[i], aliases[0]);
146
+ rb_encdb_alias(aliases[i], aliases[0]);
148
147
  }
149
148
  return rb_enc_from_index(enc_index);
150
149
  }
@@ -229,8 +228,6 @@ pg_get_rb_encoding_as_pg_encoding( rb_encoding *enc )
229
228
  return encname;
230
229
  }
231
230
 
232
- #endif /* M17N_SUPPORTED */
233
-
234
231
 
235
232
  /*
236
233
  * Ensures that the given string has enough capacity to take expand_len
@@ -260,45 +257,26 @@ pg_get_rb_encoding_as_pg_encoding( rb_encoding *enc )
260
257
  * rb_str_set_len( string, current_out - RSTRING_PTR(string) );
261
258
  *
262
259
  */
263
- #ifdef HAVE_RB_STR_MODIFY_EXPAND
264
- /* Use somewhat faster version with access to string capacity on MRI */
265
- char *
266
- pg_rb_str_ensure_capa( VALUE str, long expand_len, char *curr_ptr, char **end_ptr )
267
- {
268
- long curr_len = curr_ptr - RSTRING_PTR(str);
269
- long curr_capa = rb_str_capacity( str );
270
- if( curr_capa < curr_len + expand_len ){
271
- rb_str_set_len( str, curr_len );
272
- rb_str_modify_expand( str, (curr_len + expand_len) * 2 - curr_capa );
273
- curr_ptr = RSTRING_PTR(str) + curr_len;
274
- }
275
- if( end_ptr )
276
- *end_ptr = RSTRING_PTR(str) + rb_str_capacity( str );
277
- return curr_ptr;
278
- }
279
- #else
280
- /* Use the more portable version */
281
- char *
282
- pg_rb_str_ensure_capa( VALUE str, long expand_len, char *curr_ptr, char **end_ptr )
283
- {
284
- long curr_len = curr_ptr - RSTRING_PTR(str);
285
- long curr_capa = RSTRING_LEN( str );
286
- if( curr_capa < curr_len + expand_len ){
287
- rb_str_resize( str, (curr_len + expand_len) * 2 - curr_capa );
288
- curr_ptr = RSTRING_PTR(str) + curr_len;
289
- }
290
- if( end_ptr )
291
- *end_ptr = RSTRING_PTR(str) + RSTRING_LEN(str);
292
- return curr_ptr;
260
+ char *
261
+ pg_rb_str_ensure_capa( VALUE str, long expand_len, char *curr_ptr, char **end_ptr )
262
+ {
263
+ long curr_len = curr_ptr - RSTRING_PTR(str);
264
+ long curr_capa = rb_str_capacity( str );
265
+ if( curr_capa < curr_len + expand_len ){
266
+ rb_str_set_len( str, curr_len );
267
+ rb_str_modify_expand( str, (curr_len + expand_len) * 2 - curr_capa );
268
+ curr_ptr = RSTRING_PTR(str) + curr_len;
293
269
  }
294
- #endif
270
+ if( end_ptr )
271
+ *end_ptr = RSTRING_PTR(str) + rb_str_capacity( str );
272
+ return curr_ptr;
273
+ }
295
274
 
296
275
 
297
276
  /**************************************************************************
298
277
  * Module Methods
299
278
  **************************************************************************/
300
279
 
301
- #ifdef HAVE_PQLIBVERSION
302
280
  /*
303
281
  * call-seq:
304
282
  * PG.library_version -> Integer
@@ -316,7 +294,6 @@ pg_s_library_version(VALUE self)
316
294
  UNUSED( self );
317
295
  return INT2NUM(PQlibVersion());
318
296
  }
319
- #endif
320
297
 
321
298
 
322
299
  /*
@@ -410,9 +387,7 @@ Init_pg_ext()
410
387
  /*************************
411
388
  * PG module methods
412
389
  *************************/
413
- #ifdef HAVE_PQLIBVERSION
414
390
  rb_define_singleton_method( rb_mPG, "library_version", pg_s_library_version, 0 );
415
- #endif
416
391
  rb_define_singleton_method( rb_mPG, "isthreadsafe", pg_s_threadsafe_p, 0 );
417
392
  SINGLETON_ALIAS( rb_mPG, "is_threadsafe?", "isthreadsafe" );
418
393
  SINGLETON_ALIAS( rb_mPG, "threadsafe?", "isthreadsafe" );
@@ -478,7 +453,6 @@ Init_pg_ext()
478
453
  /* Verbose error verbosity level (#set_error_verbosity) */
479
454
  rb_define_const(rb_mPGconstants, "PQERRORS_VERBOSE", INT2FIX(PQERRORS_VERBOSE));
480
455
 
481
- #ifdef HAVE_PQPING
482
456
  /****** PG::Connection CLASS CONSTANTS: Check Server Status ******/
483
457
 
484
458
  /* Server is accepting connections. */
@@ -489,7 +463,6 @@ Init_pg_ext()
489
463
  rb_define_const(rb_mPGconstants, "PQPING_NO_RESPONSE", INT2FIX(PQPING_NO_RESPONSE));
490
464
  /* Connection not attempted (bad params). */
491
465
  rb_define_const(rb_mPGconstants, "PQPING_NO_ATTEMPT", INT2FIX(PQPING_NO_ATTEMPT));
492
- #endif
493
466
 
494
467
  /****** PG::Connection CLASS CONSTANTS: Large Objects ******/
495
468
 
@@ -524,13 +497,9 @@ Init_pg_ext()
524
497
  /* #result_status constant: A fatal error occurred. */
525
498
  rb_define_const(rb_mPGconstants, "PGRES_FATAL_ERROR", INT2FIX(PGRES_FATAL_ERROR));
526
499
  /* #result_status constant: Copy In/Out data transfer in progress. */
527
- #ifdef HAVE_CONST_PGRES_COPY_BOTH
528
500
  rb_define_const(rb_mPGconstants, "PGRES_COPY_BOTH", INT2FIX(PGRES_COPY_BOTH));
529
- #endif
530
501
  /* #result_status constant: Single tuple from larger resultset. */
531
- #ifdef HAVE_CONST_PGRES_SINGLE_TUPLE
532
502
  rb_define_const(rb_mPGconstants, "PGRES_SINGLE_TUPLE", INT2FIX(PGRES_SINGLE_TUPLE));
533
- #endif
534
503
 
535
504
  /****** Result CONSTANTS: result error field codes ******/
536
505
 
@@ -642,9 +611,7 @@ Init_pg_ext()
642
611
  /* Add the constants to the toplevel namespace */
643
612
  rb_include_module( rb_mPG, rb_mPGconstants );
644
613
 
645
- #ifdef M17N_SUPPORTED
646
614
  enc_pg2ruby = st_init_numtable();
647
- #endif
648
615
 
649
616
  /* Initialize the main extension classes */
650
617
  init_pg_connection();