Add implicitOrderby() to make sure that SpecialAllpages uses an ORDER BY when needed.
authorGreg Sabino Mullane <greg@users.mediawiki.org>
Sun, 2 Sep 2007 18:03:10 +0000 (18:03 +0000)
committerGreg Sabino Mullane <greg@users.mediawiki.org>
Sun, 2 Sep 2007 18:03:10 +0000 (18:03 +0000)
Made this an option rather than forcing the ORDER BY as testing show MySQL is
faster without it for large tables.

RELEASE-NOTES
includes/Database.php
includes/DatabaseOracle.php
includes/DatabasePostgres.php
includes/SpecialAllpages.php

index fd46bf5..3528f67 100644 (file)
@@ -429,6 +429,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 8393) <sup> and <sub> need to be preserved (without attributes) for
   entries in the table of contents
 * (bug 11114) Fix regression in read-only mode error display during editing
+* Force non-MySQL databases to use an ORDER BY in SpecialAllpages to ensure 
+  that the first page_title is truly the first page title.
 
 == API changes since 1.10 ==
 
index 5387ed4..4f8c7d5 100644 (file)
@@ -440,6 +440,14 @@ class Database {
                return true;
        }
 
+       /**
+        * Returns true if this database does an implicit order by when the column has an index
+        * For example: SELECT page_title FROM page LIMIT 1
+        */
+       function implicitOrderby() {
+               return true;
+       }
+
        /**
         * Returns true if this database can do a native search on IP columns
         * e.g. this works as expected: .. WHERE rc_ip = '127.42.12.102/32';
index 27e8529..3848548 100644 (file)
@@ -128,6 +128,9 @@ class DatabaseOracle extends Database {
        function implicitGroupby() {
                return false;
        }
+       function implicitOrderby() {
+               return false;
+       }
        function searchableIPs() {
                return true;
        }
index 113be2c..32c061a 100644 (file)
@@ -102,6 +102,9 @@ class DatabasePostgres extends Database {
        function implicitGroupby() {
                return false;
        }
+       function implicitOrderby() {
+               return false;
+       }
        function searchableIPs() {
                return true;
        }
index 8599cbf..07ff120 100644 (file)
@@ -101,7 +101,11 @@ function showToplevel ( $namespace = NS_MAIN, $including = false ) {
        $lines = $wgMemc->get( $key );
 
        if( !is_array( $lines ) ) {
-               $firstTitle = $dbr->selectField( 'page', 'page_title', $where, $fname, array( 'LIMIT' => 1 ) );
+               $options = array( 'LIMIT' => 1 );
+               if ( ! $dbr->implicitOrderby() ) {
+                       $options['ORDER BY'] = 'page_title';
+               }
+               $firstTitle = $dbr->selectField( 'page', 'page_title', $where, $fname, $options );
                $lastTitle = $firstTitle;
 
                # This array is going to hold the page_titles in order.
@@ -293,8 +297,11 @@ function showChunk( $namespace = NS_MAIN, $from, $including = false ) {
                        } else {
                                # The previous chunk is not complete, need to link to the very first title
                                # available in the database
-                               $reallyFirstPage_title = $dbr->selectField( 'page', 'page_title', array( 'page_namespace' => $namespace ), $fname, array( 'LIMIT' => 1) );
-
+                               $options = array( 'LIMIT' => 1 );
+                               if ( ! $dbr->implicitOrderby() ) {
+                                       $options['ORDER BY'] = 'page_title';
+                               }
+                               $reallyFirstPage_title = $dbr->selectField( 'page', 'page_title', array( 'page_namespace' => $namespace ), $fname, $options );
                                # Show the previous link if it s not the current requested chunk
                                if( $from != $reallyFirstPage_title ) {
                                        $prevTitle =  Title::makeTitle( $namespace, $reallyFirstPage_title );