pgsql 1.2 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +9 -9
  2. data/lib/conn_exec.c +39 -20
  3. data/lib/module.c +1 -1
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZWE3YWVlMjYyYWFkNzg5YmMwMTUwMjZlYWE4YmE0NDE5MTQ3OWJlZQ==
4
+ MTM2YjZhYjdkMzM5ZDdjYTAyZmJjOTMzYTM3NTFiY2M0Y2Y0ZWI1ZA==
5
5
  data.tar.gz: !binary |-
6
- ZjRhNzNhMmUwMzVkMzM1YjNhMTMwM2U3OTIxODY1MjhhOTI0OWMxZg==
7
- !binary "U0hBNTEy":
6
+ YWVlZTViMjA4YmYwYzg2MjVlYWYwNjdjNTA1N2ExMmRlMDU5MTY3MA==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjNlNzJjZjBmYWZkYTc2NzM2YmZlNjY0MzA2MDQ1ZmEzY2Q2NGVlMDBlMGI4
10
- NjFlYTM0MTk4Yjk1ZjJmN2M1ODRhNGQzOGY3MWJjNGU4ZmE0NmJjYjA4NzZj
11
- ZjA2NjY3NmE2ZjcwYmEyNWU5MDQ0MTJiZmMyMTMwMmQzN2UxNmY=
9
+ OWY0NWYwYzA0ZjZkZWFjYjkwMGNhOGFiZmQ3M2U5ZWRmZjY3ODc4NjRkNzhl
10
+ MDg2YzdlMmVkZDAzZjZiY2RmOWFkNTgyZTFjNzQxMTM1ZjRhN2ExNmU4OWEx
11
+ MmQzZTAwOGI4NGNkZmNhNDQyMGNhM2Y3Yjg0ODNlNDQxODFmNTg=
12
12
  data.tar.gz: !binary |-
13
- NDI2NGYzYzczNzFkODcxMDM2YzAyZWU2NzFjNjBhYjk2MWNmOWVlOTAxNjJk
14
- ODIyZDUwOGYwYzUzOTY5YWZlOGI1YzQzZWQzMmY5NjgyOWFkZTYwYzFjOGRm
15
- NjVlMzA2YzAxZjMwMWI0MmFmMWYyMjYwNTA3ZTYwMzJhOGI4NTY=
13
+ YTc3ZWJkMDg0MWUwYjdhZDdkMGViMDM5MzE5YmU2MGVmZTBkYTNlMGIwNWZh
14
+ YzQwN2Y4ZjQ0ZjE2Yjk4OWI1OTFmMzY4NGVjNmY5NDk2MjIzYTIyMzc5MWI0
15
+ ODFiNTRjMjBkN2YxNDljN2FlYWJmOWUzMDQwMDE1ODAyYWQyZGY=
@@ -37,10 +37,12 @@ static VALUE pgconn_select_values( int argc, VALUE *argv, VALUE self);
37
37
  static VALUE pgconn_get_notify( VALUE self);
38
38
 
39
39
  static VALUE pgconn_transaction( int argc, VALUE *argv, VALUE self);
40
- static VALUE rescue_transaction( VALUE self);
40
+ static VALUE rollback_transaction( VALUE self);
41
+ static VALUE commit_transaction( VALUE self);
41
42
  static VALUE yield_transaction( VALUE self);
42
43
  static VALUE pgconn_subtransaction( int argc, VALUE *argv, VALUE self);
43
- static VALUE rescue_subtransaction( VALUE ary);
44
+ static VALUE rollback_subtransaction( VALUE ary);
45
+ static VALUE release_subtransaction( VALUE ary);
44
46
  static VALUE yield_subtransaction( VALUE ary);
45
47
  static VALUE pgconn_transaction_status( VALUE self);
46
48
 
@@ -460,11 +462,17 @@ pgconn_transaction( int argc, VALUE *argv, VALUE self)
460
462
  rb_raise( rb_ePgConnTrans,
461
463
  "Nested transaction block. Use Conn#subtransaction.");
462
464
  pgresult_clear( pg_statement_exec( self, cmd, Qnil));
463
- return rb_rescue( yield_transaction, self, rescue_transaction, self);
465
+ return rb_ensure( yield_transaction, self, commit_transaction, self);
464
466
  }
465
467
 
466
468
  VALUE
