Skip Menu |

This queue is for tickets about the DBD-mysql CPAN distribution.

Report information
The Basics
Id: 83518
Status: resolved
Priority: 0/
Queue: DBD-mysql

People
Owner: Nobody in particular
Requestors: sveta.smirnova [...] oracle.com
Cc: pali [...] cpan.org
AdminCc:

Bug Information
Severity: Normal
Broken in: 3.0008
Fixed in: 4.022



Subject: DBD driver has not implemented the AutoCommit attribute
Originally reported by Craig Manley at http://bugs.mysql.com/bug.php?id=24244 Description: Normally when using transactions, I set a 'local' copy of the AutoCommit attribute so that when my transaction block exits, the original value of the AutoCommit attribute is automatically restored. Unfortunately, when using the DBD::mysql driver, Perl dies with the message "DBD driver has not implemented the AutoCommit attribute" as soon as this line is executed: local $dbh->{'AutoCommit'} = 0; Executing the same line, but without the 'local' part, works fine, but of course this is not so safe (especially in persistant code) because if the block die's, the value of $dbh->{'AutoCommit'} isn't restored to what it was. I've included a test script. My MySQL client+server versions are 5.0.27. How to repeat: #!/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(); }
From: ramesh
Recently I found the same issue with RQG mysql run. RQG trails were failing with following error. {error} # 2014-06-09T01:24:17 Child worker process completed successfully. # 2014-06-09T01:33:00 We have already exceeded time specified by --duration=x; exiting now. # 2014-06-09T01:33:03 Child worker process completed successfully. DBD driver has not implemented the AutoCommit attribute at /usr/lib64/perl5/DBI.pm line 705. # 2014-06-09T01:33:52 Query: ALTER TABLE `table100_memory_int_autoinc` KEY_BLOCK_SIZE = 2 failed: 2013 Lost connection to MySQL server during query # 2014-06-09T01:33:52 Query: FLUSH TABLE n failed: 2013 Lost connection to MySQL server during query # 2014-06-09T01:33:53 Query: TRUNCATE `table100_tokudb_int` failed: 2013 Lost connection to MySQL server during query {error} Reproduced the error with your perl script. $ ./test.pl AutoCommit: 1 AutoCommit: 1 AutoCommit: DBD driver has not implemented the AutoCommit attribute at ./test.pl line 14. $ Version info Perl DBI : perl-DBD-MySQL-4.013-3.el6.x86_64 Percona MySQL : 5.6.17 I could not reproduce the error with upgraded perl DBI module. I have used cpan to upgrade the perl module $ sudo cpanm DBD::mysql DBD::mysql is up to date. (4.027) $ $ ./test.pl AutoCommit: 1 AutoCommit: 1 AutoCommit: AutoCommit: $ On Thu Feb 21 16:56:59 2013, svetasmirnova wrote: Show quoted text
> Originally reported by Craig Manley at > http://bugs.mysql.com/bug.php?id=24244 > > Description: > Normally when using transactions, I set a 'local' copy of the AutoCommit > attribute so that when my transaction block exits, the original value of > the AutoCommit attribute is automatically restored. > > Unfortunately, when using the DBD::mysql driver, Perl dies with the > message "DBD driver has not implemented the AutoCommit attribute" as > soon as this line is executed: > local $dbh->{'AutoCommit'} = 0; > Executing the same line, but without the 'local' part, works fine, but > of course this is not so safe (especially in persistant code) because if > the block die's, the value of $dbh->{'AutoCommit'} isn't restored to > what it was. > > I've included a test script. My MySQL client+server versions are 5.0.27. > > How to repeat: > #!/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(); > }
On Štv Feb 21 16:56:59 2013, svetasmirnova wrote: Show quoted text
> Originally reported by Craig Manley at > http://bugs.mysql.com/bug.php?id=24244 > > Description: > Normally when using transactions, I set a 'local' copy of the AutoCommit > attribute so that when my transaction block exits, the original value of > the AutoCommit attribute is automatically restored. > > Unfortunately, when using the DBD::mysql driver, Perl dies with the > message "DBD driver has not implemented the AutoCommit attribute" as > soon as this line is executed: > local $dbh->{'AutoCommit'} = 0; > Executing the same line, but without the 'local' part, works fine, but > of course this is not so safe (especially in persistant code) because if > the block die's, the value of $dbh->{'AutoCommit'} isn't restored to > what it was. > > I've included a test script. My MySQL client+server versions are 5.0.27. > > How to repeat: > #!/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(); > }
Fixed in 4.022 by this pull request: https://github.com/CaptTofu/DBD-mysql/pull/25 Also duplicate of https://rt.cpan.org/Ticket/Display.html?id=76835