pgsql 1.9 → 1.9.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2519cf85dd607a31191b7992cc99a93c31fb0b1103a38462f28cd77081599f0c
4
- data.tar.gz: 026e108f08ffa63454f29504120c04f8fe8b3b1ffb664bd4626e7ca9f98f078a
3
+ metadata.gz: d735e83feb39d55f95efc1a196d433800c523fd0e73538b2c6415edd098f405c
4
+ data.tar.gz: e8e6e0b0526a73de32bf227effe13337ef125ea9f69d05099401aae4455c4288
5
5
  SHA512:
6
- metadata.gz: 608f44789a6b5c009558c75b1d37f71fd2b86d283c2b78bf361d76bf3d7bb37065b6426a26f7ecb7d97829b3b31e4e7cf4a0f53453e11fc7327a914d2d65ca8c
7
- data.tar.gz: 5e4e1fe2084fb5ba67646128d145de12840ad66c3fd54e0b22e65ea150c0d16444fc157ff19f61864fe048dd1eca4b3d7731ca8411376708ac81a2c7114b9774
6
+ metadata.gz: bbccf68542f27fc341ed1b517109655d5dd96b9d8cb21ac94e9d874f54d40eec9b3f50652967bb592cf04da68804c1351e01598ab8e4f3487ecc50b706dee65a
7
+ data.tar.gz: 388001a630086ddb47acb19672291ebe1cbd95f0349038e97189ff676e246047c4ce055bc726d065a9aea399cfdf1ff8d1e62d293178ebc6b8c131b10e4b951a
data/lib/conn_exec.c CHANGED
@@ -20,11 +20,13 @@ static void free_strings( char **strs, int len);
20
20
  static void pg_parse_parameters( int argc, VALUE *argv, VALUE *cmd, VALUE *par);
21
21
 
22
22
  static VALUE pgconn_exec( int argc, VALUE *argv, VALUE obj);
23
+ static VALUE yield_or_return_result( VALUE res);
23
24
  static VALUE pgconn_send( int argc, VALUE *argv, VALUE obj);
24
25
  static VALUE pgconn_fetch( int argc, VALUE *argv, VALUE conn);
25
26
  static void wait_for_pgsocket( PGconn *c, VALUE to);
26
- static VALUE yield_or_return_result( VALUE res);
27
27
  static VALUE clear_resultqueue( VALUE self);
28
+ static VALUE pgconn_fetch_rows( int argc, VALUE *argv, VALUE conn);
29
+ static VALUE fetch_result_each( RB_BLOCK_CALL_FUNC_ARGLIST( res, arg));
28
30
 
29
31
  static VALUE pgconn_query( int argc, VALUE *argv, VALUE self);
30
32
  static VALUE pgconn_select_row( int argc, VALUE *argv, VALUE self);
@@ -61,6 +63,7 @@ static VALUE rb_ePgConnTrans;
61
63
  static VALUE rb_ePgConnCopy;
62
64
 
63
65
  static ID id_to_a;
66
+ static ID id_fetch;
64
67
 
65
68
 
66
69
  void
@@ -190,6 +193,13 @@ pgconn_exec( int argc, VALUE *argv, VALUE self)
190
193
  return yield_or_return_result( res);
191
194
  }
192
195
 
196
+ VALUE
197
+ yield_or_return_result( VALUE result)
198
+ {
199
+ return rb_block_given_p() ?
200
+ rb_ensure( rb_yield, result, pgresult_clear, result) : result;
201
+ }
202
+
193
203
 
194
204
  /*
195
205
  * call-seq:
@@ -213,8 +223,7 @@ pgconn_exec( int argc, VALUE *argv, VALUE self)
213
223
  * end
214
224
  * end
215
225
  *
216
- * Multiple select statements will not be separated by an empty result
217
- * or something similar. Query twice if you want to separate them.
226
+ * Multiple select statements will be separated by an empty result.
218
227
  *
219
228
  * Pg::Conn.connect do |conn|
220
229
  * conn.send "SELECT 33; SELECT 'foo';" do
@@ -241,7 +250,6 @@ pgconn_send( int argc, VALUE *argv, VALUE self)
241
250
  * Fetches the results of the previous Pg::Conn#send call.
242
251
  * See there for an example.
243
252
  *
244
- * The result will be +nil+ if there are no more results.
245
253
  */
246
254
  VALUE
247
255
  pgconn_fetch( int argc, VALUE *argv, VALUE conn)
@@ -258,10 +266,10 @@ pgconn_fetch( int argc, VALUE *argv, VALUE conn)
258
266
  pg_raise_connexec( c);
