pg 1.5.9 → 1.6.3
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} +80 -0
- data/Gemfile +10 -7
- data/README-Windows.rdoc +1 -1
- data/README.ja.md +4 -4
- data/README.md +66 -23
- data/Rakefile +78 -14
- data/ext/errorcodes.def +9 -0
- data/ext/errorcodes.rb +1 -1
- data/ext/errorcodes.txt +8 -1
- data/ext/extconf.rb +189 -15
- data/ext/gvl_wrappers.c +13 -2
- data/ext/gvl_wrappers.h +33 -0
- data/ext/pg.c +16 -5
- data/ext/pg.h +15 -13
- data/ext/pg_binary_decoder.c +151 -1
- data/ext/pg_binary_encoder.c +212 -9
- data/ext/pg_cancel_connection.c +360 -0
- data/ext/pg_coder.c +54 -5
- data/ext/pg_connection.c +390 -160
- data/ext/pg_copy_coder.c +2 -2
- data/ext/pg_record_coder.c +1 -1
- data/ext/pg_result.c +104 -52
- data/ext/pg_text_decoder.c +1 -1
- data/ext/pg_text_encoder.c +22 -9
- data/ext/pg_tuple.c +8 -8
- data/ext/pg_type_map.c +4 -2
- data/ext/pg_type_map_all_strings.c +1 -1
- data/ext/pg_type_map_by_class.c +1 -1
- data/ext/pg_type_map_by_column.c +2 -1
- data/ext/pg_type_map_by_mri_type.c +1 -1
- data/ext/pg_type_map_by_oid.c +3 -1
- data/ext/pg_type_map_in_ruby.c +1 -1
- data/ext/pg_util.c +2 -2
- data/ext/pg_util.h +2 -2
- data/lib/pg/basic_type_map_for_queries.rb +7 -3
- data/lib/pg/basic_type_registry.rb +2 -2
- data/lib/pg/cancel_connection.rb +53 -0
- data/lib/pg/coder.rb +4 -2
- data/lib/pg/connection.rb +254 -131
- data/lib/pg/version.rb +2 -1
- data/lib/pg.rb +156 -130
- data/misc/glibc/Dockerfile +20 -0
- data/misc/glibc/docker-compose.yml +9 -0
- data/misc/glibc/glibc_spec.rb +5 -0
- 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 +5 -3
- data/ports/patches/krb5/1.22.1/0001-Allow-static-linking-krb5-library.patch +30 -0
- data/ports/patches/krb5/1.22.1/0002-unknown-command-line-option-on-clang.patch +12 -0
- data/ports/patches/openssl/3.5.2/0001-aarch64-mingw.patch +21 -0
- data/ports/patches/postgresql/18.1/0001-Use-workaround-of-__builtin_setjmp-only-on-MINGW-on-.patch +42 -0
- data/ports/patches/postgresql/18.1/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 +37 -22
- metadata.gz.sig +0 -0
- data/Manifest.txt +0 -72
- data/Rakefile.cross +0 -303
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b98dcd23695bd37aca4e9769e5b55a26ab53b7de01e4b44ff22d1849df08088a
|
|
4
|
+
data.tar.gz: d9610b8ca74c772db98aff8ff661fa29ea44d8917e0ef48f1e89f9cdfd3158b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 531c1c61fdb41ea77a8e8e657a536f5734fecc117f7b3a93c04707b7f16a034a841859944e097e75db12ea630ff2679ed90054e0132b96f23ee92c5807d8c07f
|
|
7
|
+
data.tar.gz: 7d7d8d8c0ff76687d63912d41cf4dea890eb63bf361378b9da075ad1f8ccda9b34353e0de0f462bff5cae2740ee17988c3aef417c92d9b38d3a1b635e6ed19f5
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/{History.md → CHANGELOG.md}
RENAMED
|
@@ -1,3 +1,83 @@
|
|
|
1
|
+
## v1.6.3 [2025-12-29] Lars Kanis <lars@greiz-reinsdorf.de>
|
|
2
|
+
|
|
3
|
+
Added:
|
|
4
|
+
- Add binary gems for ruby-4.0, now providing ruby-3.0 to 4.0. #682
|
|
5
|
+
- Improve documentation of PG::Result and README. #676
|
|
6
|
+
- 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
|
|
10
|
+
|
|
11
|
+
Removed:
|
|
12
|
+
- Drop binary gem support for platform `x86-mingw32`. #682
|
|
13
|
+
- Drop binary gems for ruby-2.7.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## v1.6.2 [2025-09-02] Lars Kanis <lars@greiz-reinsdorf.de>
|
|
17
|
+
|
|
18
|
+
- Remove several absolute paths from native binaries which pointed to build directories. [#668](https://github.com/ged/ruby-pg/pull/668)
|
|
19
|
+
- Fix bad fallback path to `pg_service.conf`. [#666](https://github.com/ged/ruby-pg/pull/666)
|
|
20
|
+
- 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)
|
|
21
|
+
- Raise a more descriptive error message in case of `pg_ext` LoadError. [#664](https://github.com/ged/ruby-pg/pull/664)
|
|
22
|
+
- Freeze some constants to make them available in a Ractor context. [#660](https://github.com/ged/ruby-pg/pull/660)
|
|
23
|
+
- Several documentation improvements.
|
|
24
|
+
- Update native binary gems to OpenSSL-3.5.2, krb5-1.22.1 and PostgreSQL-17.6.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## v1.6.1 [2025-08-03] Lars Kanis <lars@greiz-reinsdorf.de>
|
|
28
|
+
|
|
29
|
+
- 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).
|
|
30
|
+
- Serialize CompositeCoder#dimensions only when set. [#652](https://github.com/ged/ruby-pg/pull/652)
|
|
31
|
+
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.
|
|
32
|
+
- Remove dependency to MSYS2 package "postgresql" from binary Windows gem [#654](https://github.com/ged/ruby-pg/pull/654)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## v1.6.0 [2025-07-27] Lars Kanis <lars@greiz-reinsdorf.de>
|
|
36
|
+
|
|
37
|
+
Added:
|
|
38
|
+
|
|
39
|
+
- Add binary gems for Ruby 3.4.
|
|
40
|
+
- 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).
|
|
41
|
+
- Update fat binary gem to OpenSSL-3.5.1 and PostgreSQL-17.5.
|
|
42
|
+
- Add a patch to libpq to avoid starvation on bigger SSL records, which some database engines other than vanilla PostgreSQL use.
|
|
43
|
+
This patch applies to platform specific binary gems only.
|
|
44
|
+
[#616](https://github.com/ged/ruby-pg/pull/616)
|
|
45
|
+
- Add support for new query cancel functions of PostgreSQL-17.
|
|
46
|
+
This adds the new class `PG::CancelConnection` which provides the ability to cancel a query per blocking or per non-blocking functions.
|
|
47
|
+
If the new functions are available they are used and the older are no longer compiled in.
|
|
48
|
+
This way we can get rid of reading out the internal `PGcancel` struct by `Connection#backend_key`.
|
|
49
|
+
[#614](https://github.com/ged/ruby-pg/pull/614)
|
|
50
|
+
- Add PG::BinaryDecoder::Array and PG::BinaryEncoder::Array to parse and encode PostgreSQL arrays in binary format.
|
|
51
|
+
[#603](https://github.com/ged/ruby-pg/pull/603)
|
|
52
|
+
- Add possibility to define the number of array dimensions to be encoded.
|
|
53
|
+
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.
|
|
54
|
+
[#622](https://github.com/ged/ruby-pg/pull/622)
|
|
55
|
+
- Add Connection#set_chunked_rows_mode [#610](https://github.com/ged/ruby-pg/pull/610)
|
|
56
|
+
- 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.
|
|
57
|
+
[#611](https://github.com/ged/ruby-pg/pull/611)
|
|
58
|
+
- Add Connection#send_pipeline_sync, async_pipeline_sync and release GVL at PQ(sendP|P)ipelineSync.
|
|
59
|
+
[#612](https://github.com/ged/ruby-pg/pull/612)
|
|
60
|
+
- Add MINGW package dependency which is resolved by RubyInstaller.
|
|
61
|
+
[#617](https://github.com/ged/ruby-pg/pull/617)
|
|
62
|
+
- Change `conn.server_version` and `conn.protocol_version` to raise instead of return 0 on error.
|
|
63
|
+
[#632](https://github.com/ged/ruby-pg/pull/632)
|
|
64
|
+
- Fix connecting to multiple hosts after `connnect_timeout`.
|
|
65
|
+
[#637](https://github.com/ged/ruby-pg/pull/637)
|
|
66
|
+
- Fix making PG::BasicTypeMapForQueries shareable for Ractor in ruby-3.5.
|
|
67
|
+
[#636](https://github.com/ged/ruby-pg/pull/636)
|
|
68
|
+
- Fix missing array input verification in PG::TypeMapByColumn.
|
|
69
|
+
This could cause a segfault.
|
|
70
|
+
[#620](https://github.com/ged/ruby-pg/pull/620)
|
|
71
|
+
- Rename `History.md` to `CHANGELOG.md`, which is more common.
|
|
72
|
+
[#642](https://github.com/ged/ruby-pg/pull/642)
|
|
73
|
+
|
|
74
|
+
Removed:
|
|
75
|
+
|
|
76
|
+
- Drop support of Ruby < 2.7 [#606](https://github.com/ged/ruby-pg/pull/606)
|
|
77
|
+
- Drop support of PostgreSQL < 10 [#606](https://github.com/ged/ruby-pg/pull/606)
|
|
78
|
+
- Remove workaround for Truffleruby < 21.3.0 [#613](https://github.com/ged/ruby-pg/pull/613)
|
|
79
|
+
|
|
80
|
+
|
|
1
81
|
## v1.5.9 [2024-10-24] Lars Kanis <lars@greiz-reinsdorf.de>
|
|
2
82
|
|
|
3
83
|
- Enable thread safety in static OpenSSL build for Windows. [#595](https://github.com/ged/ruby-pg/pull/595)
|
data/Gemfile
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
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
|
|
|
8
|
-
group :development
|
|
9
|
-
gem "bundler", ">= 1.16", "< 3.0"
|
|
10
|
-
gem "rake-compiler", "~> 1.0"
|
|
11
|
-
gem "rake-compiler-dock", "~> 1.0"
|
|
8
|
+
group :development do
|
|
12
9
|
gem "rdoc", "~> 6.4"
|
|
10
|
+
gem "mini_portile2", "~> 2.1"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
group :test do
|
|
14
|
+
gem "bundler", ">= 1.16", "< 5.0"
|
|
15
|
+
gem "rake-compiler", "~> 1.0"
|
|
16
|
+
gem "rake-compiler-dock", "~> 1.11.0" #, 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:
|
|
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:/
|
|
5
|
+
* 変更履歴 :: link:/CHANGELOG.md
|
|
6
6
|
|
|
7
7
|
[](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
|
-
|
|
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.
|
|
45
|
-
* PostgreSQL
|
|
44
|
+
* Ruby 2.7かそれより新しいバージョン
|
|
45
|
+
* PostgreSQL 10.xかそれ以降のバージョン(ヘッダー付属のもの、例えば-devの名前のパッケージ)。
|
|
46
46
|
|
|
47
47
|
それより前のバージョンのRubyやPostgreSQLでも通常は同様に動作しますが、定期的なテストはされていません。
|
|
48
48
|
|
data/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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
|
-
* clog :: link:/
|
|
6
|
+
* clog :: link:/CHANGELOG.md
|
|
7
7
|
|
|
8
8
|
[](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
|
|
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
|
|
@@ -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,30 +42,34 @@ A small example usage:
|
|
|
39
42
|
|
|
40
43
|
## Requirements
|
|
41
44
|
|
|
42
|
-
* Ruby 2.
|
|
43
|
-
* PostgreSQL
|
|
45
|
+
* Ruby 2.7 or newer
|
|
46
|
+
* PostgreSQL 10.x or later
|
|
47
|
+
* When installing the source gem: libpq with headers, -dev packages, etc.
|
|
44
48
|
|
|
45
|
-
It usually works with earlier versions of Ruby/PostgreSQL as well, but those are
|
|
46
|
-
not regularly tested.
|
|
47
49
|
|
|
50
|
+
## How To Install
|
|
48
51
|
|
|
49
|
-
|
|
52
|
+
Install via RubyGems:
|
|
50
53
|
|
|
51
|
-
|
|
54
|
+
gem install pg
|
|
52
55
|
|
|
53
|
-
|
|
56
|
+
This installs the binary gem, specific to the running platform by default.
|
|
54
57
|
|
|
55
|
-
|
|
58
|
+
### Binary gem
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
```
|
|
60
|
+
The binary gems don't depend on the libpq package on the running system.
|
|
61
|
+
They have libpq builtin.
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
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
64
|
|
|
63
|
-
|
|
65
|
+
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
66
|
|
|
65
|
-
|
|
67
|
+
### Source gem
|
|
68
|
+
|
|
69
|
+
The source gem can be forced by:
|
|
70
|
+
|
|
71
|
+
gem uninstall pg --all
|
|
72
|
+
gem install pg --platform ruby
|
|
66
73
|
|
|
67
74
|
You may need to specify the path to the 'pg_config' program installed with
|
|
68
75
|
Postgres:
|
|
@@ -73,6 +80,28 @@ If you're installing via Bundler, you can provide compile hints like so:
|
|
|
73
80
|
|
|
74
81
|
bundle config build.pg --with-pg-config=<path to pg_config>
|
|
75
82
|
|
|
83
|
+
### Bundler
|
|
84
|
+
|
|
85
|
+
To make sure, the necessary platforms and the source gem are fetched by bundler, they can be added like so
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
bundle lock --add-platform x86_64-linux
|
|
89
|
+
bundle lock --add-platform arm64-darwin
|
|
90
|
+
bundle lock --add-platform x64-mingw-ucrt
|
|
91
|
+
bundle lock --add-platform ruby
|
|
92
|
+
bundle package --all-platforms
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
A re-run of `bundle package` is also necessary after `bundle update`, in order to retrieve the new specific gems of all platforms.
|
|
96
|
+
|
|
97
|
+
If the binary gems don't work for some reason, it's easy to force the usage of the source gem in the Gemfile:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
gem "pg", force_ruby_platform: true
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### More
|
|
104
|
+
|
|
76
105
|
See README-OS_X.rdoc for more information about installing under MacOS X, and
|
|
77
106
|
README-Windows.rdoc for Windows build/installation instructions.
|
|
78
107
|
|
|
@@ -85,6 +114,19 @@ can be found in [the `certs` directory](https://github.com/ged/ruby-pg/tree/mast
|
|
|
85
114
|
of the repository.
|
|
86
115
|
|
|
87
116
|
|
|
117
|
+
## Versioning
|
|
118
|
+
|
|
119
|
+
We tag and release gems according to the [Semantic Versioning](http://semver.org/) principle.
|
|
120
|
+
|
|
121
|
+
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.
|
|
122
|
+
|
|
123
|
+
For example:
|
|
124
|
+
|
|
125
|
+
```ruby
|
|
126
|
+
spec.add_dependency 'pg', '~> 1.0'
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
|
|
88
130
|
## Type Casts
|
|
89
131
|
|
|
90
132
|
Pg can optionally type cast result values and query parameters in Ruby or
|
|
@@ -108,7 +150,7 @@ Very basic type casting can be enabled by:
|
|
|
108
150
|
But Pg's type casting is highly customizable. That's why it's divided into
|
|
109
151
|
2 layers:
|
|
110
152
|
|
|
111
|
-
### Encoders / Decoders (ext/pg_
|
|
153
|
+
### Encoders / Decoders (ext/pg_\*coder.c, lib/pg/\*coder.rb)
|
|
112
154
|
|
|
113
155
|
This is the lower layer, containing encoding classes that convert Ruby
|
|
114
156
|
objects for transmission to the DBMS and decoding classes to convert
|
|
@@ -141,7 +183,7 @@ The following PostgreSQL column types are supported by ruby-pg (TE = Text Encode
|
|
|
141
183
|
* 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
184
|
* JSON and JSONB: [TE](rdoc-ref:PG::TextEncoder::JSON), [TD](rdoc-ref:PG::TextDecoder::JSON)
|
|
143
185
|
* 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)
|
|
186
|
+
* 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
187
|
* Composite Type (also called "Row" or "Record"): [TE](rdoc-ref:PG::TextEncoder::Record), [TD](rdoc-ref:PG::TextDecoder::Record)
|
|
146
188
|
|
|
147
189
|
The following text and binary formats can also be encoded although they are not used as column type:
|
|
@@ -150,9 +192,9 @@ The following text and binary formats can also be encoded although they are not
|
|
|
150
192
|
* Literal for insertion into SQL string: [TE](rdoc-ref:PG::TextEncoder::QuotedLiteral)
|
|
151
193
|
* SQL-Identifier: [TE](rdoc-ref:PG::TextEncoder::Identifier), [TD](rdoc-ref:PG::TextDecoder::Identifier)
|
|
152
194
|
|
|
153
|
-
###
|
|
195
|
+
### TypeMap and derivations (ext/pg_type_map\*.c, lib/pg/type_map\*.rb)
|
|
154
196
|
|
|
155
|
-
A TypeMap defines which value will be converted by which encoder/decoder.
|
|
197
|
+
A PG::TypeMap defines which value will be converted by which encoder/decoder.
|
|
156
198
|
There are different type map strategies, implemented by several derivations
|
|
157
199
|
of this class. They can be chosen and configured according to the particular
|
|
158
200
|
needs for type casting. The default type map is PG::TypeMapAllStrings.
|
|
@@ -175,11 +217,12 @@ The following type maps are prefilled with type mappings from the PG::BasicTypeR
|
|
|
175
217
|
* PG::BasicTypeMapBasedOnResult - a PG::TypeMapByOid prefilled with encoders for common PostgreSQL column types
|
|
176
218
|
* PG::BasicTypeMapForQueries - a PG::TypeMapByClass prefilled with encoders for common Ruby value classes
|
|
177
219
|
|
|
220
|
+
Several type maps can be chained by setting PG::TypeMap::DefaultTypeMappable#default_type_map .
|
|
178
221
|
|
|
179
222
|
## Thread support
|
|
180
223
|
|
|
181
|
-
PG is thread safe in such a way that different threads can use different PG::Connection objects concurrently.
|
|
182
|
-
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.
|
|
183
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.
|
|
184
227
|
|
|
185
228
|
If messages like the following are printed to stderr, you're probably using one connection from several threads:
|
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
|
-
|
|
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,24 @@ 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
|
+
['x64-mingw32', 'mingw64', 'x86_64-w64-mingw32'],
|
|
51
|
+
['x86_64-linux', 'linux-x86_64', 'x86_64-linux-gnu'],
|
|
52
|
+
['x86_64-linux-musl', 'linux-x86_64', 'x86_64-unknown-linux-musl'],
|
|
53
|
+
['aarch64-linux', 'linux-aarch64', 'aarch64-linux-gnu'],
|
|
54
|
+
['aarch64-linux-musl', 'linux-aarch64', 'aarch64-linux-musl'],
|
|
55
|
+
['x86_64-darwin', 'darwin64-x86_64', 'x86_64-apple-darwin'],
|
|
56
|
+
['arm64-darwin', 'darwin64-arm64', 'arm64-apple-darwin'],
|
|
57
|
+
].map do |platform, openssl_config, toolchain|
|
|
58
|
+
CrossLibrary.new platform, openssl_config, toolchain
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Register binary gems to be pushed to rubygems.org
|
|
62
|
+
Bundler::GemHelper.instance.cross_platforms = CrossLibraries.map(&:platform)
|
|
63
|
+
|
|
45
64
|
# Rake-compiler task
|
|
46
65
|
Rake::ExtensionTask.new do |ext|
|
|
47
66
|
ext.name = 'pg_ext'
|
|
@@ -50,24 +69,68 @@ Rake::ExtensionTask.new do |ext|
|
|
|
50
69
|
ext.lib_dir = 'lib'
|
|
51
70
|
ext.source_pattern = "*.{c,h}"
|
|
52
71
|
ext.cross_compile = true
|
|
53
|
-
ext.cross_platform = CrossLibraries.map(&:for_platform)
|
|
54
72
|
|
|
55
|
-
|
|
73
|
+
# Activate current cross compiled platform only.
|
|
74
|
+
# This is to work around the issue that `linux` platform is selected in `linux-musl` image.
|
|
75
|
+
ext.cross_platform = CrossLibraries.map(&:platform).select do |pl|
|
|
76
|
+
m = ENV["RCD_IMAGE"]&.match(/:(?<ruby_ver>[\w\.]+)-mri-(?<platform>[-\w]+)$/)
|
|
77
|
+
m && m[:platform] == pl
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
ext.cross_config_options += CrossLibraries.map do |xlib|
|
|
56
81
|
{
|
|
57
|
-
|
|
58
|
-
"--
|
|
59
|
-
"--with-
|
|
60
|
-
"--with-
|
|
61
|
-
# libpq-fe.h resides in src/interfaces/libpq/ before make install
|
|
62
|
-
"--with-opt-include=#{lib.static_postgresql_libdir}",
|
|
82
|
+
xlib.platform => [
|
|
83
|
+
"--with-cross-build=#{xlib.platform}",
|
|
84
|
+
"--with-openssl-platform=#{xlib.openssl_config}",
|
|
85
|
+
"--with-toolchain=#{xlib.toolchain}",
|
|
63
86
|
]
|
|
64
87
|
}
|
|
65
88
|
end
|
|
66
89
|
|
|
67
|
-
# Add libpq.dll to
|
|
90
|
+
# Add libpq.dll/.so to fat binary gemspecs
|
|
68
91
|
ext.cross_compiling do |spec|
|
|
69
|
-
spec.files << "
|
|
92
|
+
spec.files << "ports/#{spec.platform.to_s}/lib/libpq-ruby-pg.so.1" if spec.platform.to_s =~ /linux/
|
|
93
|
+
spec.files << "ports/#{spec.platform.to_s}/lib/libpq-ruby-pg.1.dylib" if spec.platform.to_s =~ /darwin/
|
|
94
|
+
spec.files << "ports/#{spec.platform.to_s}/lib/libpq.dll" if spec.platform.to_s =~ /mingw|mswin/
|
|
95
|
+
|
|
96
|
+
# Binary gems don't need postgresql header+lib files
|
|
97
|
+
spec.metadata.delete("msys2_mingw_dependencies")
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
task 'gem:native:prepare' do
|
|
102
|
+
require 'io/console'
|
|
103
|
+
require 'rake_compiler_dock'
|
|
104
|
+
|
|
105
|
+
# Copy gem signing key and certs to be accessible from the docker container
|
|
106
|
+
mkdir_p 'build/gem'
|
|
107
|
+
sh "cp ~/.gem/gem-*.pem build/gem/ || true"
|
|
108
|
+
sh "bundle config set cache_all false"
|
|
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
|
+
CrossLibraries.each do |xlib|
|
|
119
|
+
platform = xlib.platform
|
|
120
|
+
desc "Build fat binary gem for platform #{platform}"
|
|
121
|
+
task "gem:native:#{platform}" => ['gem:native:prepare'] do
|
|
122
|
+
RakeCompilerDock.sh <<-EOT, platform: platform
|
|
123
|
+
#{ "sudo apt-get update && sudo apt-get install -y bison flex &&" if platform =~ /darwin/ }
|
|
124
|
+
#{ # remove nm on Linux to suppress PostgreSQL's check for exit which raises thread_exit as a false positive:
|
|
125
|
+
"sudo mv `which nm` `which nm`.bak &&" if platform =~ /linux/ }
|
|
126
|
+
sudo apt-get update && sudo apt-get install -y bison flex &&
|
|
127
|
+
(cp build/gem/gem-*.pem ~/.gem/ || true) &&
|
|
128
|
+
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.0")}
|
|
130
|
+
EOT
|
|
70
131
|
end
|
|
132
|
+
desc "Build the native binary gems"
|
|
133
|
+
multitask 'gem:native' => "gem:native:#{platform}"
|
|
71
134
|
end
|
|
72
135
|
|
|
73
136
|
RSpec::Core::RakeTask.new(:spec).rspec_opts = "--profile -cfdoc"
|
|
@@ -94,7 +157,8 @@ end
|
|
|
94
157
|
|
|
95
158
|
desc "Update list of server error codes"
|
|
96
159
|
task :update_error_codes do
|
|
97
|
-
URL_ERRORCODES_TXT = "
|
|
160
|
+
# 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"
|
|
161
|
+
URL_ERRORCODES_TXT = "https://raw.githubusercontent.com/postgres/postgres/refs/tags/REL_18_0/src/backend/utils/errcodes.txt"
|
|
98
162
|
|
|
99
163
|
ERRORCODES_TXT = "ext/errorcodes.txt"
|
|
100
164
|
sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
|
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
|
|