pg 1.5.9-x86-mingw32 → 1.6.0.rc2-x86-mingw32
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/{History.md → CHANGELOG.md} +54 -0
- data/Gemfile +7 -4
- data/README-Windows.rdoc +1 -1
- data/README.ja.md +4 -4
- data/README.md +6 -5
- data/Rakefile +80 -13
- data/ext/extconf.rb +158 -14
- data/ext/gvl_wrappers.c +13 -2
- data/ext/gvl_wrappers.h +33 -0
- data/ext/pg.c +16 -5
- data/ext/pg.h +9 -9
- data/ext/pg_binary_decoder.c +150 -0
- data/ext/pg_binary_encoder.c +210 -7
- data/ext/pg_cancel_connection.c +360 -0
- data/ext/pg_coder.c +52 -5
- data/ext/pg_connection.c +368 -158
- 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 +20 -7
- 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 +2 -1
- data/ext/pg_type_map_by_mri_type.c +1 -1
- data/ext/pg_type_map_by_oid.c +3 -1
- data/ext/pg_type_map_in_ruby.c +1 -1
- data/lib/2.7/pg_ext.so +0 -0
- data/lib/3.0/pg_ext.so +0 -0
- 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/3.4/pg_ext.so +0 -0
- data/lib/pg/basic_type_map_for_queries.rb +7 -3
- data/lib/pg/basic_type_registry.rb +2 -2
- data/lib/pg/cancel_connection.rb +53 -0
- data/lib/pg/coder.rb +2 -1
- data/lib/pg/connection.rb +252 -131
- data/lib/pg/version.rb +1 -1
- data/lib/pg.rb +13 -8
- data/misc/yugabyte/Dockerfile +9 -0
- data/misc/yugabyte/docker-compose.yml +28 -0
- data/misc/yugabyte/pg-test.rb +45 -0
- data/pg.gemspec +5 -3
- data/ports/patches/krb5/1.21.3/0001-Allow-static-linking-krb5-library.patch +30 -0
- data/ports/patches/openssl/3.5.1/0001-aarch64-mingw.patch +21 -0
- data/ports/patches/postgresql/17.5/0001-Use-workaround-of-__builtin_setjmp-only-on-MINGW-on-.patch +42 -0
- data/ports/patches/postgresql/17.5/0001-libpq-Process-buffered-SSL-read-bytes-to-support-rec.patch +52 -0
- data/{lib/x86-mingw32 → ports/x86-mingw32/lib}/libpq.dll +0 -0
- data/rakelib/pg_gem_helper.rb +64 -0
- data.tar.gz.sig +0 -0
- metadata +35 -28
- metadata.gz.sig +0 -0
- data/Manifest.txt +0 -72
- data/Rakefile.cross +0 -303
- data/lib/2.5/pg_ext.so +0 -0
- data/lib/2.6/pg_ext.so +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6afb110acd5fa4e42d17d4b392dc9035811ab8b5c1d688e71d11d9304b97ad08
|
4
|
+
data.tar.gz: 13853ebf8650538bb56c621d5bb4cfe91da36112111fbeef1007d7001aec9cce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4877d769715cb654f504c8aa11b170cbf6a254d57ee84ede9bc9de378d5f5877bb3d72653c478ef7af3cfb48a1d42a056736bfb987b25e0d3e745099f90cfff
|
7
|
+
data.tar.gz: c2dabae3c567480389777e3614689743cc4c60d370ced13d072965f573b797300768cb1452432e54fa5fda05f728c4f21e54a0994b9f80303f8b3b23760fa52e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/{History.md → CHANGELOG.md}
RENAMED
@@ -1,3 +1,57 @@
|
|
1
|
+
## v1.6.0.rc2 [2025-07-16] Lars Kanis <lars@greiz-reinsdorf.de>
|
2
|
+
|
3
|
+
Added:
|
4
|
+
|
5
|
+
- Add binary gems for Ruby 3.4.
|
6
|
+
- Add fat binary gem for platform `aarch64-mingw-ucrt` aka Windows on ARM [#626](https://github.com/ged/ruby-pg/pull/626), for platform Macos on Intel and ARM [#643](https://github.com/ged/ruby-pg/pull/643) and for platform `aarch64-linux` [#646](https://github.com/ged/ruby-pg/pull/646).
|
7
|
+
- Update fat binary gem to OpenSSL-3.5.1 and PostgreSQL-17.5.
|
8
|
+
- Add a patch to libpq to avoid starvation on bigger SSL records, which some database engines other than vanilla PostgreSQL use.
|
9
|
+
This patch applies to platform specific binary gems only.
|
10
|
+
[#616](https://github.com/ged/ruby-pg/pull/616)
|
11
|
+
- Fix missing array input verification in PG::TypeMapByColumn.
|
12
|
+
This could cause a segfault.
|
13
|
+
[#620](https://github.com/ged/ruby-pg/pull/620)
|
14
|
+
- Add possibility to define the number of array dimensions to be encoded.
|
15
|
+
Setting dimensions is especially useful, when a Record shall be encoded into an Array, since the Array encoder can not distinguish if the array shall be encoded as a higher dimension or as a record otherwise.
|
16
|
+
[#622](https://github.com/ged/ruby-pg/pull/622)
|
17
|
+
- Add MINGW package dependency which is resolved by RubyInstaller.
|
18
|
+
[#617](https://github.com/ged/ruby-pg/pull/617)
|
19
|
+
- Change `conn.server_version` and `conn.protocol_version` to raise instead of return 0 on error.
|
20
|
+
[#632](https://github.com/ged/ruby-pg/pull/632)
|
21
|
+
- Fix making PG::BasicTypeMapForQueries shareable for Ractor in ruby-3.5.
|
22
|
+
[#636](https://github.com/ged/ruby-pg/pull/636)
|
23
|
+
- Rename `History.md` to `CHANGELOG.md`, which is more common.
|
24
|
+
[#642](https://github.com/ged/ruby-pg/pull/642)
|
25
|
+
- Fix connecting to multiple hosts after `connnect_timeout`.
|
26
|
+
[#637](https://github.com/ged/ruby-pg/pull/637)
|
27
|
+
|
28
|
+
|
29
|
+
## v1.6.0.rc1 [2024-11-28] Lars Kanis <lars@greiz-reinsdorf.de>
|
30
|
+
|
31
|
+
Added:
|
32
|
+
|
33
|
+
- Add fat binary gem for platform `x86_64-linux`.
|
34
|
+
[#551](https://github.com/ged/ruby-pg/pull/551#issuecomment-2504715762)
|
35
|
+
- Add PG::BinaryDecoder::Array and PG::BinaryEncoder::Array to parse and encode PostgreSQL arrays in binary format.
|
36
|
+
[#603](https://github.com/ged/ruby-pg/pull/603)
|
37
|
+
- Add support for new query cancel functions of PostgreSQL-17.
|
38
|
+
This adds the new class `PG::CancelConnection` which provides the ability to cancel a query per blocking or per non-blocking functions.
|
39
|
+
If the new functions are available they are used and the older are no longer compiled in.
|
40
|
+
This way we can get rid of reading out the internal `PGcancel` struct by `Connection#backend_key`.
|
41
|
+
[#614](https://github.com/ged/ruby-pg/pull/614)
|
42
|
+
- Add Connection#set_chunked_rows_mode [#610](https://github.com/ged/ruby-pg/pull/610)
|
43
|
+
- 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.
|
44
|
+
[#611](https://github.com/ged/ruby-pg/pull/611)
|
45
|
+
- Add Connection#send_pipeline_sync, async_pipeline_sync and release GVL at PQ(sendP|P)ipelineSync.
|
46
|
+
[#612](https://github.com/ged/ruby-pg/pull/612)
|
47
|
+
|
48
|
+
Removed:
|
49
|
+
|
50
|
+
- Drop support of Ruby < 2.7 [#606](https://github.com/ged/ruby-pg/pull/606)
|
51
|
+
- Drop support of PostgreSQL < 10 [#606](https://github.com/ged/ruby-pg/pull/606)
|
52
|
+
- Remove workaround for Truffleruby < 21.3.0 [#613](https://github.com/ged/ruby-pg/pull/613)
|
53
|
+
|
54
|
+
|
1
55
|
## v1.5.9 [2024-10-24] Lars Kanis <lars@greiz-reinsdorf.de>
|
2
56
|
|
3
57
|
- Enable thread safety in static OpenSSL build for Windows. [#595](https://github.com/ged/ruby-pg/pull/595)
|
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.9.1"
|
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/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
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
* ホーム :: https://github.com/ged/ruby-pg
|
4
4
|
* ドキュメント :: http://deveiate.org/code/pg (英語)、 https://deveiate.org/code/pg/README_ja_md.html (日本語)
|
5
|
-
* 変更履歴 :: link:/
|
5
|
+
* 変更履歴 :: link:/CHANGELOG.md
|
6
6
|
|
7
7
|
[](https://gitter.im/ged/ruby-pg?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
@@ -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
@@ -3,7 +3,7 @@
|
|
3
3
|
* home :: https://github.com/ged/ruby-pg
|
4
4
|
* docs :: http://deveiate.org/code/pg (English) ,
|
5
5
|
https://deveiate.org/code/pg/README_ja_md.html (Japanese)
|
6
|
-
* clog :: link:/
|
6
|
+
* clog :: link:/CHANGELOG.md
|
7
7
|
|
8
8
|
[](https://gitter.im/ged/ruby-pg?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
9
9
|
|
@@ -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:
|
@@ -175,6 +175,7 @@ The following type maps are prefilled with type mappings from the PG::BasicTypeR
|
|
175
175
|
* PG::BasicTypeMapBasedOnResult - a PG::TypeMapByOid prefilled with encoders for common PostgreSQL column types
|
176
176
|
* PG::BasicTypeMapForQueries - a PG::TypeMapByClass prefilled with encoders for common Ruby value classes
|
177
177
|
|
178
|
+
Several type maps can be chained by setting PG::TypeMap::DefaultTypeMappable#default_type_map .
|
178
179
|
|
179
180
|
## Thread support
|
180
181
|
|
data/Rakefile
CHANGED
@@ -11,6 +11,7 @@ require 'rake/clean'
|
|
11
11
|
require 'rspec/core/rake_task'
|
12
12
|
require 'bundler'
|
13
13
|
require 'bundler/gem_helper'
|
14
|
+
require_relative "rakelib/pg_gem_helper"
|
14
15
|
|
15
16
|
# Build directory constants
|
16
17
|
BASEDIR = Pathname( __FILE__ ).dirname
|
@@ -31,10 +32,10 @@ CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
|
|
31
32
|
CLEAN.include "lib/*/libpq.dll"
|
32
33
|
CLEAN.include "lib/pg_ext.*"
|
33
34
|
CLEAN.include "lib/pg/postgresql_lib_path.rb"
|
35
|
+
CLEAN.include "ports/*.installed"
|
36
|
+
CLEAN.include "ports/*mingw*", "ports/*linux*", "ports/*darwin*"
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
Bundler::GemHelper.install_tasks
|
38
|
+
PgGemHelper.install_tasks
|
38
39
|
$gem_spec = Bundler.load_gemspec(GEMSPEC)
|
39
40
|
|
40
41
|
desc "Turn on warnings and debugging in the build."
|
@@ -42,6 +43,23 @@ task :maint do
|
|
42
43
|
ENV['MAINTAINER_MODE'] = 'yes'
|
43
44
|
end
|
44
45
|
|
46
|
+
CrossLibrary = Struct.new :platform, :openssl_config, :toolchain
|
47
|
+
CrossLibraries = [
|
48
|
+
['aarch64-mingw-ucrt', 'mingwarm64', 'aarch64-w64-mingw32'],
|
49
|
+
['x64-mingw-ucrt', 'mingw64', 'x86_64-w64-mingw32'],
|
50
|
+
['x86-mingw32', 'mingw', 'i686-w64-mingw32'],
|
51
|
+
['x64-mingw32', 'mingw64', 'x86_64-w64-mingw32'],
|
52
|
+
['x86_64-linux', 'linux-x86_64', 'x86_64-linux-gnu'],
|
53
|
+
['aarch64-linux', 'linux-aarch64', 'aarch64-linux-gnu'],
|
54
|
+
['x86_64-darwin', 'darwin64-x86_64', 'x86_64-apple-darwin'],
|
55
|
+
['arm64-darwin', 'darwin64-arm64', 'arm64-apple-darwin'],
|
56
|
+
].map do |platform, openssl_config, toolchain|
|
57
|
+
CrossLibrary.new platform, openssl_config, toolchain
|
58
|
+
end
|
59
|
+
|
60
|
+
# Register binary gems to be pushed to rubygems.org
|
61
|
+
Bundler::GemHelper.instance.cross_platforms = CrossLibraries.map(&:platform)
|
62
|
+
|
45
63
|
# Rake-compiler task
|
46
64
|
Rake::ExtensionTask.new do |ext|
|
47
65
|
ext.name = 'pg_ext'
|
@@ -50,24 +68,73 @@ Rake::ExtensionTask.new do |ext|
|
|
50
68
|
ext.lib_dir = 'lib'
|
51
69
|
ext.source_pattern = "*.{c,h}"
|
52
70
|
ext.cross_compile = true
|
53
|
-
ext.cross_platform = CrossLibraries.map(&:
|
71
|
+
ext.cross_platform = CrossLibraries.map(&:platform)
|
54
72
|
|
55
|
-
ext.cross_config_options += CrossLibraries.map do |
|
73
|
+
ext.cross_config_options += CrossLibraries.map do |xlib|
|
56
74
|
{
|
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}",
|
75
|
+
xlib.platform => [
|
76
|
+
"--with-cross-build=#{xlib.platform}",
|
77
|
+
"--with-openssl-platform=#{xlib.openssl_config}",
|
78
|
+
"--with-toolchain=#{xlib.toolchain}",
|
63
79
|
]
|
64
80
|
}
|
65
81
|
end
|
66
82
|
|
67
|
-
# Add libpq.dll to
|
83
|
+
# Add libpq.dll/.so to fat binary gemspecs
|
68
84
|
ext.cross_compiling do |spec|
|
69
|
-
spec.files << "
|
85
|
+
spec.files << "ports/#{spec.platform.to_s}/lib/libpq-ruby-pg.so.1" if spec.platform.to_s =~ /linux/
|
86
|
+
spec.files << "ports/#{spec.platform.to_s}/lib/libpq-ruby-pg.1.dylib" if spec.platform.to_s =~ /darwin/
|
87
|
+
spec.files << "ports/#{spec.platform.to_s}/lib/libpq.dll" if spec.platform.to_s =~ /mingw|mswin/
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
task 'gem:native:prepare' do
|
92
|
+
require 'io/console'
|
93
|
+
require 'rake_compiler_dock'
|
94
|
+
|
95
|
+
# Copy gem signing key and certs to be accessible from the docker container
|
96
|
+
mkdir_p 'build/gem'
|
97
|
+
sh "cp ~/.gem/gem-*.pem build/gem/ || true"
|
98
|
+
sh "bundle package"
|
99
|
+
begin
|
100
|
+
OpenSSL::PKey.read(File.read(File.expand_path("~/.gem/gem-private_key.pem")), ENV["GEM_PRIVATE_KEY_PASSPHRASE"] || "")
|
101
|
+
rescue OpenSSL::PKey::PKeyError
|
102
|
+
ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = STDIN.getpass("Enter passphrase of gem signature key: ")
|
103
|
+
retry
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
task 'install_darwin_mig', [:arch] do |t, args|
|
108
|
+
sh <<~EOT
|
109
|
+
rm -rf bootstrap_cmds &&
|
110
|
+
git clone --branch=cross_platform https://github.com/markmentovai/bootstrap_cmds &&
|
111
|
+
cd bootstrap_cmds &&
|
112
|
+
autoreconf --install &&
|
113
|
+
sh configure &&
|
114
|
+
make &&
|
115
|
+
sed -E -i 's/^cppflags=(.*)/cppflags=(\\1 "-D#{args[:arch]}" "-I\\/opt\\/osxcross\\/target\\/SDK\\/MacOSX11.1.sdk\\/usr\\/include")/' migcom.tproj/mig.sh &&
|
116
|
+
sudo make install
|
117
|
+
EOT
|
118
|
+
end
|
119
|
+
|
120
|
+
CrossLibraries.each do |xlib|
|
121
|
+
platform = xlib.platform
|
122
|
+
desc "Build fat binary gem for platform #{platform}"
|
123
|
+
task "gem:native:#{platform}" => ['gem:native:prepare'] do
|
124
|
+
RakeCompilerDock.sh <<-EOT, platform: platform
|
125
|
+
#{ "sudo apt-get update && sudo apt-get install -y bison flex &&" if platform =~ /darwin/ }
|
126
|
+
#{ # remove nm on Linux to suppress PostgreSQL's check for exit which raises thread_exit as a false positive:
|
127
|
+
"sudo mv `which nm` `which nm`.bak &&" if platform =~ /linux/ }
|
128
|
+
sudo apt-get update && sudo apt-get install -y bison flex &&
|
129
|
+
(cp build/gem/gem-*.pem ~/.gem/ || true) &&
|
130
|
+
bundle install --local &&
|
131
|
+
#{ "rake install_darwin_mig[__arm64__]" if platform =~ /arm64-darwin/ }
|
132
|
+
#{ "rake install_darwin_mig[__x86_64__]" if platform =~ /x86_64-darwin/ }
|
133
|
+
rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKEOPTS=-j`nproc` RUBY_CC_VERSION=#{RakeCompilerDock.ruby_cc_version("~>2.7", "~>3.0")}
|
134
|
+
EOT
|
70
135
|
end
|
136
|
+
desc "Build the native binary gems"
|
137
|
+
multitask 'gem:native' => "gem:native:#{platform}"
|
71
138
|
end
|
72
139
|
|
73
140
|
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,163 @@ 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.5.1'
|
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.5'
|
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|darwin/
|
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|darwin/
|
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
|
+
def configure
|
95
|
+
if RUBY_PLATFORM=~/darwin/
|
96
|
+
ENV["CC"] = host[/^.*[^\.\d]/] + "-clang"
|
97
|
+
ENV["CXX"] = host[/^.*[^\.\d]/] + "-c++"
|
98
|
+
|
99
|
+
# Manually set the correct values for configure checks that libkrb5 won't be
|
100
|
+
# able to perform because we're cross-compiling.
|
101
|
+
ENV["krb5_cv_attr_constructor_destructor"] = "yes"
|
102
|
+
ENV["ac_cv_func_regcomp"] = "yes"
|
103
|
+
ENV["ac_cv_printf_positional"] = "yes"
|
104
|
+
end
|
105
|
+
super
|
106
|
+
end
|
107
|
+
end
|
108
|
+
# We specify -fcommon to get around duplicate definition errors in recent gcc.
|
109
|
+
# See https://github.com/cockroachdb/cockroach/issues/49734
|
110
|
+
recipe.configure_options << "CFLAGS=-fcommon#{" -fPIC" if RUBY_PLATFORM =~ /linux/}"
|
111
|
+
recipe.configure_options << "LDFLAGS=-framework Kerberos" if RUBY_PLATFORM =~ /darwin/
|
112
|
+
recipe.configure_options << "--without-keyutils"
|
113
|
+
recipe.configure_options << "--disable-nls"
|
114
|
+
recipe.configure_options << "--disable-silent-rules"
|
115
|
+
recipe.configure_options << "--without-system-verto"
|
116
|
+
recipe.configure_options << "krb5_cv_attr_constructor_destructor=yes"
|
117
|
+
recipe.configure_options << "ac_cv_func_regcomp=yes"
|
118
|
+
recipe.configure_options << "ac_cv_printf_positional=yes"
|
119
|
+
recipe.host = toolchain
|
120
|
+
recipe.cook_and_activate
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# We build a libpq library file which static links OpenSSL and krb5.
|
125
|
+
# Our builtin libpq is referenced in different ways depending on the OS:
|
126
|
+
# - Window: Add the ports directory at runtime per RubyInstaller::Runtime.add_dll_directory
|
127
|
+
# The file is called "libpq.dll"
|
128
|
+
# - Linux: Add a rpath to pg_ext.so which references the ports directory.
|
129
|
+
# The file is called "libpq-ruby-pg.so.1" to avoid loading of system libpq by accident.
|
130
|
+
# - Macos: Add a reference with relative path in pg_ext.so to the ports directory.
|
131
|
+
# The file is called "libpq-ruby-pg.1.dylib" to avoid loading of other libpq by accident.
|
132
|
+
libpq_orig, libpq_rubypg = case RUBY_PLATFORM
|
133
|
+
when /linux/ then ["libpq.so.5", "libpq-ruby-pg.so.1"]
|
134
|
+
when /darwin/ then ["libpq.5.dylib", "libpq-ruby-pg.1.dylib"]
|
135
|
+
# when /mingw/ then ["libpq.dll", "libpq.dll"] # renaming not needed
|
136
|
+
end
|
137
|
+
|
138
|
+
postgresql_recipe = BuildRecipe.new("postgresql", POSTGRESQL_VERSION, [POSTGRESQL_SOURCE_URI]).tap do |recipe|
|
139
|
+
class << recipe
|
140
|
+
def configure_defaults
|
141
|
+
[
|
142
|
+
"--target=#{host}",
|
143
|
+
"--host=#{host}",
|
144
|
+
'--with-openssl',
|
145
|
+
*(RUBY_PLATFORM=~/linux|darwin/ ? ['--with-gssapi'] : []),
|
146
|
+
'--without-zlib',
|
147
|
+
'--without-icu',
|
148
|
+
'--without-readline',
|
149
|
+
'ac_cv_search_gss_store_cred_into=',
|
150
|
+
]
|
151
|
+
end
|
152
|
+
def compile
|
153
|
+
execute 'compile include', "#{make_cmd} -C src/include install"
|
154
|
+
execute 'compile interfaces', "#{make_cmd} -C src/interfaces install"
|
155
|
+
end
|
156
|
+
def install
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
recipe.host = toolchain
|
161
|
+
recipe.configure_options << "CFLAGS=#{" -fPIC" if RUBY_PLATFORM =~ /linux|darwin/}"
|
162
|
+
recipe.configure_options << "LDFLAGS=-L#{openssl_recipe.path}/lib -L#{openssl_recipe.path}/lib64 -L#{openssl_recipe.path}/lib-arm64 #{"-Wl,-soname,#{libpq_rubypg} -lgssapi_krb5 -lkrb5 -lk5crypto -lkrb5support -ldl" if RUBY_PLATFORM =~ /linux/} #{"-Wl,-install_name,@loader_path/../../ports/#{gem_platform}/lib/#{libpq_rubypg} -lgssapi_krb5 -lkrb5 -lk5crypto -lkrb5support -lresolv -framework Kerberos" if RUBY_PLATFORM =~ /darwin/}"
|
163
|
+
recipe.configure_options << "LIBS=-lkrb5 -lcom_err -lk5crypto -lkrb5support -lresolv" if RUBY_PLATFORM =~ /linux/
|
164
|
+
recipe.configure_options << "LIBS=-lssl -lwsock32 -lgdi32 -lws2_32 -lcrypt32" if RUBY_PLATFORM =~ /mingw|mswin/
|
165
|
+
recipe.configure_options << "CPPFLAGS=-I#{openssl_recipe.path}/include"
|
166
|
+
recipe.cook_and_activate
|
167
|
+
end
|
168
|
+
|
169
|
+
# Use our own library name for libpq to avoid loading of system libpq by accident.
|
170
|
+
FileUtils.ln_sf File.join(postgresql_recipe.port_path, "lib/#{libpq_orig}"),
|
171
|
+
File.join(postgresql_recipe.port_path, "lib/#{libpq_rubypg}")
|
28
172
|
# Avoid dependency to external libgcc.dll on x86-mingw32
|
29
|
-
$LDFLAGS << " -static-libgcc"
|
173
|
+
$LDFLAGS << " -static-libgcc" if RUBY_PLATFORM =~ /mingw|mswin/
|
174
|
+
# Avoid: "libpq.so: undefined reference to `dlopen'" in cross-ruby-2.7.8
|
175
|
+
$LDFLAGS << " -Wl,--no-as-needed" if RUBY_PLATFORM !~ /aarch64|arm64|darwin/
|
176
|
+
# Find libpq in the ports directory coming from lib/3.x
|
177
|
+
# It is shared between all compiled ruby versions.
|
178
|
+
$LDFLAGS << " '-Wl,-rpath=$$ORIGIN/../../ports/#{gem_platform}/lib'" if RUBY_PLATFORM =~ /linux/
|
30
179
|
# Don't use pg_config for cross build, but --with-pg-* path options
|
31
|
-
dir_config
|
180
|
+
dir_config('pg', "#{postgresql_recipe.path}/include", "#{postgresql_recipe.path}/lib")
|
32
181
|
|
182
|
+
$defs.push( "-DPG_IS_BINARY_GEM")
|
33
183
|
else
|
34
184
|
# Native build
|
35
185
|
|
@@ -79,7 +229,7 @@ $INSTALLFILES = {
|
|
79
229
|
"./postgresql_lib_path.rb" => "$(RUBYLIBDIR)/pg/"
|
80
230
|
}
|
81
231
|
|
82
|
-
if
|
232
|
+
if /solaris/ =~ RUBY_PLATFORM
|
83
233
|
append_cppflags( '-D__EXTENSIONS__' )
|
84
234
|
end
|
85
235
|
|
@@ -144,26 +294,20 @@ if /mingw/ =~ RUBY_PLATFORM && RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
|
|
144
294
|
end
|
145
295
|
end
|
146
296
|
|
147
|
-
have_func '
|
297
|
+
have_func 'PQencryptPasswordConn', 'libpq-fe.h' or # since PostgreSQL-10
|
148
298
|
abort "Your PostgreSQL is too old. Either install an older version " +
|
149
|
-
"of this gem or upgrade your database to at least PostgreSQL-
|
299
|
+
"of this gem or upgrade your database to at least PostgreSQL-10."
|
150
300
|
# 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
301
|
have_func 'PQresultMemorySize', 'libpq-fe.h' # since PostgreSQL-12
|
155
302
|
have_func 'PQenterPipelineMode', 'libpq-fe.h' do |src| # since PostgreSQL-14
|
156
303
|
# Ensure header files fit as well
|
157
304
|
src + " int con(){ return PGRES_PIPELINE_SYNC; }"
|
158
305
|
end
|
306
|
+
have_func 'PQsetChunkedRowsMode', 'libpq-fe.h' # since PostgreSQL-17
|
159
307
|
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
308
|
have_func 'rb_io_wait' # since ruby-3.0
|
163
309
|
have_func 'rb_io_descriptor' # since ruby-3.1
|
164
310
|
|
165
|
-
# unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
|
166
|
-
have_header 'unistd.h'
|
167
311
|
have_header 'inttypes.h'
|
168
312
|
have_header('ruby/fiber/scheduler.h') if RUBY_PLATFORM=~/mingw|mswin/
|
169
313
|
|
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
|
|