From: Domas Mituzas Date: Wed, 9 Jun 2004 16:14:41 +0000 (+0000) Subject: Remove 'USE INDEX' for non-mysql X-Git-Tag: 1.5.0alpha1~2963 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=9cac06d2ccdff00dfe3b10388c0b4ceb3178012b;p=lhc%2Fweb%2Fwiklou.git Remove 'USE INDEX' for non-mysql --- diff --git a/includes/Article.php b/includes/Article.php index 87e5633ba4..1e47445a6a 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1,4 +1,6 @@ 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'; diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 4b8bca41c3..1890ae489f 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -118,7 +118,7 @@ cellpadding='0' cellspacing='4px' class='diff'> # 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'> $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"; diff --git a/includes/PageHistory.php b/includes/PageHistory.php index 5b57eec0b6..a79e76f0bb 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -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"; diff --git a/includes/SpecialAncientpages.php b/includes/SpecialAncientpages.php index 52bc0058b3..3aa93a54a4 100644 --- a/includes/SpecialAncientpages.php +++ b/includes/SpecialAncientpages.php @@ -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"; } diff --git a/includes/SpecialWatchlist.php b/includes/SpecialWatchlist.php index 619dc38445..45c055cc5d 100644 --- a/includes/SpecialWatchlist.php +++ b/includes/SpecialWatchlist.php @@ -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" ) ) . "
\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