From b5efd9f1fc75b08a378ac3a5dad3df290b8f34a3 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 19 Feb 2015 01:05:20 +0000 Subject: [PATCH] database: Avoid use of PDO transaction system for SQLite This is in preparation for changing doBegin() to use BEGIN IMMEDIATE. PDO::beginTransaction() doesn't support any parameters for mode. Use direct queries instead so that modes (such as IMMEDIATE) can be used. Since PDO's transaction system maintains state internally (similarly to what MediaWiki Database classes do) we have to abandon use of PDO commit() and rollback() as well (in favour of direct queries already provided by DatabaseBase). Bug: T89180 Change-Id: I2ad2a3c2a6d4737f5ef8822fba7cbcf5e36021f4 --- includes/db/DatabaseSqlite.php | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php index 9257ffe508..95c44dfaf3 100644 --- a/includes/db/DatabaseSqlite.php +++ b/includes/db/DatabaseSqlite.php @@ -144,8 +144,8 @@ class DatabaseSqlite extends DatabaseBase { } $this->mOpened = !!$this->mConn; - # set error codes only, don't raise exceptions if ( $this->mOpened ) { + # Set error codes only, don't raise exceptions $this->mConn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT ); # Enforce LIKE to be case sensitive, just like MySQL $this->query( 'PRAGMA case_sensitive_like = 1' ); @@ -711,38 +711,6 @@ class DatabaseSqlite extends DatabaseBase { return false; } - protected function doBegin( $fname = '' ) { - if ( $this->mTrxLevel == 1 ) { - $this->commit( __METHOD__ ); - } - try { - $this->mConn->beginTransaction(); - } catch ( PDOException $e ) { - throw new DBUnexpectedError( $this, 'Error in BEGIN query: ' . $e->getMessage() ); - } - $this->mTrxLevel = 1; - } - - protected function doCommit( $fname = '' ) { - if ( $this->mTrxLevel == 0 ) { - return; - } - try { - $this->mConn->commit(); - } catch ( PDOException $e ) { - throw new DBUnexpectedError( $this, 'Error in COMMIT query: ' . $e->getMessage() ); - } - $this->mTrxLevel = 0; - } - - protected function doRollback( $fname = '' ) { - if ( $this->mTrxLevel == 0 ) { - return; - } - $this->mConn->rollBack(); - $this->mTrxLevel = 0; - } - /** * @param string $s * @return string -- 2.20.1