What's wrong with txn_do()? Rob
On Wed, Jul 8, 2009 at 15:18, Robert Heinzmann<[email protected]> 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/[email protected] > -- 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/[email protected]
