pg 1.5.8 → 1.6.0.rc1
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 +37 -0
- data/README-Windows.rdoc +1 -1
- data/README.ja.md +3 -3
- data/README.md +4 -4
- data/Rakefile +56 -13
- data/ext/errorcodes.def +4 -5
- data/ext/errorcodes.txt +2 -5
- 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/pg/basic_type_registry.rb +2 -2
- data/lib/pg/cancel_connection.rb +30 -0
- data/lib/pg/connection.rb +187 -133
- data/lib/pg/version.rb +1 -1
- data/lib/pg.rb +13 -8
- data/pg.gemspec +5 -3
- data.tar.gz.sig +0 -0
- metadata +10 -21
- metadata.gz.sig +0 -0
- data/.appveyor.yml +0 -42
- data/.gems +0 -6
- data/.gemtest +0 -0
- data/.github/workflows/binary-gems.yml +0 -117
- data/.github/workflows/source-gem.yml +0 -152
- data/.gitignore +0 -22
- data/.hgsigs +0 -34
- data/.hgtags +0 -41
- data/.irbrc +0 -23
- data/.pryrc +0 -23
- data/.tm_properties +0 -21
- data/.travis.yml +0 -49
- data/Rakefile.cross +0 -298
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79b95ddd7cf2f41c4295570df7472993c734fa4f562631f4d8a2dd57f959a2e2
|
4
|
+
data.tar.gz: 14c732693af768e0ee2b071e9bbd2a7def69ca3e3e2140b8c55406634ab7272c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89d7479a9c132c1ff8844b1346d083ce3b7d37a275fcc8e4d56523a3a49f79e44f4620fa1b4ad8b53d0e71ebdb36f278a48b9aa792169492395a2e412142b161
|
7
|
+
data.tar.gz: ac4ad88528e83ab1fb7132ae9b8f6b0c685a747ea46c802c4f16fda4d9c26b01e01fe207a31525293eb3e68d74044850a754598a4ba61640b24762b6b39eb542
|
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,40 @@
|
|
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
|
+
|
27
|
+
## v1.5.9 [2024-10-24] Lars Kanis <lars@greiz-reinsdorf.de>
|
28
|
+
|
29
|
+
- Enable thread safety in static OpenSSL build for Windows. [#595](https://github.com/ged/ruby-pg/pull/595)
|
30
|
+
- Remove raising `conect_timeout` from 1 to 2 seconds. [#590](https://github.com/ged/ruby-pg/pull/590)
|
31
|
+
- Fix binary copy_data in Ractor context. [#594](https://github.com/ged/ruby-pg/pull/594)
|
32
|
+
- Exclude CI files and hidden files from built gem. [#591](https://github.com/ged/ruby-pg/pull/591)
|
33
|
+
This is to simplify security inspection.
|
34
|
+
- Update error classes to PostgreSQL-17.
|
35
|
+
- Update Windows fat binary gem to OpenSSL-3.4.0 and PostgreSQL-17.0.
|
36
|
+
|
37
|
+
|
1
38
|
## v1.5.8 [2024-09-06] Lars Kanis <lars@greiz-reinsdorf.de>
|
2
39
|
|
3
40
|
- Fix host list duplication every time conn.reset is used. [#586](https://github.com/ged/ruby-pg/pull/586)
|
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"
|
@@ -94,7 +137,7 @@ end
|
|
94
137
|
|
95
138
|
desc "Update list of server error codes"
|
96
139
|
task :update_error_codes do
|
97
|
-
URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/
|
140
|
+
URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL_17_0"
|
98
141
|
|
99
142
|
ERRORCODES_TXT = "ext/errorcodes.txt"
|
100
143
|
sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
|
data/ext/errorcodes.def
CHANGED
@@ -453,6 +453,10 @@
|
|
453
453
|
VALUE klass = define_error_class( "IdleInTransactionSessionTimeout", "25" );
|
454
454
|
register_error_class( "25P03", klass );
|
455
455
|
}
|
456
|
+
{
|
457
|
+
VALUE klass = define_error_class( "TransactionTimeout", "25" );
|
458
|
+
register_error_class( "25P04", klass );
|
459
|
+
}
|
456
460
|
{
|
457
461
|
VALUE klass = define_error_class( "InvalidSqlStatementName", NULL );
|
458
462
|
register_error_class( "26000", klass );
|
@@ -885,11 +889,6 @@
|
|
885
889
|
VALUE klass = define_error_class( "DuplicateFile", "58" );
|
886
890
|
register_error_class( "58P02", klass );
|
887
891
|
}
|
888
|
-
{
|
889
|
-
VALUE klass = define_error_class( "SnapshotTooOld", NULL );
|
890
|
-
register_error_class( "72000", klass );
|
891
|
-
register_error_class( "72", klass );
|
892
|
-
}
|
893
892
|
{
|
894
893
|
VALUE klass = define_error_class( "ConfigFileError", NULL );
|
895
894
|
register_error_class( "F0000", klass );
|
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-2024, 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
|
@@ -252,6 +252,7 @@ Section: Class 25 - Invalid Transaction State
|
|
252
252
|
25P01 E ERRCODE_NO_ACTIVE_SQL_TRANSACTION no_active_sql_transaction
|
253
253
|
25P02 E ERRCODE_IN_FAILED_SQL_TRANSACTION in_failed_sql_transaction
|
254
254
|
25P03 E ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT idle_in_transaction_session_timeout
|
255
|
+
25P04 E ERRCODE_TRANSACTION_TIMEOUT transaction_timeout
|
255
256
|
|
256
257
|
Section: Class 26 - Invalid SQL Statement Name
|
257
258
|
|
@@ -439,10 +440,6 @@ Section: Class 58 - System Error (errors external to PostgreSQL itself)
|
|
439
440
|
58P01 E ERRCODE_UNDEFINED_FILE undefined_file
|
440
441
|
58P02 E ERRCODE_DUPLICATE_FILE duplicate_file
|
441
442
|
|
442
|
-
Section: Class 72 - Snapshot Failure
|
443
|
-
# (class borrowed from Oracle)
|
444
|
-
72000 E ERRCODE_SNAPSHOT_TOO_OLD snapshot_too_old
|
445
|
-
|
446
443
|
Section: Class F0 - Configuration File Error
|
447
444
|
|
448
445
|
# (PostgreSQL-specific error class)
|
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
|
}
|