pgsql 1.8 → 1.9

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: b9774f4721fba4301276843fea1a5287083234d0aadf8947559b08e2619a97e7
4
- data.tar.gz: b6df52ab912e62f814770c339cce1de5444f41c249869a6edf3e069dd6be7132
3
+ metadata.gz: 2519cf85dd607a31191b7992cc99a93c31fb0b1103a38462f28cd77081599f0c
4
+ data.tar.gz: 026e108f08ffa63454f29504120c04f8fe8b3b1ffb664bd4626e7ca9f98f078a
5
5
  SHA512:
6
- metadata.gz: 908112734acf984c86746934cea2471a702e0eeb7b93a5bf39b4abbd640eae9cb962788da168396919994429fce7d6cbfe04c3b6834e8bb5bd5a845d2a248ace
7
- data.tar.gz: c4ac1fe22fca378f9e321f6fbc33bbd3371d0e7e831321c9ad496ce673d7a7d120a8527c31f07696a66ffa0d7c35ec760540e6954ed8c013db233056d60d3197
6
+ metadata.gz: 608f44789a6b5c009558c75b1d37f71fd2b86d283c2b78bf361d76bf3d7bb37065b6426a26f7ecb7d97829b3b31e4e7cf4a0f53453e11fc7327a914d2d65ca8c
7
+ data.tar.gz: 5e4e1fe2084fb5ba67646128d145de12840ad66c3fd54e0b22e65ea150c0d16444fc157ff19f61864fe048dd1eca4b3d7731ca8411376708ac81a2c7114b9774
data/lib/conn_exec.c CHANGED
@@ -8,6 +8,8 @@
8
8
  #include "conn_quote.h"
9
9
  #include "result.h"
10
10
 
11
+ #include <math.h>
12
+
11
13
 
12
14
  static void pg_raise_connexec( struct pgconn_data *c);
13
15
 
@@ -19,7 +21,8 @@ static void pg_parse_parameters( int argc, VALUE *argv, VALUE *cmd, VALUE *par);
19
21
 
20
22
  static VALUE pgconn_exec( int argc, VALUE *argv, VALUE obj);
21
23
  static VALUE pgconn_send( int argc, VALUE *argv, VALUE obj);
22
- static VALUE pgconn_fetch( VALUE obj);
24
+ static VALUE pgconn_fetch( int argc, VALUE *argv, VALUE conn);
25
+ static void wait_for_pgsocket( PGconn *c, VALUE to);
23
26
  static VALUE yield_or_return_result( VALUE res);
24
27
  static VALUE clear_resultqueue( VALUE self);
25
28
 
@@ -30,9 +33,9 @@ static VALUE pgconn_select_values( int argc, VALUE *argv, VALUE self);
30
33
  static VALUE pgconn_get_notify( VALUE self);
31
34
 
32
35
  static VALUE pgconn_transaction( int argc, VALUE *argv, VALUE self);
33
- static VALUE rollback_transaction( VALUE self, VALUE err);
36
+ static VALUE rollback_transaction( VALUE conn, VALUE err);
34
37
  static VALUE commit_transaction( VALUE self);
35
- static VALUE yield_transaction( VALUE self);
38
+ static VALUE yield_transaction( VALUE conn);
36
39
  static VALUE pgconn_subtransaction( int argc, VALUE *argv, VALUE self);
37
40
  static VALUE rollback_subtransaction( VALUE ary, VALUE err);
38
41
  static VALUE release_subtransaction( VALUE ary);
@@ -53,6 +56,7 @@ static VALUE backup_end( VALUE conn);
53
56
 
54
57
 
55
58
  static VALUE rb_ePgConnExec;
59
+ static VALUE rb_ePgConnTimeout;
56
60
  static VALUE rb_ePgConnTrans;
57
61
  static VALUE rb_ePgConnCopy;
58
62
 
@@ -72,8 +76,7 @@ pg_statement_exec( VALUE conn, VALUE cmd, VALUE par)
72
76
  struct pgconn_data *c;
73
77
  PGresult *result;
74
78
 
75
- Data_Get_Struct( conn, struct pgconn_data, c);
76
- pg_check_conninvalid( c);
79
+ c = get_pgconn( conn);
77
80
  if (NIL_P( par))
78
81
  result = PQexec( c->conn, pgconn_destring( c, cmd, NULL));
