Remove 'USE INDEX' for non-mysql
authorDomas Mituzas <midom@users.mediawiki.org>
Wed, 9 Jun 2004 16:14:41 +0000 (16:14 +0000)
committerDomas Mituzas <midom@users.mediawiki.org>
Wed, 9 Jun 2004 16:14:41 +0000 (16:14 +0000)
includes/Article.php
includes/DifferenceEngine.php
includes/PageHistory.php
includes/SpecialAncientpages.php
includes/SpecialWatchlist.php

index 87e5633..1e47445 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+# $Id$
+#
 # Class representing a Wikipedia article and history.
 # See design.doc for an overview.
 
@@ -1322,7 +1324,7 @@ class Article {
 
        function rollback()
        {
-               global $wgUser, $wgLang, $wgOut, $wgRequest;
+               global $wgUser, $wgLang, $wgOut, $wgRequest, $wgIsMySQL;
 
                if ( ! $wgUser->isSysop() ) {
                        $wgOut->sysopRequired();
@@ -1370,8 +1372,10 @@ class Article {
                }
                
                # Get the last edit not by this guy
+
+               $use_index=$wgIsMySQL?"USE INDEX (name_title_timestamp)":"";
                $sql = 'SELECT old_text,old_user,old_user_text,old_timestamp,old_flags ' .
-               'FROM old USE INDEX (name_title_timestamp)' .
+               'FROM old {$use_index}' .
                "WHERE old_namespace={$n} AND old_title='{$tt}'" .
                "AND (old_user <> {$uid} OR old_user_text <> '{$ut}')" .
                'ORDER BY inverse_timestamp LIMIT 1';
index 4b8bca4..1890ae4 100644 (file)
@@ -118,7 +118,7 @@ cellpadding='0' cellspacing='4px' class='diff'><tr>
        #
        function loadText()
        {
-               global $wgTitle, $wgOut, $wgLang;
+               global $wgTitle, $wgOut, $wgLang, $wgIsMySQL;
                $fname = "DifferenceEngine::loadText";
                
                if ( 0 == $this->mNewid || 0 == $this->mOldid ) {
@@ -152,8 +152,9 @@ cellpadding='0' cellspacing='4px' class='diff'><tr>
                        $this->mNewComment = $s->old_comment;
                }
                if ( 0 == $this->mOldid ) {
+                       $use_index=$wgIsMySQL?"USE INDEX (name_title_timestamp)":"";
                        $sql = "SELECT old_namespace,old_title,old_timestamp,old_text,old_flags,old_user_text,old_comment " .
-                         "FROM old USE INDEX (name_title_timestamp) WHERE " .
+                         "FROM old $use_index WHERE " .
                          "old_namespace=" . $this->mNewPage->getNamespace() . " AND " .
                          "old_title='" . wfStrencode( $this->mNewPage->getDBkey() ) .
                          "' ORDER BY inverse_timestamp LIMIT 1";
index 5b57eec..a79e76f 100644 (file)
@@ -17,7 +17,7 @@ class PageHistory {
 
        function history()
        {
-               global $wgUser, $wgOut, $wgLang;
+               global $wgUser, $wgOut, $wgLang, $wgIsMySQL;
 
                # If page hasn't changed, client can cache this
                
@@ -54,9 +54,10 @@ class PageHistory {
                
                $namespace = $this->mTitle->getNamespace();
                $title = $this->mTitle->getText();
+               $use_index=$wgIsMySQL?"USE INDEX (name_title_timestamp)":"";
                $sql = "SELECT old_id,old_user," .
                  "old_comment,old_user_text,old_timestamp,old_minor_edit ".
-                 "FROM old USE INDEX (name_title_timestamp) " .
+                 "FROM old $use_index " .
                  "WHERE old_namespace={$namespace} AND " .
                  "old_title='" . wfStrencode( $this->mTitle->getDBkey() ) . "' " .
                  "ORDER BY inverse_timestamp LIMIT $rawoffset, $limitplus";
index 52bc005..3aa93a5 100644 (file)
@@ -13,12 +13,14 @@ class AncientPagesPage extends QueryPage {
        }
 
        function getSQL() {
+               global $wgIsMySQL;
+               $use_index=$wgIsMySQL?"USE INDEX (cur_timestamp)":"";
                return
                        "SELECT 'Ancientpages' as type,
                                        cur_namespace as namespace,
                                cur_title as title,
                                UNIX_TIMESTAMP(cur_timestamp) as value
-                       FROM cur USE INDEX (cur_timestamp)
+                       FROM cur $use_index
                        WHERE cur_namespace=0 AND cur_is_redirect=0";
        }
        
index 619dc38..45c055c 100644 (file)
@@ -5,7 +5,7 @@ require_once( "WatchedItem.php" );
 function wfSpecialWatchlist()
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc;
-       global $wgUseWatchlistCache, $wgWLCacheTimeout, $wgDBname;
+       global $wgUseWatchlistCache, $wgWLCacheTimeout, $wgDBname, $wgIsMySQL;
        global $days, $limit, $target; # From query string
        $fname = "wfSpecialWatchlist";
 
@@ -137,11 +137,11 @@ function wfSpecialWatchlist()
                $wgLang->formatNum( $nitems ), $wgLang->formatNum( $npages ), $y,
                $specialTitle->escapeLocalUrl( "magic=yes" ) ) . "</i><br />\n" );
         
-
+       $use_index=$wgIsMySQL?"USE INDEX ($x)":"";
        $sql = "SELECT
   cur_namespace,cur_title,cur_comment, cur_id,
   cur_user,cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new
-  FROM watchlist,cur USE INDEX ($x)
+  FROM watchlist,cur $use_index
   WHERE wl_user=$uid
   AND $z
   AND wl_title=cur_title