pg 1.5.8 → 1.6.2

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/{History.md → CHANGELOG.md} +76 -0
  4. data/Gemfile +7 -4
  5. data/README-Windows.rdoc +1 -1
  6. data/README.ja.md +4 -4
  7. data/README.md +60 -20
  8. data/Rakefile +92 -14
  9. data/ext/errorcodes.def +4 -5
  10. data/ext/errorcodes.txt +2 -5
  11. data/ext/extconf.rb +188 -15
  12. data/ext/gvl_wrappers.c +13 -2
  13. data/ext/gvl_wrappers.h +33 -0
  14. data/ext/pg.c +16 -5
  15. data/ext/pg.h +9 -9
  16. data/ext/pg_binary_decoder.c +151 -1
  17. data/ext/pg_binary_encoder.c +212 -9
  18. data/ext/pg_cancel_connection.c +360 -0
  19. data/ext/pg_coder.c +54 -5
  20. data/ext/pg_connection.c +368 -158
  21. data/ext/pg_copy_coder.c +2 -2
  22. data/ext/pg_record_coder.c +1 -1
  23. data/ext/pg_result.c +15 -17
  24. data/ext/pg_text_decoder.c +1 -1
  25. data/ext/pg_text_encoder.c +22 -9
  26. data/ext/pg_tuple.c +7 -7
  27. data/ext/pg_type_map.c +4 -2
  28. data/ext/pg_type_map_all_strings.c +1 -1
  29. data/ext/pg_type_map_by_class.c +1 -1
  30. data/ext/pg_type_map_by_column.c +2 -1
  31. data/ext/pg_type_map_by_mri_type.c +1 -1
  32. data/ext/pg_type_map_by_oid.c +3 -1
  33. data/ext/pg_type_map_in_ruby.c +1 -1
  34. data/ext/pg_util.c +2 -2
  35. data/ext/pg_util.h +2 -2
  36. data/lib/pg/basic_type_map_for_queries.rb +7 -3
  37. data/lib/pg/basic_type_registry.rb +2 -2
  38. data/lib/pg/cancel_connection.rb +53 -0
  39. data/lib/pg/coder.rb +4 -2
  40. data/lib/pg/connection.rb +259 -138
  41. data/lib/pg/version.rb +2 -1
  42. data/lib/pg.rb +156 -130
  43. data/misc/glibc/Dockerfile +20 -0
  44. data/misc/glibc/docker-compose.yml +9 -0
  45. data/misc/glibc/glibc_spec.rb +5 -0
  46. data/misc/yugabyte/Dockerfile +9 -0
  47. data/misc/yugabyte/docker-compose.yml +28 -0
  48. data/misc/yugabyte/pg-test.rb +45 -0
  49. data/pg.gemspec +8 -4
  50. data/ports/patches/krb5/1.22.1/0001-Allow-static-linking-krb5-library.patch +30 -0
  51. data/ports/patches/krb5/1.22.1/0002-unknown-command-line-option-on-clang.patch +12 -0
  52. data/ports/patches/openssl/3.5.2/0001-aarch64-mingw.patch +21 -0
  53. data/ports/patches/postgresql/17.6/0001-Use-workaround-of-__builtin_setjmp-only-on-MINGW-on-.patch +42 -0
  54. data/ports/patches/postgresql/17.6/0001-libpq-Process-buffered-SSL-read-bytes-to-support-rec.patch +52 -0
  55. data/rakelib/pg_gem_helper.rb +64 -0
  56. data.tar.gz.sig +0 -0
  57. metadata +36 -36
  58. metadata.gz.sig +0 -0
  59. data/.appveyor.yml +0 -42
  60. data/.gems +0 -6
  61. data/.gemtest +0 -0
  62. data/.github/workflows/binary-gems.yml +0 -117
  63. data/.github/workflows/source-gem.yml +0 -152
  64. data/.gitignore +0 -22
  65. data/.hgsigs +0 -34
  66. data/.hgtags +0 -41
  67. data/.irbrc +0 -23
  68. data/.pryrc +0 -23
  69. data/.tm_properties +0 -21
  70. data/.travis.yml +0 -49
  71. data/Manifest.txt +0 -72
  72. data/Rakefile.cross +0 -298
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af4acb6c7ea394621dc7464296e728a4e245ee83d49bd27ccb06bc3b2f1ac8fd
4
- data.tar.gz: 6f15907b13e4d76a2b1cb88a34cc00bc719300ca2b5dc0a6a60a90cd8c14a05a
3
+ metadata.gz: 40f704970acf17f5fc3514de1e25454441776d1a5ae7b267c791d2bc59bfdb82
4
+ data.tar.gz: f727c84142cc8d5a576b974c4cbf866e3d69d15004815c088461fef5c1f76190
5
5
  SHA512:
