AW: [Dbix-class] Manual Transaction Handling for Sybase ?

Robert Heinzmann Robert.Heinzmann at 1und1.de
Wed Jul 8 19:49:18 GMT 2009


Found a solution, 

the Problem is the "begin". If I skip the "begin", I can just run "commit / rollback" at the end.

Robert

 

> -----Ursprüngliche Nachricht-----
> Von: Rob Kinyon [mailto:rob.kinyon at gmail.com] 
> Gesendet: Mittwoch, 8. Juli 2009 21:22
> An: DBIx::Class user and developer list
> Betreff: Re: [Dbix-class] Manual Transaction Handling for Sybase ?
> 
> What's wrong with txn_do()?
> 
> Rob
> 
> On Wed, Jul 8, 2009 at 15:18, Robert 
> Heinzmann<Robert.Heinzmann at 1und1.de> wrote:
> > Hello,
> >
> > I'm using DBIx::Class and I want to implement manual transactions.
> >
> > Connection is set to "AutoCommit => 0". I issue manual
> >
> > ----
> > txn_begin()
> >
> > Insert
> > Update
> > Select
> >
> > txn_commit() / txn_rollback()
> > ----
> >
> > However no Transaction takes place. DBIC Trace shows no BEGIN or 
> > COMMIT / ROLLBACK.
> >
> > I added the following:
> >
> > print Dumper($db->storage->{transaction_depth});
> > $db->storage()->txn_begin() or $logger->error_die("ERROR Starting 
> > Transaction"); print Dumper($db->storage->{transaction_depth});
> >
> > print Dumper($db->storage->{transaction_depth});
> > $db->storage()->txn_rollback() or $logger->error_die("ERROR 
> Starting 
> > Transaction"); print Dumper($db->storage->{transaction_depth});
> >
> >
> > This gives
> >
> > $VAR1 = 1;
> > $VAR1 = 2;
> >
> > $VAR1 = 2;
> > $VAR1 = 1;
> >
> > ----
> > /usr/share/perl5/DBIx/Class/Storage/DBI.pm
> > (Version Lenny: ii  libdbix-class-perl                0.08010-2 
> > Extensible and flexible object <-> relational mapper)
> > ----
> > sub txn_begin {
> >  my $self = shift;
> >  $self->ensure_connected();
> >  if($self->{transaction_depth} == 0) {
> >    $self->debugobj->txn_begin()
> >      if $self->debug;
> >    # this isn't ->_dbh-> because
> >    #  we should reconnect on begin_work
> >    #  for AutoCommit users
> >    $self->dbh->begin_work;
> >  }
> >  $self->{transaction_depth}++;
> > }
> >
> > sub txn_commit {
> >  my $self = shift;
> >  if ($self->{transaction_depth} == 1) {
> >    my $dbh = $self->_dbh;
> >    $self->debugobj->txn_commit()
> >      if ($self->debug);
> >    $dbh->commit;
> >    $self->{transaction_depth} = 0
> >      if $self->_dbh_autocommit;
> >  }
> >  elsif($self->{transaction_depth} > 1) {
> >    $self->{transaction_depth}--
> >  }
> > }
> >
> > sub ensure_connected {
> >  my ($self) = @_;
> >
> >  unless ($self->connected) {
> >    $self->_populate_dbh;
> >  }
> > }
> >
> > sub _populate_dbh {
> >  my ($self) = @_;
> >  my @info = @{$self->_dbi_connect_info || []};
> >  $self->_dbh($self->_connect(@info));
> >
> >  # Always set the transaction depth on connect, since
> >  #  there is no transaction in progress by definition
> >  $self->{transaction_depth} = $self->_dbh_autocommit ? 0 : 1;
> >
> >  if(ref $self eq 'DBIx::Class::Storage::DBI') {
> >    my $driver = $self->_dbh->{Driver}->{Name};
> >    if
> > 
> ($self->load_optional_class("DBIx::Class::Storage::DBI::${driver}")) {
> >      bless $self, "DBIx::Class::Storage::DBI::${driver}";
> >      $self->_rebless() if $self->can('_rebless');
> >    }
> >  }
> >
> >  my $connection_do = $self->on_connect_do;
> >  $self->_do_connection_actions($connection_do) if 
> ref($connection_do);
> >
> >  $self->_conn_pid($$);
> >  $self->_conn_tid(threads->tid) if $INC{'threads.pm'}; }
> >
> >
> > For me this means with AutoCommit => 0 I cant do any 
> transactions at all
> > ...
> >
> > Looks like a bug ?
> >
> > P.s. Storage is Sybase. Any hints ?
> >
> > Regards,
> > Robert
> >
> >
> > _______________________________________________
> > List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> > IRC: irc.perl.org#dbix-class
> > SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> > Searchable Archive: 
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
> >
> 
> 
> 
> -- 
> Thanks,
> Rob Kinyon
> 
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: 
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
> 



More information about the DBIx-Class mailing list