Add implicitGroupby function to account for different database behaviors.
authorGreg Sabino Mullane <greg@users.mediawiki.org>
Tue, 2 Jan 2007 21:34:42 +0000 (21:34 +0000)
committerGreg Sabino Mullane <greg@users.mediawiki.org>
Tue, 2 Jan 2007 21:34:42 +0000 (21:34 +0000)
includes/Database.php
includes/DatabasePostgres.php
includes/SpecialCategories.php

index 14764bd..eb1ee13 100644 (file)
@@ -369,6 +369,13 @@ class Database {
                return false;
        }
 
+       /**
+        * Returns true if this database does an implicit sort when doing GROUP BY
+        */
+       function implicitGroupby() {
+               return true;
+       }
+
        /**#@+
         * Get function
         */
index b78e6d5..803c0e2 100644 (file)
@@ -37,6 +37,10 @@ class DatabasePostgres extends Database {
                return true;
        }
 
+       function implicitGroupby() {
+               return false;
+       }
+
        static function newFromParams( $server = false, $user = false, $password = false, $dbName = false,
                $failFunction = false, $flags = 0)
        {
index 89cff20..346eac6 100644 (file)
@@ -30,10 +30,11 @@ class CategoriesPage extends QueryPage {
                $NScat = NS_CATEGORY;
                $dbr =& wfGetDB( DB_SLAVE );
                $categorylinks = $dbr->tableName( 'categorylinks' );
+               $implicit_groupby = $dbr->implicitGroupby() ? '1' : 'cl_to';
                $s= "SELECT 'Categories' as type,
                                {$NScat} as namespace,
                                cl_to as title,
-                               1 as value,
+                               $implicit_groupby as value,
                                COUNT(*) as count
                           FROM $categorylinks
                           GROUP BY 1,2,3,4";