jenkins-bot has submitted this change and it was merged.

Change subject: PostgreSQL: Fix ORDER BY NULL
......................................................................


PostgreSQL: Fix ORDER BY NULL

MySQL automatically orders by the GROUP BY columns if no ORDER BY
is specified.  You can countermand this by specifying
ORDER BY NULL, which can give speed improvements in some cases,
for example if the GROUP BY was implemented by hashing then a
sort is unneeded and wastes time.

PostgreSQL does not tolerate the ORDER BY NULL syntax,
and does not need an analgous hint because it never does
gratuitious sorting of the nature just discussed.

This patch makes PostgreSQL ignore the ORDER BY NULL clause.

It might be a better approach to find a way to add this clause
specifically to MySQL, rather than to drop it specifically from
other database engines.

SQLite seems to tolerate the MySQL syntax.  Oracle and MSSQL
were not evaluated.

Bug: 67594
Change-Id: Ia9666136edd25e1e0d0728a8b28a92e44d00abc6
(cherry picked from commit ae811ddb6cc4932291cf73ce7768789eb39a33fd)
---
M RELEASE-NOTES-1.23
M includes/db/DatabasePostgres.php
2 files changed, 14 insertions(+), 0 deletions(-)

Approvals:
  MarkAHershberger: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23
index 15bd4f5..b4b82f6 100644
--- a/RELEASE-NOTES-1.23
+++ b/RELEASE-NOTES-1.23
@@ -1,6 +1,14 @@
 Security reminder: MediaWiki does not require PHP's register_globals. If you
 have it on, turn it '''off''' if you can.
 
+== MediaWiki 1.23.2 ==
+
+This is a security and maintenance release of the MediaWiki 1.23 branch.
+
+=== Changes since 1.23.1 ===
+
+* (bug 67594) Special:ActiveUsers: Fix to work with PostgreSQL
+
 == MediaWiki 1.23.1 ==
 
 This is a security and maintenance release of the MediaWiki 1.23 branch.
diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php
index 6aee528..bbc8ad3 100644
--- a/includes/db/DatabasePostgres.php
+++ b/includes/db/DatabasePostgres.php
@@ -826,6 +826,8 @@
         * In Postgres when using FOR UPDATE, only the main table and tables 
that are inner joined
         * can be locked. That means tables in an outer join cannot be FOR 
UPDATE locked. Trying to do
         * so causes a DB error. This wrapper checks which tables can be locked 
and adjusts it accordingly.
+        * 
+        * MySQL uses "ORDER BY NULL" as an optimization hint, but that syntax 
is illegal in PostgreSQL.
         */
        function selectSQLText( $table, $vars, $conds = '', $fname = __METHOD__,
                $options = array(), $join_conds = array()
@@ -841,6 +843,10 @@
                                        }
                                }
                        }
+
+                       if ( isset( $options['ORDER BY'] ) && $options['ORDER 
BY'] == 'NULL' ) {
+                               unset( $options['ORDER BY'] );
+                       }
                }
 
                return parent::selectSQLText( $table, $vars, $conds, $fname, 
$options, $join_conds );

-- 
To view, visit https://gerrit.wikimedia.org/r/144824
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia9666136edd25e1e0d0728a8b28a92e44d00abc6
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_23
Gerrit-Owner: Jjanes <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: MarkAHershberger <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to