pg 1.4.6 → 1.6.1
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} +185 -3
- data/Gemfile +12 -3
- data/README-Windows.rdoc +1 -1
- data/README.ja.md +75 -41
- data/README.md +86 -31
- data/Rakefile +95 -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 +70 -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 +18 -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/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# pg
|
2
2
|
|
3
3
|
* home :: https://github.com/ged/ruby-pg
|
4
|
-
* docs :: http://deveiate.org/code/pg
|
5
|
-
|
4
|
+
* docs :: http://deveiate.org/code/pg (English) ,
|
5
|
+
https://deveiate.org/code/pg/README_ja_md.html (Japanese)
|
6
|
+
* clog :: link:/CHANGELOG.md
|
6
7
|
|
7
8
|
[](https://gitter.im/ged/ruby-pg?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
8
9
|
|
@@ -10,7 +11,7 @@
|
|
10
11
|
## Description
|
11
12
|
|
12
13
|
Pg is the Ruby interface to the [PostgreSQL RDBMS](http://www.postgresql.org/).
|
13
|
-
It works with [PostgreSQL
|
14
|
+
It works with [PostgreSQL 10 and later](http://www.postgresql.org/support/versioning/).
|
14
15
|
|
15
16
|
A small example usage:
|
16
17
|
```ruby
|
@@ -38,30 +39,35 @@ A small example usage:
|
|
38
39
|
|
39
40
|
## Requirements
|
40
41
|
|
41
|
-
* Ruby 2.
|
42
|
-
* PostgreSQL
|
42
|
+
* Ruby 2.7 or newer
|
43
|
+
* PostgreSQL 10.x or later
|
44
|
+
* When installing the source gem: libpq with headers, -dev packages, etc.
|
43
45
|
|
44
|
-
It usually works with earlier versions of Ruby/PostgreSQL as well, but those are
|
45
|
-
not regularly tested.
|
46
46
|
|
47
|
+
## How To Install
|
47
48
|
|
48
|
-
|
49
|
+
Install via RubyGems:
|
49
50
|
|
50
|
-
|
51
|
+
gem install pg
|
51
52
|
|
52
|
-
|
53
|
+
This installs the binary gem, specific to the running platform by default.
|
53
54
|
|
54
|
-
|
55
|
+
### Binary gem
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
```
|
57
|
+
The binary gems don't depend on the libpq package on the running system.
|
58
|
+
They have libpq builtin.
|
59
59
|
|
60
|
-
|
60
|
+
The gems for platform `x86_64-linux` and `aarch64-linux` run on Alpine Linux, but require the package `gcompat` there as long as we don't provide a native gem for platform `x86_64-linux-musl`. Install this package like so:
|
61
61
|
|
62
|
-
|
62
|
+
apk add gcompat
|
63
63
|
|
64
|
-
|
64
|
+
There is one use case the binary gems don't support: Retrieval of connection [options from LDAP](https://www.postgresql.org/docs/current/libpq-ldap.html). To support this `libldap` would be necessary, but it has a lot of dependencies. It doesn't seem to be a widely used feature and that it's worth to support it. If it's necessary, the source gem can be forced.
|
65
|
+
|
66
|
+
### Source gem
|
67
|
+
|
68
|
+
The source gem can be forced by:
|
69
|
+
|
70
|
+
gem install pg --platform ruby
|
65
71
|
|
66
72
|
You may need to specify the path to the 'pg_config' program installed with
|
67
73
|
Postgres:
|
@@ -72,6 +78,28 @@ If you're installing via Bundler, you can provide compile hints like so:
|
|
72
78
|
|
73
79
|
bundle config build.pg --with-pg-config=<path to pg_config>
|
74
80
|
|
81
|
+
### Bundler
|
82
|
+
|
83
|
+
To make sure, the necessary platforms and the source gem are fetched by bundler, they can be added like so
|
84
|
+
|
85
|
+
```
|
86
|
+
bundle lock --add-platform x86_64-linux
|
87
|
+
bundle lock --add-platform arm64-darwin
|
88
|
+
bundle lock --add-platform x64-mingw-ucrt
|
89
|
+
bundle lock --add-platform ruby
|
90
|
+
bundle package --all-platforms
|
91
|
+
```
|
92
|
+
|
93
|
+
A re-run of `bundle package` is also necessary after `bundle update`, in order to retrieve the new specific gems of all platforms.
|
94
|
+
|
95
|
+
If the binary gems don't work for some reason, it's easy to force the usage of the source gem in the Gemfile:
|
96
|
+
|
97
|
+
```
|
98
|
+
gem "pg", force_ruby_platform: true
|
99
|
+
```
|
100
|
+
|
101
|
+
### More
|
102
|
+
|
75
103
|
See README-OS_X.rdoc for more information about installing under MacOS X, and
|
76
104
|
README-Windows.rdoc for Windows build/installation instructions.
|
77
105
|
|
@@ -84,6 +112,19 @@ can be found in [the `certs` directory](https://github.com/ged/ruby-pg/tree/mast
|
|
84
112
|
of the repository.
|
85
113
|
|
86
114
|
|
115
|
+
## Versioning
|
116
|
+
|
117
|
+
We tag and release gems according to the [Semantic Versioning](http://semver.org/) principle.
|
118
|
+
|
119
|
+
As a result of this policy, you can (and should) specify a dependency on this gem using the [Pessimistic Version Constraint](http://guides.rubygems.org/patterns/#pessimistic-version-constraint) with two digits of precision.
|
120
|
+
|
121
|
+
For example:
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
spec.add_dependency 'pg', '~> 1.0'
|
125
|
+
```
|
126
|
+
|
127
|
+
|
87
128
|
## Type Casts
|
88
129
|
|
89
130
|
Pg can optionally type cast result values and query parameters in Ruby or
|
@@ -124,26 +165,28 @@ to convert single values to/from their string representation.
|
|
124
165
|
The following PostgreSQL column types are supported by ruby-pg (TE = Text Encoder, TD = Text Decoder, BE = Binary Encoder, BD = Binary Decoder):
|
125
166
|
|
126
167
|
* Integer: [TE](rdoc-ref:PG::TextEncoder::Integer), [TD](rdoc-ref:PG::TextDecoder::Integer), [BD](rdoc-ref:PG::BinaryDecoder::Integer) 💡 No links? Switch to [here](https://deveiate.org/code/pg/README_md.html#label-Type+Casts) 💡
|
127
|
-
|
168
|
+
* BE: [Int2](rdoc-ref:PG::BinaryEncoder::Int2), [Int4](rdoc-ref:PG::BinaryEncoder::Int4), [Int8](rdoc-ref:PG::BinaryEncoder::Int8)
|
128
169
|
* Float: [TE](rdoc-ref:PG::TextEncoder::Float), [TD](rdoc-ref:PG::TextDecoder::Float), [BD](rdoc-ref:PG::BinaryDecoder::Float)
|
170
|
+
* BE: [Float4](rdoc-ref:PG::BinaryEncoder::Float4), [Float8](rdoc-ref:PG::BinaryEncoder::Float8)
|
129
171
|
* Numeric: [TE](rdoc-ref:PG::TextEncoder::Numeric), [TD](rdoc-ref:PG::TextDecoder::Numeric)
|
130
172
|
* Boolean: [TE](rdoc-ref:PG::TextEncoder::Boolean), [TD](rdoc-ref:PG::TextDecoder::Boolean), [BE](rdoc-ref:PG::BinaryEncoder::Boolean), [BD](rdoc-ref:PG::BinaryDecoder::Boolean)
|
131
173
|
* String: [TE](rdoc-ref:PG::TextEncoder::String), [TD](rdoc-ref:PG::TextDecoder::String), [BE](rdoc-ref:PG::BinaryEncoder::String), [BD](rdoc-ref:PG::BinaryDecoder::String)
|
132
174
|
* Bytea: [TE](rdoc-ref:PG::TextEncoder::Bytea), [TD](rdoc-ref:PG::TextDecoder::Bytea), [BE](rdoc-ref:PG::BinaryEncoder::Bytea), [BD](rdoc-ref:PG::BinaryDecoder::Bytea)
|
133
175
|
* Base64: [TE](rdoc-ref:PG::TextEncoder::ToBase64), [TD](rdoc-ref:PG::TextDecoder::FromBase64), [BE](rdoc-ref:PG::BinaryEncoder::FromBase64), [BD](rdoc-ref:PG::BinaryDecoder::ToBase64)
|
134
176
|
* Timestamp:
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
*
|
177
|
+
* TE: [local](rdoc-ref:PG::TextEncoder::TimestampWithoutTimeZone), [UTC](rdoc-ref:PG::TextEncoder::TimestampUtc), [with-TZ](rdoc-ref:PG::TextEncoder::TimestampWithTimeZone)
|
178
|
+
* TD: [local](rdoc-ref:PG::TextDecoder::TimestampLocal), [UTC](rdoc-ref:PG::TextDecoder::TimestampUtc), [UTC-to-local](rdoc-ref:PG::TextDecoder::TimestampUtcToLocal)
|
179
|
+
* BE: [local](rdoc-ref:PG::BinaryEncoder::TimestampLocal), [UTC](rdoc-ref:PG::BinaryEncoder::TimestampUtc)
|
180
|
+
* BD: [local](rdoc-ref:PG::BinaryDecoder::TimestampLocal), [UTC](rdoc-ref:PG::BinaryDecoder::TimestampUtc), [UTC-to-local](rdoc-ref:PG::BinaryDecoder::TimestampUtcToLocal)
|
181
|
+
* 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)
|
139
182
|
* JSON and JSONB: [TE](rdoc-ref:PG::TextEncoder::JSON), [TD](rdoc-ref:PG::TextDecoder::JSON)
|
140
183
|
* Inet: [TE](rdoc-ref:PG::TextEncoder::Inet), [TD](rdoc-ref:PG::TextDecoder::Inet)
|
141
|
-
* Array: [TE](rdoc-ref:PG::TextEncoder::Array), [TD](rdoc-ref:PG::TextDecoder::Array)
|
184
|
+
* 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)
|
142
185
|
* Composite Type (also called "Row" or "Record"): [TE](rdoc-ref:PG::TextEncoder::Record), [TD](rdoc-ref:PG::TextDecoder::Record)
|
143
186
|
|
144
|
-
The following text formats can also be encoded although they are not used as column type:
|
187
|
+
The following text and binary formats can also be encoded although they are not used as column type:
|
145
188
|
|
146
|
-
* COPY input and output data: [TE](rdoc-ref:PG::TextEncoder::CopyRow), [TD](rdoc-ref:PG::TextDecoder::CopyRow)
|
189
|
+
* COPY input and output data: [TE](rdoc-ref:PG::TextEncoder::CopyRow), [TD](rdoc-ref:PG::TextDecoder::CopyRow), [BE](rdoc-ref:PG::BinaryEncoder::CopyRow), [BD](rdoc-ref:PG::BinaryDecoder::CopyRow)
|
147
190
|
* Literal for insertion into SQL string: [TE](rdoc-ref:PG::TextEncoder::QuotedLiteral)
|
148
191
|
* SQL-Identifier: [TE](rdoc-ref:PG::TextEncoder::Identifier), [TD](rdoc-ref:PG::TextDecoder::Identifier)
|
149
192
|
|
@@ -172,6 +215,7 @@ The following type maps are prefilled with type mappings from the PG::BasicTypeR
|
|
172
215
|
* PG::BasicTypeMapBasedOnResult - a PG::TypeMapByOid prefilled with encoders for common PostgreSQL column types
|
173
216
|
* PG::BasicTypeMapForQueries - a PG::TypeMapByClass prefilled with encoders for common Ruby value classes
|
174
217
|
|
218
|
+
Several type maps can be chained by setting PG::TypeMap::DefaultTypeMappable#default_type_map .
|
175
219
|
|
176
220
|
## Thread support
|
177
221
|
|
@@ -190,7 +234,7 @@ If messages like the following are printed to stderr, you're probably using one
|
|
190
234
|
|
191
235
|
## Fiber IO scheduler support
|
192
236
|
|
193
|
-
Pg is fully compatible with `Fiber.scheduler` introduced in Ruby-3.0.
|
237
|
+
Pg is fully compatible with `Fiber.scheduler` introduced in Ruby-3.0 since pg-1.3.0.
|
194
238
|
On Windows support for `Fiber.scheduler` is available on Ruby-3.1 or newer.
|
195
239
|
All possibly blocking IO operations are routed through the `Fiber.scheduler` if one is registered for the running thread.
|
196
240
|
That is why pg internally uses the asynchronous libpq interface even for synchronous/blocking method calls.
|
@@ -205,6 +249,16 @@ They are not compatible with `Fiber.scheduler`, so that blocking states are not
|
|
205
249
|
That means the operation will work properly, but IO waiting states can not be used to switch to another Fiber doing IO.
|
206
250
|
|
207
251
|
|
252
|
+
## Ractor support
|
253
|
+
|
254
|
+
Pg is fully compatible with Ractor introduced in Ruby-3.0 since pg-1.5.0.
|
255
|
+
All type en/decoders and type maps are shareable between ractors if they are made frozen by `Ractor.make_shareable`.
|
256
|
+
Also frozen PG::Result and PG::Tuple objects can be shared.
|
257
|
+
All frozen objects (except PG::Connection) can still be used to do communication with the PostgreSQL server or to read retrieved data.
|
258
|
+
|
259
|
+
PG::Connection is not shareable and must be created within each Ractor to establish a dedicated connection.
|
260
|
+
|
261
|
+
|
208
262
|
## Contributing
|
209
263
|
|
210
264
|
To report bugs, suggest features, or check out the source with Git,
|
@@ -214,7 +268,8 @@ After checking out the source, install all dependencies:
|
|
214
268
|
|
215
269
|
$ bundle install
|
216
270
|
|
217
|
-
Cleanup extension files, packaging files, test databases
|
271
|
+
Cleanup extension files, packaging files, test databases.
|
272
|
+
Run this to change between PostgreSQL versions:
|
218
273
|
|
219
274
|
$ rake clean
|
220
275
|
|
@@ -222,13 +277,13 @@ Compile extension:
|
|
222
277
|
|
223
278
|
$ rake compile
|
224
279
|
|
225
|
-
Run tests/specs
|
280
|
+
Run tests/specs on the PostgreSQL version that `pg_config --bindir` points to:
|
226
281
|
|
227
|
-
$
|
282
|
+
$ rake test
|
228
283
|
|
229
|
-
Or run a specific test
|
284
|
+
Or run a specific test per file and line number on a specific PostgreSQL version:
|
230
285
|
|
231
|
-
$ PATH
|
286
|
+
$ PATH=/usr/lib/postgresql/14/bin:$PATH rspec -Ilib -fd spec/pg/connection_spec.rb:455
|
232
287
|
|
233
288
|
Generate the API documentation:
|
234
289
|
|
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,25 @@ 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
|
+
['x86_64-linux-musl', 'linux-x86_64', 'x86_64-unknown-linux-musl'],
|
54
|
+
['aarch64-linux', 'linux-aarch64', 'aarch64-linux-gnu'],
|
55
|
+
['aarch64-linux-musl', 'linux-aarch64', 'aarch64-linux-musl'],
|
56
|
+
['x86_64-darwin', 'darwin64-x86_64', 'x86_64-apple-darwin'],
|
57
|
+
['arm64-darwin', 'darwin64-arm64', 'arm64-apple-darwin'],
|
58
|
+
].map do |platform, openssl_config, toolchain|
|
59
|
+
CrossLibrary.new platform, openssl_config, toolchain
|
60
|
+
end
|
61
|
+
|
62
|
+
# Register binary gems to be pushed to rubygems.org
|
63
|
+
Bundler::GemHelper.instance.cross_platforms = CrossLibraries.map(&:platform)
|
64
|
+
|
42
65
|
# Rake-compiler task
|
43
66
|
Rake::ExtensionTask.new do |ext|
|
44
67
|
ext.name = 'pg_ext'
|
@@ -47,24 +70,82 @@ Rake::ExtensionTask.new do |ext|
|
|
47
70
|
ext.lib_dir = 'lib'
|
48
71
|
ext.source_pattern = "*.{c,h}"
|
49
72
|
ext.cross_compile = true
|
50
|
-
ext.cross_platform = CrossLibraries.map(&:for_platform)
|
51
73
|
|
52
|
-
|
74
|
+
# Activate current cross compiled platform only.
|
75
|
+
# This is to work around the issue that `linux` platform is selected in `linux-musl` image.
|
76
|
+
ext.cross_platform = CrossLibraries.map(&:platform).select do |pl|
|
77
|
+
m = ENV["RCD_IMAGE"]&.match(/:(?<ruby_ver>[\d\.]+)-mri-(?<platform>[-\w]+)$/)
|
78
|
+
m && m[:platform] == pl
|
79
|
+
end
|
80
|
+
|
81
|
+
ext.cross_config_options += CrossLibraries.map do |xlib|
|
53
82
|
{
|
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}",
|
83
|
+
xlib.platform => [
|
84
|
+
"--with-cross-build=#{xlib.platform}",
|
85
|
+
"--with-openssl-platform=#{xlib.openssl_config}",
|
86
|
+
"--with-toolchain=#{xlib.toolchain}",
|
60
87
|
]
|
61
88
|
}
|
62
89
|
end
|
63
90
|
|
64
|
-
# Add libpq.dll to
|
91
|
+
# Add libpq.dll/.so to fat binary gemspecs
|
65
92
|
ext.cross_compiling do |spec|
|
66
|
-
spec.files << "
|
93
|
+
spec.files << "ports/#{spec.platform.to_s}/lib/libpq-ruby-pg.so.1" if spec.platform.to_s =~ /linux/
|
94
|
+
spec.files << "ports/#{spec.platform.to_s}/lib/libpq-ruby-pg.1.dylib" if spec.platform.to_s =~ /darwin/
|
95
|
+
spec.files << "ports/#{spec.platform.to_s}/lib/libpq.dll" if spec.platform.to_s =~ /mingw|mswin/
|
96
|
+
|
97
|
+
# Binary gems don't postgresql header+lib files
|
98
|
+
spec.metadata.delete("msys2_mingw_dependencies")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
task 'gem:native:prepare' do
|
103
|
+
require 'io/console'
|
104
|
+
require 'rake_compiler_dock'
|
105
|
+
|
106
|
+
# Copy gem signing key and certs to be accessible from the docker container
|
107
|
+
mkdir_p 'build/gem'
|
108
|
+
sh "cp ~/.gem/gem-*.pem build/gem/ || true"
|
109
|
+
sh "bundle package"
|
110
|
+
begin
|
111
|
+
OpenSSL::PKey.read(File.read(File.expand_path("~/.gem/gem-private_key.pem")), ENV["GEM_PRIVATE_KEY_PASSPHRASE"] || "")
|
112
|
+
rescue OpenSSL::PKey::PKeyError
|
113
|
+
ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = STDIN.getpass("Enter passphrase of gem signature key: ")
|
114
|
+
retry
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
task 'install_darwin_mig', [:arch] do |t, args|
|
119
|
+
sh <<~EOT
|
120
|
+
rm -rf bootstrap_cmds &&
|
121
|
+
git clone --branch=cross_platform https://github.com/markmentovai/bootstrap_cmds &&
|
122
|
+
cd bootstrap_cmds &&
|
123
|
+
autoreconf --install &&
|
124
|
+
sh configure &&
|
125
|
+
make &&
|
126
|
+
sed -E -i 's/^cppflags=(.*)/cppflags=(\\1 "-D#{args[:arch]}" "-I\\/opt\\/osxcross\\/target\\/SDK\\/MacOSX11.1.sdk\\/usr\\/include")/' migcom.tproj/mig.sh &&
|
127
|
+
sudo make install
|
128
|
+
EOT
|
129
|
+
end
|
130
|
+
|
131
|
+
CrossLibraries.each do |xlib|
|
132
|
+
platform = xlib.platform
|
133
|
+
desc "Build fat binary gem for platform #{platform}"
|
134
|
+
task "gem:native:#{platform}" => ['gem:native:prepare'] do
|
135
|
+
RakeCompilerDock.sh <<-EOT, platform: platform
|
136
|
+
#{ "sudo apt-get update && sudo apt-get install -y bison flex &&" if platform =~ /darwin/ }
|
137
|
+
#{ # remove nm on Linux to suppress PostgreSQL's check for exit which raises thread_exit as a false positive:
|
138
|
+
"sudo mv `which nm` `which nm`.bak &&" if platform =~ /linux/ }
|
139
|
+
sudo apt-get update && sudo apt-get install -y bison flex &&
|
140
|
+
(cp build/gem/gem-*.pem ~/.gem/ || true) &&
|
141
|
+
bundle install --local &&
|
142
|
+
#{ "rake install_darwin_mig[__arm64__]" if platform =~ /arm64-darwin/ }
|
143
|
+
#{ "rake install_darwin_mig[__x86_64__]" if platform =~ /x86_64-darwin/ }
|
144
|
+
rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKEOPTS=-j`nproc` RUBY_CC_VERSION=#{RakeCompilerDock.ruby_cc_version("~>2.7", "~>3.0")}
|
145
|
+
EOT
|
67
146
|
end
|
147
|
+
desc "Build the native binary gems"
|
148
|
+
multitask 'gem:native' => "gem:native:#{platform}"
|
68
149
|
end
|
69
150
|
|
70
151
|
RSpec::Core::RakeTask.new(:spec).rspec_opts = "--profile -cfdoc"
|
@@ -91,7 +172,7 @@ end
|
|
91
172
|
|
92
173
|
desc "Update list of server error codes"
|
93
174
|
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/
|
175
|
+
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
176
|
|
96
177
|
ERRORCODES_TXT = "ext/errorcodes.txt"
|
97
178
|
sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDLjCCAhagAwIBAgIBCzANBgkqhkiG9w0BAQsFADA9MQ4wDAYDVQQDDAVrYW5p
|
3
|
+
czEXMBUGCgmSJomT8ixkARkWB2NvbWNhcmQxEjAQBgoJkiaJk/IsZAEZFgJkZTAe
|
4
|
+
Fw0yMzA0MjgwOTI0NDhaFw0yNDA0MjcwOTI0NDhaMD0xDjAMBgNVBAMMBWthbmlz
|
5
|
+
MRcwFQYKCZImiZPyLGQBGRYHY29tY2FyZDESMBAGCgmSJomT8ixkARkWAmRlMIIB
|
6
|
+
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApop+rNmg35bzRugZ21VMGqI6
|
7
|
+
HGzPLO4VHYncWn/xmgPU/ZMcZdfj6MzIaZJ/czXyt4eHpBk1r8QOV3gBXnRXEjVW
|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FMdAKo4H46GBYNO96r6b74t++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)
|