259
267
  if (PQisBusy( c->conn) == 0)
260
268
  while ((result = PQgetResult( c->conn)) != NULL) {
261
- if (PQntuples( result) == 0)
262
- PQclear( result);
263
- else
264
- rb_yield( pgresult_new( result, c, Qnil, Qnil));
269
+ VALUE res;
270
+
271
+ res = pgresult_new( result, c, Qnil, Qnil);
272
+ rb_ensure( rb_yield, res, pgresult_clear, res);
265
273
  }
266
274
  return Qnil;
267
275
  }
@@ -310,13 +318,6 @@ wait_for_pgsocket( PGconn *c, VALUE to)
310
318
  rb_raise( rb_ePgConnTimeout, "Wait for data timed out.");
311
319
  }
312
320
 
313
- VALUE
314
- yield_or_return_result( VALUE result)
315
- {
316
- return rb_block_given_p() ?
317
- rb_ensure( rb_yield, result, pgresult_clear, result) : result;
318
- }
319
-
320
321
  VALUE
321
322
  clear_resultqueue( VALUE conn)
322
323
  {
@@ -347,6 +348,37 @@ clear_resultqueue( VALUE conn)
347
348
  }
348
349
 
349
350
 
351
+ /*
352
+ * call-seq:
353
+ * conn.fetch_rows( timeout = nil) { |row| ... } -> obj
354
+ *
355
+ * Fetches the results of the previous Pg::Conn#send call as an array.
356
+ *
357
+ * Multiple select statements will _not_ be separated by an empty array or
358
+ * something similar. Query twice or call +#fetch+ if you want to separate
359
+ * them.
360
+ *
361
+ * Pg::Conn.connect do |conn|
362
+ * conn.send "SELECT 33; SELECT 'foo';" do
363
+ * conn.fetch { |row|
364
+ * puts row.inspect
365
+ * }
366
+ * end
367
+ * end
368
+ */
369
+ VALUE
370
+ pgconn_fetch_rows( int argc, VALUE *argv, VALUE conn)
371
+ {
372
+ if (!id_fetch)
373
+ id_fetch = rb_intern( "fetch");
374
+ return rb_block_call( conn, id_fetch, argc, argv, fetch_result_each, Qnil);
375
+ }
376
+
377
+ VALUE
378
+ fetch_result_each( RB_BLOCK_CALL_FUNC_ARGLIST( res, arg))
379
+ {
380
+ return pgresult_each( res);
381
+ }
350
382
 
351
383
 
352
384
  /*
@@ -945,6 +977,7 @@ Init_pgsql_conn_exec( void)
945
977
  rb_define_method( rb_cPgConn, "exec", &pgconn_exec, -1);
946
978
  rb_define_method( rb_cPgConn, "send", &pgconn_send, -1);
947
979
  rb_define_method( rb_cPgConn, "fetch", &pgconn_fetch, -1);
980
+ rb_define_method( rb_cPgConn, "fetch_rows", &pgconn_fetch_rows, -1);
948
981
 
949
982
  rb_define_method( rb_cPgConn, "query", &pgconn_query, -1);
950
983
  rb_define_method( rb_cPgConn, "select_row", &pgconn_select_row, -1);
@@ -977,6 +1010,7 @@ Init_pgsql_conn_exec( void)
977
1010
 
978
1011
  rb_define_method( rb_cPgConn, "backup", &pgconn_backup, 1);
979
1012
 
980
- id_to_a = 0;
1013
+ id_to_a = 0;
1014
+ id_fetch = 0;
981
1015
  }
982
1016
 
data/lib/conn_quote.c CHANGED
@@ -355,7 +355,7 @@ pgconn_for_copy( VALUE self, VALUE obj)
355
355
  rb_global_variable( &pg_escape_regex);
356
356
  }
357
357
  if (RTEST( rb_reg_match( pg_escape_regex, ret)))
358
- ret = rb_block_call( ret, id_gsub, 1, &pg_escape_regex, gsub_escape_i, Qnil);
358
+ ret = rb_block_call( ret, id_gsub, 1, &pg_escape_regex, &gsub_escape_i, Qnil);
359
359
  }
360
360
  return ret;
361
361
  }
data/lib/module.c CHANGED
@@ -8,7 +8,7 @@
8
8
  #include "result.h"
9
9
 
10
10
 
11
- #define PGSQL_VERSION "1.9"
11
+ #define PGSQL_VERSION "1.9.1"
12
12
 
13
13
 
14
14
  VALUE rb_mPg;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgsql
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.9'
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-08 00:00:00.000000000 Z
11
+ date: 2021-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: autorake