467
- rescue_transaction( VALUE self)
469
+ yield_transaction( VALUE self)
470
+ {
471
+ return rb_rescue( rb_yield, self, rollback_transaction, self);
472
+ }
473
+
474
+ VALUE
475
+ rollback_transaction( VALUE self)
468
476
  {
469
477
  pgresult_clear( pg_statement_exec( self, rb_str_new2( "rollback;"), Qnil));
470
478
  rb_exc_raise( RB_ERRINFO);
@@ -472,13 +480,14 @@ rescue_transaction( VALUE self)
472
480
  }
473
481
 
474
482
  VALUE
475
- yield_transaction( VALUE self)
483
+ commit_transaction( VALUE self)
476
484
  {
477
- VALUE r;
485
+ struct pgconn_data *c;
478
486
 
479
- r = rb_yield( self);
480
- pgresult_clear( pg_statement_exec( self, rb_str_new2( "commit;"), Qnil));
481
- return r;
487
+ Data_Get_Struct( self, struct pgconn_data, c);
488
+ if (PQtransactionStatus( c->conn) > PQTRANS_IDLE)
489
+ pgresult_clear( pg_statement_exec( self, rb_str_new2( "commit;"), Qnil));
490
+ return Qnil;
482
491
  }
483
492
 
484
493
 
@@ -514,11 +523,17 @@ pgconn_subtransaction( int argc, VALUE *argv, VALUE self)
514
523
  rb_str_buf_cat2( cmd, ";");
515
524
 
516
525
  pgresult_clear( pg_statement_exec( self, cmd, Qnil));
517
- return rb_rescue( yield_subtransaction, ya, rescue_subtransaction, ya);
526
+ return rb_ensure( yield_subtransaction, ya, release_subtransaction, ya);
518
527
  }
519
528
 
520
529
  VALUE
521
- rescue_subtransaction( VALUE ary)
530
+ yield_subtransaction( VALUE ary)
531
+ {
532
+ return rb_rescue( rb_yield, ary, rollback_subtransaction, ary);
533
+ }
534
+
535
+ VALUE
536
+ rollback_subtransaction( VALUE ary)
522
537
  {
523
538
  VALUE cmd;
524
539
 
@@ -526,21 +541,25 @@ rescue_subtransaction( VALUE ary)
526
541
  rb_str_buf_append( cmd, rb_ary_entry( ary, 1));
527
542
  rb_str_buf_cat2( cmd, ";");
528
543
  pgresult_clear( pg_statement_exec( rb_ary_entry( ary, 0), cmd, Qnil));
544
+ rb_ary_store( ary, 1, Qnil);
529
545
  rb_exc_raise( RB_ERRINFO);
530
546
  return Qnil;
531
547
  }
532
548
 
533
549
  VALUE
534
- yield_subtransaction( VALUE ary)
550
+ release_subtransaction( VALUE ary)
535
551
  {
536
- VALUE r, cmd;
537
-
538
- r = rb_yield( ary);
539
- cmd = rb_str_buf_new2( "release savepoint ");
540
- rb_str_buf_append( cmd, rb_ary_entry( ary, 1));
541
- rb_str_buf_cat2( cmd, ";");
542
- pgresult_clear( pg_statement_exec( rb_ary_entry( ary, 0), cmd, Qnil));
543
- return r;
552
+ VALUE cmd;
553
+ VALUE n;
554
+
555
+ n = rb_ary_entry( ary, 1);
556
+ if (!NIL_P( n)) {
557
+ cmd = rb_str_buf_new2( "release savepoint ");
558
+ rb_str_buf_append( cmd, n);
559
+ rb_str_buf_cat2( cmd, ";");
560
+ pgresult_clear( pg_statement_exec( rb_ary_entry( ary, 0), cmd, Qnil));
561
+ }
562
+ return Qnil;
544
563
  }
545
564
 
546
565
 
@@ -7,7 +7,7 @@
7
7
  #include "conn.h"
8
8
 
9
9
 
10
- #define PGSQL_VERSION "1.2"
10
+ #define PGSQL_VERSION "1.3"
11
11
 
12
12
 
13
13
  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.2'
4
+ version: '1.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-09 00:00:00.000000000 Z
11
+ date: 2013-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: autorake
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - PostgreSQL
81
81
  rubyforge_project: NONE
82
- rubygems_version: 2.0.7
82
+ rubygems_version: 2.1.11
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: PostgreSQL-API for Ruby