Permalink
Browse files

Akiban does not support nested transactions at the moment so only beg…

…in a new transaction if not already in a transaction.
  • Loading branch information...
posulliv committed Aug 14, 2012
1 parent a48684c commit 3d4668f860366e108ef93aa32d78d749d9ab70b0
Showing with 10 additions and 4 deletions.
  1. +10 −4 lib/Doctrine/DBAL/Driver/AkibanSrv/AkibanSrvConnection.php
@@ -126,8 +126,11 @@ public function lastInsertId($name = null)
*/
public function beginTransaction()
{
- if (! pg_query($this->_dbh, "BEGIN")) {
- throw AkibanSrvException::fromErrorString($this->errorInfo());
+ $trxStatus = pg_transaction_status($this->_dbh);
+ if (! $trxStatus == PGSQL_TRANSACTION_INTRANS) {
+ if (! pg_query($this->_dbh, "BEGIN")) {
+ throw AkibanSrvException::fromErrorString($this->errorInfo());
+ }
}
return true;
}
@@ -148,8 +151,11 @@ public function commit()
*/
public function rollBack()
{
- if (! pg_query($this->_dbh, "ROLLBACK")) {
- throw AkibanSrvException::fromErrorString($this->errorInfo());
+ $trxStatus = pg_transaction_status($this->_dbh);
+ if ($trxStatus == PGSQL_TRANSACTION_INTRANS) {
+ if (! pg_query($this->_dbh, "ROLLBACK")) {
+ throw AkibanSrvException::fromErrorString($this->errorInfo());
+ }
}
return true;
}

0 comments on commit 3d4668f

Please sign in to comment.