pg 1.5.2 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79eb5b70c2045456b11a407f31913f728593cb196090f7bc1e94f012e1e37070
4
- data.tar.gz: d6b9f0685a71e45482cb9c776fc8e092e7aa810d6a74364eb809f217a8cd09f1
3
+ metadata.gz: e50a6829d4fe134af52d85429a3db06240fb6d228b96ef5b3fade98d38f4d199
4
+ data.tar.gz: 281f5700e856a64a4a7c3157bbef4398345ac16698dbcdce54ed0408c0448457
5
5
  SHA512:
6
- metadata.gz: 8125aac41396b831d5a1986a80ceee2376c79ebc9ce5607c5739f7285ee0e4069dbd636b98ba51722b251f210c6295199bcd8589af7b77a9816a4156d190fa22
7
- data.tar.gz: feed68644345ae49bd4d1f2ce62571ea25ef8c8e7d032552096575a832b67595a84b18de09c6bdb9d007d3a845837ee9a6e031b746aa212d342580ab89bd793b
6
+ metadata.gz: 4ca887b068f003b077c17fca5e8297368f5236ed74ae16888a64312fed269110c455e2cd58105b5a23fbb53a1841b081ae215d3a4c3473815914642fcdde75cc
7
+ data.tar.gz: 86599add8d622097727be30a1a05259c69d8c83fa73e1dad0f46125e95685a752a5df24f235158ff0d62dbfe99034aa8512e89bc39f26edf81a2540c466a6541
checksums.yaml.gz.sig CHANGED
Binary file
@@ -42,6 +42,10 @@ jobs:
42
42
  ruby: "2.5"
43
43
  PGVERSION: 9.4.26-1-windows-x64
44
44
  PGVER: "9.4"
45
+ - os: windows
46
+ ruby: "mswin"
47
+ PGVERSION: 15.1-1-windows-x64
48
+ PGVER: "15"
45
49
  - os: ubuntu
46
50
  ruby: "head"
47
51
  PGVER: "15"
@@ -82,7 +86,7 @@ jobs:
82
86
  name: source-gem
83
87
 
84
88
  - name: Install required packages Windows
85
- if: matrix.os == 'windows'
89
+ if: matrix.os == 'windows' && matrix.ruby != 'mswin'
86
90
  shell: cmd
87
91
  run: ridk exec sh -c "pacman --sync --needed --noconfirm ${MINGW_PACKAGE_PREFIX}-gcc"
88
92
 
