jenkins-bot has submitted this change and it was merged.

Change subject: Allow configuring the transaction locking mode for SQLite
......................................................................


Allow configuring the transaction locking mode for SQLite

Bug: T89180
Change-Id: Ib18347299ea78f9b31e56313b2acf749f693cddb
---
M includes/db/DatabaseSqlite.php
1 file changed, 23 insertions(+), 0 deletions(-)

Approvals:
  Tim Starling: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php
index 7b04716..0b51972 100644
--- a/includes/db/DatabaseSqlite.php
+++ b/includes/db/DatabaseSqlite.php
@@ -32,6 +32,9 @@
        /** @var string File name for SQLite database file */
        public $mDatabaseFile;
 
+       /** @var string Transaction mode */
+       protected $trxMode;
+
        /** @var int The number of rows affected as an integer */
        protected $mAffectedRows;
 
@@ -44,6 +47,11 @@
        /** @var FSLockManager (hopefully on the same server as the DB) */
        protected $lockMgr;
 
+       /**
+        * Additional params include:
+        *   - trxMode : one of (deferred, immediate, exclusive)
+        * @param array $p
+        */
        function __construct( array $p ) {
                global $wgSharedDB, $wgSQLiteDataDir;
 
@@ -56,6 +64,12 @@
                                        $this->attachDatabase( $wgSharedDB );
                                }
                        }
+               }
+
+               $this->trxMode = isset( $p['trxMode'] ) ? strtoupper( 
$p['trxMode'] ) : null;
+               if ( $this->trxMode && !in_array( $this->trxMode, array( 
'IMMEDIATE', 'EXCLUSIVE' ) ) ) {
+                       $this->trxMode = null;
+                       wfWarn( "Invalid SQLite transaction mode provided." );
                }
 
                $this->lockMgr = new FSLockManager( array( 'lockDirectory' => 
"$wgSQLiteDataDir/locks" ) );
@@ -697,6 +711,15 @@
                return false;
        }
 
+       protected function doBegin( $fname = '' ) {
+               if ( $this->trxMode ) {
+                       $this->query( "BEGIN {$this->trxMode}", $fname );
+               } else {
+                       $this->query( 'BEGIN', $fname );
+               }
+               $this->mTrxLevel = 1;
+       }
+
        /**
         * @param string $s
         * @return string

-- 
To view, visit https://gerrit.wikimedia.org/r/192480
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib18347299ea78f9b31e56313b2acf749f693cddb
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com>
Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to