pgsql 1.9 → 1.9.2
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.c +3 -3
- data/lib/conn_exec.c +50 -16
- data/lib/conn_quote.c +4 -13
- data/lib/module.c +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09bfda9c735da18dfbd986a66e29ad0fb7d7a89257e47fe2696094e6deb6d012'
|
4
|
+
data.tar.gz: ffb57400fdf3a67e777a76f8070d85c785bd3a588679da9316e620c96460ff84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eda3796cb0d7604b3e2119d08f6cea4cee5d1a1455ceee2fa018fbbc5a9426f88d97ffd1714e9d01879fd6b5fadbafe2eb23b4b60b959f85d7a85c73aa9311e1
|
7
|
+
data.tar.gz: b9cd0c5e075530a708bca6956977dfd7482b3e478186fb1bc169633ce1d4fcbf8f02f88668a3dcca3552103c545f0c1a19d6d89190cfd5441ed7a7d4cbce51aa
|
data/lib/conn.c
CHANGED
@@ -166,7 +166,7 @@ pgconn_mkstring( struct pgconn_data *ptr, const char *str)
|
|
166
166
|
VALUE r;
|
167
167
|
|
168
168
|
if (str) {
|
169
|
-
r =
|
169
|
+
r = rb_str_new2( str);
|
170
170
|
pgconn_encode_out4in( ptr, r);
|
171
171
|
} else
|
172
172
|
r = Qnil;
|
@@ -179,7 +179,7 @@ pgconn_mkstringn( struct pgconn_data *ptr, const char *str, int len)
|
|
179
179
|
VALUE r;
|
180
180
|
|
181
181
|
if (str) {
|
182
|
-
r =
|
182
|
+
r = rb_str_new( str, len);
|
183
183
|
pgconn_encode_out4in( ptr, r);
|
184
184
|
} else
|
185
185
|
r = Qnil;
|
@@ -438,7 +438,7 @@ pgconn_client_encoding( VALUE self)
|
|
438
438
|
{
|
439
439
|
char *encoding = (char *) pg_encoding_to_char(
|
440
440
|
PQclientEncoding( get_pgconn( self)->conn));
|
441
|
-
return
|
441
|
+
return rb_str_new2( encoding);
|
442
442
|
}
|
443
443
|
|
444
444
|
/*
|
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
@@ -159,7 +159,6 @@ pgconn_escape_bytea( VALUE self, VALUE str)
|
|
159
159
|
(unsigned char *) RSTRING_PTR( str), RSTRING_LEN( str), &l);
|
160
160
|
ret = rb_str_new( (char *) s, l - 1);
|
161
161
|
PQfreemem( s);
|
162
|
-
OBJ_INFECT( ret, str);
|
163
162
|
return ret;
|
164
163
|
}
|
165
164
|
|
@@ -216,7 +215,6 @@ pgconn_unescape_bytea( VALUE self, VALUE obj)
|
|
216
215
|
rb_enc_associate( ret, rb_to_encoding( enc));
|
217
216
|
#endif
|
218
217
|
|
219
|
-
OBJ_INFECT( ret, obj);
|
220
218
|
return ret;
|
221
219
|
}
|
222
220
|
|
@@ -285,10 +283,9 @@ pgconn_stringize( VALUE self, VALUE obj)
|
|
285
283
|
VALUE co;
|
286
284
|
|
287
285
|
co = CLASS_OF( obj);
|
288
|
-
if (co == rb_cTime)
|
286
|
+
if (co == rb_cTime)
|
289
287
|
result = rb_funcall( obj, id_iso8601, 0);
|
290
|
-
|
291
|
-
} else if (co == rb_cDate)
|
288
|
+
else if (co == rb_cDate)
|
292
289
|
result = rb_obj_as_string( obj);
|
293
290
|
else if (co == rb_cDateTime)
|
294
291
|
result = rb_obj_as_string( obj);
|
@@ -298,7 +295,6 @@ pgconn_stringize( VALUE self, VALUE obj)
|
|
298
295
|
else if (rb_respond_to( obj, id_to_postgres)) {
|
299
296
|
result = rb_funcall( obj, id_to_postgres, 0);
|
300
297
|
StringValue( result);
|
301
|
-
OBJ_INFECT( result, obj);
|
302
298
|
} else
|
303
299
|
result = rb_obj_as_string( obj);
|
304
300
|
}
|
@@ -355,7 +351,7 @@ pgconn_for_copy( VALUE self, VALUE obj)
|
|
355
351
|
rb_global_variable( &pg_escape_regex);
|
356
352
|
}
|
357
353
|
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);
|
354
|
+
ret = rb_block_call( ret, id_gsub, 1, &pg_escape_regex, &gsub_escape_i, Qnil);
|
359
355
|
}
|
360
356
|
return ret;
|
361
357
|
}
|
@@ -428,10 +424,8 @@ stringize_array( VALUE self, VALUE result, VALUE ary)
|
|
428
424
|
rb_str_buf_cat2( result, ",");
|
429
425
|
}
|
430
426
|
r = pgconn_stringize( self, *o);
|
431
|
-
if (!NIL_P( *o))
|
427
|
+
if (!NIL_P( *o))
|
432
428
|
r = dquote_string( r);
|
433
|
-
OBJ_INFECT( result, *o);
|
434
|
-
}
|
435
429
|
rb_str_buf_append( result, r);
|
436
430
|
}
|
437
431
|
return result;
|
@@ -542,7 +536,6 @@ VALUE pgconn_quote( VALUE self, VALUE obj)
|
|
542
536
|
rb_str_buf_cat2( res, "::");
|
543
537
|
rb_str_buf_cat2( res, type);
|
544
538
|
}
|
545
|
-
OBJ_INFECT( res, obj);
|
546
539
|
}
|
547
540
|
break;
|
548
541
|
}
|
@@ -578,7 +571,6 @@ quote_string( VALUE conn, VALUE str)
|
|
578
571
|
res = rb_str_new2( p);
|
579
572
|
PQfreemem( p);
|
580
573
|
rb_enc_associate( res, rb_enc_get( str));
|
581
|
-
OBJ_INFECT( res, str);
|
582
574
|
return res;
|
583
575
|
}
|
584
576
|
|
@@ -643,7 +635,6 @@ pgconn_quote_identifier( VALUE self, VALUE str)
|
|
643
635
|
res = rb_str_new2( p);
|
644
636
|
PQfreemem( p);
|
645
637
|
rb_enc_associate( res, rb_enc_get( str));
|
646
|
-
OBJ_INFECT( res, str);
|
647
638
|
return res;
|
648
639
|
}
|
649
640
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bertram Scharpf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: autorake
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version: '0'
|
74
74
|
requirements:
|
75
75
|
- PostgreSQL
|
76
|
-
rubygems_version: 3.
|
76
|
+
rubygems_version: 3.4.17
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: PostgreSQL-API for Ruby
|