data/History.md CHANGED
@@ -1,3 +1,22 @@
1
+ ## v1.5.4 [2023-09-01] Lars Kanis <lars@greiz-reinsdorf.de>
2
+
3
+ - Fix compiling the pg extension with MSVC 2022. [#535](https://github.com/ged/ruby-pg/pull/535)
4
+ - Set PG::Connection's encoding even if setting client_encoding on connection startup fails. [#541](https://github.com/ged/ruby-pg/pull/541)
5
+ - Don't set the server's client_encoding if it's unnecessary. [#542](https://github.com/ged/ruby-pg/pull/542)
6
+ This is important for connection proxies, who disallow configuration settings.
7
+
8
+
9
+ ## v1.5.3 [2023-04-28] Lars Kanis <lars@greiz-reinsdorf.de>
10
+
11
+ - Fix possible segfault when creating a new PG::Result with type map. [#530](https://github.com/ged/ruby-pg/pull/530)
12
+ - Add category to deprecation warnings of Coder.new, so that they are suppressed for most users. [#528](https://github.com/ged/ruby-pg/pull/528)
13
+
14
+
15
+ ## v1.5.2 [2023-04-26] Lars Kanis <lars@greiz-reinsdorf.de>
16
+
17
+ - Fix regression in copy_data regarding binary format when using no coder. [#527](https://github.com/ged/ruby-pg/pull/527)
18
+
19
+
1
20
  ## v1.5.1 [2023-04-24] Lars Kanis <lars@greiz-reinsdorf.de>
2
21
 
3
22
  - Don't overwrite flags of timestamp coders. [#524](https://github.com/ged/ruby-pg/pull/524)
data/README.ja.md CHANGED
@@ -1,9 +1,8 @@
1
1
  # pg
2
2
 
3
- * home :: https://github.com/ged/ruby-pg
4
- * docs :: http://deveiate.org/code/pg (English) ,
5
- https://deveiate.org/code/pg/README_ja_md.html (Japanese)
6
- * clog :: link:/History.md
3
+ * ホーム :: https://github.com/ged/ruby-pg
4
+ * ドキュメント :: http://deveiate.org/code/pg (英語)、 https://deveiate.org/code/pg/README_ja_md.html (日本語)
5
+ * 変更履歴 :: link:/History.md
7
6
 
8
7
  [![https://gitter.im/ged/ruby-pg
9
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)
@@ -84,8 +83,9 @@ README-Windows.rdoc を参照してください。
84
83
 
85
84
  ## 型変換
86
85
 
87
- PgにはおまけとしてRubyとネイティブCコードにある結果の値やクエリ引数の型変換ができます。
88
- こうすることでデータベースとのデータの往来を加速させられますが、それは文字列のアロケーションが減り、(より遅い)Rubyのコードでの変換部分が除かれるからです。
86
+ Pgでは任意でRubyと素のCコードにある結果の値やクエリ引数の型変換ができます。
87
+ こうすることでデータベースとのデータの往来を加速させられます。
88
+ なぜなら文字列のアロケーションが減り、(比較的遅い)Rubyのコードでの変換部分が省かれるからです。
89
89
 
90
90
  とても基本的な型変換は次のようにできます。
91
91
  ```ruby
@@ -104,9 +104,13 @@ PgにはおまけとしてRubyとネイティブCコードにある結果の値
104
104
 
105
105
  ### エンコーダーとデコーダー (ext/pg_*coder.c, lib/pg/*coder.rb)
106
106
 
107
- こちらはより低層で、DBMSへ転送するためにRubyのオブジェクトを変換するエンコーディングクラスと取得してきたデータをRubyのオブジェクトに変換し戻すデコーディングクラスが含まれています。クラスはそれぞれの形式によって名前空間PG::TextEncoder、PG::TextDecoder、PG::BinaryEncoder、そしてPG::BinaryDecoderに分かれています。
107
+ こちらはより低層で、DBMSへ転送するためにRubyのオブジェクトを変換するエンコーディングクラスと、取得してきたデータをRubyのオブジェクトに変換し戻すデコーディングクラスが含まれています。
108
+ クラスはそれぞれの形式によって名前空間 PG::TextEncoder, PG::TextDecoder, PG::BinaryEncoder, そして
109
+ PG::BinaryDecoder に分かれています。
108
110
 
109
- エンコーダーないしデコーダーオブジェクトにOIDデータ型や形式コード(テキストないしバイナリ)や任意で名前を割り当てることができます。要素のエンコーダーないしデコーダーを割り当てることによって複合型を構築することもできます。PG::CoderオブジェクトはPG::TypeMapをセットアップしたりその代わりに単一の値と文字列表現とを相互に変換したりするのに使えます。
111
+ エンコーダーないしデコーダーオブジェクトにOIDデータ型や形式コード(テキストないしバイナリ)や任意で名前を割り当てることができます。
112
+ 要素のエンコーダーないしデコーダーを割り当てることによって複合型を構築することもできます。
113
+ PG::Coder オブジェクトは PG::TypeMap をセットアップしたり、その代わりに単一の値と文字列表現とを相互に変換したりするのに使えます。
110
114
 
111
115
  ruby-pgでは以下のPostgreSQLカラム型に対応しています(TE = Text Encoder、TD = Text Decoder、BE =
112
116
  Binary Encoder、BD = Binary Decoder)。
@@ -137,14 +141,11 @@ Binary Encoder、BD = Binary Decoder)。
137
141
  [現地時間](rdoc-ref:PG::TextEncoder::TimestampWithoutTimeZone)、[UTC](rdoc-ref:PG::TextEncoder::TimestampUtc)、[タイムゾーン付き](rdoc-ref:PG::TextEncoder::TimestampWithTimeZone)
138
142
  * TD:
139
143
  [現地時間](rdoc-ref:PG::TextDecoder::TimestampLocal)、[UTC](rdoc-ref:PG::TextDecoder::TimestampUtc)、[UTCから現地時間へ](rdoc-ref:PG::TextDecoder::TimestampUtcToLocal)
140
- * BE: [local](rdoc-ref:PG::BinaryEncoder::TimestampLocal),
141
- [UTC](rdoc-ref:PG::BinaryEncoder::TimestampUtc)
144
+ * BE:
145
+ [現地時間](rdoc-ref:PG::BinaryEncoder::TimestampLocal)、[UTC](rdoc-ref:PG::BinaryEncoder::TimestampUtc)
142
146
  * BD:
143
147
  [現地時間](rdoc-ref:PG::BinaryDecoder::TimestampLocal)、[UTC](rdoc-ref:PG::BinaryDecoder::TimestampUtc)、[UTCから現地時間へ](rdoc-ref:PG::BinaryDecoder::TimestampUtcToLocal)
144
- * Date: [TE](rdoc-ref:PG::TextEncoder::Date),
145
- [TD](rdoc-ref:PG::TextDecoder::Date),
146
- [BE](rdoc-ref:PG::BinaryEncoder::Date),
147
- [BD](rdoc-ref:PG::BinaryDecoder::Date)
148
+ * 日付:[TE](rdoc-ref:PG::TextEncoder::Date)、[TD](rdoc-ref:PG::TextDecoder::Date)、[BE](rdoc-ref:PG::BinaryEncoder::Date)、[BD](rdoc-ref:PG::BinaryDecoder::Date)
148
149
  * JSONとJSONB:
149
150
  [TE](rdoc-ref:PG::TextEncoder::JSON)、[TD](rdoc-ref:PG::TextDecoder::JSON)
150
151
  * Inet:
@@ -153,8 +154,7 @@ Binary Encoder、BD = Binary Decoder)。
153
154
  [TE](rdoc-ref:PG::TextEncoder::Array)、[TD](rdoc-ref:PG::TextDecoder::Array)
154
155
  * 複合型(「行」や「レコード」などとも言います):[TE](rdoc-ref:PG::TextEncoder::Record)、[TD](rdoc-ref:PG::TextDecoder::Record)
155
156
 
156
- The following text and binary formats can also be encoded although they are
157
- not used as column type:
157
+ カラム型として使われていませんが、以下のテキスト形式とバイナリ形式もエンコードできます。
158
158
 
159
159
  * COPYの入出力データ:[TE](rdoc-ref:PG::TextEncoder::CopyRow)、[TD](rdoc-ref:PG::TextDecoder::CopyRow),
160
160
  [BE](rdoc-ref:PG::BinaryEncoder::CopyRow),
@@ -163,11 +163,16 @@ not used as column type:
163
163
  * SQLの識別子:
164
164
  [TE](rdoc-ref:PG::TextEncoder::Identifier)、[TD](rdoc-ref:PG::TextDecoder::Identifier)
165
165
 
166
- ### PG::TypeMapとその派生 (ext/pg_type_map*.c, lib/pg/type_map*.rb)
166
+ ### PG::TypeMap とその派生 (ext/pg_type_map*.c, lib/pg/type_map*.rb)
167
167
 
168
- TypeMapはエンコーダーまたはデコーダーのどちらによってどの値を変換するかを定義します。様々な型の対応付け戦略があるので、このクラスにはいくつかの派生が実装されています。型変換の特有の需要に合わせてそれらの派生から選んで調整を加えることができます。既定の型の対応付けはPG::TypeMapAllStringsです。
168
+ TypeMapはエンコーダーまたはデコーダーのどちらによってどの値を変換するかを定義します。
169
+ 様々な型の対応付け戦略があるので、このクラスにはいくつかの派生が実装されています。
170
+ 型変換の特有の需要に合わせてそれらの派生から選んで調整を加えることができます。
171
+ 既定の型の対応付けは PG::TypeMapAllStrings です。
169
172
 
170
- 型の対応付けは、結果の集合それぞれに対し、接続毎ないしクエリ毎に割り当てることができます。型の対応付けはCOPYの入出力データストリーミングでも使うことができます。PG::Connection#copy_dataを参照してください。
173
+ 型の対応付けは、結果の集合それぞれに対し、接続毎ないしクエリ毎に割り当てることができます。
174
+ 型の対応付けはCOPYの入出力データストリーミングでも使うことができます。
175
+ PG::Connection#copy_data を参照してください。
171
176
 
172
177
  以下の基底となる型の対応付けが使えます。
173
178
 
@@ -177,19 +182,21 @@ TypeMapはエンコーダーまたはデコーダーのどちらによってど
177
182
  * PG::TypeMapByOid - PostgreSQLのOIDデータ型によってデコーダーを選択します
178
183
  * PG::TypeMapInRuby - Rubyで独自の型の対応付けを定義します
179
184
 
180
- 以下の型の対応付けはPG::BasicTypeRegistry由来の型の対応付けが入った状態になっています。
185
+ 以下の型の対応付けは PG::BasicTypeRegistry 由来の型の対応付けが入った状態になっています。
181
186
 
182
- * PG::BasicTypeMapForResults -
183
- PG::TypeMapByOidによくあるPostgreSQLカラム型用にデコーダーが入った状態になっています
184
- * PG::BasicTypeMapBasedOnResult -
185
- PG::TypeMapByOidによくあるPostgreSQLカラム型用のエンコーダーが入った状態になっています
186
- * PG::BasicTypeMapForQueries -
187
- PG::TypeMapByClassによくあるRubyの値クラス用にエンコーダーが入った状態になっています
187
+ * PG::BasicTypeMapForResults - PG::TypeMapByOid
188
+ によくあるPostgreSQLカラム型用にデコーダーが入った状態になっています
189
+ * PG::BasicTypeMapBasedOnResult - PG::TypeMapByOid
190
+ によくあるPostgreSQLカラム型用のエンコーダーが入った状態になっています
191
+ * PG::BasicTypeMapForQueries - PG::TypeMapByClass
192
+ によくあるRubyの値クラス用にエンコーダーが入った状態になっています
188
193
 
189
194
 
190
195
  ## スレッド対応
191
196
 
192
- PGには個々のスレッドが別々のPG::Connectionオブジェクトを同時に使えるという点でスレッド安全性があります。しかし1つ以上のスレッドから同時にPgのオブジェクトにアクセスすると安全ではありません。そのため必ず、毎回新しいスレッドを作るときに新しいデータベースサーバー接続を開くか、スレッド安全性のある方法で接続を管理するActiveRecordのようなラッパーライブラリを使うようにしてください。
197
+ PGには個々のスレッドが別々の PG::Connection オブジェクトを同時に使えるという点でスレッド安全性があります。
198
+ しかし1つ以上のスレッドから同時にPgのオブジェクトにアクセスすると安全ではありません。
199
+ そのため必ず、毎回新しいスレッドを作るときに新しいデータベースサーバー接続を開くか、スレッド安全性のある方法で接続を管理するActiveRecordのようなラッパーライブラリを使うようにしてください。
193
200
 
194
201
  以下のようなメッセージが標準エラー出力に表示された場合、恐らく複数のスレッドが1つの接続を使っています。
195
202
 
@@ -202,13 +209,30 @@ PGには個々のスレッドが別々のPG::Connectionオブジェクトを同
202
209
 
203
210
  ## Fiber IOスケジューラー対応
204
211
 
205
- PgはRuby-3.0で導入された`Fiber.scheduler`に完全に対応しています。`Fiber.scheduler`のWindows対応についてはRuby-3.1以降で使えます。`Fiber.scheduler`が走らせているスレッドに登録されている場合、起こりうる全てのブロッキングIO操作はそのスケジューラーを経由します。同期的であったりブロックしたりするメソッド呼び出しについてもpgが内部的に非同期のlibpqインターフェースを使っているのはそれが理由です。またlibpqの組み込み関数に代えてRubyのDNS解決を使っています。
212
+ pg-1.3.0以降で、PgはRuby-3.0で導入された`Fiber.scheduler`に完全に対応しています。
213
+ Windowsでは、`Fiber.scheduler`対応はRuby-3.1以降で使えます。
214
+ `Fiber.scheduler`が走らせているスレッドに登録されている場合、起こりうる全てのブロッキングIO操作はそのスケジューラーを経由します。
215
+ 同期的であったりブロックしたりするメソッド呼び出しについてもpgが内部的に非同期のlibpqインターフェースを使っているのはそれが理由です。
216
+ またlibpqの組み込み関数に代えてRubyのDNS解決を使っています。
206
217
 
207
- 内部的にPgは常にlibpqのノンブロッキング接続モードを使います。それからブロッキングモードで走っているように振舞いますが、もし`Fiber.scheduler`が登録されていれば全てのブロッキングIOはそのスケジューラーを通じてRubyで制御されます。`PG::Connection.setnonblocking(true)`が呼ばれたらノンブロッキング状態が有効になったままになりますが、それ以降のブロッキング状態の制御が無効になるので、呼び出しているプログラムはブロッキング状態を自力で制御しなければなりません。
218
+ 内部的にPgは常にlibpqのノンブロッキング接続モードを使います。
219
+ それからブロッキングモードで走っているように振舞いますが、もし`Fiber.scheduler`が登録されていれば全てのブロッキングIOはそのスケジューラーを通じてRubyで制御されます。
220
+ `PG::Connection.setnonblocking(true)`が呼ばれたらノンブロッキング状態が有効になったままになりますが、それ以降のブロッキング状態の制御が無効になるので、呼び出しているプログラムはブロッキング状態を自力で制御しなければなりません。
208
221
 
209
222
  この規則の1つの例外には、`PG::Connection#lo_create`や外部ライブラリを使う認証メソッド(GSSAPI認証など)のような、大きめのオブジェクト用のメソッドがあります。これらは`Fiber.scheduler`と互換性がないため、ブロッキング状態は登録されたIOスケジューラに渡されません。つまり操作は適切に実行されますが、IO待ち状態に別のIOを扱うFiberから使用を切り替えてくることができなくなります。
210
223
 
211
224
 
225
+ ## Ractor対応
226
+
227
+ pg-1.5.0以降で、PgはRuby-3.0で導入されたRactorと完全な互換性があります。
228
+ 型エンコーダーないしデコーダー、及び型の対応付けが`Ractor.make_shareable`により凍結されている場合、これらをractor間で共有できます。
229
+ また凍結された PG::Result と PG::Tuple オブジェクトも共有できます。
230
+ 少なくとも全ての凍結されたオブジェクト(ただし PG::Connection
231
+ を除く)はPostgreSQLサーバーとのやり取りをしたり取得されたデータを読むのに使えます。
232
+
233
+ PG::Connection は共有できません。個々の接続を確立するために、それぞれのRactor内で作られなければなりません。
234
+
235
+
212
236
  ## 貢献
213
237
 
214
238
  バグを報告したり機能を提案したりGitでソースをチェックアウトしたりするには[プロジェクトページをご確認ください](https://github.com/ged/ruby-pg)。
@@ -271,6 +295,6 @@ Portions copyright LAIKA, Inc.
271
295
 
272
296
  ## 謝辞
273
297
 
274
- 長年にわたって貢献してくださった方々についてはContributors.rdocを参照してください。
298
+ 長年にわたって貢献してくださった方々については Contributors.rdoc を参照してください。
275
299
 
276
300
  ruby-listとruby-devメーリングリストの方々に感謝します。またPostgreSQLを開発された方々へも謝意を表します。
data/ext/extconf.rb CHANGED
@@ -60,6 +60,10 @@ else
60
60
  if dlldir && RbConfig::CONFIG["RPATHFLAG"].to_s.empty?
61
61
  append_ldflags "-Wl,-rpath,#{dlldir.quote}"
62
62
  end
63
+
64
+ if /mswin/ =~ RUBY_PLATFORM
65
+ $libs = append_library($libs, 'ws2_32')
66
+ end
63
67
  end
64
68
 
65
69
  $stderr.puts "Using libpq from #{dlldir}"
data/ext/pg.c CHANGED
@@ -125,7 +125,7 @@ const char * const (pg_enc_pg2ruby_mapping[][2]) = {
125
125
  * - returns NULL if the client encoding is 'SQL_ASCII'.
126
126
  * - returns ASCII-8BIT if the client encoding is unknown.
127
127
  */
128
- rb_encoding *
128
+ static rb_encoding *
129
129
  pg_get_pg_encoding_as_rb_encoding( int enc_id )
130
130
  {
131
131
  const char *name = pg_encoding_to_char( enc_id );
data/ext/pg.h CHANGED
@@ -369,7 +369,6 @@ pgresult_get_this( VALUE self )
369
369
  }
370
370
 
371
371
 
372
- rb_encoding * pg_get_pg_encoding_as_rb_encoding _(( int ));
373
372
  rb_encoding * pg_get_pg_encname_as_rb_encoding _(( const char * ));
374
373
  const char * pg_get_rb_encoding_as_pg_encoding _(( rb_encoding * ));
375
374
  rb_encoding *pg_conn_enc_get _(( PGconn * ));
data/ext/pg_connection.c CHANGED
@@ -4171,16 +4171,23 @@ static VALUE
4171
4171
  pgconn_set_default_encoding( VALUE self )
4172
4172
  {
4173
4173
  PGconn *conn = pg_get_pgconn( self );
4174
- rb_encoding *enc;
4175
- const char *encname;
4174
+ rb_encoding *rb_enc;
4176
4175
 
4177
4176
  rb_check_frozen(self);
4178
- if (( enc = rb_default_internal_encoding() )) {
4179
- encname = pg_get_rb_encoding_as_pg_encoding( enc );
4180
- if ( pgconn_set_client_encoding_async(self, rb_str_new_cstr(encname)) != 0 )
4181
- rb_warning( "Failed to set the default_internal encoding to %s: '%s'",
4182
- encname, PQerrorMessage(conn) );
4183
- return rb_enc_from_encoding( enc );
4177
+ if (( rb_enc = rb_default_internal_encoding() )) {
4178
+ rb_encoding * conn_encoding = pg_conn_enc_get( conn );
4179
+
4180
+ /* Don't set the server encoding, if it's unnecessary.
4181
+ * This is important for connection proxies, who disallow configuration settings.
4182
+ */
4183
+ if ( conn_encoding != rb_enc ) {
4184
+ const char *encname = pg_get_rb_encoding_as_pg_encoding( rb_enc );
4185
+ if ( pgconn_set_client_encoding_async(self, rb_str_new_cstr(encname)) != 0 )
4186
+ rb_warning( "Failed to set the default_internal encoding to %s: '%s'",
4187
+ encname, PQerrorMessage(conn) );
4188
+ }
4189
+ pgconn_set_internal_encoding_index( self );
4190
+ return rb_enc_from_encoding( rb_enc );
4184
4191
  } else {
4185
4192
  pgconn_set_internal_encoding_index( self );
4186
4193
  return Qnil;
data/ext/pg_result.c CHANGED
@@ -208,12 +208,16 @@ pg_new_result2(PGresult *result, VALUE rb_pgconn)
208
208
 
209
209
  this = (t_pg_result *)xmalloc(sizeof(*this) + sizeof(*this->fnames) * nfields);
210
210
  this->pgresult = result;
211
+ /* Initialize connection and typemap prior to any object allocations,
212
+ * to make sure valid objects are marked. */
213
+ this->connection = rb_pgconn;
214
+ this->typemap = pg_typemap_all_strings;
215
+ this->p_typemap = RTYPEDDATA_DATA( this->typemap );
211
216
  this->nfields = -1;
212
217
  this->tuple_hash = Qnil;
213
218
  this->field_map = Qnil;
214
219
  this->flags = 0;
215
220
  self = TypedData_Wrap_Struct(rb_cPGresult, &pgresult_type, this);
216
- RB_OBJ_WRITE(self, &this->connection, rb_pgconn);
217
221
 
218
222
  if( result ){
219
223
  t_pg_connection *p_conn = pg_get_connection(rb_pgconn);
@@ -227,8 +231,6 @@ pg_new_result2(PGresult *result, VALUE rb_pgconn)
227
231
  this->p_typemap = RTYPEDDATA_DATA( this->typemap );
228
232
  this->flags = p_conn->flags;
229
233
  } else {
230
- RB_OBJ_WRITE(self, &this->typemap, pg_typemap_all_strings);
231
- this->p_typemap = RTYPEDDATA_DATA( this->typemap );
232
234
  this->enc_idx = rb_locale_encindex();
233
235
  }
234
236
 
@@ -390,7 +392,7 @@ pg_result_clear(VALUE self)
390
392
  * It also denies setting a type_map or field_name_type.
391
393
  *
392
394
  */
393
- VALUE
395
+ static VALUE
394
396
  pg_result_freeze(VALUE self)
395
397
  {
396
398
  t_pg_result *this = pgresult_get_this(self);
@@ -405,7 +407,7 @@ pg_result_freeze(VALUE self)
405
407
  *
406
408
  * Returns +true+ if the backend result memory has been freed.
407
409
  */
408
- VALUE
410
+ static VALUE
409
411
  pgresult_cleared_p( VALUE self )
410
412
  {
411
413
  t_pg_result *this = pgresult_get_this(self);
@@ -422,7 +424,7 @@ pgresult_cleared_p( VALUE self )
422
424
  * All other Result objects are automatically cleared by the GC when the object is no longer in use or manually by PG::Result#clear .
423
425
  *
424
426
  */
425
- VALUE
427
+ static VALUE
426
428
  pgresult_autoclear_p( VALUE self )
427
429
  {
428
430
  t_pg_result *this = pgresult_get_this(self);
@@ -1422,8 +1424,9 @@ pgresult_type_map_set(VALUE self, VALUE typemap)
1422
1424
  /* Check type of method param */
1423
1425
  TypedData_Get_Struct(typemap, t_typemap, &pg_typemap_type, p_typemap);
1424
1426
 
1425
- RB_OBJ_WRITE(self, &this->typemap, p_typemap->funcs.fit_to_result( typemap, self ));
1426
- this->p_typemap = RTYPEDDATA_DATA( this->typemap );
1427
+ typemap = p_typemap->funcs.fit_to_result( typemap, self );
1428
+ RB_OBJ_WRITE(self, &this->typemap, typemap);
1429
+ this->p_typemap = RTYPEDDATA_DATA( typemap );
1427
1430
 
1428
1431
  return typemap;
1429
1432
  }
@@ -287,9 +287,7 @@ pg_tmbc_init(VALUE self, VALUE conv_ary)
287
287
  t_pg_coder *p_coder;
288
288
  /* Check argument type and store the coder pointer */
289
289
  TypedData_Get_Struct(obj, t_pg_coder, &pg_coder_type, p_coder);
290
- if( p_coder ){
291
- RB_OBJ_WRITTEN(self, Qnil, p_coder->coder_obj);
292
- }
290
+ RB_OBJ_WRITTEN(self, Qnil, p_coder->coder_obj);
293
291
  this->convs[i].cconv = p_coder;
294
292
  }
295
293
  }
@@ -6,19 +6,19 @@ module PG
6
6
  # Convenience classes for timezone options
7
7
  class TimestampUtc < Timestamp
8
8
  def initialize(hash={}, **kwargs)
9
- warn "PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}" unless hash.empty?
9
+ warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) unless hash.empty?
10
10
  super(**hash, **kwargs, flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_UTC)
11
11
  end
12
12
  end
13
13
  class TimestampUtcToLocal < Timestamp
14
14
  def initialize(hash={}, **kwargs)
15
- warn "PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}" unless hash.empty?
15
+ warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) unless hash.empty?
16
16
  super(**hash, **kwargs, flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_LOCAL)
17
17
  end
18
18
  end
19
19
  class TimestampLocal < Timestamp
20
20
  def initialize(hash={}, **kwargs)
21
- warn "PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}" unless hash.empty?
21
+ warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) unless hash.empty?
22
22
  super(**hash, **kwargs, flags: PG::Coder::TIMESTAMP_DB_LOCAL | PG::Coder::TIMESTAMP_APP_LOCAL)
23
23
  end
24
24
  end
@@ -6,13 +6,13 @@ module PG
6
6
  # Convenience classes for timezone options
7
7
  class TimestampUtc < Timestamp
8
8
  def initialize(hash={}, **kwargs)
9
- warn "PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}" unless hash.empty?
9
+ warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) unless hash.empty?
10
10
  super(**hash, **kwargs, flags: PG::Coder::TIMESTAMP_DB_UTC)
11
11
  end
12
12
  end
13
13
  class TimestampLocal < Timestamp
14
14
  def initialize(hash={}, **kwargs)
15
- warn "PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}" unless hash.empty?
15
+ warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) unless hash.empty?
16
16
  super(**hash, **kwargs, flags: PG::Coder::TIMESTAMP_DB_LOCAL)
17
17
  end
18
18
  end
data/lib/pg/coder.rb CHANGED
@@ -7,7 +7,7 @@ module PG
7
7
 
8
8
  module BinaryFormatting
9
9
  def initialize(hash={}, **kwargs)
10
- warn "PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}" unless hash.empty?
10
+ warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) unless hash.empty?
11
11
  super(format: 1, **hash, **kwargs)
12
12
  end
13
13
  end
@@ -15,7 +15,7 @@ module PG
15
15
 
16
16
  # Create a new coder object based on the attribute Hash.
17
17
  def initialize(hash=nil, **kwargs)
18
- warn "PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}" if hash
18
+ warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) if hash
19
19
 
20
20
  (hash || kwargs).each do |key, val|
21
21
  send("#{key}=", val)
@@ -6,19 +6,19 @@ module PG
6
6
  # Convenience classes for timezone options
7
7
  class TimestampUtc < Timestamp
8
8
  def initialize(hash={}, **kwargs)
9
- warn "PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}" unless hash.empty?
9
+ warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) unless hash.empty?
10
10
  super(**hash, **kwargs, flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_UTC)
11
11
  end
12
12
  end
13
13
  class TimestampUtcToLocal < Timestamp
14
14
  def initialize(hash={}, **kwargs)
15
- warn "PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}" unless hash.empty?
15
+ warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) unless hash.empty?
16
16
  super(**hash, **kwargs, flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_LOCAL)
17
17
  end
18
18
  end
19
19
  class TimestampLocal < Timestamp
20
20
  def initialize(hash={}, **kwargs)
21
- warn "PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}" unless hash.empty?
21
+ warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) unless hash.empty?
22
22
  super(**hash, **kwargs, flags: PG::Coder::TIMESTAMP_DB_LOCAL | PG::Coder::TIMESTAMP_APP_LOCAL)
23
23
  end
24
24
  end
data/lib/pg/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module PG
2
2
  # Library version
3
- VERSION = '1.5.2'
3
+ VERSION = '1.5.4'
4
4
  end
data/lib/pg.rb CHANGED
@@ -115,4 +115,15 @@ module PG
115
115
  require 'pg/tuple'
116
116
  autoload :VERSION, 'pg/version'
117
117
 
118
+
119
+ # Avoid "uninitialized constant Truffle::WarningOperations" on Truffleruby up to 22.3.1
120
+ if RUBY_ENGINE=="truffleruby" && !defined?(Truffle::WarningOperations)
121
+ module TruffleFixWarn
122
+ def warn(str, category=nil)
123
+ super(str)
124
+ end
125
+ end
126
+ Warning.extend(TruffleFixWarn)
127
+ end
128
+
118
129
  end # module PG
@@ -1,4 +1,4 @@
1
- po4a version 0.69.
1
+ po4a version 0.68.
2
2
  Written by Martin Quinson and Denis Barbier.
3
3
 
4
4
  Copyright © 2002-2022 Software in the Public Interest, Inc.