RE: AutoCommit does not work




Artem Harutyunyan wrote:
Hi,

Consider, please, the following piece of code:

___________________________________________________________________________
______
my $dbh = DBI->connect($dsn, $user, $pass, {RaiseError =>
1,PrintError =>1});

$dbh->{'AutoCommit'} = 0;

my $sth = $dbh->prepare(q{INSERT INTO TRANSACTION(toGroup, fromGroup,
amount) VALUES(?,?,?)});
eval{
$sth->execute("kuku","DADDY","3.14");
print "Going to sleep...\n\n\n";
sleep (60);
};
if ($@) {
print "Error !!!\n\n";
$dbh->rollback();
exit(-2);
}

$dbh->commit();


___________________________________________________________________________
______

It connects to the database, turns AutoCommit off, prepares the
statement,
executes it, waits for 60 seconds and commits the statement.
Although I do not get any errors, it does not work as I expect. The
problem
is that I can see the new entry inside the table before $dbh->commit() is
called from the code. The same problem appears also when
$dbh->begin_work
is used.

The underlying database is mySQL version 5.0.24 and the version of DBI is
1.50.

Could you please, give any hints how to debug the problem ?
Thanks in advance,
Artem.

Artem,
In MySQL your table must be of type INNOB for transactions to be
supported.

HTH

Mary>
.



Relevant Pages

  • AutoCommit does not work
    ... my $sth = $dbh->prepare(q{INSERT INTO TRANSACTION(toGroup, fromGroup, ... amount) VALUES}); ... sleep; ... The underlying database is mySQL version 5.0.24 and the version of DBI is ...
    (perl.dbi.users)
  • Re: speed
    ... use the EXPLAIN function for mysql to check out how well your ... coming to your site go ahead and open persistant connections to mysql ... If you want to test how fast your app is going to run try ... a page will load when X amount of users hit the site but you might want ...
    (alt.php)
  • DBD::mysql::st execute failed: Lost connection to MySQL server during query at (eval 38) line 127, <
    ... Every other connection to mySQL works flawlessly, ... 947 postfix localhost postfix 23 Sleep ... mySQL doesn't get restarted, and amavisd reconnects ... The server is under very low load and it's ...
    (perl.dbi.users)
  • Re: Request suggestion for query
    ... The first is a request for a suggestion of a SQL query. ... First I suggest you learn some relational database design. ... SELECT SUM(amount) as amount FROM budget WHERE member_id=1 ... Second, LIMIT is a MySQL extension, not standard SQL. ...
    (comp.databases)
  • Measuring per thread CPU consumption & others statistics for NPTL
    ... process particular query as well as amount of IO needed. ... Second question is about accuracy - Is any way to get system/user CPU ... MySQL AB, www.mysql.com ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)