On Wed, Jan 24, 2007 at 12:22:49PM -0600, Brandon Black wrote: > > > >Nope, I'm talking about the -current branch. I think that the code when > >it reconnections should check to see whether the internal transaction > >count is non-zero, and if it raise an exception instead of proceeding. > >That would be the safest thing to do. > > > > In the txn_begin/txn_end case that's true, although it needs some > careful thought and testing. However, txn_do is much more robust, and > I don't believe it currently suffers from this problem. >
Ok. First things first. It appears that some of the dependancy code
isn't working properly.
Look at this patch:
=== Storage/DBI/mysql.pm
==================================================================
--- Storage/DBI/mysql.pm (revision 3050)
+++ Storage/DBI/mysql.pm (local)
@@ -7,6 +7,10 @@
# __PACKAGE__->load_components(qw/PK::Auto/);
+sub _dbh_txn_begin {
+ print "mysql:_dbh_txn_begin\n";
+}
+
sub _dbh_last_insert_id {
my ($self, $dbh, $source, $col) = @_;
$dbh->{mysql_insertid};
=== Storage/DBI.pm
==================================================================
--- Storage/DBI.pm (revision 3050)
+++ Storage/DBI.pm (local)
@@ -741,6 +741,7 @@
sub _dbh_txn_begin {
my ($self, $dbh) = @_;
+print "storage:_dbh_txn_begin\n";
if ($dbh->{AutoCommit}) {
$self->debugobj->txn_begin()
if ($self->debug);
@@ -750,8 +751,10 @@
sub txn_begin {
my $self = shift;
- $self->dbh_do($self->can('_dbh_txn_begin'))
- if $self->{transaction_depth}++ == 0;
+print "storage:txn_begin\n";
+# $self->dbh_do($self->can('_dbh_txn_begin'))
+# if $self->{transaction_depth}++ == 0;
+ $self->dbh_do($self->can('_dbh_txn_begin'));
}
sub _dbh_txn_commit {
The point here being to see if I can override _dbh_txn_commit in the
database specific driver file (mysql in this case).
However with this test code:
my $schema = .... however you get your schema ...;
$schema->txn_begin();
print "A\n";
$schema->txn_begin();
print "A2\n";
$schema->txn_begin();
print "A3\n";
eval { $schema->txn_rollback(); }; print Dumper $@;
print "R3\n";
eval { $schema->txn_rollback(); }; print Dumper $@;
print "R2\n";
eval { $schema->txn_rollback(); }; print Dumper $@;
print "R1\n";
$schema->txn_begin();
print "A\n";
$schema->txn_begin();
print "A2\n";
$schema->txn_begin();
print "A3\n";
eval { $schema->txn_rollback(); }; print Dumper $@;
print "R3\n";
eval { $schema->txn_rollback(); }; print Dumper $@;
print "R2\n";
eval { $schema->txn_rollback(); }; print Dumper $@;
print "R1\n";
I get this output:
transwarp% env DBIC_TRACE=1 ./test.pl
storage:txn_begin
storage:_dbh_txn_begin
BEGIN WORK
A
storage:txn_begin
mysql:_dbh_txn_begin
A2
storage:txn_begin
mysql:_dbh_txn_begin
A3
ROLLBACK
$VAR1 = '';
R3
$VAR1 = '';
R2
$VAR1 = '';
R1
storage:txn_begin
mysql:_dbh_txn_begin
A
storage:txn_begin
mysql:_dbh_txn_begin
A2
storage:txn_begin
mysql:_dbh_txn_begin
A3
$VAR1 = '';
R3
$VAR1 = '';
R2
$VAR1 = '';
R1
Notice that the first time that txn_begin is called it isn't calling the
code in ...::DBI::mysql, however it does subsequently.
I've not totally got my head around the auto loading code yet, but it
appears that the ...:DBI::driver code is being loaded too late.
It ought to be auto loaded when the schema object is populated, not
when the database connection is made.
Joe
--
=== Josef Karthauser ([EMAIL PROTECTED]) === http://x2obuilder.com/tao ===
pgpVFiWYJxoDS.pgp
Description: PGP signature
_______________________________________________ List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class Wiki: http://dbix-class.shadowcatsystems.co.uk/ IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/ Searchable Archive: http://www.mail-archive.com/[email protected]/
