From 765ed250697b52e5c0fdc78bbe5532271d66c255 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Tue, 2 Jan 2007 21:34:42 +0000 Subject: [PATCH] Add implicitGroupby function to account for different database behaviors. --- includes/Database.php | 7 +++++++ includes/DatabasePostgres.php | 4 ++++ includes/SpecialCategories.php | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/includes/Database.php b/includes/Database.php index 14764bd8fd..eb1ee1359c 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -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 */ diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php index b78e6d5c51..803c0e26fb 100644 --- a/includes/DatabasePostgres.php +++ b/includes/DatabasePostgres.php @@ -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) { diff --git a/includes/SpecialCategories.php b/includes/SpecialCategories.php index 89cff20a05..346eac633d 100644 --- a/includes/SpecialCategories.php +++ b/includes/SpecialCategories.php @@ -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"; -- 2.20.1