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 +4 -4
- data/lib/conn_exec.c +50 -16
- data/lib/conn_quote.c +1 -1
- data/lib/module.c +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d735e83feb39d55f95efc1a196d433800c523fd0e73538b2c6415edd098f405c
|
4
|
+
data.tar.gz: e8e6e0b0526a73de32bf227effe13337ef125ea9f69d05099401aae4455c4288
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
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
|
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
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:
|
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-
|
11
|
+
date: 2021-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: autorake
|