79
82
  else {
@@ -97,8 +100,7 @@ pg_statement_send( VALUE conn, VALUE cmd, VALUE par)
97
100
  struct pgconn_data *c;
98
101
  int res;
99
102
 
100
- Data_Get_Struct( conn, struct pgconn_data, c);
101
- pg_check_conninvalid( c);
103
+ c = get_pgconn( conn);
102
104
  if (NIL_P( par))
103
105
  res = PQsendQuery( c->conn, pgconn_destring( c, cmd, NULL));
104
106
  else {
@@ -112,6 +114,7 @@ pg_statement_send( VALUE conn, VALUE cmd, VALUE par)
112
114
  }
113
115
  if (res <= 0)
114
116
  pg_raise_connexec( c);
117
+ PQsetSingleRowMode( c->conn);
115
118
  }
116
119
 
117
120
  char **
@@ -123,7 +126,7 @@ params_to_strings( VALUE conn, VALUE params, int *len)
123
126
  char **values, **v;
124
127
  char *a;
125
128
 
126
- Data_Get_Struct( conn, struct pgconn_data, c);
129
+ c = get_pgconn( conn);
127
130
  ptr = RARRAY_PTR( params);
128
131
  *len = l = RARRAY_LEN( params);
129
132
  values = ALLOC_N( char *, l);
@@ -195,18 +198,29 @@ pgconn_exec( int argc, VALUE *argv, VALUE self)
195
198
  * Sends an asynchronous SQL query request specified by +sql+ to the
196
199
  * PostgreSQL server.
197
200
  *
201
+ * This sets the query into single row mode. You have to call +Pg::Conn#fetch+
202
+ * what will yield one-row results. You may cancel the delivery by breaking
203
+ * the loop.
204
+ *
198
205
  * Use Pg::Conn#fetch to fetch the results after you waited for data.
199
206
  *
200
207
  * Pg::Conn.connect do |conn|
201
208
  * conn.send "SELECT pg_sleep(3), * FROM t;" do
202
- * ins = [ conn.socket]
203
- * loop do
204
- * r = IO.select ins, nil, nil, 0.5
205
- * break if r
206
- * puts Time.now
207
- * end
208
- * res = conn.fetch
209
- * res.each { |w| puts w.inspect }
209
+ * conn.fetch { |res|
210
+ * puts res.first.inspect
211
+ * break if (rand 3) < 1
212
+ * }
213
+ * end
214
+ * end
215
+ *
216
+ * Multiple select statements will not be separated by an empty result
217
+ * or something similar. Query twice if you want to separate them.
218
+ *
219
+ * Pg::Conn.connect do |conn|
220
+ * conn.send "SELECT 33; SELECT 'foo';" do
221
+ * conn.fetch { |res|
222
+ * puts res.first.inspect
223
+ * }
210
224
  * end
211
225
  * end
212
226
  */
@@ -222,8 +236,7 @@ pgconn_send( int argc, VALUE *argv, VALUE self)
222
236
 
223
237
  /*
224
238
  * call-seq:
225
- * conn.fetch() -> result or nil
226
- * conn.fetch() { |result| ... } -> obj
239
+ * conn.fetch( timeout = nil) { |result| ... } -> obj
227
240
  *
228
241
  * Fetches the results of the previous Pg::Conn#send call.
229
242
  * See there for an example.
@@ -231,20 +244,70 @@ pgconn_send( int argc, VALUE *argv, VALUE self)
231
244
  * The result will be +nil+ if there are no more results.
232
245
  */
233
246
  VALUE