6
- metadata.gz: c6a7859212429f25047b10e58a989eeeedd2685cc537be1d3e477fddc02a0a70ebc86b81d77b7bfd46a1439f3558a6e7459d32dc05460e5d739b5a60c065efb4
7
- data.tar.gz: d2a4e22dd35c71e3851bb44adfe1b9ccb88e01f689e4718cb099f5da39218d553575ec38d2d866d23998d52256cfa69abfbabd7c9a130a9e25b765eb5ed4b8b9
6
+ metadata.gz: 2d3df7542a3b3b001709d59b9e75a0ed3bf734db3b3b5cc2fa293278920720a4443fa4e13365926cfca3df08862137bc89f6bc5b13167607c935c1d95f55c848
7
+ data.tar.gz: fb5d5d62930e3dba1ef983c0201fcd86b2c46eacd920f22372372b34b5e628333d0090d2b10f75f0075eba189df24e964a8cdf27b8bf2ff396d7d9bae7adf5dd
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,3 +1,79 @@
1
+ ## v1.6.2 [2025-09-02] Lars Kanis <lars@greiz-reinsdorf.de>
2
+
3
+ - Remove several absolute paths from native binaries which pointed to build directories. [#668](https://github.com/ged/ruby-pg/pull/668)
4
+ - Fix bad fallback path to `pg_service.conf`. [#666](https://github.com/ged/ruby-pg/pull/666)
5
+ - Use `rbpg_` prefix for `base64_*` functions to avoid name clashes with functions provided by other libraries like Heimdal on Macos. [#667](https://github.com/ged/ruby-pg/pull/667)
6
+ - Raise a more descriptive error message in case of `pg_ext` LoadError. [#664](https://github.com/ged/ruby-pg/pull/664)
7
+ - Freeze some constants to make them available in a Ractor context. [#660](https://github.com/ged/ruby-pg/pull/660)
8
+ - Several documentation improvements.
9
+ - Update native binary gems to OpenSSL-3.5.2, krb5-1.22.1 and PostgreSQL-17.6.
10
+
11
+
12
+ ## v1.6.1 [2025-08-03] Lars Kanis <lars@greiz-reinsdorf.de>
13
+
14
+ - Add binary gems for platforms `aarch64-linux-musl` and `x86_64-linux-musl` without the need to install package `gcompat`. [#657](https://github.com/ged/ruby-pg/pull/657).
15
+ - Serialize CompositeCoder#dimensions only when set. [#652](https://github.com/ged/ruby-pg/pull/652)
16
+ This fixes the compatibility to pg-1.5.9, when deserializing Marshal data from pg-1.6, as long as the new attribute isn't used.
17
+ - Remove dependency to MSYS2 package "postgresql" from binary Windows gem [#654](https://github.com/ged/ruby-pg/pull/654)
18
+
19
+
20
+ ## v1.6.0 [2025-07-27] Lars Kanis <lars@greiz-reinsdorf.de>
21
+
22
+ Added:
23
+
24
+ - Add binary gems for Ruby 3.4.
25
+ - 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), for platform `aarch64-linux` [#646](https://github.com/ged/ruby-pg/pull/646) and for platform `x86_64-linux` [#551](https://github.com/ged/ruby-pg/pull/551#issuecomment-2504715762).
26
+ - Update fat binary gem to OpenSSL-3.5.1 and PostgreSQL-17.5.
27
+ - Add a patch to libpq to avoid starvation on bigger SSL records, which some database engines other than vanilla PostgreSQL use.
28
+ This patch applies to platform specific binary gems only.
29
+ [#616](https://github.com/ged/ruby-pg/pull/616)
30
+ - Add support for new query cancel functions of PostgreSQL-17.
31
+ This adds the new class `PG::CancelConnection` which provides the ability to cancel a query per blocking or per non-blocking functions.
32
+ If the new functions are available they are used and the older are no longer compiled in.
33
+ This way we can get rid of reading out the internal `PGcancel` struct by `Connection#backend_key`.
34
+ [#614](https://github.com/ged/ruby-pg/pull/614)
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 possibility to define the number of array dimensions to be encoded.
38
+ 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.
39
+ [#622](https://github.com/ged/ruby-pg/pull/622)
40
+ - Add Connection#set_chunked_rows_mode [#610](https://github.com/ged/ruby-pg/pull/610)
41
+ - 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.
42
+ [#611](https://github.com/ged/ruby-pg/pull/611)
43
+ - Add Connection#send_pipeline_sync, async_pipeline_sync and release GVL at PQ(sendP|P)ipelineSync.
44
+ [#612](https://github.com/ged/ruby-pg/pull/612)
45
+ - Add MINGW package dependency which is resolved by RubyInstaller.
46
+ [#617](https://github.com/ged/ruby-pg/pull/617)
47
+ - Change `conn.server_version` and `conn.protocol_version` to raise instead of return 0 on error.
48
+ [#632](https://github.com/ged/ruby-pg/pull/632)
49
+ - Fix connecting to multiple hosts after `connnect_timeout`.
50
+ [#637](https://github.com/ged/ruby-pg/pull/637)
51
+ - Fix making PG::BasicTypeMapForQueries shareable for Ractor in ruby-3.5.
52
+ [#636](https://github.com/ged/ruby-pg/pull/636)
53
+ - Fix missing array input verification in PG::TypeMapByColumn.
54
+ This could cause a segfault.
55
+ [#620](https://github.com/ged/ruby-pg/pull/620)
56
+ - Rename `History.md` to `CHANGELOG.md`, which is more common.
57
+ [#642](https://github.com/ged/ruby-pg/pull/642)
58
+
59
+ Removed:
60
+
61
+ - Drop support of Ruby < 2.7 [#606](https://github.com/ged/ruby-pg/pull/606)
62
+ - Drop support of PostgreSQL < 10 [#606](https://github.com/ged/ruby-pg/pull/606)
63
+ - Remove workaround for Truffleruby < 21.3.0 [#613](https://github.com/ged/ruby-pg/pull/613)
64
+
65
+
66
+ ## v1.5.9 [2024-10-24] Lars Kanis <lars@greiz-reinsdorf.de>
67
+
68
+ - Enable thread safety in static OpenSSL build for Windows. [#595](https://github.com/ged/ruby-pg/pull/595)
69
+ - Remove raising `conect_timeout` from 1 to 2 seconds. [#590](https://github.com/ged/ruby-pg/pull/590)
70
+ - Fix binary copy_data in Ractor context. [#594](https://github.com/ged/ruby-pg/pull/594)
71
+ - Exclude CI files and hidden files from built gem. [#591](https://github.com/ged/ruby-pg/pull/591)
72
+ This is to simplify security inspection.
73
+ - Update error classes to PostgreSQL-17.
74
+ - Update Windows fat binary gem to OpenSSL-3.4.0 and PostgreSQL-17.0.
75
+
76
+
1
77
  ## v1.5.8 [2024-09-06] Lars Kanis <lars@greiz-reinsdorf.de>
2
78
 
3
79
  - Fix host list duplication every time conn.reset is used. [#586](https://github.com/ged/ruby-pg/pull/586)
data/Gemfile CHANGED
@@ -5,13 +5,16 @@ gemspec
5
5
 
6
6
  source "https://rubygems.org/"
7
7
 
8
- group :development, :test do
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.0"
12
- gem "rdoc", "~> 6.4"
16
+ gem "rake-compiler-dock", "~> 1.9.1", git: "https://github.com/rake-compiler/rake-compiler-dock"
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:windows
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:/History.md
5
+ * 変更履歴 :: link:/CHANGELOG.md
6
6
 
7
7
  [![https://gitter.im/ged/ruby-pg
8
8
  でチャットに参加](https://badges.gitter.im/Join%20Chat.svg)](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
- 9.3以降](http://www.postgresql.org/support/versioning/)で動作します。
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.5かそれより新しいバージョン
45
- * PostgreSQL 9.3.xかそれ以降のバージョン(ヘッダー付属のもの、例えば-devの名前のパッケージ)。
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:/History.md
6
+ * clog :: link:/CHANGELOG.md
7
7
 
8
8
  [![Join the chat at https://gitter.im/ged/ruby-pg](https://badges.gitter.im/Join%20Chat.svg)](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 9.3 and later](http://www.postgresql.org/support/versioning/).
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,30 +39,34 @@ A small example usage:
39
39
 
40
40
  ## Requirements
41
41
 
42
- * Ruby 2.5 or newer
43
- * PostgreSQL 9.3.x or later (with headers, -dev packages, etc).
42
+ * Ruby 2.7 or newer
43
+ * PostgreSQL 10.x or later
44
+ * When installing the source gem: libpq with headers, -dev packages, etc.
44
45
 
45
- It usually works with earlier versions of Ruby/PostgreSQL as well, but those are
46
- not regularly tested.
47
46
 
47
+ ## How To Install
48
48
 
49
- ## Versioning
49
+ Install via RubyGems:
50
50
 
51
- We tag and release gems according to the [Semantic Versioning](http://semver.org/) principle.
51
+ gem install pg
52
52
 
53
- 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.
53
+ This installs the binary gem, specific to the running platform by default.
54
54
 
55
- For example:
55
+ ### Binary gem
56
56
 
57
- ```ruby
58
- spec.add_dependency 'pg', '~> 1.0'
59
- ```
57
+ The binary gems don't depend on the libpq package on the running system.
58
+ They have libpq builtin.
60
59
 
61
- ## How To Install
60
+ The gems for platform `x86_64-linux` and `aarch64-linux` run on Alpine Linux, but require the package `gcompat`, while the native gems for platform `*-linux-musl` work without that dependency.
62
61
 
63
- Install via RubyGems:
62
+ 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.
64
63
 
65
- gem install pg
64
+ ### Source gem
65
+
66
+ The source gem can be forced by:
67
+
68
+ gem uninstall pg --all
69
+ gem install pg --platform ruby
66
70
 
67
71
  You may need to specify the path to the 'pg_config' program installed with
68
72
  Postgres:
@@ -73,6 +77,28 @@ If you're installing via Bundler, you can provide compile hints like so:
73
77
 
74
78
  bundle config build.pg --with-pg-config=<path to pg_config>
75
79
 
80
+ ### Bundler
81
+
82
+ To make sure, the necessary platforms and the source gem are fetched by bundler, they can be added like so
83
+
84
+ ```
85
+ bundle lock --add-platform x86_64-linux
86
+ bundle lock --add-platform arm64-darwin
87
+ bundle lock --add-platform x64-mingw-ucrt
88
+ bundle lock --add-platform ruby
89
+ bundle package --all-platforms
90
+ ```
91
+
92
+ A re-run of `bundle package` is also necessary after `bundle update`, in order to retrieve the new specific gems of all platforms.
93
+
94
+ If the binary gems don't work for some reason, it's easy to force the usage of the source gem in the Gemfile:
95
+
96
+ ```
97
+ gem "pg", force_ruby_platform: true
98
+ ```
99
+
100
+ ### More
101
+
76
102
  See README-OS_X.rdoc for more information about installing under MacOS X, and
77
103
  README-Windows.rdoc for Windows build/installation instructions.
78
104
 
@@ -85,6 +111,19 @@ can be found in [the `certs` directory](https://github.com/ged/ruby-pg/tree/mast
85
111
  of the repository.
86
112
 
87
113
 
114
+ ## Versioning
115
+
116
+ We tag and release gems according to the [Semantic Versioning](http://semver.org/) principle.
117
+
118
+ 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.
119
+
120
+ For example:
121
+
122
+ ```ruby
123
+ spec.add_dependency 'pg', '~> 1.0'
124
+ ```
125
+
126
+
88
127
  ## Type Casts
89
128
 
90
129
  Pg can optionally type cast result values and query parameters in Ruby or
@@ -108,7 +147,7 @@ Very basic type casting can be enabled by:
108
147
  But Pg's type casting is highly customizable. That's why it's divided into
109
148
  2 layers:
110
149
 
111
- ### Encoders / Decoders (ext/pg_*coder.c, lib/pg/*coder.rb)
150
+ ### Encoders / Decoders (ext/pg_\*coder.c, lib/pg/\*coder.rb)
112
151
 
113
152
  This is the lower layer, containing encoding classes that convert Ruby
114
153
  objects for transmission to the DBMS and decoding classes to convert
@@ -141,7 +180,7 @@ The following PostgreSQL column types are supported by ruby-pg (TE = Text Encode
141
180
  * 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
181
  * JSON and JSONB: [TE](rdoc-ref:PG::TextEncoder::JSON), [TD](rdoc-ref:PG::TextDecoder::JSON)
143
182
  * 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)
183
+ * 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
184
  * Composite Type (also called "Row" or "Record"): [TE](rdoc-ref:PG::TextEncoder::Record), [TD](rdoc-ref:PG::TextDecoder::Record)
146
185
 
147
186
  The following text and binary formats can also be encoded although they are not used as column type:
@@ -150,9 +189,9 @@ The following text and binary formats can also be encoded although they are not
150
189
  * Literal for insertion into SQL string: [TE](rdoc-ref:PG::TextEncoder::QuotedLiteral)
151
190
  * SQL-Identifier: [TE](rdoc-ref:PG::TextEncoder::Identifier), [TD](rdoc-ref:PG::TextDecoder::Identifier)
152
191
 
153
- ### PG::TypeMap and derivations (ext/pg_type_map*.c, lib/pg/type_map*.rb)
192
+ ### TypeMap and derivations (ext/pg_type_map\*.c, lib/pg/type_map\*.rb)
154
193
 
155
- A TypeMap defines which value will be converted by which encoder/decoder.
194
+ A PG::TypeMap defines which value will be converted by which encoder/decoder.
156
195
  There are different type map strategies, implemented by several derivations
157
196
  of this class. They can be chosen and configured according to the particular
158
197
  needs for type casting. The default type map is PG::TypeMapAllStrings.
@@ -175,6 +214,7 @@ The following type maps are prefilled with type mappings from the PG::BasicTypeR
175
214
  * PG::BasicTypeMapBasedOnResult - a PG::TypeMapByOid prefilled with encoders for common PostgreSQL column types
176
215
  * PG::BasicTypeMapForQueries - a PG::TypeMapByClass prefilled with encoders for common Ruby value classes
177
216
 
217
+ Several type maps can be chained by setting PG::TypeMap::DefaultTypeMappable#default_type_map .
178
218
 
179
219
  ## Thread support
180
220
 
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
- load 'Rakefile.cross'
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,25 @@ 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
+ ['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
+
45
65
  # Rake-compiler task
46
66
  Rake::ExtensionTask.new do |ext|
47
67
  ext.name = 'pg_ext'
@@ -50,24 +70,82 @@ Rake::ExtensionTask.new do |ext|
50
70
  ext.lib_dir = 'lib'
51
71
  ext.source_pattern = "*.{c,h}"
52
72
  ext.cross_compile = true
53
- ext.cross_platform = CrossLibraries.map(&:for_platform)
54
73
 
55
- ext.cross_config_options += CrossLibraries.map do |lib|
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>[\w\.]+)-mri-(?<platform>[-\w]+)$/)
78
+ m && m[:platform] == pl
79
+ end
80
+
81
+ ext.cross_config_options += CrossLibraries.map do |xlib|
56
82
  {
57
- lib.for_platform => [
58
- "--enable-windows-cross",
59
- "--with-pg-include=#{lib.static_postgresql_incdir}",
60
- "--with-pg-lib=#{lib.static_postgresql_libdir}",
61
- # libpq-fe.h resides in src/interfaces/libpq/ before make install
62
- "--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}",
63
87
  ]
64
88
  }
65
89
  end
66
90
 
67
- # Add libpq.dll to windows binary gemspec
91
+ # Add libpq.dll/.so to fat binary gemspecs
68
92
  ext.cross_compiling do |spec|
69
- spec.files << "lib/#{spec.platform}/libpq.dll"
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 --all"
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 MAKEFLAGS="-j`nproc` V=1" RUBY_CC_VERSION=#{RakeCompilerDock.ruby_cc_version("~>2.7", "~>3.0")}
145
+ EOT
70
146
  end
147
+ desc "Build the native binary gems"
148
+ multitask 'gem:native' => "gem:native:#{platform}"
71
149
  end
72
150
 
73
151
  RSpec::Core::RakeTask.new(:spec).rspec_opts = "--profile -cfdoc"
@@ -94,7 +172,7 @@ end
94
172
 
95
173
  desc "Update list of server error codes"
96
174
  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/REL_16_0"
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"
98
176
 
99
177
  ERRORCODES_TXT = "ext/errorcodes.txt"
100
178
  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-2023, PostgreSQL Global Development Group
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)