Use savepoints for nested transactions

- XE에서 사용하던 savepoint 방식을 복원
- 트랜잭션 안에서 commit이 무시되더라도 해당 사실을 알리는 로그를 남기도록 함
This commit is contained in:
Kijin Sung 2021-02-04 16:39:09 +09:00
parent 76c6ef56f2
commit b9cb5f429a

View file

@ -572,6 +572,10 @@ class DB
Debug::addQuery($this->getQueryLog('START TRANSACTION', 0));
}
}
else
{
$this->_handle->exec(sprintf('SAVEPOINT `%s%s%d`', $this->_prefix, 'savepoint', $this->_transaction_level));
}
$this->_transaction_level++;
return $this->_transaction_level;
}
@ -600,6 +604,10 @@ class DB
Debug::addQuery($this->getQueryLog('ROLLBACK', 0));
}
}
else
{
$this->_handle->exec(sprintf('ROLLBACK TO SAVEPOINT `%s%s%d`', $this->_prefix, 'savepoint', $this->_transaction_level - 1));
}
$this->_transaction_level--;
return $this->_transaction_level;
}
@ -628,6 +636,13 @@ class DB
Debug::addQuery($this->getQueryLog('COMMIT', 0));
}
}
else
{
if (Debug::isEnabledForCurrentUser())
{
Debug::addQuery($this->getQueryLog('NESTED COMMIT IGNORED BY RHYMIX', 0));
}
}
$this->_transaction_level--;
return $this->_transaction_level;
}