234
- pgconn_fetch( VALUE self)
247
+ pgconn_fetch( int argc, VALUE *argv, VALUE conn)
235
248
  {
236
249
  struct pgconn_data *c;
237
250
  PGresult *result;
251
+ VALUE to;
252
+
253
+ rb_scan_args( argc, argv, "01", &to);
238
254
 
239
- Data_Get_Struct( self, struct pgconn_data, c);
240
- pg_check_conninvalid( c);
255
+ c = get_pgconn( conn);
256
+ wait_for_pgsocket( c->conn, to);
241
257
  if (PQconsumeInput( c->conn) == 0)
242
258
  pg_raise_connexec( c);
243
- if (PQisBusy( c->conn) > 0)
244
- return Qnil;
245
- result = PQgetResult( c->conn);
246
- return result == NULL ? Qnil :
247
- yield_or_return_result( pgresult_new( result, c, Qnil, Qnil));
259
+ if (PQisBusy( c->conn) == 0)
260
+ 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));
265
+ }
266
+ return Qnil;
267
+ }
268
+
269
+ void
270
+ wait_for_pgsocket( PGconn *c, VALUE to)
271
+ {
272
+ int fd;
273
+ fd_set readset;
274
+ struct timeval tv, *ptv;
275
+
276
+ fd = PQsocket( c);
277
+
278
+ FD_ZERO(&readset);
279
+ FD_SET(fd, &readset);
280
+
281
+ ptv = NULL;
282
+ if (!NIL_P( to)) {
283
+ int type = TYPE( to);
284
+ if (type == T_FIXNUM) {
285
+ tv.tv_sec = FIX2LONG( to);
286
+ tv.tv_usec = 0;
287
+ } else {
288
+ double x;
289
+ switch (type) {
290
+ case T_FLOAT:
291
+ x = RFLOAT_VALUE( to);
292
+ break;
293
+ case T_BIGNUM:
294
+ x = rb_big2dbl( to);
295
+ break;
296
+ case T_RATIONAL:
297
+ x = rb_num2dbl( to);
298
+ break;
299
+ default:
300
+ x = RFLOAT_VALUE( rb_funcall( to, rb_intern( "to_f"), 0));
301
+ break;
302
+ }
303
+ tv.tv_sec = floor( x);
304
+ tv.tv_usec = round( (x-tv.tv_sec)*1000000);
305
+ }
306
+ ptv = &tv;
307
+ }
308
+
309
+ if (select( fd+1, &readset, NULL, NULL, ptv) < 0 || !FD_ISSET( fd, &readset))
310
+ rb_raise( rb_ePgConnTimeout, "Wait for data timed out.");
248
311
  }
249
312
 
250
313
  VALUE
@@ -255,14 +318,31 @@ yield_or_return_result( VALUE result)
255
318
  }
256
319
 
257
320
  VALUE
258
- clear_resultqueue( VALUE self)
321
+ clear_resultqueue( VALUE conn)
259
322
  {
260
323
  struct pgconn_data *c;
261
324
  PGresult *result;
325
+ int cancelled;
262
326
 
263
- Data_Get_Struct( self, struct pgconn_data, c);
264
- while ((result = PQgetResult( c->conn)) != NULL)
327
+ c = get_pgconn( conn);
328
+ cancelled = 0;
329
+ while ((result = PQgetResult( c->conn)) != NULL) {
265
330
  PQclear( result);
331
+ if (!cancelled) {
332
+ char errbuf[ 256];
333
+ PGcancel *cancel;
334
+ int ret;
335
+
336
+ cancel = PQgetCancel( c->conn);
337
+ if (cancel == NULL)
338
+ rb_raise( rb_ePgConnTrans, "Could not get cancel object.");
339
+ ret = PQcancel( cancel, errbuf, sizeof errbuf);
340
+ PQfreeCancel( cancel);
341
+ if (ret == 0)
342
+ rb_raise( rb_ePgConnTrans, "Cancel of sent query failed: %s", errbuf);
343
+ cancelled = 1;
344
+ }
345
+ }
266
346
  return Qnil;
267
347
  }
268
348
 
@@ -387,14 +467,14 @@ pgconn_select_values( int argc, VALUE *argv, VALUE self)
387
467
  * Returns a notifier. If there is no unprocessed notifier, it returns +nil+.
388
468
  */
389
469
  VALUE
