pg 1.5.9-x64-mingw-ucrt → 1.6.0.rc1-x64-mingw-ucrt
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Gemfile +7 -4
- data/History.md +26 -0
- data/README-Windows.rdoc +1 -1
- data/README.ja.md +3 -3
- data/README.md +4 -4
- data/Rakefile +55 -12
- data/ext/extconf.rb +119 -13
- data/ext/gvl_wrappers.c +13 -2
- data/ext/gvl_wrappers.h +33 -0
- data/ext/pg.c +16 -5
- data/ext/pg.h +8 -9
- data/ext/pg_binary_decoder.c +150 -0
- data/ext/pg_binary_encoder.c +203 -7
- data/ext/pg_cancel_connection.c +360 -0
- data/ext/pg_coder.c +3 -5
- data/ext/pg_connection.c +337 -148
- data/ext/pg_copy_coder.c +2 -2
- data/ext/pg_record_coder.c +1 -1
- data/ext/pg_result.c +9 -11
- data/ext/pg_text_encoder.c +2 -2
- data/ext/pg_tuple.c +2 -2
- data/ext/pg_type_map.c +1 -1
- data/ext/pg_type_map_all_strings.c +1 -1
- data/ext/pg_type_map_by_class.c +1 -1
- data/ext/pg_type_map_by_column.c +1 -1
- data/ext/pg_type_map_by_mri_type.c +1 -1
- data/ext/pg_type_map_by_oid.c +1 -1
- data/ext/pg_type_map_in_ruby.c +1 -1
- data/lib/3.1/pg_ext.so +0 -0
- data/lib/3.2/pg_ext.so +0 -0
- data/lib/3.3/pg_ext.so +0 -0
- data/lib/pg/basic_type_registry.rb +2 -2
- data/lib/pg/cancel_connection.rb +30 -0
- data/lib/pg/connection.rb +182 -126
- data/lib/pg/version.rb +1 -1
- data/lib/pg.rb +13 -8
- data/pg.gemspec +2 -2
- data/{lib/x64-mingw-ucrt → ports/x64-mingw-ucrt/lib}/libpq.dll +0 -0
- data.tar.gz.sig +0 -0
- metadata +10 -7
- metadata.gz.sig +0 -0
- data/Rakefile.cross +0 -303
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 982a6af9fab44a4e3ff9024aefe49171647f525b00bfe92b769ea3a69013ff77
|
4
|
+
data.tar.gz: 5802f40a4cc6c57a334bc60914be533d90d2c6232ccdb1f950d5943dcc469bb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ffeda5e719ec59735f571b00d32176e8c4898695d8cdb32db21810dbb1440954d0df3d223551e73a62c083318818be8949a3d824fb6f3ed762e598863ab3135
|
7
|
+
data.tar.gz: 57bab05407a836cee582c36d712043d1e227dc818a879790bb832c956100097e0b7a924bd7c6d50ba735915864e30c047f7cff3173078cb5f95221e66f1f9645
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/Gemfile
CHANGED
@@ -5,13 +5,16 @@ gemspec
|
|
5
5
|
|
6
6
|
source "https://rubygems.org/"
|
7
7
|
|
8
|
-
group :development
|
8
|
+
group :development do
|
9
|
+
gem "rdoc", "~> 6.4"
|
10
|
+
gem "mini_portile2", "~> 2.1"
|
11
|
+
end
|
12
|
+
|
13
|
+
group :test do
|
9
14
|
gem "bundler", ">= 1.16", "< 3.0"
|
10
15
|
gem "rake-compiler", "~> 1.0"
|
11
|
-
gem "rake-compiler-dock", "~> 1.
|
12
|
-
gem "rdoc", "~> 6.4"
|
16
|
+
gem "rake-compiler-dock", "~> 1.5"
|
13
17
|
gem "rspec", "~> 3.5"
|
14
|
-
gem "ostruct", "~> 0.5" # for Rakefile.cross
|
15
18
|
# "bigdecimal" is a gem on ruby-3.4+ and it's optional for ruby-pg.
|
16
19
|
# Specs should succeed without it, but 4 examples are then excluded.
|
17
20
|
# With bigdecimal commented out here, corresponding tests are omitted on ruby-3.4+ but are executed on ruby < 3.4.
|
data/History.md
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
## v1.6.0.rc1 [2024-11-28] Lars Kanis <lars@greiz-reinsdorf.de>
|
2
|
+
|
3
|
+
Added:
|
4
|
+
|
5
|
+
- Add fat binary gem for platform `x86_64-linux`.
|
6
|
+
[#551](https://github.com/ged/ruby-pg/pull/551#issuecomment-2504715762)
|
7
|
+
- Add PG::BinaryDecoder::Array and PG::BinaryEncoder::Array to parse and encode PostgreSQL arrays in binary format.
|
8
|
+
[#603](https://github.com/ged/ruby-pg/pull/603)
|
9
|
+
- Add support for new query cancel functions of PostgreSQL-17.
|
10
|
+
This adds the new class `PG::CancelConnection` which provides the ability to cancel a query per blocking or per non-blocking functions.
|
11
|
+
If the new functions are available they are used and the older are no longer compiled in.
|
12
|
+
This way we can get rid of reading out the internal `PGcancel` struct by `Connection#backend_key`.
|
13
|
+
[#614](https://github.com/ged/ruby-pg/pull/614)
|
14
|
+
- Add Connection#set_chunked_rows_mode [#610](https://github.com/ged/ruby-pg/pull/610)
|
15
|
+
- Add PG::Connection#close_prepared, PG::Connection#close_portal, PG::Connection#send_close_prepared and PG::Connection#send_close_portal which are new in PostgreSQL-17.
|
16
|
+
[#611](https://github.com/ged/ruby-pg/pull/611)
|
17
|
+
- Add Connection#send_pipeline_sync, async_pipeline_sync and release GVL at PQ(sendP|P)ipelineSync.
|
18
|
+
[#612](https://github.com/ged/ruby-pg/pull/612)
|
19
|
+
|
20
|
+
Removed:
|
21
|
+
|
22
|
+
- Drop support of Ruby < 2.7 [#606](https://github.com/ged/ruby-pg/pull/606)
|
23
|
+
- Drop support of PostgreSQL < 10 [#606](https://github.com/ged/ruby-pg/pull/606)
|
24
|
+
- Remove workaround for Truffleruby < 21.3.0 [#613](https://github.com/ged/ruby-pg/pull/613)
|
25
|
+
|
26
|
+
|
1
27
|
## v1.5.9 [2024-10-24] Lars Kanis <lars@greiz-reinsdorf.de>
|
2
28
|
|
3
29
|
- Enable thread safety in static OpenSSL build for Windows. [#595](https://github.com/ged/ruby-pg/pull/595)
|
data/README-Windows.rdoc
CHANGED
@@ -41,7 +41,7 @@ sure it is started. A native Docker installation is best on Linux.
|
|
41
41
|
|
42
42
|
Then run:
|
43
43
|
|
44
|
-
rake gem:
|
44
|
+
rake gem:native
|
45
45
|
|
46
46
|
This will download a docker image suited for building windows gems, and it
|
47
47
|
will download and build OpenSSL and PostgreSQL. Finally the gem is built
|
data/README.ja.md
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
Pgは[PostgreSQL
|
14
14
|
RDBMS](http://www.postgresql.org/)へのRubyのインターフェースです。[PostgreSQL
|
15
|
-
|
15
|
+
10以降](http://www.postgresql.org/support/versioning/)で動作します。
|
16
16
|
|
17
17
|
簡単な使用例は次の通りです。
|
18
18
|
```ruby
|
@@ -41,8 +41,8 @@ Actionsのビルド状況](https://github.com/ged/ruby-pg/actions/workflows/sour
|
|
41
41
|
|
42
42
|
## 要件
|
43
43
|
|
44
|
-
* Ruby 2.
|
45
|
-
* PostgreSQL
|
44
|
+
* Ruby 2.7かそれより新しいバージョン
|
45
|
+
* PostgreSQL 10.xかそれ以降のバージョン(ヘッダー付属のもの、例えば-devの名前のパッケージ)。
|
46
46
|
|
47
47
|
それより前のバージョンのRubyやPostgreSQLでも通常は同様に動作しますが、定期的なテストはされていません。
|
48
48
|
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
## Description
|
12
12
|
|
13
13
|
Pg is the Ruby interface to the [PostgreSQL RDBMS](http://www.postgresql.org/).
|
14
|
-
It works with [PostgreSQL
|
14
|
+
It works with [PostgreSQL 10 and later](http://www.postgresql.org/support/versioning/).
|
15
15
|
|
16
16
|
A small example usage:
|
17
17
|
```ruby
|
@@ -39,8 +39,8 @@ A small example usage:
|
|
39
39
|
|
40
40
|
## Requirements
|
41
41
|
|
42
|
-
* Ruby 2.
|
43
|
-
* PostgreSQL
|
42
|
+
* Ruby 2.7 or newer
|
43
|
+
* PostgreSQL 10.x or later (with headers, -dev packages, etc).
|
44
44
|
|
45
45
|
It usually works with earlier versions of Ruby/PostgreSQL as well, but those are
|
46
46
|
not regularly tested.
|
@@ -141,7 +141,7 @@ The following PostgreSQL column types are supported by ruby-pg (TE = Text Encode
|
|
141
141
|
* Date: [TE](rdoc-ref:PG::TextEncoder::Date), [TD](rdoc-ref:PG::TextDecoder::Date), [BE](rdoc-ref:PG::BinaryEncoder::Date), [BD](rdoc-ref:PG::BinaryDecoder::Date)
|
142
142
|
* JSON and JSONB: [TE](rdoc-ref:PG::TextEncoder::JSON), [TD](rdoc-ref:PG::TextDecoder::JSON)
|
143
143
|
* Inet: [TE](rdoc-ref:PG::TextEncoder::Inet), [TD](rdoc-ref:PG::TextDecoder::Inet)
|
144
|
-
* Array: [TE](rdoc-ref:PG::TextEncoder::Array), [TD](rdoc-ref:PG::TextDecoder::Array)
|
144
|
+
* Array: [TE](rdoc-ref:PG::TextEncoder::Array), [TD](rdoc-ref:PG::TextDecoder::Array), [BE](rdoc-ref:PG::BinaryEncoder::Array), [BD](rdoc-ref:PG::BinaryDecoder::Array)
|
145
145
|
* Composite Type (also called "Row" or "Record"): [TE](rdoc-ref:PG::TextEncoder::Record), [TD](rdoc-ref:PG::TextDecoder::Record)
|
146
146
|
|
147
147
|
The following text and binary formats can also be encoded although they are not used as column type:
|
data/Rakefile
CHANGED
@@ -31,8 +31,8 @@ CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
|
|
31
31
|
CLEAN.include "lib/*/libpq.dll"
|
32
32
|
CLEAN.include "lib/pg_ext.*"
|
33
33
|
CLEAN.include "lib/pg/postgresql_lib_path.rb"
|
34
|
-
|
35
|
-
|
34
|
+
CLEAN.include "ports/*.installed"
|
35
|
+
CLEAN.include "ports/*mingw*", "ports/*linux*"
|
36
36
|
|
37
37
|
Bundler::GemHelper.install_tasks
|
38
38
|
$gem_spec = Bundler.load_gemspec(GEMSPEC)
|
@@ -42,6 +42,16 @@ task :maint do
|
|
42
42
|
ENV['MAINTAINER_MODE'] = 'yes'
|
43
43
|
end
|
44
44
|
|
45
|
+
CrossLibrary = Struct.new :platform, :openssl_config, :toolchain
|
46
|
+
CrossLibraries = [
|
47
|
+
['x64-mingw-ucrt', 'mingw64', 'x86_64-w64-mingw32'],
|
48
|
+
['x86-mingw32', 'mingw', 'i686-w64-mingw32'],
|
49
|
+
['x64-mingw32', 'mingw64', 'x86_64-w64-mingw32'],
|
50
|
+
['x86_64-linux', 'linux-x86_64', 'x86_64-redhat-linux-gnu'],
|
51
|
+
].map do |platform, openssl_config, toolchain|
|
52
|
+
CrossLibrary.new platform, openssl_config, toolchain
|
53
|
+
end
|
54
|
+
|
45
55
|
# Rake-compiler task
|
46
56
|
Rake::ExtensionTask.new do |ext|
|
47
57
|
ext.name = 'pg_ext'
|
@@ -50,24 +60,57 @@ Rake::ExtensionTask.new do |ext|
|
|
50
60
|
ext.lib_dir = 'lib'
|
51
61
|
ext.source_pattern = "*.{c,h}"
|
52
62
|
ext.cross_compile = true
|
53
|
-
ext.cross_platform = CrossLibraries.map(&:
|
63
|
+
ext.cross_platform = CrossLibraries.map(&:platform)
|
54
64
|
|
55
|
-
ext.cross_config_options += CrossLibraries.map do |
|
65
|
+
ext.cross_config_options += CrossLibraries.map do |xlib|
|
56
66
|
{
|
57
|
-
|
58
|
-
"--
|
59
|
-
"--with-
|
60
|
-
"--with-
|
61
|
-
# libpq-fe.h resides in src/interfaces/libpq/ before make install
|
62
|
-
"--with-opt-include=#{lib.static_postgresql_libdir}",
|
67
|
+
xlib.platform => [
|
68
|
+
"--with-cross-build=#{xlib.platform}",
|
69
|
+
"--with-openssl-platform=#{xlib.openssl_config}",
|
70
|
+
"--with-toolchain=#{xlib.toolchain}",
|
63
71
|
]
|
64
72
|
}
|
65
73
|
end
|
66
74
|
|
67
|
-
# Add libpq.dll to
|
75
|
+
# Add libpq.dll/.so to fat binary gemspecs
|
68
76
|
ext.cross_compiling do |spec|
|
69
|
-
spec.files << "
|
77
|
+
spec.files << "ports/#{spec.platform.to_s}/lib/libpq-ruby-pg.so.1" if spec.platform.to_s =~ /linux/
|
78
|
+
spec.files << "ports/#{spec.platform.to_s}/lib/libpq.dll" if spec.platform.to_s =~ /mingw|mswin/
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
task 'gem:native:prepare' do
|
83
|
+
require 'io/console'
|
84
|
+
require 'rake_compiler_dock'
|
85
|
+
|
86
|
+
# Copy gem signing key and certs to be accessible from the docker container
|
87
|
+
mkdir_p 'build/gem'
|
88
|
+
sh "cp ~/.gem/gem-*.pem build/gem/ || true"
|
89
|
+
sh "bundle package"
|
90
|
+
begin
|
91
|
+
OpenSSL::PKey.read(File.read(File.expand_path("~/.gem/gem-private_key.pem")), ENV["GEM_PRIVATE_KEY_PASSPHRASE"] || "")
|
92
|
+
rescue OpenSSL::PKey::PKeyError
|
93
|
+
ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = STDIN.getpass("Enter passphrase of gem signature key: ")
|
94
|
+
retry
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
CrossLibraries.each do |xlib|
|
99
|
+
platform = xlib.platform
|
100
|
+
desc "Build fat binary gem for platform #{platform}"
|
101
|
+
task "gem:native:#{platform}" => ['gem:native:prepare'] do
|
102
|
+
RakeCompilerDock.sh <<-EOT, platform: platform
|
103
|
+
#{ "sudo yum install -y perl-IPC-Cmd bison flex &&" if platform =~ /linux/ }
|
104
|
+
#{ # remove nm on Linux to suppress PostgreSQL's check for exit which raises thread_exit as a false positive:
|
105
|
+
"sudo mv `which nm` `which nm`.bak && sudo mv `which nm` `which nm`.bak &&" if platform =~ /linux/ }
|
106
|
+
#{ "sudo apt-get update && sudo apt-get install -y bison flex &&" if platform =~ /mingw/ }
|
107
|
+
(cp build/gem/gem-*.pem ~/.gem/ || true) &&
|
108
|
+
bundle install --local &&
|
109
|
+
rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKEOPTS=-j`nproc` RUBY_CC_VERSION=3.3.0:3.2.0:3.1.0:3.0.0:2.7.0
|
110
|
+
EOT
|
70
111
|
end
|
112
|
+
desc "Build the native binary gems"
|
113
|
+
multitask 'gem:native' => "gem:native:#{platform}"
|
71
114
|
end
|
72
115
|
|
73
116
|
RSpec::Core::RakeTask.new(:spec).rspec_opts = "--profile -cfdoc"
|
data/ext/extconf.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'pp'
|
2
2
|
require 'mkmf'
|
3
3
|
|
4
|
-
|
5
4
|
if ENV['MAINTAINER_MODE']
|
6
5
|
$stderr.puts "Maintainer mode enabled."
|
7
6
|
$CFLAGS <<
|
@@ -24,12 +23,125 @@ else
|
|
24
23
|
$stderr.puts "Calling libpq with GVL locked"
|
25
24
|
end
|
26
25
|
|
27
|
-
if
|
26
|
+
if gem_platform=with_config("cross-build")
|
27
|
+
gem 'mini_portile2', '~>2.1'
|
28
|
+
require 'mini_portile2'
|
29
|
+
|
30
|
+
OPENSSL_VERSION = ENV['OPENSSL_VERSION'] || '3.4.0'
|
31
|
+
OPENSSL_SOURCE_URI = "http://www.openssl.org/source/openssl-#{OPENSSL_VERSION}.tar.gz"
|
32
|
+
|
33
|
+
KRB5_VERSION = ENV['KRB5_VERSION'] || '1.21.3'
|
34
|
+
KRB5_SOURCE_URI = "http://kerberos.org/dist/krb5/#{KRB5_VERSION[/^(\d+\.\d+)/]}/krb5-#{KRB5_VERSION}.tar.gz"
|
35
|
+
|
36
|
+
POSTGRESQL_VERSION = ENV['POSTGRESQL_VERSION'] || '17.2'
|
37
|
+
POSTGRESQL_SOURCE_URI = "http://ftp.postgresql.org/pub/source/v#{POSTGRESQL_VERSION}/postgresql-#{POSTGRESQL_VERSION}.tar.bz2"
|
38
|
+
|
39
|
+
class BuildRecipe < MiniPortile
|
40
|
+
def initialize(name, version, files)
|
41
|
+
super(name, version)
|
42
|
+
self.files = files
|
43
|
+
rootdir = File.expand_path('../..', __FILE__)
|
44
|
+
self.target = File.join(rootdir, "ports")
|
45
|
+
self.patch_files = Dir[File.join(target, "patches", self.name, self.version, "*.patch")].sort
|
46
|
+
end
|
47
|
+
|
48
|
+
def port_path
|
49
|
+
"#{target}/#{RUBY_PLATFORM}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def cook_and_activate
|
53
|
+
checkpoint = File.join(self.target, "#{self.name}-#{self.version}-#{RUBY_PLATFORM}.installed")
|
54
|
+
unless File.exist?(checkpoint)
|
55
|
+
self.cook
|
56
|
+
FileUtils.touch checkpoint
|
57
|
+
end
|
58
|
+
self.activate
|
59
|
+
self
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
openssl_platform = with_config("openssl-platform")
|
64
|
+
toolchain = with_config("toolchain")
|
65
|
+
|
66
|
+
openssl_recipe = BuildRecipe.new("openssl", OPENSSL_VERSION, [OPENSSL_SOURCE_URI]).tap do |recipe|
|
67
|
+
class << recipe
|
68
|
+
attr_accessor :openssl_platform
|
69
|
+
def configure
|
70
|
+
envs = []
|
71
|
+
envs << "CFLAGS=-DDSO_WIN32 -DOPENSSL_THREADS" if RUBY_PLATFORM =~ /mingw|mswin/
|
72
|
+
envs << "CFLAGS=-fPIC -DOPENSSL_THREADS" if RUBY_PLATFORM =~ /linux/
|
73
|
+
execute('configure', ['env', *envs, "./Configure", openssl_platform, "threads", "-static", "CROSS_COMPILE=#{host}-", configure_prefix], altlog: "config.log")
|
74
|
+
end
|
75
|
+
def compile
|
76
|
+
execute('compile', "#{make_cmd} build_libs")
|
77
|
+
end
|
78
|
+
def install
|
79
|
+
execute('install', "#{make_cmd} install_dev")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
recipe.openssl_platform = openssl_platform
|
84
|
+
recipe.host = toolchain
|
85
|
+
recipe.cook_and_activate
|
86
|
+
end
|
87
|
+
|
88
|
+
if RUBY_PLATFORM =~ /linux/
|
89
|
+
krb5_recipe = BuildRecipe.new("krb5", KRB5_VERSION, [KRB5_SOURCE_URI]).tap do |recipe|
|
90
|
+
class << recipe
|
91
|
+
def work_path
|
92
|
+
File.join(super, "src")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
# We specify -fcommon to get around duplicate definition errors in recent gcc.
|
96
|
+
# See https://github.com/cockroachdb/cockroach/issues/49734
|
97
|
+
recipe.configure_options << "CFLAGS=-fcommon#{" -fPIC" if RUBY_PLATFORM =~ /linux/}"
|
98
|
+
recipe.configure_options << "--without-keyutils"
|
99
|
+
recipe.host = toolchain
|
100
|
+
recipe.cook_and_activate
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
postgresql_recipe = BuildRecipe.new("postgresql", POSTGRESQL_VERSION, [POSTGRESQL_SOURCE_URI]).tap do |recipe|
|
105
|
+
class << recipe
|
106
|
+
def configure_defaults
|
107
|
+
[
|
108
|
+
"--target=#{host}",
|
109
|
+
"--host=#{host}",
|
110
|
+
'--with-openssl',
|
111
|
+
*(RUBY_PLATFORM=~/linux/ ? ['--with-gssapi'] : []),
|
112
|
+
'--without-zlib',
|
113
|
+
'--without-icu',
|
114
|
+
]
|
115
|
+
end
|
116
|
+
def compile
|
117
|
+
execute 'compile include', "#{make_cmd} -C src/include install"
|
118
|
+
execute 'compile interfaces', "#{make_cmd} -C src/interfaces install"
|
119
|
+
end
|
120
|
+
def install
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
recipe.configure_options << "CFLAGS=#{" -fPIC" if RUBY_PLATFORM =~ /linux/}"
|
125
|
+
recipe.configure_options << "LDFLAGS=-L#{openssl_recipe.path}/lib -L#{openssl_recipe.path}/lib64 #{"-Wl,-soname,libpq-ruby-pg.so.1 -lgssapi_krb5 -lkrb5 -lk5crypto -lkrb5support" if RUBY_PLATFORM =~ /linux/}"
|
126
|
+
recipe.configure_options << "LIBS=-lkrb5 -lcom_err -lk5crypto -lkrb5support -lresolv" if RUBY_PLATFORM =~ /linux/
|
127
|
+
recipe.configure_options << "LIBS=-lssl -lwsock32 -lgdi32 -lws2_32 -lcrypt32" if RUBY_PLATFORM =~ /mingw|mswin/
|
128
|
+
recipe.configure_options << "CPPFLAGS=-I#{openssl_recipe.path}/include"
|
129
|
+
recipe.host = toolchain
|
130
|
+
recipe.cook_and_activate
|
131
|
+
end
|
132
|
+
|
133
|
+
# Use our own library name for libpq to avoid loading of system libpq by accident.
|
134
|
+
FileUtils.ln_sf File.join(postgresql_recipe.port_path, "lib/libpq.so.5"),
|
135
|
+
File.join(postgresql_recipe.port_path, "lib/libpq-ruby-pg.so.1")
|
28
136
|
# Avoid dependency to external libgcc.dll on x86-mingw32
|
29
137
|
$LDFLAGS << " -static-libgcc"
|
138
|
+
# Find libpq in the ports directory coming from lib/3.3
|
139
|
+
# It is shared between all compiled ruby versions.
|
140
|
+
$LDFLAGS << " '-Wl,-rpath=$$ORIGIN/../../ports/#{gem_platform}/lib'"
|
30
141
|
# Don't use pg_config for cross build, but --with-pg-* path options
|
31
|
-
dir_config
|
142
|
+
dir_config('pg', "#{postgresql_recipe.path}/include", "#{postgresql_recipe.path}/lib")
|
32
143
|
|
144
|
+
$defs.push( "-DPG_IS_BINARY_GEM")
|
33
145
|
else
|
34
146
|
# Native build
|
35
147
|
|
@@ -79,7 +191,7 @@ $INSTALLFILES = {
|
|
79
191
|
"./postgresql_lib_path.rb" => "$(RUBYLIBDIR)/pg/"
|
80
192
|
}
|
81
193
|
|
82
|
-
if
|
194
|
+
if /solaris/ =~ RUBY_PLATFORM
|
83
195
|
append_cppflags( '-D__EXTENSIONS__' )
|
84
196
|
end
|
85
197
|
|
@@ -144,26 +256,20 @@ if /mingw/ =~ RUBY_PLATFORM && RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
|
|
144
256
|
end
|
145
257
|
end
|
146
258
|
|
147
|
-
have_func '
|
259
|
+
have_func 'PQencryptPasswordConn', 'libpq-fe.h' or # since PostgreSQL-10
|
148
260
|
abort "Your PostgreSQL is too old. Either install an older version " +
|
149
|
-
"of this gem or upgrade your database to at least PostgreSQL-
|
261
|
+
"of this gem or upgrade your database to at least PostgreSQL-10."
|
150
262
|
# optional headers/functions
|
151
|
-
have_func 'PQsslAttribute', 'libpq-fe.h' # since PostgreSQL-9.5
|
152
|
-
have_func 'PQresultVerboseErrorMessage', 'libpq-fe.h' # since PostgreSQL-9.6
|
153
|
-
have_func 'PQencryptPasswordConn', 'libpq-fe.h' # since PostgreSQL-10
|
154
263
|
have_func 'PQresultMemorySize', 'libpq-fe.h' # since PostgreSQL-12
|
155
264
|
have_func 'PQenterPipelineMode', 'libpq-fe.h' do |src| # since PostgreSQL-14
|
156
265
|
# Ensure header files fit as well
|
157
266
|
src + " int con(){ return PGRES_PIPELINE_SYNC; }"
|
158
267
|
end
|
268
|
+
have_func 'PQsetChunkedRowsMode', 'libpq-fe.h' # since PostgreSQL-17
|
159
269
|
have_func 'timegm'
|
160
|
-
have_func 'rb_gc_adjust_memory_usage' # since ruby-2.4
|
161
|
-
have_func 'rb_gc_mark_movable' # since ruby-2.7
|
162
270
|
have_func 'rb_io_wait' # since ruby-3.0
|
163
271
|
have_func 'rb_io_descriptor' # since ruby-3.1
|
164
272
|
|
165
|
-
# unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
|
166
|
-
have_header 'unistd.h'
|
167
273
|
have_header 'inttypes.h'
|
168
274
|
have_header('ruby/fiber/scheduler.h') if RUBY_PLATFORM=~/mingw|mswin/
|
169
275
|
|
data/ext/gvl_wrappers.c
CHANGED
@@ -5,8 +5,19 @@
|
|
5
5
|
|
6
6
|
#include "pg.h"
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
|
9
|
+
#ifndef HAVE_PQSETCHUNKEDROWSMODE
|
10
|
+
PGresult *PQclosePrepared(PGconn *conn, const char *stmtName){return NULL;}
|
11
|
+
PGresult *PQclosePortal(PGconn *conn, const char *portalName){return NULL;}
|
12
|
+
int PQsendClosePrepared(PGconn *conn, const char *stmtName){return 0;}
|
13
|
+
int PQsendClosePortal(PGconn *conn, const char *portalName){return 0;}
|
14
|
+
int PQsendPipelineSync(PGconn *conn){return 0;}
|
15
|
+
int PQcancelBlocking(PGcancelConn *cancelConn){return 0;}
|
16
|
+
int PQcancelStart(PGcancelConn *cancelConn){return 0;}
|
17
|
+
PostgresPollingStatusType PQcancelPoll(PGcancelConn *cancelConn){return PGRES_POLLING_FAILED;}
|
18
|
+
#endif
|
19
|
+
#ifndef HAVE_PQENTERPIPELINEMODE
|
20
|
+
int PQpipelineSync(PGconn *conn){return 0;}
|
10
21
|
#endif
|
11
22
|
|
12
23
|
#ifdef ENABLE_GVL_UNLOCK
|
data/ext/gvl_wrappers.h
CHANGED
@@ -21,6 +21,10 @@
|
|
21
21
|
# include RUBY_EXTCONF_H
|
22
22
|
#endif
|
23
23
|
|
24
|
+
#ifndef HAVE_PQSETCHUNKEDROWSMODE
|
25
|
+
typedef struct pg_cancel_conn PGcancelConn;
|
26
|
+
#endif
|
27
|
+
|
24
28
|
#define DEFINE_PARAM_LIST1(type, name) \
|
25
29
|
name,
|
26
30
|
|
@@ -149,6 +153,12 @@
|
|
149
153
|
#define FOR_EACH_PARAM_OF_PQdescribePortal(param) \
|
150
154
|
param(PGconn *, conn)
|
151
155
|
|
156
|
+
#define FOR_EACH_PARAM_OF_PQclosePrepared(param) \
|
157
|
+
param(PGconn *, conn)
|
158
|
+
|
159
|
+
#define FOR_EACH_PARAM_OF_PQclosePortal(param) \
|
160
|
+
param(PGconn *, conn)
|
161
|
+
|
152
162
|
#define FOR_EACH_PARAM_OF_PQgetResult(param)
|
153
163
|
|
154
164
|
#define FOR_EACH_PARAM_OF_PQputCopyData(param) \
|
@@ -196,11 +206,25 @@
|
|
196
206
|
#define FOR_EACH_PARAM_OF_PQsendDescribePortal(param) \
|
197
207
|
param(PGconn *, conn)
|
198
208
|
|
209
|
+
#define FOR_EACH_PARAM_OF_PQsendClosePrepared(param) \
|
210
|
+
param(PGconn *, conn)
|
211
|
+
|
212
|
+
#define FOR_EACH_PARAM_OF_PQsendClosePortal(param) \
|
213
|
+
param(PGconn *, conn)
|
214
|
+
|
215
|
+
#define FOR_EACH_PARAM_OF_PQpipelineSync(param)
|
216
|
+
|
217
|
+
#define FOR_EACH_PARAM_OF_PQsendPipelineSync(param)
|
218
|
+
|
199
219
|
#define FOR_EACH_PARAM_OF_PQsetClientEncoding(param) \
|
200
220
|
param(PGconn *, conn)
|
201
221
|
|
202
222
|
#define FOR_EACH_PARAM_OF_PQisBusy(param)
|
203
223
|
|
224
|
+
#define FOR_EACH_PARAM_OF_PQcancelBlocking(param)
|
225
|
+
#define FOR_EACH_PARAM_OF_PQcancelStart(param)
|
226
|
+
#define FOR_EACH_PARAM_OF_PQcancelPoll(param)
|
227
|
+
|
204
228
|
#define FOR_EACH_PARAM_OF_PQencryptPasswordConn(param) \
|
205
229
|
param(PGconn *, conn) \
|
206
230
|
param(const char *, passwd) \
|
@@ -225,6 +249,8 @@
|
|
225
249
|
function(PQprepare, GVL_TYPE_NONVOID, PGresult *, const Oid *, paramTypes) \
|
226
250
|
function(PQdescribePrepared, GVL_TYPE_NONVOID, PGresult *, const char *, stmtName) \
|
227
251
|
function(PQdescribePortal, GVL_TYPE_NONVOID, PGresult *, const char *, portalName) \
|
252
|
+
function(PQclosePrepared, GVL_TYPE_NONVOID, PGresult *, const char *, stmtName) \
|
253
|
+
function(PQclosePortal, GVL_TYPE_NONVOID, PGresult *, const char *, portalName) \
|
228
254
|
function(PQgetResult, GVL_TYPE_NONVOID, PGresult *, PGconn *, conn) \
|
229
255
|
function(PQputCopyData, GVL_TYPE_NONVOID, int, int, nbytes) \
|
230
256
|
function(PQputCopyEnd, GVL_TYPE_NONVOID, int, const char *, errormsg) \
|
@@ -236,8 +262,15 @@
|
|
236
262
|
function(PQsendQueryPrepared, GVL_TYPE_NONVOID, int, int, resultFormat) \
|
237
263
|
function(PQsendDescribePrepared, GVL_TYPE_NONVOID, int, const char *, stmt) \
|
238
264
|
function(PQsendDescribePortal, GVL_TYPE_NONVOID, int, const char *, portal) \
|
265
|
+
function(PQsendClosePrepared, GVL_TYPE_NONVOID, int, const char *, stmt) \
|
266
|
+
function(PQsendClosePortal, GVL_TYPE_NONVOID, int, const char *, portal) \
|
267
|
+
function(PQpipelineSync, GVL_TYPE_NONVOID, int, PGconn *, conn) \
|
268
|
+
function(PQsendPipelineSync, GVL_TYPE_NONVOID, int, PGconn *, conn) \
|
239
269
|
function(PQsetClientEncoding, GVL_TYPE_NONVOID, int, const char *, encoding) \
|
240
270
|
function(PQisBusy, GVL_TYPE_NONVOID, int, PGconn *, conn) \
|
271
|
+
function(PQcancelBlocking, GVL_TYPE_NONVOID, int, PGcancelConn *, conn) \
|
272
|
+
function(PQcancelStart, GVL_TYPE_NONVOID, int, PGcancelConn *, conn) \
|
273
|
+
function(PQcancelPoll, GVL_TYPE_NONVOID, PostgresPollingStatusType, PGcancelConn *, conn) \
|
241
274
|
function(PQencryptPasswordConn, GVL_TYPE_NONVOID, char *, const char *, algorithm) \
|
242
275
|
function(PQcancel, GVL_TYPE_NONVOID, int, int, errbufsize);
|
243
276
|
|
data/ext/pg.c
CHANGED
@@ -404,6 +404,10 @@ Init_pg_ext(void)
|
|
404
404
|
/* Checking if server is in standby mode. Available since PostgreSQL-14. */
|
405
405
|
rb_define_const(rb_mPGconstants, "CONNECTION_CHECK_STANDBY", INT2FIX(CONNECTION_CHECK_STANDBY));
|
406
406
|
#endif
|
407
|
+
#if PG_MAJORVERSION_NUM >= 17
|
408
|
+
/* Waiting for connection attempt to be started. Available since PostgreSQL-17. */
|
409
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_ALLOCATED", INT2FIX(CONNECTION_ALLOCATED));
|
410
|
+
#endif
|
407
411
|
|
408
412
|
/****** PG::Connection CLASS CONSTANTS: Nonblocking connection polling status ******/
|
409
413
|
|
@@ -451,14 +455,12 @@ Init_pg_ext(void)
|
|
451
455
|
rb_define_const(rb_mPGconstants, "PQERRORS_SQLSTATE", INT2FIX(PQERRORS_SQLSTATE));
|
452
456
|
#endif
|
453
457
|
|
454
|
-
#ifdef HAVE_PQRESULTVERBOSEERRORMESSAGE
|
455
458
|
/* See Connection#set_error_context_visibility */
|
456
459
|
rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_NEVER", INT2FIX(PQSHOW_CONTEXT_NEVER));
|
457
460
|
/* See Connection#set_error_context_visibility */
|
458
461
|
rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_ERRORS", INT2FIX(PQSHOW_CONTEXT_ERRORS));
|
459
462
|
/* See Connection#set_error_context_visibility */
|
460
463
|
rb_define_const(rb_mPGconstants, "PQSHOW_CONTEXT_ALWAYS", INT2FIX(PQSHOW_CONTEXT_ALWAYS));
|
461
|
-
#endif
|
462
464
|
|
463
465
|
/****** PG::Connection CLASS CONSTANTS: Check Server Status ******/
|
464
466
|
|
@@ -506,6 +508,10 @@ Init_pg_ext(void)
|
|
506
508
|
rb_define_const(rb_mPGconstants, "PGRES_COPY_BOTH", INT2FIX(PGRES_COPY_BOTH));
|
507
509
|
/* Result#result_status constant - Single tuple from larger resultset. */
|
508
510
|
rb_define_const(rb_mPGconstants, "PGRES_SINGLE_TUPLE", INT2FIX(PGRES_SINGLE_TUPLE));
|
511
|
+
#ifdef HAVE_PQSETCHUNKEDROWSMODE
|
512
|
+
/* Result#result_status constant - tuple chunk from larger resultset. */
|
513
|
+
rb_define_const(rb_mPGconstants, "PGRES_TUPLES_CHUNK", INT2FIX(PGRES_TUPLES_CHUNK));
|
514
|
+
#endif
|
509
515
|
|
510
516
|
#ifdef HAVE_PQENTERPIPELINEMODE
|
511
517
|
/* Result#result_status constant - The PG::Result represents a synchronization point in pipeline mode, requested by Connection#pipeline_sync.
|
@@ -530,16 +536,14 @@ Init_pg_ext(void)
|
|
530
536
|
*/
|
531
537
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY", INT2FIX(PG_DIAG_SEVERITY));
|
532
538
|
|
533
|
-
#ifdef PG_DIAG_SEVERITY_NONLOCALIZED
|
534
539
|
/* Result#result_error_field argument constant
|
535
540
|
*
|
536
541
|
* 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).
|
537
542
|
* This is identical to the PG_DIAG_SEVERITY field except that the contents are never localized.
|
538
543
|
*
|
539
|
-
* Available since PostgreSQL-9.6
|
540
544
|
*/
|
541
545
|
rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY_NONLOCALIZED", INT2FIX(PG_DIAG_SEVERITY_NONLOCALIZED));
|
542
|
-
|
546
|
+
|
543
547
|
/* Result#result_error_field argument constant
|
544
548
|
*
|
545
549
|
* The SQLSTATE code for the error.
|
@@ -667,6 +671,12 @@ Init_pg_ext(void)
|
|
667
671
|
/* PostgreSQL compiled in default port */
|
668
672
|
rb_define_const(rb_mPGconstants, "DEF_PGPORT", INT2FIX(DEF_PGPORT));
|
669
673
|
|
674
|
+
#ifdef PG_IS_BINARY_GEM
|
675
|
+
rb_define_const(rb_mPG, "IS_BINARY_GEM", Qtrue);
|
676
|
+
#else
|
677
|
+
rb_define_const(rb_mPG, "IS_BINARY_GEM", Qfalse);
|
678
|
+
#endif
|
679
|
+
|
670
680
|
/* Add the constants to the toplevel namespace */
|
671
681
|
rb_include_module( rb_mPG, rb_mPGconstants );
|
672
682
|
|
@@ -689,4 +699,5 @@ Init_pg_ext(void)
|
|
689
699
|
init_pg_copycoder();
|
690
700
|
init_pg_recordcoder();
|
691
701
|
init_pg_tuple();
|
702
|
+
init_pg_cancon();
|
692
703
|
}
|
data/ext/pg.h
CHANGED
@@ -76,14 +76,7 @@ typedef long suseconds_t;
|
|
76
76
|
#define PG_MAX_COLUMNS 4000
|
77
77
|
#endif
|
78
78
|
|
79
|
-
#ifdef HAVE_RB_GC_MARK_MOVABLE
|
80
|
-
#define pg_compact_callback(x) (x)
|
81
79
|
#define pg_gc_location(x) x = rb_gc_location(x)
|
82
|
-
#else
|
83
|
-
#define rb_gc_mark_movable(x) rb_gc_mark(x)
|
84
|
-
#define pg_compact_callback(x) {(x)}
|
85
|
-
#define pg_gc_location(x) UNUSED(x)
|
86
|
-
#endif
|
87
80
|
|
88
81
|
/* For compatibility with ruby < 3.0 */
|
89
82
|
#ifndef RUBY_TYPED_FROZEN_SHAREABLE
|
@@ -123,10 +116,8 @@ typedef struct {
|
|
123
116
|
/* enable automatic flushing of send data at the end of send_query calls */
|
124
117
|
unsigned int flush_data : 1;
|
125
118
|
|
126
|
-
#if defined(_WIN32)
|
127
119
|
/* File descriptor to be used for rb_w32_unwrap_io_handle() */
|
128
120
|
int ruby_sd;
|
129
|
-
#endif
|
130
121
|
} t_pg_connection;
|
131
122
|
|
132
123
|
typedef struct pg_coder t_pg_coder;
|
@@ -312,6 +303,7 @@ void init_pg_text_decoder _(( void ));
|
|
312
303
|
void init_pg_binary_encoder _(( void ));
|
313
304
|
void init_pg_binary_decoder _(( void ));
|
314
305
|
void init_pg_tuple _(( void ));
|
306
|
+
void init_pg_cancon _(( void ));
|
315
307
|
VALUE lookup_error_class _(( const char * ));
|
316
308
|
VALUE pg_bin_dec_bytea _(( t_pg_coder*, const char *, int, int, int, int ));
|
317
309
|
VALUE pg_text_dec_string _(( t_pg_coder*, const char *, int, int, int, int ));
|
@@ -351,6 +343,13 @@ void pg_typemap_compact _(( void * ));
|
|
351
343
|
PGconn *pg_get_pgconn _(( VALUE ));
|
352
344
|
t_pg_connection *pg_get_connection _(( VALUE ));
|
353
345
|
VALUE pgconn_block _(( int, VALUE *, VALUE ));
|
346
|
+
#ifdef __GNUC__
|
347
|
+
__attribute__((format(printf, 3, 4)))
|
348
|
+
#endif
|
349
|
+
NORETURN(void pg_raise_conn_error _(( VALUE klass, VALUE self, const char *format, ...)));
|
350
|
+
VALUE pg_wrap_socket_io _(( int sd, VALUE self, VALUE *p_socket_io, int *p_ruby_sd ));
|
351
|
+
void pg_unwrap_socket_io _(( VALUE self, VALUE *p_socket_io, int ruby_sd ));
|
352
|
+
|
354
353
|
|
355
354
|
VALUE pg_new_result _(( PGresult *, VALUE ));
|
356
355
|
VALUE pg_new_result_autoclear _(( PGresult *, VALUE ));
|