pg 1.4.6 → 1.6.0
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} +177 -3
- data/Gemfile +12 -3
- data/README-Windows.rdoc +1 -1
- data/README.ja.md +75 -41
- data/README.md +34 -19
- data/Rakefile +84 -14
- data/certs/kanis@comcard.de.pem +20 -0
- data/certs/larskanis-2024.pem +24 -0
- data/ext/errorcodes.def +4 -5
- data/ext/errorcodes.txt +2 -5
- data/ext/extconf.rb +165 -14
- data/ext/gvl_wrappers.c +13 -2
- data/ext/gvl_wrappers.h +33 -0
- data/ext/pg.c +28 -35
- data/ext/pg.h +18 -14
- data/ext/pg_binary_decoder.c +231 -0
- data/ext/pg_binary_encoder.c +427 -0
- data/ext/pg_cancel_connection.c +360 -0
- data/ext/pg_coder.c +68 -12
- data/ext/pg_connection.c +473 -208
- data/ext/pg_copy_coder.c +316 -23
- data/ext/pg_record_coder.c +12 -11
- data/ext/pg_result.c +102 -30
- data/ext/pg_text_decoder.c +31 -10
- data/ext/pg_text_encoder.c +58 -26
- data/ext/pg_tuple.c +36 -33
- data/ext/pg_type_map.c +4 -3
- data/ext/pg_type_map_all_strings.c +3 -3
- data/ext/pg_type_map_by_class.c +6 -4
- data/ext/pg_type_map_by_column.c +9 -4
- data/ext/pg_type_map_by_mri_type.c +1 -1
- data/ext/pg_type_map_by_oid.c +10 -5
- data/ext/pg_type_map_in_ruby.c +6 -3
- data/lib/pg/basic_type_map_based_on_result.rb +21 -1
- data/lib/pg/basic_type_map_for_queries.rb +23 -10
- data/lib/pg/basic_type_map_for_results.rb +26 -3
- data/lib/pg/basic_type_registry.rb +46 -36
- data/lib/pg/binary_decoder/date.rb +9 -0
- data/lib/pg/binary_decoder/timestamp.rb +26 -0
- data/lib/pg/binary_encoder/timestamp.rb +20 -0
- data/lib/pg/cancel_connection.rb +53 -0
- data/lib/pg/coder.rb +17 -14
- data/lib/pg/connection.rb +387 -172
- data/lib/pg/exceptions.rb +6 -0
- data/lib/pg/text_decoder/date.rb +21 -0
- data/lib/pg/text_decoder/inet.rb +9 -0
- data/lib/pg/text_decoder/json.rb +17 -0
- data/lib/pg/text_decoder/numeric.rb +9 -0
- data/lib/pg/text_decoder/timestamp.rb +30 -0
- data/lib/pg/text_encoder/date.rb +13 -0
- data/lib/pg/text_encoder/inet.rb +31 -0
- data/lib/pg/text_encoder/json.rb +17 -0
- data/lib/pg/text_encoder/numeric.rb +9 -0
- data/lib/pg/text_encoder/timestamp.rb +24 -0
- data/lib/pg/version.rb +1 -1
- data/lib/pg.rb +78 -17
- 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 +9 -5
- 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/rakelib/pg_gem_helper.rb +64 -0
- data.tar.gz.sig +0 -0
- metadata +61 -49
- 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 -137
- data/.gitignore +0 -19
- 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/Manifest.txt +0 -72
- data/Rakefile.cross +0 -298
- data/lib/pg/binary_decoder.rb +0 -23
- data/lib/pg/constants.rb +0 -12
- data/lib/pg/text_decoder.rb +0 -46
- data/lib/pg/text_encoder.rb +0 -59
- data/translation/.po4a-version +0 -7
- data/translation/po/all.pot +0 -875
- data/translation/po/ja.po +0 -868
- data/translation/po4a.cfg +0 -9
data/Rakefile
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# -*- rake -*-
|
2
2
|
|
3
|
+
# Enable english error messages, as some specs depend on them
|
4
|
+
ENV["LANG"] = "C"
|
5
|
+
|
3
6
|
require 'rbconfig'
|
4
7
|
require 'pathname'
|
5
8
|
require 'tmpdir'
|
@@ -8,6 +11,7 @@ require 'rake/clean'
|
|
8
11
|
require 'rspec/core/rake_task'
|
9
12
|
require 'bundler'
|
10
13
|
require 'bundler/gem_helper'
|
14
|
+
require_relative "rakelib/pg_gem_helper"
|
11
15
|
|
12
16
|
# Build directory constants
|
13
17
|
BASEDIR = Pathname( __FILE__ ).dirname
|
@@ -28,10 +32,10 @@ CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
|
|
28
32
|
CLEAN.include "lib/*/libpq.dll"
|
29
33
|
CLEAN.include "lib/pg_ext.*"
|
30
34
|
CLEAN.include "lib/pg/postgresql_lib_path.rb"
|
35
|
+
CLEAN.include "ports/*.installed"
|
36
|
+
CLEAN.include "ports/*mingw*", "ports/*linux*", "ports/*darwin*"
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
Bundler::GemHelper.install_tasks
|
38
|
+
PgGemHelper.install_tasks
|
35
39
|
$gem_spec = Bundler.load_gemspec(GEMSPEC)
|
36
40
|
|
37
41
|
desc "Turn on warnings and debugging in the build."
|
@@ -39,6 +43,23 @@ task :maint do
|
|
39
43
|
ENV['MAINTAINER_MODE'] = 'yes'
|
40
44
|
end
|
41
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
|
+
|
42
63
|
# Rake-compiler task
|
43
64
|
Rake::ExtensionTask.new do |ext|
|
44
65
|
ext.name = 'pg_ext'
|
@@ -47,24 +68,73 @@ Rake::ExtensionTask.new do |ext|
|
|
47
68
|
ext.lib_dir = 'lib'
|
48
69
|
ext.source_pattern = "*.{c,h}"
|
49
70
|
ext.cross_compile = true
|
50
|
-
ext.cross_platform = CrossLibraries.map(&:
|
71
|
+
ext.cross_platform = CrossLibraries.map(&:platform)
|
51
72
|
|
52
|
-
ext.cross_config_options += CrossLibraries.map do |
|
73
|
+
ext.cross_config_options += CrossLibraries.map do |xlib|
|
53
74
|
{
|
54
|
-
|
55
|
-
"--
|
56
|
-
"--with-
|
57
|
-
"--with-
|
58
|
-
# libpq-fe.h resides in src/interfaces/libpq/ before make install
|
59
|
-
"--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}",
|
60
79
|
]
|
61
80
|
}
|
62
81
|
end
|
63
82
|
|
64
|
-
# Add libpq.dll to
|
83
|
+
# Add libpq.dll/.so to fat binary gemspecs
|
65
84
|
ext.cross_compiling do |spec|
|
66
|
-
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
|
67
135
|
end
|
136
|
+
desc "Build the native binary gems"
|
137
|
+
multitask 'gem:native' => "gem:native:#{platform}"
|
68
138
|
end
|
69
139
|
|
70
140
|
RSpec::Core::RakeTask.new(:spec).rspec_opts = "--profile -cfdoc"
|
@@ -91,7 +161,7 @@ end
|
|
91
161
|
|
92
162
|
desc "Update list of server error codes"
|
93
163
|
task :update_error_codes do
|
94
|
-
URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/
|
164
|
+
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"
|
95
165
|
|
96
166
|
ERRORCODES_TXT = "ext/errorcodes.txt"
|
97
167
|
sh "wget #{URL_ERRORCODES_TXT.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frMWqbOahj9uth6WSxhNexUtbjk6P8emmXOJi5
|
12
|
+
chQPnWX+N3Gj+jjYxqTFdwT7Mj3pv1VHa+aNUbqSPpvJeDyxRIuo9hvzDaBHb/Cg
|
13
|
+
9qRVcm8a96n4t7y2lrX1oookY6bkBaxWOMtWlqIprq8JZXM9AgMBAAGjOTA3MAkG
|
14
|
+
A1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQ4h1tIyvdUWtMI739xMzTR
|
15
|
+
7EfMFzANBgkqhkiG9w0BAQsFAAOCAYEArBmHSfnUyNWf3R1Fx0mMHloWGdcKn2D2
|
16
|
+
BsqTApXU2nADiyppIqRq4b9e7hw342uzadSLkoQcEFOxThLRhAcijoWfQVBcsbV/
|
17
|
+
ZsCY1qlUTIJuSWxaSyS4efUX+N4eMNyPM9oW/sphlWFo0DgI34Y9WB6HDzH+O71y
|
18
|
+
R7PARke3f4kYnRJf5yRQLPDrH9UYt9KlBQm6l7XMtr5EMnQt0EfcmZEi9H4t/vS2
|
19
|
+
haxvpFMdAKo4H46GBYNO96r6b74t++vgQSBTg/AFVwvRZwNSrPPcBfb4xxeEAhRR
|
20
|
+
x+LU7feIH7lZ//3buiyD03gLAEtHXai0Y+/VfuWIpwYJAl2BO/tU7FS/dtbJq9oc
|
21
|
+
dI36Yyzy+BrCM0WT4oCsagePNb97FaNhl4F6sM5JEPT0ZPxRx0i3G4TNNIYziVos
|
22
|
+
5wFER6XhvvLDFAMh/jMg+s7Wd5SbSHgHNSUaUGVtdWkVPOer6oF0aLdZUR3CETkn
|
23
|
+
5nWXZma/BUd3YgYA/Xumc6QQqIS4p7mr
|
24
|
+
-----END CERTIFICATE-----
|
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 <<
|
@@ -9,6 +8,8 @@ if ENV['MAINTAINER_MODE']
|
|
9
8
|
' -ggdb' <<
|
10
9
|
' -DDEBUG' <<
|
11
10
|
' -pedantic'
|
11
|
+
$LDFLAGS <<
|
12
|
+
' -ggdb'
|
12
13
|
end
|
13
14
|
|
14
15
|
if pgdir = with_config( 'pg' )
|
@@ -22,12 +23,163 @@ else
|
|
22
23
|
$stderr.puts "Calling libpq with GVL locked"
|
23
24
|
end
|
24
25
|
|
25
|
-
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}")
|
26
172
|
# Avoid dependency to external libgcc.dll on x86-mingw32
|
27
|
-
$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/
|
28
179
|
# Don't use pg_config for cross build, but --with-pg-* path options
|
29
|
-
dir_config
|
180
|
+
dir_config('pg', "#{postgresql_recipe.path}/include", "#{postgresql_recipe.path}/lib")
|
30
181
|
|
182
|
+
$defs.push( "-DPG_IS_BINARY_GEM")
|
31
183
|
else
|
32
184
|
# Native build
|
33
185
|
|
@@ -60,6 +212,10 @@ else
|
|
60
212
|
if dlldir && RbConfig::CONFIG["RPATHFLAG"].to_s.empty?
|
61
213
|
append_ldflags "-Wl,-rpath,#{dlldir.quote}"
|
62
214
|
end
|
215
|
+
|
216
|
+
if /mswin/ =~ RUBY_PLATFORM
|
217
|
+
$libs = append_library($libs, 'ws2_32')
|
218
|
+
end
|
63
219
|
end
|
64
220
|
|
65
221
|
$stderr.puts "Using libpq from #{dlldir}"
|
@@ -73,7 +229,7 @@ $INSTALLFILES = {
|
|
73
229
|
"./postgresql_lib_path.rb" => "$(RUBYLIBDIR)/pg/"
|
74
230
|
}
|
75
231
|
|
76
|
-
if
|
232
|
+
if /solaris/ =~ RUBY_PLATFORM
|
77
233
|
append_cppflags( '-D__EXTENSIONS__' )
|
78
234
|
end
|
79
235
|
|
@@ -138,25 +294,20 @@ if /mingw/ =~ RUBY_PLATFORM && RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
|
|
138
294
|
end
|
139
295
|
end
|
140
296
|
|
141
|
-
have_func '
|
297
|
+
have_func 'PQencryptPasswordConn', 'libpq-fe.h' or # since PostgreSQL-10
|
142
298
|
abort "Your PostgreSQL is too old. Either install an older version " +
|
143
|
-
"of this gem or upgrade your database to at least PostgreSQL-
|
299
|
+
"of this gem or upgrade your database to at least PostgreSQL-10."
|
144
300
|
# optional headers/functions
|
145
|
-
have_func 'PQsslAttribute', 'libpq-fe.h' # since PostgreSQL-9.5
|
146
|
-
have_func 'PQresultVerboseErrorMessage', 'libpq-fe.h' # since PostgreSQL-9.6
|
147
|
-
have_func 'PQencryptPasswordConn', 'libpq-fe.h' # since PostgreSQL-10
|
148
301
|
have_func 'PQresultMemorySize', 'libpq-fe.h' # since PostgreSQL-12
|
149
302
|
have_func 'PQenterPipelineMode', 'libpq-fe.h' do |src| # since PostgreSQL-14
|
150
303
|
# Ensure header files fit as well
|
151
304
|
src + " int con(){ return PGRES_PIPELINE_SYNC; }"
|
152
305
|
end
|
306
|
+
have_func 'PQsetChunkedRowsMode', 'libpq-fe.h' # since PostgreSQL-17
|
153
307
|
have_func 'timegm'
|
154
|
-
have_func 'rb_gc_adjust_memory_usage' # since ruby-2.4
|
155
|
-
have_func 'rb_gc_mark_movable' # since ruby-2.7
|
156
308
|
have_func 'rb_io_wait' # since ruby-3.0
|
309
|
+
have_func 'rb_io_descriptor' # since ruby-3.1
|
157
310
|
|
158
|
-
# unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
|
159
|
-
have_header 'unistd.h'
|
160
311
|
have_header 'inttypes.h'
|
161
312
|
have_header('ruby/fiber/scheduler.h') if RUBY_PLATFORM=~/mingw|mswin/
|
162
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
|
|