390
- pgconn_get_notify( VALUE self)
470
+ pgconn_get_notify( VALUE conn)
391
471
  {
392
472
  struct pgconn_data *c;
393
473
  PGnotify *notify;
394
474
  VALUE rel, pid, ext;
395
475
  VALUE ret;
396
476
 
397
- Data_Get_Struct( self, struct pgconn_data, c);
477
+ c = get_pgconn( conn);
398
478
  if (PQconsumeInput( c->conn) == 0)
399
479
  pg_raise_connexec( c);
400
480
  notify = PQnotifies( c->conn);
@@ -423,7 +503,7 @@ pgconn_get_notify( VALUE self)
423
503
  *
424
504
  */
425
505
  VALUE
426
- pgconn_transaction( int argc, VALUE *argv, VALUE self)
506
+ pgconn_transaction( int argc, VALUE *argv, VALUE conn)
427
507
  {
428
508
  struct pgconn_data *c;
429
509
  VALUE ser, ro;
@@ -431,50 +511,50 @@ pgconn_transaction( int argc, VALUE *argv, VALUE self)
431
511
  int p;
432
512
 
433
513
  rb_scan_args( argc, argv, "02", &ser, &ro);
434
- cmd = rb_str_buf_new2( "begin");
514
+ cmd = rb_str_buf_new2( "BEGIN");
435
515
  p = 0;
436
516
  if (!NIL_P( ser)) {
437
- rb_str_buf_cat2( cmd, " isolation level ");
438
- rb_str_buf_cat2( cmd, RTEST(ser) ? "serializable" : "read committed");
517
+ rb_str_buf_cat2( cmd, " ISOLATION LEVEL ");
518
+ rb_str_buf_cat2( cmd, RTEST(ser) ? "SERIALIZABLE" : "READ COMMITTED");
439
519
  p++;
440
520
  }
441
521
  if (!NIL_P( ro)) {
442
522
  if (p) rb_str_buf_cat2( cmd, ",");
443
- rb_str_buf_cat2( cmd, " read ");
444
- rb_str_buf_cat2( cmd, (RTEST(ro) ? "only" : "write"));
523
+ rb_str_buf_cat2( cmd, " READ ");
524
+ rb_str_buf_cat2( cmd, (RTEST(ro) ? "ONLY" : "WRITE"));
445
525
  }
446
526
  rb_str_buf_cat2( cmd, ";");
447
527
 
448
- Data_Get_Struct( self, struct pgconn_data, c);
528
+ c = get_pgconn( conn);
449
529
  if (PQtransactionStatus( c->conn) > PQTRANS_IDLE)
450
530
  rb_raise( rb_ePgConnTrans,
451
531
  "Nested transaction block. Use Conn#subtransaction.");
452
- pgresult_clear( pg_statement_exec( self, cmd, Qnil));
453
- return rb_ensure( yield_transaction, self, commit_transaction, self);
532
+ pgresult_clear( pg_statement_exec( conn, cmd, Qnil));
533
+ return rb_ensure( yield_transaction, conn, commit_transaction, conn);
454
534
  }
455
535
 
456
536
  VALUE
457
- yield_transaction( VALUE self)
537
+ yield_transaction( VALUE conn)
458
538
  {
459
- return rb_rescue( rb_yield, self, rollback_transaction, self);
539
+ return rb_rescue( rb_yield, conn, rollback_transaction, conn);
460
540
  }
461
541
 
462
542
  VALUE
463
- rollback_transaction( VALUE self, VALUE err)
543
+ rollback_transaction( VALUE conn, VALUE err)
464
544
  {
465
- pgresult_clear( pg_statement_exec( self, rb_str_new2( "ROLLBACK;"), Qnil));
545
+ pgresult_clear( pg_statement_exec( conn, rb_str_new2( "ROLLBACK;"), Qnil));
466
546
  rb_exc_raise( err);
467
547
  return Qnil;
468
548
  }
469
549
 
470
550
  VALUE
471
- commit_transaction( VALUE self)
551
+ commit_transaction( VALUE conn)
472
552
  {
473
553
  struct pgconn_data *c;
474
554
 
475
- Data_Get_Struct( self, struct pgconn_data, c);
555
+ c = get_pgconn( conn);
476
556
  if (PQtransactionStatus( c->conn) > PQTRANS_IDLE)
477
- pgresult_clear( pg_statement_exec( self, rb_str_new2( "COMMIT;"), Qnil));
557
+ pgresult_clear( pg_statement_exec( conn, rb_str_new2( "COMMIT;"), Qnil));
478
558
  return Qnil;
479
559
  }
480
560
 
@@ -496,13 +576,13 @@ pgconn_subtransaction( int argc, VALUE *argv, VALUE self)
496
576
  char *p;
497
577
  int n;
498
578
 
499
- Data_Get_Struct( self, struct pgconn_data, c);
579
+ c = get_pgconn( self);
500
580
  a = rb_scan_args( argc, argv, "1*", &sp, &par);
501
581
  StringValue( sp);
502
582
  if (a > 1)
503
583
  sp = rb_str_format(RARRAY_LEN(par), RARRAY_PTR(par), sp);
504
584
 
505
- cmd = rb_str_buf_new2( "savepoint ");
585
+ cmd = rb_str_buf_new2( "SAVEPOINT ");
506
586
  q = pgconn_destring( c, sp, &n);
507
587
  p = PQescapeIdentifier( c->conn, q, n);
508
588
  rb_str_buf_cat2( cmd, p);
@@ -525,7 +605,7 @@ rollback_subtransaction( VALUE ary, VALUE err)
525
605
  {
526
606
  VALUE cmd;
527
607
 
528
- cmd = rb_str_buf_new2( "rollback to savepoint ");
608
+ cmd = rb_str_buf_new2( "ROLLBACK TO SAVEPOINT ");
529
609
  rb_str_buf_append( cmd, rb_ary_entry( ary, 1));
530
610
  rb_str_buf_cat2( cmd, ";");
531
611
  pgresult_clear( pg_statement_exec( rb_ary_entry( ary, 0), cmd, Qnil));
@@ -542,7 +622,7 @@ release_subtransaction( VALUE ary)
542
622
 
543
623
  n = rb_ary_entry( ary, 1);
544
624
  if (!NIL_P( n)) {
545
- cmd = rb_str_buf_new2( "release savepoint ");
625
+ cmd = rb_str_buf_new2( "RELEASE SAVEPOINT ");
546
626
  rb_str_buf_append( cmd, n);
547
627
  rb_str_buf_cat2( cmd, ";");
548
628
  pgresult_clear( pg_statement_exec( rb_ary_entry( ary, 0), cmd, Qnil));
@@ -570,7 +650,7 @@ pgconn_transaction_status( VALUE self)
570
650
  {
571
651
  struct pgconn_data *c;
572
652
 
573
- Data_Get_Struct( self, struct pgconn_data, c);
653
+ c = get_pgconn( self);
574
654
  return INT2FIX( PQtransactionStatus( c->conn));
575
655
  }
576
656
 
@@ -585,7 +665,7 @@ pgconn_transaction_status( VALUE self)
585
665
  *
586
666
  * conn.copy_stdin "COPY t FROM STDIN;" do
587
667
  * ary = ...
588
- * l = stringize_line ary
668
+ * l = conn.stringize_line ary
589
669
  * conn.put l
590
670
  * end
591
671
  *
@@ -610,7 +690,7 @@ put_end( VALUE self)
610
690
  int r;
611
691
  PGresult *res;
612
692
 
613
- Data_Get_Struct( self, struct pgconn_data, c);
693
+ c = get_pgconn( self);
614
694
  /*
615
695
  * I would like to hand over something like
616
696
  * RSTRING_PTR( rb_obj_as_string( rb_errinfo()))
@@ -670,7 +750,7 @@ pgconn_putline( VALUE self, VALUE arg)
670
750
  str = t;
671
751
  }
672
752
 
673
- Data_Get_Struct( self, struct pgconn_data, c);
753
+ c = get_pgconn( self);
674
754
  p = pgconn_destring( c, str, &l);
675
755
  r = PQputCopyData( c->conn, p, l);
676
756
  if (r < 0)
@@ -722,7 +802,7 @@ get_end( VALUE self)
722
802
  struct pgconn_data *c;
723
803
  PGresult *res;
724
804
 
725
- Data_Get_Struct( self, struct pgconn_data, c);
805
+ c = get_pgconn( self);
726
806
  if ((res = PQgetResult( c->conn)) != NULL)
727
807
  pgresult_new( res, c, Qnil, Qnil);
728
808
  return Qnil;
@@ -753,7 +833,7 @@ pgconn_getline( int argc, VALUE *argv, VALUE self)
753
833
 
754
834
  async = rb_scan_args( argc, argv, "01", &as) > 0 && !NIL_P( as) ? 1 : 0;
755
835
 
756
- Data_Get_Struct( self, struct pgconn_data, c);
836
+ c = get_pgconn( self);
757
837
  r = PQgetCopyData( c->conn, &b, async);
758
838
  if (r > 0) {
759
839
  VALUE ret;
@@ -787,7 +867,7 @@ pgconn_each_line( VALUE self)
787
867
  int r;
788
868
  VALUE s;
789
869
 
790
- Data_Get_Struct( self, struct pgconn_data, c);
870
+ c = get_pgconn( self);
791
871
  for (; (r = PQgetCopyData( c->conn, &b, 0)) > 0;) {
792
872
  s = pgconn_mkstringn( c, b, r);
793
873
  PQfreemem( b);
@@ -857,13 +937,14 @@ Init_pgsql_conn_exec( void)
857
937
  rb_cPgConn = rb_define_class_under( rb_mPg, "Conn", rb_cObject);
858
938
  #endif
859
939
 
860
- rb_ePgConnExec = rb_define_class_under( rb_cPgConn, "ExecError", rb_ePgError);
861
- rb_ePgConnTrans = rb_define_class_under( rb_cPgConn, "TransactionError", rb_ePgError);
862
- rb_ePgConnCopy = rb_define_class_under( rb_cPgConn, "CopyError", rb_ePgError);
940
+ rb_ePgConnExec = rb_define_class_under( rb_cPgConn, "ExecError", rb_ePgError);
941
+ rb_ePgConnTimeout = rb_define_class_under( rb_cPgConn, "Timeout", rb_ePgError);
942
+ rb_ePgConnTrans = rb_define_class_under( rb_cPgConn, "TransactionError", rb_ePgError);
943
+ rb_ePgConnCopy = rb_define_class_under( rb_cPgConn, "CopyError", rb_ePgError);
863
944
 
864
945
  rb_define_method( rb_cPgConn, "exec", &pgconn_exec, -1);
865
946
  rb_define_method( rb_cPgConn, "send", &pgconn_send, -1);
866
- rb_define_method( rb_cPgConn, "fetch", &pgconn_fetch, 0);
947
+ rb_define_method( rb_cPgConn, "fetch", &pgconn_fetch, -1);
867
948
 
868
949
  rb_define_method( rb_cPgConn, "query", &pgconn_query, -1);
869
950
  rb_define_method( rb_cPgConn, "select_row", &pgconn_select_row, -1);
data/lib/conn_quote.c CHANGED
@@ -472,7 +472,7 @@ gsub_escape_i( RB_BLOCK_CALL_FUNC_ARGLIST( c, arg))
472
472
  * This method is to prevent you from saying something like <code>"insert into
473
473
  * ... (E'#{conn.stringize obj}', ...);"</code>. It is more efficient to say
474
474
  *
475
- * conn.exec "insert into ... (#{conn.quote obj}, ...);"
475
+ * conn.exec "INSERT INTO ... (#{conn.quote obj}, ...);"
476
476
  *
477
477
  * Your self-defined classes will be checked whether they have a method named
478
478
  * +to_postgres+. If that doesn't exist the object will be converted by
@@ -517,25 +517,25 @@ VALUE pgconn_quote( VALUE self, VALUE obj)
517
517
  co = CLASS_OF( obj);
518
518
  if (co == rb_cTime) {
519
519
  res = rb_funcall( obj, id_iso8601, 0);
520
- type = "timestamptz";
520
+ type = "TIMESTAMPTZ";
521
521
  } else if (co == rb_cDate) {
522
522
  res = rb_obj_as_string( obj);
523
- type = "date";
523
+ type = "DATE";
524
524
  } else if (co == rb_cDateTime) {
525
525
  res = rb_obj_as_string( obj);
526
- type = "timestamptz";
526
+ type = "TIMESTAMPTZ";
527
527
  } else if (co == pg_monetary_class() &&
528
528
  rb_respond_to( obj, id_raw)) {
529
529
  res = rb_funcall( obj, id_raw, 0);
530
530
  StringValue( res);
531
- type = "money";
531
+ type = "MONEY";
532
532
  } else if (rb_respond_to( obj, id_to_postgres)) {
533
533
  res = rb_funcall( obj, id_to_postgres, 0);
534
534
  StringValue( res);
535
535
  type = NULL;
536
536
  } else {
537
537
  res = rb_obj_as_string( obj);
538
- type = "unknown";
538
+ type = "UNKNOWN";
539
539
  }
540
540
  res = quote_string( self, res);
541
541
  if (type != NULL) {
data/lib/module.c CHANGED
@@ -8,7 +8,7 @@
8
8
  #include "result.h"
9
9
 
10
10
 
11
- #define PGSQL_VERSION "1.8"
11
+ #define PGSQL_VERSION "1.9"
12
12
 
13
13
 
14
14
  VALUE rb_mPg;
data/lib/result.c CHANGED
@@ -241,6 +241,8 @@ pgresult_new( PGresult *result, struct pgconn_data *conn, VALUE cmd, VALUE par)
241
241
  case PGRES_TUPLES_OK:
242
242
  case PGRES_COPY_OUT:
243
243
  case PGRES_COPY_IN:
244
+ case PGRES_COPY_BOTH:
245
+ case PGRES_SINGLE_TUPLE:
244
246
  break;
245
247
  case PGRES_BAD_RESPONSE:
246
248
  case PGRES_NONFATAL_ERROR:
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.8'
4
+ version: '1.9'
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-04-11 00:00:00.000000000 Z
11
+ date: 2021-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: autorake