diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php
index 7ab6f0e65..5b6ac09fd 100644
--- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php
+++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php
@@ -100,9 +100,9 @@ class LimitSubqueryOutputWalker extends SqlWalker
                 $hiddens[$idx] = $expr->hiddenAliasResultVariable;
                 $expr->hiddenAliasResultVariable = false;
             }
-            
+
             $innerSql = parent::walkSelectStatement($AST);
-    
+
             // Restore hiddens
             foreach ($AST->selectClause->selectExpressions as $idx => $expr) {
                 $expr->hiddenAliasResultVariable = $hiddens[$idx];
@@ -164,11 +164,8 @@ class LimitSubqueryOutputWalker extends SqlWalker
         $sql = sprintf('SELECT DISTINCT %s FROM (%s) dctrn_result',
             implode(', ', $sqlIdentifier), $innerSql);
 
-        if ($this->platform instanceof PostgreSqlPlatform ||
-            $this->platform instanceof OraclePlatform) {
-            // http://www.doctrine-project.org/jira/browse/DDC-1958
-            $this->preserveSqlOrdering($AST, $sqlIdentifier, $innerSql, $sql);
-        }
+        // http://www.doctrine-project.org/jira/browse/DDC-1958
+        $sql = $this->preserveSqlOrdering($AST, $sqlIdentifier, $innerSql, $sql);
 
         // Apply the limit and offset.
         $sql = $this->platform->modifyLimitQuery(
@@ -185,7 +182,7 @@ class LimitSubqueryOutputWalker extends SqlWalker
 
         return $sql;
     }
-    
+
     /**
      * Generates new SQL for Postgresql or Oracle if necessary.
      *
@@ -196,7 +193,7 @@ class LimitSubqueryOutputWalker extends SqlWalker
      *
      * @return void
      */
-    public function preserveSqlOrdering(SelectStatement $AST, array $sqlIdentifier, $innerSql, &$sql)
+    public function preserveSqlOrdering(SelectStatement $AST, array $sqlIdentifier, $innerSql, $sql)
     {
         // For every order by, find out the SQL alias by inspecting the ResultSetMapping.
         $sqlOrderColumns = array();
@@ -219,11 +216,6 @@ class LimitSubqueryOutputWalker extends SqlWalker
             $sqlOrderColumns = array_diff($sqlOrderColumns, $sqlIdentifier);
         }
 
-        // We don't need orderBy in inner query.
-        // However at least on 5.4.6 I'm getting a segmentation fault and thus we don't clear it for now.
-        /*$AST->orderByClause = null;
-        $innerSql = parent::walkSelectStatement($AST);*/
-
         if (count($orderBy)) {
             $sql = sprintf(
                 'SELECT DISTINCT %s FROM (%s) dctrn_result ORDER BY %s',
@@ -232,5 +224,7 @@ class LimitSubqueryOutputWalker extends SqlWalker
                 implode(', ', $orderBy)
             );
         }
+
+        return $sql;
     }
 }