From b9cb5f429af521eba96d0a3db955bc6c7a0aee8e Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 4 Feb 2021 16:39:09 +0900 Subject: [PATCH] Use savepoints for nested transactions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - XE에서 사용하던 savepoint 방식을 복원 - 트랜잭션 안에서 commit이 무시되더라도 해당 사실을 알리는 로그를 남기도록 함 --- common/framework/db.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/common/framework/db.php b/common/framework/db.php index 4002c4fc5..6666756fd 100644 --- a/common/framework/db.php +++ b/common/framework/db.php @@ -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; }