pg 1.6.2-aarch64-linux → 1.7.0-aarch64-linux
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 +61 -0
- data/Gemfile +5 -4
- data/README.ja.md +81 -30
- data/README.md +20 -10
- data/Rakefile +13 -26
- data/certs/larskanis-2026.pem +24 -0
- data/ext/errorcodes.def +9 -0
- data/ext/errorcodes.rb +1 -1
- data/ext/errorcodes.txt +8 -1
- data/ext/extconf.rb +19 -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 +14 -15
- 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 +218 -161
- data/ext/pg_copy_coder.c +34 -21
- data/ext/pg_record_coder.c +10 -6
- data/ext/pg_result.c +131 -61
- data/ext/pg_text_decoder.c +6 -6
- data/ext/pg_text_encoder.c +7 -2
- data/ext/pg_tuple.c +2 -2
- 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/3.1/pg_ext.so +0 -0
- data/lib/3.2/pg_ext.so +0 -0
- data/lib/3.3/pg_ext.so +0 -0
- data/lib/3.4/pg_ext.so +0 -0
- data/lib/4.0/pg_ext.so +0 -0
- 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/ports/aarch64-linux/lib/libpq-ruby-pg.so.1 +0 -0
- data/sample/async_mixed.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +21 -23
- metadata.gz.sig +0 -0
- data/lib/2.7/pg_ext.so +0 -0
- data/lib/3.0/pg_ext.so +0 -0
- data/ports/patches/openssl/3.5.2/0001-aarch64-mingw.patch +0 -21
- data/ports/patches/postgresql/17.6/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/{17.6 → 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: 7934c31d08e883ce9ad8cf0183589323bdc1ac17d7956cc92b49e2bd23ca21df
|
|
4
|
+
data.tar.gz: 6631ad156d0d8ecc44990d1e4c44e8b63dc48960d5616715933ed78b75ceb022
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 47a54a41c795f6df1a6e4e85b4b88472435f8280cda251a0667f3eb232d03fc66c29423ee05049e3d4a8c2ad14c91f444b5a25cc512bf1cefc62c54b46d12365
|
|
7
|
+
data.tar.gz: 193b997143a72ce7076db60a5e4e1e3de92b5db6c4b4aef17cab4e1302ca1441197eacb460512b89db084db65aa0f97145548cbdcc92fa9eee2bfe2d46434b58
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
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
|
+
|
|
44
|
+
## v1.6.3 [2025-12-29] Lars Kanis <lars@greiz-reinsdorf.de>
|
|
45
|
+
|
|
46
|
+
Added:
|
|
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)
|
|
51
|
+
- Update errorcodes to PostgreSQL-18.
|
|
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)
|
|
55
|
+
|
|
56
|
+
Removed:
|
|
57
|
+
|
|
58
|
+
- Drop binary gem support for platform `x86-mingw32`. [#682](https://github.com/ged/ruby-pg/pull/682)
|
|
59
|
+
- Drop binary gems for ruby-2.7.
|
|
60
|
+
|
|
61
|
+
|
|
1
62
|
## v1.6.2 [2025-09-02] Lars Kanis <lars@greiz-reinsdorf.de>
|
|
2
63
|
|
|
3
64
|
- Remove several absolute paths from native binaries which pointed to build directories. [#668](https://github.com/ged/ruby-pg/pull/668)
|
data/Gemfile
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- ruby -*-
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
gemspec
|
|
3
|
+
# No pg gem, since "bundle package" fails on bundler-2.7+, if the extension isn't built
|
|
4
|
+
# gemspec
|
|
5
5
|
|
|
6
6
|
source "https://rubygems.org/"
|
|
7
7
|
|
|
@@ -11,13 +11,14 @@ group :development do
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
group :test do
|
|
14
|
-
gem "bundler", ">= 1.16", "<
|
|
14
|
+
gem "bundler", ">= 1.16", "< 5.0"
|
|
15
15
|
gem "rake-compiler", "~> 1.0"
|
|
16
|
-
gem "rake-compiler-dock", "~> 1.
|
|
16
|
+
gem "rake-compiler-dock", "~> 1.11.0" #, git: "https://github.com/rake-compiler/rake-compiler-dock"
|
|
17
17
|
gem "rspec", "~> 3.5"
|
|
18
18
|
# "bigdecimal" is a gem on ruby-3.4+ and it's optional for ruby-pg.
|
|
19
19
|
# Specs should succeed without it, but 4 examples are then excluded.
|
|
20
20
|
# With bigdecimal commented out here, corresponding tests are omitted on ruby-3.4+ but are executed on ruby < 3.4.
|
|
21
21
|
# That way we can check both situations in CI.
|
|
22
22
|
# gem "bigdecimal", "~> 3.0"
|
|
23
|
+
gem "drb"
|
|
23
24
|
end
|
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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# pg
|
|
2
2
|
|
|
3
3
|
* home :: https://github.com/ged/ruby-pg
|
|
4
|
-
* docs :: http://deveiate.org/code/pg (English) ,
|
|
4
|
+
* docs :: http://deveiate.org/code/pg/README_md.html (English) ,
|
|
5
5
|
https://deveiate.org/code/pg/README_ja_md.html (Japanese)
|
|
6
6
|
* clog :: link:/CHANGELOG.md
|
|
7
7
|
|
|
@@ -30,6 +30,9 @@ A small example usage:
|
|
|
30
30
|
end
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
See the PG::Connection class for query methods and the PG::Result class for information on working with the results of a query.
|
|
34
|
+
|
|
35
|
+
|
|
33
36
|
## Build Status
|
|
34
37
|
|
|
35
38
|
[](https://github.com/ged/ruby-pg/actions/workflows/source-gem.yml)
|
|
@@ -39,7 +42,7 @@ A small example usage:
|
|
|
39
42
|
|
|
40
43
|
## Requirements
|
|
41
44
|
|
|
42
|
-
* Ruby
|
|
45
|
+
* Ruby 3.1 or newer
|
|
43
46
|
* PostgreSQL 10.x or later
|
|
44
47
|
* When installing the source gem: libpq with headers, -dev packages, etc.
|
|
45
48
|
|
|
@@ -218,8 +221,8 @@ Several type maps can be chained by setting PG::TypeMap::DefaultTypeMappable#def
|
|
|
218
221
|
|
|
219
222
|
## Thread support
|
|
220
223
|
|
|
221
|
-
PG is thread safe in such a way that different threads can use different PG::Connection objects concurrently.
|
|
222
|
-
However it is not safe to access any
|
|
224
|
+
PG is thread safe in such a way that different threads or fibers can use different PG::Connection objects concurrently.
|
|
225
|
+
However it is not safe to access any PG object simultaneously from more than one thread or fiber unless the object is frozen.
|
|
223
226
|
So make sure to open a new database server connection for every new thread or use a wrapper library like ActiveRecord that manages connections in a thread safe way.
|
|
224
227
|
|
|
225
228
|
If messages like the following are printed to stderr, you're probably using one connection from several threads:
|
|
@@ -234,18 +237,25 @@ If messages like the following are printed to stderr, you're probably using one
|
|
|
234
237
|
## Fiber IO scheduler support
|
|
235
238
|
|
|
236
239
|
Pg is fully compatible with `Fiber.scheduler` introduced in Ruby-3.0 since pg-1.3.0.
|
|
237
|
-
On Windows support for `Fiber.scheduler` is available on Ruby-3.1 or newer.
|
|
238
240
|
All possibly blocking IO operations are routed through the `Fiber.scheduler` if one is registered for the running thread.
|
|
239
241
|
That is why pg internally uses the asynchronous libpq interface even for synchronous/blocking method calls.
|
|
240
242
|
It also uses Ruby's DNS resolution instead of libpq's builtin functions.
|
|
241
243
|
|
|
242
244
|
Internally Pg always uses the nonblocking connection mode of libpq.
|
|
243
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`.
|
|
244
|
-
When `PG::Connection
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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.
|
|
249
259
|
|
|
250
260
|
|
|
251
261
|
## Ractor support
|
data/Rakefile
CHANGED
|
@@ -47,8 +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
|
-
['x86-mingw32', 'mingw', 'i686-w64-mingw32'],
|
|
51
|
-
['x64-mingw32', 'mingw64', 'x86_64-w64-mingw32'],
|
|
52
50
|
['x86_64-linux', 'linux-x86_64', 'x86_64-linux-gnu'],
|
|
53
51
|
['x86_64-linux-musl', 'linux-x86_64', 'x86_64-unknown-linux-musl'],
|
|
54
52
|
['aarch64-linux', 'linux-aarch64', 'aarch64-linux-gnu'],
|
|
@@ -94,7 +92,7 @@ Rake::ExtensionTask.new do |ext|
|
|
|
94
92
|
spec.files << "ports/#{spec.platform.to_s}/lib/libpq-ruby-pg.1.dylib" if spec.platform.to_s =~ /darwin/
|
|
95
93
|
spec.files << "ports/#{spec.platform.to_s}/lib/libpq.dll" if spec.platform.to_s =~ /mingw|mswin/
|
|
96
94
|
|
|
97
|
-
# Binary gems don't postgresql header+lib files
|
|
95
|
+
# Binary gems don't need postgresql header+lib files
|
|
98
96
|
spec.metadata.delete("msys2_mingw_dependencies")
|
|
99
97
|
end
|
|
100
98
|
end
|
|
@@ -106,7 +104,8 @@ task 'gem:native:prepare' do
|
|
|
106
104
|
# Copy gem signing key and certs to be accessible from the docker container
|
|
107
105
|
mkdir_p 'build/gem'
|
|
108
106
|
sh "cp ~/.gem/gem-*.pem build/gem/ || true"
|
|
109
|
-
sh "bundle
|
|
107
|
+
sh "bundle config set cache_all false"
|
|
108
|
+
sh "bundle package"
|
|
110
109
|
begin
|
|
111
110
|
OpenSSL::PKey.read(File.read(File.expand_path("~/.gem/gem-private_key.pem")), ENV["GEM_PRIVATE_KEY_PASSPHRASE"] || "")
|
|
112
111
|
rescue OpenSSL::PKey::PKeyError
|
|
@@ -115,19 +114,6 @@ task 'gem:native:prepare' do
|
|
|
115
114
|
end
|
|
116
115
|
end
|
|
117
116
|
|
|
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
117
|
CrossLibraries.each do |xlib|
|
|
132
118
|
platform = xlib.platform
|
|
133
119
|
desc "Build fat binary gem for platform #{platform}"
|
|
@@ -139,9 +125,7 @@ CrossLibraries.each do |xlib|
|
|
|
139
125
|
sudo apt-get update && sudo apt-get install -y bison flex &&
|
|
140
126
|
(cp build/gem/gem-*.pem ~/.gem/ || true) &&
|
|
141
127
|
bundle install --local &&
|
|
142
|
-
|
|
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")}
|
|
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")}
|
|
145
129
|
EOT
|
|
146
130
|
end
|
|
147
131
|
desc "Build the native binary gems"
|
|
@@ -172,7 +156,8 @@ end
|
|
|
172
156
|
|
|
173
157
|
desc "Update list of server error codes"
|
|
174
158
|
task :update_error_codes do
|
|
175
|
-
URL_ERRORCODES_TXT = "
|
|
159
|
+
# URL_ERRORCODES_TXT = "https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL_18_0"
|
|
160
|
+
URL_ERRORCODES_TXT = "https://raw.githubusercontent.com/postgres/postgres/refs/tags/REL_18_0/src/backend/utils/errcodes.txt"
|
|
176
161
|
|
|
177
162
|
ERRORCODES_TXT = "ext/errorcodes.txt"
|
|
178
163
|
sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
|
|
@@ -187,10 +172,12 @@ end
|
|
|
187
172
|
|
|
188
173
|
desc "Translate readme"
|
|
189
174
|
task :translate do
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
175
|
+
cd "translation" do
|
|
176
|
+
# po4a's lexer might change, so record its version for reference
|
|
177
|
+
sh "LANG=C po4a --version > .po4a-version"
|
|
193
178
|
|
|
194
|
-
|
|
195
|
-
|
|
179
|
+
pot = 'po/en.pot'
|
|
180
|
+
File.file?(pot) or FileUtils.touch(pot)
|
|
181
|
+
sh "po4a po4a.cfg"
|
|
182
|
+
end
|
|
196
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/errorcodes.def
CHANGED
|
@@ -87,6 +87,11 @@
|
|
|
87
87
|
VALUE klass = define_error_class( "StackedDiagnosticsAccessedWithoutActiveHandler", "0Z" );
|
|
88
88
|
register_error_class( "0Z002", klass );
|
|
89
89
|
}
|
|
90
|
+
{
|
|
91
|
+
VALUE klass = define_error_class( "InvalidArgumentForXquery", NULL );
|
|
92
|
+
register_error_class( "10608", klass );
|
|
93
|
+
register_error_class( "10", klass );
|
|
94
|
+
}
|
|
90
95
|
{
|
|
91
96
|
VALUE klass = define_error_class( "CaseNotFound", NULL );
|
|
92
97
|
register_error_class( "20000", klass );
|
|
@@ -889,6 +894,10 @@
|
|
|
889
894
|
VALUE klass = define_error_class( "DuplicateFile", "58" );
|
|
890
895
|
register_error_class( "58P02", klass );
|
|
891
896
|
}
|
|
897
|
+
{
|
|
898
|
+
VALUE klass = define_error_class( "FileNameTooLong", "58" );
|
|
899
|
+
register_error_class( "58P03", klass );
|
|
900
|
+
}
|
|
892
901
|
{
|
|
893
902
|
VALUE klass = define_error_class( "ConfigFileError", NULL );
|
|
894
903
|
register_error_class( "F0000", klass );
|
data/ext/errorcodes.rb
CHANGED
|
@@ -28,7 +28,7 @@ EOCODE
|
|
|
28
28
|
sqlstate, ews, errcode_macro_name = $1, $2, $3
|
|
29
29
|
next unless ews=='E'
|
|
30
30
|
|
|
31
|
-
is_sqlclass = sqlstate[2..-1] == '000'
|
|
31
|
+
is_sqlclass = sqlstate[2..-1] == '000' || sqlstate == '10608'
|
|
32
32
|
class_code = sqlstate[0,2]
|
|
33
33
|
baseclass_code = is_sqlclass ? 'NULL' : class_code.inspect
|
|
34
34
|
class_name = camelize(errcode_macro_name.sub('ERRCODE_', '').downcase)
|
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-2025, 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
|
|
@@ -141,6 +141,12 @@ Section: Class 0Z - Diagnostics Exception
|
|
|
141
141
|
0Z000 E ERRCODE_DIAGNOSTICS_EXCEPTION diagnostics_exception
|
|
142
142
|
0Z002 E ERRCODE_STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER stacked_diagnostics_accessed_without_active_handler
|
|
143
143
|
|
|
144
|
+
Section: Class 10 - XQuery Error
|
|
145
|
+
|
|
146
|
+
# recent SQL versions define quite a few codes in this class, but for now
|
|
147
|
+
# we are only using this generic one
|
|
148
|
+
10608 E ERRCODE_INVALID_ARGUMENT_FOR_XQUERY invalid_argument_for_xquery
|
|
149
|
+
|
|
144
150
|
Section: Class 20 - Case Not Found
|
|
145
151
|
|
|
146
152
|
20000 E ERRCODE_CASE_NOT_FOUND case_not_found
|
|
@@ -439,6 +445,7 @@ Section: Class 58 - System Error (errors external to PostgreSQL itself)
|
|
|
439
445
|
58030 E ERRCODE_IO_ERROR io_error
|
|
440
446
|
58P01 E ERRCODE_UNDEFINED_FILE undefined_file
|
|
441
447
|
58P02 E ERRCODE_DUPLICATE_FILE duplicate_file
|
|
448
|
+
58P03 E ERRCODE_FILE_NAME_TOO_LONG file_name_too_long
|
|
442
449
|
|
|
443
450
|
Section: Class F0 - Configuration File Error
|
|
444
451
|
|