i'm trying to handle a bug report filed against DBD::mysql about getting
this error using the exampe code below. (http://bugs.mysql.com/24244)
but as far as i can tell, we are handling the AutoCommit attribute
properly, and basically the same as other drivers. looking at the DBI.xs
code, i see this comment:
/* driver should have intercepted this and either handled it */
/* or set valuesv to either the 'magic' on or off value. */
but i can't find any documentation of these magic on and off values, and
the other DBD drivers i've looked at don't appear to be doing anything
special.
what am i missing?
thanks.
jim
#!/usr/local/bin/perl -w
use strict;
use DBI;
my $dbh = DBI->connect('dbi:mysql:database=test:localhost', 'test', '',
{'RaiseError' => 1, 'PrintError' => 0, 'AutoCommit' => 1});
unless(defined($dbh)) {
die($DBI::errstr);
}
$dbh->do('DROP TABLE IF EXISTS tinnodb');
$dbh->do('CREATE TABLE tinnodb (id INTEGER UNSIGNED NOT NULL
AUTO_INCREMENT
PRIMARY KEY, data VARCHAR(25)) TYPE InnoDB');
print 'AutoCommit: ' . $dbh->{'AutoCommit'} . "\n";
$dbh->{'AutoCommit'} = 1;
do_stuff();
print 'AutoCommit: ' . $dbh->{'AutoCommit'} . "\n";
sub do_stuff {
print 'AutoCommit: ' . $dbh->{'AutoCommit'} . "\n";
local $dbh->{'AutoCommit'} = 0; # removing 'local' works
print 'AutoCommit: ' . $dbh->{'AutoCommit'} . "\n";
my $sth = $dbh->prepare('INSERT INTO tinnodb (data) VALUES
(?)');
$sth->execute('bla');
$sth->execute('foo');
$sth->finish();
$dbh->commit();
$dbh->disconnect();
}