pg 1.6.3 → 1.7.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/CHANGELOG.md +52 -6
- data/Gemfile +1 -0
- data/README.ja.md +81 -30
- data/README.md +14 -7
- data/Rakefile +8 -7
- data/certs/larskanis-2026.pem +24 -0
- data/ext/extconf.rb +18 -28
- data/ext/gvl_wrappers.c +2 -2
- data/ext/gvl_wrappers.h +40 -160
- data/ext/pg.c +8 -12
- data/ext/pg.h +8 -11
- data/ext/pg_binary_decoder.c +6 -2
- data/ext/pg_binary_encoder.c +7 -0
- data/ext/pg_cancel_connection.c +6 -6
- data/ext/pg_coder.c +4 -4
- data/ext/pg_connection.c +196 -159
- data/ext/pg_copy_coder.c +34 -21
- data/ext/pg_record_coder.c +10 -6
- data/ext/pg_result.c +42 -26
- data/ext/pg_text_decoder.c +6 -6
- data/ext/pg_text_encoder.c +7 -2
- data/ext/pg_tuple.c +1 -1
- data/ext/pg_type_map.c +41 -1
- data/ext/pg_type_map_all_strings.c +2 -2
- data/ext/pg_type_map_by_class.c +1 -1
- data/ext/pg_type_map_by_column.c +2 -2
- 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_map_based_on_result.rb +5 -0
- data/lib/pg/basic_type_map_for_queries.rb +9 -2
- data/lib/pg/basic_type_map_for_results.rb +5 -0
- data/lib/pg/connection.rb +166 -76
- data/lib/pg/text_decoder/date.rb +1 -1
- data/lib/pg/text_decoder/json.rb +1 -1
- data/lib/pg/text_encoder/date.rb +7 -1
- data/lib/pg/text_encoder/json.rb +1 -1
- data/lib/pg/version.rb +1 -1
- data/misc/yugabyte/docker-compose.yml +1 -1
- data/pg.gemspec +1 -1
- data/sample/async_mixed.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +18 -19
- metadata.gz.sig +0 -0
- data/ports/patches/openssl/3.5.2/0001-aarch64-mingw.patch +0 -21
- data/ports/patches/postgresql/18.1/0001-libpq-Process-buffered-SSL-read-bytes-to-support-rec.patch +0 -52
- /data/ports/patches/krb5/{1.22.1 → 1.22.2}/0001-Allow-static-linking-krb5-library.patch +0 -0
- /data/ports/patches/krb5/{1.22.1 → 1.22.2}/0002-unknown-command-line-option-on-clang.patch +0 -0
- /data/ports/patches/postgresql/{18.1 → 18.6}/0001-Use-workaround-of-__builtin_setjmp-only-on-MINGW-on-.patch +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 01ff8f72c20e6b96364acee8cc436df0d1305861cd3edba88be07c81fc0e2e55
|
|
4
|
+
data.tar.gz: e1dce91f9a03eaf081e11705175902c43471710612d299d626e2bb796c6990f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1326d36f1ebcd07e755615fa2bdc78c46bcf937f1d085c080816dee7f93790ce3aedcb58ff3be4840e6f1c713c7a81e2879bfa934d4fbcdea3faa891f83fc534
|
|
7
|
+
data.tar.gz: 80b0474f35ffd2ef4339fbb635a375b4de216ef3a0c8f3b9ad5da6b4f5e6767edae9794fe15364ca6f27667867e137cba809b1770c63436102f3389c3c42f27a
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,61 @@
|
|
|
1
|
+
## v1.7.0 [2026-10-02] Lars Kanis <lars@greiz-reinsdorf.de>
|
|
2
|
+
|
|
3
|
+
Added:
|
|
4
|
+
|
|
5
|
+
- Add PG::Connection#embed_params and keyword `:typename` for its parameter casting. [#726](https://github.com/ged/ruby-pg/pull/726)
|
|
6
|
+
This allows to generate SQL strings with embedded parameters for easier debugging.
|
|
7
|
+
- Add PG::Connection#full_protocol_version which is new in PostgreSQL-18 [#695](https://github.com/ged/ruby-pg/pull/695)
|
|
8
|
+
- Add PG::Result#each_tuple [#675](https://github.com/ged/ruby-pg/pull/675)
|
|
9
|
+
- Add PG::TypeMap#query_param_encoders to retrieve encoders. [#726](https://github.com/ged/ruby-pg/pull/726)
|
|
10
|
+
- Deduplicate result field name strings for better performance. [#750](https://github.com/ged/ruby-pg/pull/750)
|
|
11
|
+
|
|
12
|
+
Removed:
|
|
13
|
+
|
|
14
|
+
- Remove compatibility to ruby < 3.1 and drops support of ruby-2.7 and ruby-3.0. [#749](https://github.com/ged/ruby-pg/pull/749)
|
|
15
|
+
- Remove GLV unlocking at all functions which process data modifiable in a second thread. [#721](https://github.com/ged/ruby-pg/pull/721)
|
|
16
|
+
This avoids possible premature garbage collection of query parameters and possible VM crash due to concurrent data manipulation.
|
|
17
|
+
- Remove `:static_symbol` result field names. [#691](https://github.com/ged/ruby-pg/pull/691)
|
|
18
|
+
- Remove enforced rpath addition when no rpath is configured in rbconfig. [#699](https://github.com/ged/ruby-pg/pull/699)
|
|
19
|
+
|
|
20
|
+
Fixes:
|
|
21
|
+
|
|
22
|
+
- Limit memory allocation on invalid input into PG::BinaryDecoder::Array. [#743](https://github.com/ged/ruby-pg/pull/743)
|
|
23
|
+
- Free COPY buffers when decoders raise to avoid possible memory leak in get_copy_data. [#742](https://github.com/ged/ruby-pg/pull/742)
|
|
24
|
+
- Prevent SQL injection in set_client_encoding. [#741](https://github.com/ged/ruby-pg/pull/741)
|
|
25
|
+
- Add GC_GUARD to temporary ruby objects for conninfo string to avoid it's GC'ed prematurely. [#739](https://github.com/ged/ruby-pg/pull/739)
|
|
26
|
+
- Remove option "quirks_mode" from JSON en/decoder to fix compat with json-3.0 gem. [#737](https://github.com/ged/ruby-pg/pull/737)
|
|
27
|
+
- Respect calendar type of Ruby and PostgreSQL. [#725](https://github.com/ged/ruby-pg/pull/725)
|
|
28
|
+
- Fix broken set_notice_(receiver|processor) callback after GC.compact. [#734](https://github.com/ged/ruby-pg/pull/734)
|
|
29
|
+
- Disable DNS resolution in ruby when a service file is used, so that the priority of parameters is equal to libpq. [#635](https://github.com/ged/ruby-pg/pull/635)
|
|
30
|
+
- Use RARRAY_LENINT to avoid possible overflow. [#728](https://github.com/ged/ruby-pg/pull/728)
|
|
31
|
+
- Fix possible integer overflow at PG::BinaryEncoder::CopyRow and PG::TextEncoder::CopyRow. [#714](https://github.com/ged/ruby-pg/pull/714), [#715](https://github.com/ged/ruby-pg/pull/715)
|
|
32
|
+
- Avoid possible integer overflow in query parameter encoding. [#719](https://github.com/ged/ruby-pg/pull/719)
|
|
33
|
+
- Ensure conninfo is a valid C string before closing the connection to avoid a double free of PGconn. [#709](https://github.com/ged/ruby-pg/pull/709)
|
|
34
|
+
- Raise on a too large input string to PG::TextEncoder::Bytea. [#717](https://github.com/ged/ruby-pg/pull/717)
|
|
35
|
+
- Check PG::BinaryEncoder::CopyRow array input size instead of producing an invalid output.
|
|
36
|
+
- Remove accidentally copied "static" keyword from Copy and Record encoder. [#711](https://github.com/ged/ruby-pg/pull/711)
|
|
37
|
+
- Avoid possibility to replace typemap while being used in Copy and Record encoders and decoders. [#707](https://github.com/ged/ruby-pg/pull/707)
|
|
38
|
+
- Add GC_GUARD's for encoding converted strings sent to the server. [#705](https://github.com/ged/ruby-pg/pull/705)
|
|
39
|
+
- Fix incomplete transaction commit when thread is shutdown ungracefully. [#704](https://github.com/ged/ruby-pg/pull/704)
|
|
40
|
+
- Assign VALUE after registration per rb_gc_register_address() [#703](https://github.com/ged/ruby-pg/pull/703)
|
|
41
|
+
- Update dependencies for binary gems to PostgreSQL-18.6, OpenSSL-3.6.5, krb5-1.22.2 [#752](https://github.com/ged/ruby-pg/pull/752)
|
|
42
|
+
|
|
43
|
+
|
|
1
44
|
## v1.6.3 [2025-12-29] Lars Kanis <lars@greiz-reinsdorf.de>
|
|
2
45
|
|
|
3
46
|
Added:
|
|
4
|
-
|
|
5
|
-
-
|
|
47
|
+
|
|
48
|
+
- Add binary gems for ruby-4.0, now providing ruby-3.0 to 4.0. [#682](https://github.com/ged/ruby-pg/pull/682)
|
|
49
|
+
- Update fat binary gem to OpenSSL-3.6.0 and PostgreSQL-18.1.
|
|
50
|
+
- Improve documentation of PG::Result and README. [#676](https://github.com/ged/ruby-pg/pull/676)
|
|
6
51
|
- Update errorcodes to PostgreSQL-18.
|
|
7
|
-
- Use `rb_hash_new_capa` on Ruby-3.2+ . #674
|
|
8
|
-
- Deny any server communication on a frozen PG::Connection . #677
|
|
9
|
-
- Fix possible race condition in PG::Result in Ractor context. #674
|
|
52
|
+
- Use `rb_hash_new_capa` on Ruby-3.2+ . [#674](https://github.com/ged/ruby-pg/pull/674)
|
|
53
|
+
- Deny any server communication on a frozen PG::Connection . [#677](https://github.com/ged/ruby-pg/pull/677)
|
|
54
|
+
- Fix possible race condition in PG::Result in Ractor context. [#674](https://github.com/ged/ruby-pg/pull/674)
|
|
10
55
|
|
|
11
56
|
Removed:
|
|
12
|
-
|
|
57
|
+
|
|
58
|
+
- Drop binary gem support for platform `x86-mingw32`. [#682](https://github.com/ged/ruby-pg/pull/682)
|
|
13
59
|
- Drop binary gems for ruby-2.7.
|
|
14
60
|
|
|
15
61
|
|
data/Gemfile
CHANGED
data/README.ja.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# pg
|
|
2
2
|
|
|
3
3
|
* ホーム :: https://github.com/ged/ruby-pg
|
|
4
|
-
* ドキュメント :: http://deveiate.org/code/pg (英語)、 https://deveiate.org/code/pg/README_ja_md.html (日本語)
|
|
4
|
+
* ドキュメント :: http://deveiate.org/code/pg/README_md.html (英語)、 https://deveiate.org/code/pg/README_ja_md.html (日本語)
|
|
5
5
|
* 変更履歴 :: link:/CHANGELOG.md
|
|
6
6
|
|
|
7
7
|
[へのRubyのインターフェースです。
|
|
|
31
31
|
end
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
問い合わせのメソッドについては PG::Connection クラスを、問い合わせの結果を取り回す際の情報については PG::Result
|
|
35
|
+
クラスを参照してください。
|
|
36
|
+
|
|
37
|
+
|
|
34
38
|
## ビルド状況
|
|
35
39
|
|
|
36
40
|
[の取得です。
|
|
70
|
+
これに対応するには`libldap`が必要でしょうが、沢山の依存関係があります。
|
|
71
|
+
広く使われている機能のようにも対応する価値があるとも思われません。
|
|
72
|
+
必要であれば、ソースgemに強制できます。
|
|
65
73
|
|
|
66
|
-
|
|
74
|
+
### ソースgem
|
|
75
|
+
|
|
76
|
+
ソースgemは次のように強制できます。
|
|
77
|
+
|
|
78
|
+
gem uninstall pg --all
|
|
79
|
+
gem install pg --platform ruby
|
|
67
80
|
|
|
68
81
|
Postgresと一緒にインストールされた'pg_config'プログラムへのパスを指定する必要があるかもしれません。
|
|
69
82
|
|
|
@@ -73,6 +86,29 @@ Bundlerを介してインストールした場合は次のようにコンパイ
|
|
|
73
86
|
|
|
74
87
|
bundle config build.pg --with-pg-config=<path to pg_config>
|
|
75
88
|
|
|
89
|
+
### Bundler
|
|
90
|
+
|
|
91
|
+
必要なプラットフォームとソースgemがbundlerにより取得されることを確実にするためには、次のように加えられます。
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
bundle lock --add-platform x86_64-linux
|
|
95
|
+
bundle lock --add-platform arm64-darwin
|
|
96
|
+
bundle lock --add-platform x64-mingw-ucrt
|
|
97
|
+
bundle lock --add-platform ruby
|
|
98
|
+
bundle package --all-platforms
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`bundle package`の再実行は`bundle
|
|
102
|
+
update`後にも必須であり、これはすべてのプラットフォームの新しい特定のgemを取得するためです。
|
|
103
|
+
|
|
104
|
+
バイナリgemが何らかの理由で動作しないなら、Gemfileでソースgemの利用を簡単に強制できます。
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
gem "pg", force_ruby_platform: true
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### その他
|
|
111
|
+
|
|
76
112
|
MacOS Xへインストールする詳しい情報については README-OS_X.rdoc を、Windows用のビルドやインストールの説明については
|
|
77
113
|
README-Windows.rdoc を参照してください。
|
|
78
114
|
|
|
@@ -81,9 +117,22 @@ README-Windows.rdoc を参照してください。
|
|
|
81
117
|
署名されたgemとしてインストールしたい場合は、リポジトリの[`certs`ディレクトリ](https://github.com/ged/ruby-pg/tree/master/certs)にgemの署名をする公開証明書があります。
|
|
82
118
|
|
|
83
119
|
|
|
120
|
+
## バージョン管理
|
|
121
|
+
|
|
122
|
+
[セマンティックバージョニング](http://semver.org/)の原則にしたがってgemをタグ付けしてリリースしています。
|
|
123
|
+
|
|
124
|
+
この方針の結果として、2つの数字を指定する[悲観的バージョン制約](http://guides.rubygems.org/patterns/#pessimistic-version-constraint)を使ってこのgemへの依存関係を指定することができます(またそうすべきです)。
|
|
125
|
+
|
|
126
|
+
例えば次の通りです。
|
|
127
|
+
|
|
128
|
+
```ruby
|
|
129
|
+
spec.add_dependency 'pg', '~> 1.0'
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
|
|
84
133
|
## 型変換
|
|
85
134
|
|
|
86
|
-
Pgでは任意でRubyと素のC
|
|
135
|
+
Pgでは任意でRubyと素のCコードにある結果の値や問い合わせ引数の型変換ができます。
|
|
87
136
|
こうすることでデータベースとのデータの往来を加速させられます。
|
|
88
137
|
なぜなら文字列のアロケーションが減り、(比較的遅い)Rubyのコードでの変換部分が省かれるからです。
|
|
89
138
|
|
|
@@ -102,10 +151,10 @@ Pgでは任意でRubyと素のCコードにある結果の値やクエリ引数
|
|
|
102
151
|
|
|
103
152
|
しかしPgの型変換はかなり調整が効きます。2層に分かれているのがその理由です。
|
|
104
153
|
|
|
105
|
-
### エンコーダーとデコーダー (ext/pg_
|
|
154
|
+
### エンコーダーとデコーダー (ext/pg_\*coder.c, lib/pg/\*coder.rb)
|
|
106
155
|
|
|
107
156
|
こちらはより低層で、DBMSへ転送するためにRubyのオブジェクトを変換するエンコーディングクラスと、取得してきたデータをRubyのオブジェクトに変換し戻すデコーディングクラスが含まれています。
|
|
108
|
-
クラスはそれぞれの形式によって名前空間 PG::TextEncoder, PG::TextDecoder, PG::BinaryEncoder,
|
|
157
|
+
クラスはそれぞれの形式によって名前空間 PG::TextEncoder, PG::TextDecoder, PG::BinaryEncoder,
|
|
109
158
|
PG::BinaryDecoder に分かれています。
|
|
110
159
|
|
|
111
160
|
エンコーダーないしデコーダーオブジェクトにOIDデータ型や形式コード(テキストないしバイナリ)や任意で名前を割り当てることができます。
|
|
@@ -145,13 +194,14 @@ Binary Encoder、BD = Binary Decoder)。
|
|
|
145
194
|
[現地時間](rdoc-ref:PG::BinaryEncoder::TimestampLocal)、[UTC](rdoc-ref:PG::BinaryEncoder::TimestampUtc)
|
|
146
195
|
* BD:
|
|
147
196
|
[現地時間](rdoc-ref:PG::BinaryDecoder::TimestampLocal)、[UTC](rdoc-ref:PG::BinaryDecoder::TimestampUtc)、[UTCから現地時間へ](rdoc-ref:PG::BinaryDecoder::TimestampUtcToLocal)
|
|
148
|
-
*
|
|
197
|
+
* Date:
|
|
198
|
+
[TE](rdoc-ref:PG::TextEncoder::Date)、[TD](rdoc-ref:PG::TextDecoder::Date)、[BE](rdoc-ref:PG::BinaryEncoder::Date)、[BD](rdoc-ref:PG::BinaryDecoder::Date)
|
|
149
199
|
* JSONとJSONB:
|
|
150
200
|
[TE](rdoc-ref:PG::TextEncoder::JSON)、[TD](rdoc-ref:PG::TextDecoder::JSON)
|
|
151
201
|
* Inet:
|
|
152
202
|
[TE](rdoc-ref:PG::TextEncoder::Inet)、[TD](rdoc-ref:PG::TextDecoder::Inet)
|
|
153
203
|
* Array:
|
|
154
|
-
[TE](rdoc-ref:PG::TextEncoder::Array)、[TD](rdoc-ref:PG::TextDecoder::Array)
|
|
204
|
+
[TE](rdoc-ref:PG::TextEncoder::Array)、[TD](rdoc-ref:PG::TextDecoder::Array)、[BE](rdoc-ref:PG::BinaryEncoder::Array)、[BD](rdoc-ref:PG::BinaryDecoder::Array)
|
|
155
205
|
* 複合型(「行」や「レコード」などとも言います):[TE](rdoc-ref:PG::TextEncoder::Record)、[TD](rdoc-ref:PG::TextDecoder::Record)
|
|
156
206
|
|
|
157
207
|
カラム型として使われていませんが、以下のテキスト形式とバイナリ形式もエンコードできます。
|
|
@@ -163,14 +213,14 @@ Binary Encoder、BD = Binary Decoder)。
|
|
|
163
213
|
* SQLの識別子:
|
|
164
214
|
[TE](rdoc-ref:PG::TextEncoder::Identifier)、[TD](rdoc-ref:PG::TextDecoder::Identifier)
|
|
165
215
|
|
|
166
|
-
###
|
|
216
|
+
### TypeMap とその派生 (ext/pg_type_map\*.c, lib/pg/type_map\*.rb)
|
|
167
217
|
|
|
168
|
-
TypeMap
|
|
169
|
-
|
|
170
|
-
|
|
218
|
+
PG::TypeMap はどのエンコーダーないしデコーダーによってどの値が変換されるかを定義します。
|
|
219
|
+
様々な型の対応付けの戦略があり、このクラスの複数の派生により実装されています。
|
|
220
|
+
型変換の特有の需要に合わせてそれらから選んで構成できます。
|
|
171
221
|
既定の型の対応付けは PG::TypeMapAllStrings です。
|
|
172
222
|
|
|
173
|
-
|
|
223
|
+
型の対応付けは、結果の集合それぞれに対し、接続毎ないし問い合わせ毎に割り当てることができます。
|
|
174
224
|
型の対応付けはCOPYの入出力データストリーミングでも使うことができます。
|
|
175
225
|
PG::Connection#copy_data を参照してください。
|
|
176
226
|
|
|
@@ -191,12 +241,14 @@ PG::Connection#copy_data を参照してください。
|
|
|
191
241
|
* PG::BasicTypeMapForQueries - PG::TypeMapByClass
|
|
192
242
|
によくあるRubyの値クラス用にエンコーダーが入った状態になっています
|
|
193
243
|
|
|
244
|
+
PG::TypeMap::DefaultTypeMappable#default_type_map
|
|
245
|
+
を設定することで複数の型の対応付けを連鎖させられます。
|
|
194
246
|
|
|
195
247
|
## スレッド対応
|
|
196
248
|
|
|
197
|
-
PG
|
|
198
|
-
|
|
199
|
-
|
|
249
|
+
PG には個々のスレッドないしファイバが個々の PG::Connection オブジェクトを並行に使えるという点でスレッド安全です。
|
|
250
|
+
しかしながら1つ以上のスレッドないしファイバから同時に何らかの PG のオブジェクトにアクセスするのは安全ではありません。
|
|
251
|
+
そのため必ず、新しいスレッドないしファイバの一つ一つに対して新しいデータベースサーバー接続を開くか、スレッド安全な方法で接続を管理するActiveRecordのようなラッパーライブラリを使ってください。
|
|
200
252
|
|
|
201
253
|
以下のようなメッセージが標準エラー出力に表示された場合、恐らく複数のスレッドが1つの接続を使っています。
|
|
202
254
|
|
|
@@ -210,13 +262,12 @@ PGには個々のスレッドが別々の PG::Connection オブジェクトを
|
|
|
210
262
|
## Fiber IOスケジューラー対応
|
|
211
263
|
|
|
212
264
|
pg-1.3.0以降で、PgはRuby-3.0で導入された`Fiber.scheduler`に完全に対応しています。
|
|
213
|
-
Windowsでは、`Fiber.scheduler`対応はRuby-3.1以降で使えます。
|
|
214
265
|
`Fiber.scheduler`が走らせているスレッドに登録されている場合、起こりうる全てのブロッキングIO操作はそのスケジューラーを経由します。
|
|
215
266
|
同期的であったりブロックしたりするメソッド呼び出しについてもpgが内部的に非同期のlibpqインターフェースを使っているのはそれが理由です。
|
|
216
267
|
またlibpqの組み込み関数に代えてRubyのDNS解決を使っています。
|
|
217
268
|
|
|
218
|
-
内部的にPgは常にlibpqのノンブロッキング接続モードを使います。
|
|
219
|
-
|
|
269
|
+
内部的に Pg は常にlibpqのノンブロッキング接続モードを使います。
|
|
270
|
+
それからブロッキングモードで走っているように振舞いますが、すべてのブロッキングIOが、可能であれば登録された`Fiber.schedular`を通じて、確実にRubyで制御されます。
|
|
220
271
|
`PG::Connection.setnonblocking(true)`が呼ばれたらノンブロッキング状態が有効になったままになりますが、それ以降のブロッキング状態の制御が無効になるので、呼び出しているプログラムはブロッキング状態を自力で制御しなければなりません。
|
|
221
272
|
|
|
222
273
|
この規則の1つの例外には、`PG::Connection#lo_create`や外部ライブラリを使う認証メソッド(GSSAPI認証など)のような、大きめのオブジェクト用のメソッドがあります。これらは`Fiber.scheduler`と互換性がないため、ブロッキング状態は登録されたIOスケジューラに渡されません。つまり操作は適切に実行されますが、IO待ち状態に別のIOを扱うFiberから使用を切り替えてくることができなくなります。
|
data/README.md
CHANGED
|
@@ -42,7 +42,7 @@ See the PG::Connection class for query methods and the PG::Result class for info
|
|
|
42
42
|
|
|
43
43
|
## Requirements
|
|
44
44
|
|
|
45
|
-
* Ruby
|
|
45
|
+
* Ruby 3.1 or newer
|
|
46
46
|
* PostgreSQL 10.x or later
|
|
47
47
|
* When installing the source gem: libpq with headers, -dev packages, etc.
|
|
48
48
|
|
|
@@ -237,18 +237,25 @@ If messages like the following are printed to stderr, you're probably using one
|
|
|
237
237
|
## Fiber IO scheduler support
|
|
238
238
|
|
|
239
239
|
Pg is fully compatible with `Fiber.scheduler` introduced in Ruby-3.0 since pg-1.3.0.
|
|
240
|
-
On Windows support for `Fiber.scheduler` is available on Ruby-3.1 or newer.
|
|
241
240
|
All possibly blocking IO operations are routed through the `Fiber.scheduler` if one is registered for the running thread.
|
|
242
241
|
That is why pg internally uses the asynchronous libpq interface even for synchronous/blocking method calls.
|
|
243
242
|
It also uses Ruby's DNS resolution instead of libpq's builtin functions.
|
|
244
243
|
|
|
245
244
|
Internally Pg always uses the nonblocking connection mode of libpq.
|
|
246
245
|
It then behaves like running in blocking mode but ensures, that all blocking IO is handled in Ruby through a possibly registered `Fiber.scheduler`.
|
|
247
|
-
When `PG::Connection
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
246
|
+
When `PG::Connection#setnonblocking(true)` is called then the nonblocking state stays enabled, but the additional handling of blocking states is disabled, so that the calling program has to handle blocking states on its own.
|
|
247
|
+
|
|
248
|
+
There are some exceptions to the `Fiber.scheduler` compatibility, so that blocking states are not passed to the registered IO scheduler.
|
|
249
|
+
That means the operation will work properly, but IO waiting states can not be used to switch to another Fiber doing IO:
|
|
250
|
+
|
|
251
|
+
* Methods for large objects like `PG::Connection#lo_create`
|
|
252
|
+
* Authentication methods using external libraries (like GSSAPI or LDAP authentication)
|
|
253
|
+
* LDAP lookup of connection parameters: https://www.postgresql.org/docs/current/libpq-ldap.html
|
|
254
|
+
* A connection string/hash with the `service` parameter set but not `host` and `port`.
|
|
255
|
+
`Thread.scheduler` compatible alternatives are:
|
|
256
|
+
* Set the service via `PGSERVICE`environment variable
|
|
257
|
+
* Set the `host` and `port` parameters explicit in the connection string/hash.
|
|
258
|
+
* Set the `hostaddr` in the service file.
|
|
252
259
|
|
|
253
260
|
|
|
254
261
|
## Ractor support
|
data/Rakefile
CHANGED
|
@@ -47,7 +47,6 @@ CrossLibrary = Struct.new :platform, :openssl_config, :toolchain
|
|
|
47
47
|
CrossLibraries = [
|
|
48
48
|
['aarch64-mingw-ucrt', 'mingwarm64', 'aarch64-w64-mingw32'],
|
|
49
49
|
['x64-mingw-ucrt', 'mingw64', 'x86_64-w64-mingw32'],
|
|
50
|
-
['x64-mingw32', 'mingw64', 'x86_64-w64-mingw32'],
|
|
51
50
|
['x86_64-linux', 'linux-x86_64', 'x86_64-linux-gnu'],
|
|
52
51
|
['x86_64-linux-musl', 'linux-x86_64', 'x86_64-unknown-linux-musl'],
|
|
53
52
|
['aarch64-linux', 'linux-aarch64', 'aarch64-linux-gnu'],
|
|
@@ -126,7 +125,7 @@ CrossLibraries.each do |xlib|
|
|
|
126
125
|
sudo apt-get update && sudo apt-get install -y bison flex &&
|
|
127
126
|
(cp build/gem/gem-*.pem ~/.gem/ || true) &&
|
|
128
127
|
bundle install --local &&
|
|
129
|
-
rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKEFLAGS="-j`nproc` V=1" RUBY_CC_VERSION=#{RakeCompilerDock.ruby_cc_version("~>4.0", "~>3.
|
|
128
|
+
rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKEFLAGS="-j`nproc` V=1" RUBY_CC_VERSION=#{RakeCompilerDock.ruby_cc_version("~>4.0", "~>3.1")}
|
|
130
129
|
EOT
|
|
131
130
|
end
|
|
132
131
|
desc "Build the native binary gems"
|
|
@@ -173,10 +172,12 @@ end
|
|
|
173
172
|
|
|
174
173
|
desc "Translate readme"
|
|
175
174
|
task :translate do
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
cd "translation" do
|
|
176
|
+
# po4a's lexer might change, so record its version for reference
|
|
177
|
+
sh "LANG=C po4a --version > .po4a-version"
|
|
179
178
|
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
pot = 'po/en.pot'
|
|
180
|
+
File.file?(pot) or FileUtils.touch(pot)
|
|
181
|
+
sh "po4a po4a.cfg"
|
|
182
|
+
end
|
|
182
183
|
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
|
2
|
+
MIIEBDCCAmygAwIBAgIBBDANBgkqhkiG9w0BAQsFADAoMSYwJAYDVQQDDB1sYXJz
|
|
3
|
+
L0RDPWdyZWl6LXJlaW5zZG9yZi9EQz1kZTAeFw0yNjAyMTQyMTU3MTlaFw0yNzAy
|
|
4
|
+
MTQyMTU3MTlaMCgxJjAkBgNVBAMMHWxhcnMvREM9Z3JlaXotcmVpbnNkb3JmL0RD
|
|
5
|
+
PWRlMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAwum6Y1KznfpzXOT/
|
|
6
|
+
mZgJTBbxZuuZF49Fq3K0WA67YBzNlDv95qzSp7V/7Ek3NCcnT7G+2kSuhNo1FhdN
|
|
7
|
+
eSDO/moYebZNAcu3iqLsuzuULXPLuoU0GsMnVMqV9DZPh7cQHE5EBZ7hlzDBK7k/
|
|
8
|
+
8nBMvR0mHo77kIkapHc26UzVq/G0nKLfDsIHXVylto3PjzOumjG6GhmFN4r3cP6e
|
|
9
|
+
SDfl1FSeRYVpt4kmQULz/zdSaOH3AjAq7PM2Z91iGwQvoUXMANH2v89OWjQO/NHe
|
|
10
|
+
JMNDFsmHK/6Ji4Kk48Z3TyscHQnipAID5GhS1oD21/WePdj7GhmbF5gBzkV5uepd
|
|
11
|
+
eJQPgWGwrQW/Z2oPjRuJrRofzWfrMWqbOahj9uth6WSxhNexUtbjk6P8emmXOJi5
|
|
12
|
+
chQPnWX+N3Gj+jjYxqTFdwT7Mj3pv1VHa+aNUbqSPpvJeDyxRIuo9hvzDaBHb/Cg
|
|
13
|
+
9qRVcm8a96n4t7y2lrX1oookY6bkBaxWOMtWlqIprq8JZXM9AgMBAAGjOTA3MAkG
|
|
14
|
+
A1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQ4h1tIyvdUWtMI739xMzTR
|
|
15
|
+
7EfMFzANBgkqhkiG9w0BAQsFAAOCAYEAWuY62AlTOhipB443sEkhK0G09vjB3v0j
|
|
16
|
+
9A2HlHXMOcgilbfbMR7ejT+/ynwdqMkrYCQCvoQH06NgIzFi2u6cKKmb2rWXMAF1
|
|
17
|
+
g0NLTs1h/KFsfwuX7IOQ9LxkMl9jlYWdFptFi9oQhlfgmFAFLiZJzNA0+QZMgW6A
|
|
18
|
+
e3usJh0/pT8E0hLWnJdomEF7pNsFyfKjbp5KWRd585z3dePi0iPcpzdByCnJsO36
|
|
19
|
+
Hyl/JsJZyHwpR6LlgfpXmYFwxeFZvpJg2S9O7Yo+qlgiaIUbnkVxOqfEXhCRZm8d
|
|
20
|
+
vfBZ6NSBwcdh7tXk01Yeqap0OtIE7Ey6C/so7uc3vZE6lPZ8xumMYyZ1lJTk5WwS
|
|
21
|
+
qgNbJXZWC/Q9RqPbOZXj4Q2Rq0iFfGNPlkKVeDabXfAASAVtrUb1gByb2b53Kq6N
|
|
22
|
+
OZ/RmpA4/XcoJIE2pnoUq8j6WCeNJ9m11JS2NmgUvYtdMFgMJWoH/hiF71l8dH3v
|
|
23
|
+
76Q140MRgXCuR7RMxztucM6XZQbk1VSO
|
|
24
|
+
-----END CERTIFICATE-----
|
data/ext/extconf.rb
CHANGED
|
@@ -27,14 +27,14 @@ if gem_platform=with_config("cross-build")
|
|
|
27
27
|
gem 'mini_portile2', '~>2.1'
|
|
28
28
|
require 'mini_portile2'
|
|
29
29
|
|
|
30
|
-
OPENSSL_VERSION = ENV['OPENSSL_VERSION'] || '3.6.
|
|
31
|
-
OPENSSL_SOURCE_URI = "
|
|
30
|
+
OPENSSL_VERSION = ENV['OPENSSL_VERSION'] || '3.6.5'
|
|
31
|
+
OPENSSL_SOURCE_URI = "https://www.openssl.org/source/openssl-#{OPENSSL_VERSION}.tar.gz"
|
|
32
32
|
|
|
33
|
-
KRB5_VERSION = ENV['KRB5_VERSION'] || '1.22.
|
|
34
|
-
KRB5_SOURCE_URI = "
|
|
33
|
+
KRB5_VERSION = ENV['KRB5_VERSION'] || '1.22.2'
|
|
34
|
+
KRB5_SOURCE_URI = "https://kerberos.org/dist/krb5/#{KRB5_VERSION[/^(\d+\.\d+)/]}/krb5-#{KRB5_VERSION}.tar.gz"
|
|
35
35
|
|
|
36
|
-
POSTGRESQL_VERSION = ENV['POSTGRESQL_VERSION'] || '18.
|
|
37
|
-
POSTGRESQL_SOURCE_URI = "
|
|
36
|
+
POSTGRESQL_VERSION = ENV['POSTGRESQL_VERSION'] || '18.6'
|
|
37
|
+
POSTGRESQL_SOURCE_URI = "https://ftp.postgresql.org/pub/source/v#{POSTGRESQL_VERSION}/postgresql-#{POSTGRESQL_VERSION}.tar.bz2"
|
|
38
38
|
|
|
39
39
|
class BuildRecipe < MiniPortile
|
|
40
40
|
def initialize(name, version, files)
|
|
@@ -64,6 +64,12 @@ if gem_platform=with_config("cross-build")
|
|
|
64
64
|
self.activate
|
|
65
65
|
self
|
|
66
66
|
end
|
|
67
|
+
|
|
68
|
+
# Increase number of download retries; otherwise it fails often in CI
|
|
69
|
+
alias download_file_count_3 download_file
|
|
70
|
+
def download_file(url, full_path, count = 60)
|
|
71
|
+
download_file_count_3(url, full_path, count)
|
|
72
|
+
end
|
|
67
73
|
end
|
|
68
74
|
|
|
69
75
|
openssl_platform = with_config("openssl-platform")
|
|
@@ -76,7 +82,7 @@ if gem_platform=with_config("cross-build")
|
|
|
76
82
|
envs = []
|
|
77
83
|
envs << "CFLAGS=-DDSO_WIN32 -DOPENSSL_THREADS" if RUBY_PLATFORM =~ /mingw|mswin/
|
|
78
84
|
envs << "CFLAGS=-fPIC -DOPENSSL_THREADS" if RUBY_PLATFORM =~ /linux|darwin/
|
|
79
|
-
execute('configure', ['env', *envs, "./Configure", openssl_platform, "threads", "-static", "CROSS_COMPILE=#{host}-", "--prefix=/"], altlog: "config.log")
|
|
85
|
+
execute('configure', ['env', *envs, "./Configure", openssl_platform, "threads", "-static", "CROSS_COMPILE=#{host}-", "--prefix=/", "--libdir=lib"], altlog: "config.log")
|
|
80
86
|
end
|
|
81
87
|
def compile
|
|
82
88
|
execute('compile', "#{make_cmd} build_libs")
|
|
@@ -92,7 +98,7 @@ if gem_platform=with_config("cross-build")
|
|
|
92
98
|
end
|
|
93
99
|
|
|
94
100
|
if RUBY_PLATFORM =~ /linux|darwin/
|
|
95
|
-
|
|
101
|
+
BuildRecipe.new("krb5", KRB5_VERSION, [KRB5_SOURCE_URI]).tap do |recipe|
|
|
96
102
|
class << recipe
|
|
97
103
|
def work_path
|
|
98
104
|
File.join(super, "src")
|
|
@@ -170,7 +176,7 @@ if gem_platform=with_config("cross-build")
|
|
|
170
176
|
|
|
171
177
|
recipe.host = toolchain
|
|
172
178
|
recipe.configure_options << "CFLAGS=#{" -fPIC" if RUBY_PLATFORM =~ /linux|darwin/}"
|
|
173
|
-
recipe.configure_options << "LDFLAGS=-L#{openssl_recipe.path}/lib
|
|
179
|
+
recipe.configure_options << "LDFLAGS=-L#{openssl_recipe.path}/lib #{"-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/}"
|
|
174
180
|
recipe.configure_options << "LIBS=-lkrb5 -lcom_err -lk5crypto -lkrb5support -lresolv" if RUBY_PLATFORM =~ /linux/
|
|
175
181
|
recipe.configure_options << "LIBS=-lssl -lwsock32 -lgdi32 -lws2_32 -lcrypt32" if RUBY_PLATFORM =~ /mingw|mswin/
|
|
176
182
|
recipe.configure_options << "CPPFLAGS=-I#{openssl_recipe.path}/include"
|
|
@@ -185,8 +191,6 @@ if gem_platform=with_config("cross-build")
|
|
|
185
191
|
$LDFLAGS << " -L#{postgresql_recipe.path}/lib"
|
|
186
192
|
# Avoid dependency to external libgcc.dll on x86-mingw32
|
|
187
193
|
$LDFLAGS << " -static-libgcc" if RUBY_PLATFORM =~ /mingw|mswin/
|
|
188
|
-
# Avoid: "libpq.so: undefined reference to `dlopen'" in cross-ruby-2.7.8
|
|
189
|
-
$LDFLAGS << " -Wl,--no-as-needed" if RUBY_PLATFORM !~ /aarch64|arm64|darwin/
|
|
190
194
|
# Find libpq in the ports directory coming from lib/3.x
|
|
191
195
|
# It is shared between all compiled ruby versions.
|
|
192
196
|
$LDFLAGS << " '-Wl,-rpath=$$ORIGIN/../../ports/#{gem_platform}/lib'" if RUBY_PLATFORM =~ /linux/
|
|
@@ -218,13 +222,6 @@ else
|
|
|
218
222
|
dlldir = libdir
|
|
219
223
|
end
|
|
220
224
|
|
|
221
|
-
# Try to use runtime path linker option, even if RbConfig doesn't know about it.
|
|
222
|
-
# The rpath option is usually set implicit by dir_config(), but so far not
|
|
223
|
-
# on MacOS-X.
|
|
224
|
-
if dlldir && RbConfig::CONFIG["RPATHFLAG"].to_s.empty?
|
|
225
|
-
append_ldflags "-Wl,-rpath,#{dlldir.quote}"
|
|
226
|
-
end
|
|
227
|
-
|
|
228
225
|
if /mswin/ =~ RUBY_PLATFORM
|
|
229
226
|
$libs = append_library($libs, 'ws2_32')
|
|
230
227
|
end
|
|
@@ -307,22 +304,15 @@ if /mingw/ =~ RUBY_PLATFORM && RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
|
|
|
307
304
|
end
|
|
308
305
|
|
|
309
306
|
have_func 'PQencryptPasswordConn', 'libpq-fe.h' or # since PostgreSQL-10
|
|
310
|
-
abort "Your PostgreSQL is too old.
|
|
311
|
-
|
|
307
|
+
abort "Your PostgreSQL client library (libpq) is too old. " +
|
|
308
|
+
"Either install an older version of this gem " +
|
|
309
|
+
"or upgrade your database to at least PostgreSQL-10."
|
|
312
310
|
# optional headers/functions
|
|
313
311
|
have_func 'PQresultMemorySize', 'libpq-fe.h' # since PostgreSQL-12
|
|
314
|
-
have_func 'PQenterPipelineMode', 'libpq-fe.h' do |src| # since PostgreSQL-14
|
|
315
|
-
# Ensure header files fit as well
|
|
316
|
-
src + " int con(){ return PGRES_PIPELINE_SYNC; }"
|
|
317
|
-
end
|
|
318
|
-
have_func 'PQsetChunkedRowsMode', 'libpq-fe.h' # since PostgreSQL-17
|
|
319
312
|
have_func 'timegm'
|
|
320
|
-
have_func 'rb_io_wait' # since ruby-3.0
|
|
321
|
-
have_func 'rb_io_descriptor' # since ruby-3.1
|
|
322
313
|
have_func 'rb_hash_new_capa' # since ruby-3.2
|
|
323
314
|
|
|
324
315
|
have_header 'inttypes.h'
|
|
325
|
-
have_header('ruby/fiber/scheduler.h') if RUBY_PLATFORM=~/mingw|mswin/
|
|
326
316
|
|
|
327
317
|
checking_for "C99 variable length arrays" do
|
|
328
318
|
$defs.push( "-DHAVE_VARIABLE_LENGTH_ARRAYS" ) if try_compile('void test_vla(int l){ int vla[l]; }')
|
data/ext/gvl_wrappers.c
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
#include "pg.h"
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
#ifndef
|
|
9
|
+
#ifndef LIBPQ_HAS_CHUNK_MODE
|
|
10
10
|
PGresult *PQclosePrepared(PGconn *conn, const char *stmtName){return NULL;}
|
|
11
11
|
PGresult *PQclosePortal(PGconn *conn, const char *portalName){return NULL;}
|
|
12
12
|
int PQsendClosePrepared(PGconn *conn, const char *stmtName){return 0;}
|
|
@@ -16,7 +16,7 @@ int PQcancelBlocking(PGcancelConn *cancelConn){return 0;}
|
|
|
16
16
|
int PQcancelStart(PGcancelConn *cancelConn){return 0;}
|
|
17
17
|
PostgresPollingStatusType PQcancelPoll(PGcancelConn *cancelConn){return PGRES_POLLING_FAILED;}
|
|
18
18
|
#endif
|
|
19
|
-
#ifndef
|
|
19
|
+
#ifndef LIBPQ_HAS_PIPELINING
|
|
20
20
|
int PQpipelineSync(PGconn *conn){return 0;}
|
|
21
21
|
#endif
|
|
22
22
|
|