* Move generic return true; various for lock functions to parent, no need to implemen...
authorChad Horohoe <demon@users.mediawiki.org>
Wed, 29 Jul 2009 23:41:16 +0000 (23:41 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Wed, 29 Jul 2009 23:41:16 +0000 (23:41 +0000)
* Make LOW PRIORITY optional
* Use sourceFile instead of dbsource

includes/db/Database.php
includes/db/DatabaseIbm_db2.php
includes/db/DatabaseMssql.php
includes/db/DatabaseMysql.php
includes/db/DatabaseOracle.php
includes/db/DatabasePostgres.php
includes/db/DatabaseSqlite.php

index c505161..246b2af 100644 (file)
@@ -2200,7 +2200,9 @@ abstract class DatabaseBase {
         * @param $method String: Name of method calling us
         * @return bool
         */
-       abstract public function lock( $lockName, $method, $timeout = 5 );
+       public function lock( $lockName, $method, $timeout = 5 ) {
+               return true;
+       }
 
        /**
         * Release a lock.
@@ -2213,7 +2215,9 @@ abstract class DatabaseBase {
         * by this thread (in which case the lock is not released), and NULL if the named 
         * lock did not exist
         */
-       abstract public function unlock( $lockName, $method );
+       public function unlock( $lockName, $method ) {
+               return true;
+       }
 
        /**
         * Lock specific tables
@@ -2221,15 +2225,20 @@ abstract class DatabaseBase {
         * @param $read Array of tables to lock for read access
         * @param $write Array of tables to lock for write access
         * @param $method String name of caller
+        * @param $lowPriority bool Whether to indicate writes to be LOW PRIORITY
         */
-       abstract public function lockTables( $read, $write, $method );
+       public function lockTables( $read, $write, $method, $lowPriority = true ) {
+               return true;
+       }
        
        /**
         * Unlock specific tables
         *
         * @param $method String the caller
         */
-       abstract public function unlockTables( $method );
+       public function unlockTables( $method ) {
+               return true;
+       }
        
        /**
         * Get search engine class. All subclasses of this
index aa0e7a5..59b3024 100644 (file)
@@ -707,7 +707,7 @@ EOF;
                        $this->applySchema();
                        $this->begin();
                        
-                       $res = dbsource( "../maintenance/ibm_db2/tables.sql", $this);
+                       $res = $this->sourceFile( "../maintenance/ibm_db2/tables.sql" );
                        $res = null;
        
                        // TODO: update mediawiki_version table
@@ -1527,13 +1527,6 @@ EOF;
         * TODO
         * @return bool true
         */
-       public function lock( $lockName, $method ) { wfDebug('Not implemented for DB2: lock()'); return true; }
-       /**
-        * Not implemented
-        * TODO
-        * @return bool true
-        */
-       public function unlock( $lockName, $method ) { wfDebug('Not implemented for DB2: unlock()'); return true; }
        /**
         * Not implemented
         * @deprecated
index acd1188..9521a1a 100644 (file)
@@ -979,16 +979,6 @@ class DatabaseMssql extends DatabaseBase {
                }
        }
        
-       /** 
-        * No-op lock functions
-        */
-       public function lock( $lockName, $method ) {
-               return true;
-       }
-       public function unlock( $lockName, $method ) {
-               return true;
-       }
-       
        public function getSearchEngine() {
                return "SearchEngineDummy";
        }
index f86c405..104d140 100644 (file)
@@ -326,11 +326,14 @@ class DatabaseMysql extends DatabaseBase {
                return $row->lockstatus;
        }
 
-       public function lockTables( $read, $write, $method ) {
+       public function lockTables( $read, $write, $method, $lowPriority = true ) {
                $items = array();
 
                foreach( $write as $table ) {
-                       $items[] = $this->tableName( $table ) . ' LOW_PRIORITY WRITE';
+                       $tbl = $this->tableName( $table ) . 
+                                       $lowPriority ? ' LOW_PRIORITY' : '' . 
+                                       ' WRITE';
+                       $items[] = $tbl;
                }
                foreach( $read as $table ) {
                        $items[] = $this->tableName( $table ) . ' READ';
index 351c591..34ab158 100644 (file)
@@ -888,7 +888,7 @@ class DatabaseOracle extends DatabaseBase {
                global $wgVersion, $wgDBmwschema, $wgDBts2schema, $wgDBport, $wgDBuser;
                
                echo "<li>Creating DB objects</li>\n";
-               $res = dbsource( "../maintenance/ora/tables.sql", $this);
+               $res = $this->sourceFile( "../maintenance/ora/tables.sql" );
                
                // Avoid the non-standard "REPLACE INTO" syntax
                echo "<li>Populating table interwiki</li>\n";
@@ -1067,16 +1067,6 @@ class DatabaseOracle extends DatabaseBase {
                return parent::replaceVars($ins);
        }
 
-       /** 
-        * No-op lock functions
-        */
-       public function lock( $lockName, $method ) {
-               return true;
-       }
-       public function unlock( $lockName, $method ) {
-               return true;
-       }
-       
        public function getSearchEngine() {
                return "SearchOracle";
        }
index a485a66..db78cf2 100644 (file)
@@ -1239,7 +1239,7 @@ END;
                }
                $this->doQuery("DROP TABLE $safeschema.$ctest");
 
-               $res = dbsource( "../maintenance/postgres/tables.sql", $this);
+               $res = $this->sourceFile( "../maintenance/postgres/tables.sql" );
 
                ## Update version information
                $mwv = $this->addQuotes($wgVersion);
@@ -1394,22 +1394,7 @@ END;
                return implode( ' || ', $stringList );
        }
 
-       /* These are not used yet, but we know we don't want the default version */
-
-       public function lock( $lockName, $method, $timeout = 5 ) {
-               return true;
-       }
-       public function unlock( $lockName, $method ) {
-               return true;
-       }
-       
        public function getSearchEngine() {
                return "SearchPostgres";
        }
-
-       /** Todo: maybe implement this? */
-       public function lockTables( $read, $write, $method ) {}
-
-       public function unlockTables( $method ) {}
-
 } // end DatabasePostgres class
index 85f0b08..43ba8bc 100644 (file)
@@ -408,16 +408,6 @@ class DatabaseSqlite extends DatabaseBase {
                }
        }
        
-       /** 
-        * No-op lock functions
-        */
-       public function lock( $lockName, $method, $timeout = 5 ) {
-               return true;
-       }
-       public function unlock( $lockName, $method ) {
-               return true;
-       }
-       
        public function getSearchEngine() {
                return "SearchEngineDummy";
        }
@@ -459,10 +449,6 @@ class DatabaseSqlite extends DatabaseBase {
                return $s;
        }
 
-       public function lockTables( $read, $write, $method ) {}
-
-       public function unlockTables( $method ) {}
-       
        /*
         * Build a concatenation list to feed into a SQL query
         */