[Bast-commits] r7617 - DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Thu Sep 10 00:16:03 GMT 2009


Author: caelum
Date: 2009-09-10 00:16:03 +0000 (Thu, 10 Sep 2009)
New Revision: 7617

Modified:
   DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm
Log:
do blob update over _insert_dbh

Modified: DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm	2009-09-09 16:01:15 UTC (rev 7616)
+++ DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm	2009-09-10 00:16:03 UTC (rev 7617)
@@ -286,7 +286,7 @@
         || (!$blob_cols && !$dumb_last_insert_id) 
   ) {
     return $self->_insert (
-      $source, $to_insert, $blob_cols, $identity_col, $next
+      $next, $source, $to_insert, $blob_cols, $identity_col
     );
   }
 
@@ -297,9 +297,6 @@
 
   local $self->{_dbh};
 
-  # localize so it appears right if we blow out with an exception
-  local $self->{transaction_depth} = 0;
-
   $self->_insert_dbh($self->_connect(@{ $self->_dbi_connect_info }))
     unless $self->_insert_dbh;
 
@@ -311,7 +308,7 @@
   $self->_insert_dbh($self->_dbh);
 
   my $updated_cols = $self->_insert (
-    $source, $to_insert, $blob_cols, $identity_col, $next
+    $next, $source, $to_insert, $blob_cols, $identity_col
   );
 
   $guard->commit;
@@ -321,7 +318,7 @@
 }
 
 sub _insert {
-  my ($self, $source, $to_insert, $blob_cols, $identity_col, $next) = @_;
+  my ($self, $next, $source, $to_insert, $blob_cols, $identity_col) = @_;
 
   my $updated_cols = $self->$next ($source, $to_insert);
 
@@ -341,12 +338,25 @@
   my ($source, $fields, $where) = @_;
 
   my $wantarray = wantarray;
-
   my $blob_cols = $self->_remove_blob_cols($source, $fields);
 
-# update+blob update(s) done atomically
-  my $guard = $self->txn_scope_guard if $blob_cols;
+  if (not $blob_cols) {
+    return $self->next::method(@_);
+  }
 
+# update+blob update(s) done atomically on separate connection (see insert)
+  local $self->{_dbh};
+
+  $self->_insert_dbh($self->_connect(@{ $self->_dbi_connect_info }))
+    unless $self->_insert_dbh;
+
+  $self->{_dbh} = $self->_insert_dbh;
+  my $guard = $self->txn_scope_guard;
+
+  # _dbh_begin_work in the guard may reconnect,
+  # so we update the accessor just in case
+  $self->_insert_dbh($self->_dbh);
+
   my @res;
   if ($wantarray) {
     @res    = $self->next::method(@_);
@@ -358,9 +368,9 @@
     $self->next::method(@_);
   }
 
-  $self->_update_blobs($source, $blob_cols, $where) if $blob_cols;
+  $self->_update_blobs($source, $blob_cols, $where);
 
-  $guard->commit if $guard;
+  $guard->commit;
 
   return $wantarray ? @res : $res[0];
 }




More information about the Bast-commits mailing list