我对您解决问题的思路很感兴趣


在 2011-4-25,21:54,smallfish <[email protected]> 写道:

> myisam是不支持事务的
> --
> blog: http://chenxiaoyu.org
> 
> 
> 
> 2011/4/25 Anthony WU <[email protected]>
> 高手!轉成InnoDB後則沒有問題
> 
> 
> -------- Original Message  --------
> Subject: Re: [PerlChina] DBD::mysql 的 TRANSACTION 問題
> From: silent <[email protected]>
> To: [email protected]
> Date: 25/4/2011 21:44
>> myisam ?
>> 
>> 在 2011年4月25日 下午9:33,Anthony WU <[email protected]>写 道:
>> 請問有沒有前輩使用過 DBD::mysql 的 TRANSACTION 模式?
>> 我在編寫時發現 DBD::mysql 中的 TRANSACTION 產生不了應有的 rollback 功能。
>> 而且測試過 AutoCommit、begin_work 的調用中沒有發生 $@ 擲出 又或 $dbh->errstr 訊息
>> 在不修改原有代碼而只修改 DSN 的 driver name 成 Pg,在同樣的 table 設計中 PostgreSQL Server 下則沒有問題
>> 以下是我所用的最簡單的測試代碼:
>> 
>> #!/usr/bin/perl
>> #perl v5.12.3
>> use DBI;
>> use DBI::DBD;
>> 
>> #my $dbh=DBI->connect ('dbi:Pg:database=TEST;host=localhost', 'root' , '', 
>> {AutoCommit => 1});
>> #printf ("DBD::Pg::VERSION: %s\n",  $DBD::Pg::VERSION);                   
>> #DBD::Pg::VERSION: 2.17.1
>> #mysql server 5.1.55-1
>> 
>> my $dbh=DBI->connect ('dbi:mysql:database=TEST;host=localhost', 'root' , '', 
>> {AutoCommit => 1});
>> printf ("DBD::mysql::VERSION: %s\n",  $DBD::mysql::VERSION);           
>> #DBD::mysql::VERSION: 4.017
>> #postgresql server 8.4.7-1
>> printf ("DBI::DBD::VERSION: %s\n",  $DBI::DBD::VERSION);                  
>> #DBI::DBD::VERSION: 12.014120
>> printf ("DBI::VERSION: %s\n",  $DBI::VERSION);                               
>>          #DBI::VERSION: 1.613
>> 
>> $dbh->begin_work ();
>> $sth = $dbh->prepare ("INSERT INTO messages (title, messages) VALUES(?, 
>> ?);");
>> $sth->execute ("TITLE", "MESSAGES");
>> $dbh->rollback ();
>> #$dbh->commit ();
>> $dbh->disconnect ();
>> exit;
>> 
>> -- 
>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
>> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
>> 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>> 
>> 
>> -- 
>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
>> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
>> 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
> 
> -- 
> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
> 
> -- 
> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

-- 
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

回复