MDL-25268 dml - change whitespace capture in limitfrom/limitnum regexp. Fixes some border cases

This commit is contained in:
Eloy Lafuente
2010-11-20 00:49:01 +00:00
parent a5c55a58c2
commit 6bfe81293f
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -686,8 +686,8 @@ class mssql_native_moodle_database extends moodle_database {
if ($limitfrom or $limitnum) {
if ($limitnum >= 1) { // Only apply TOP clause if we have any limitnum (limitfrom offset is handled later)
$fetch = $limitfrom + $limitnum;
$sql = preg_replace('/^([\s(])*SELECT([\s]+)(DISTINCT|ALL)?(?!\s*TOP\s*\()/i',
"\\1SELECT\\2\\3 TOP $fetch", $sql);
$sql = preg_replace('/^([\s(])*SELECT([\s]+(DISTINCT|ALL))?(?!\s*TOP\s*\()/i',
"\\1SELECT\\2 TOP $fetch", $sql);
}
}
+2 -2
View File
@@ -778,8 +778,8 @@ class sqlsrv_native_moodle_database extends moodle_database {
$offset = max(0, $offset);
if ($limit > 0 && $offset == 0) {
$sql1 = preg_replace('/^([\s(])*SELECT([\s]+)(DISTINCT|ALL)?(?!\s*TOP\s*\()/i',
"\\1SELECT\\2\\3 TOP $limit", $sql);
$sql1 = preg_replace('/^([\s(])*SELECT([\s]+(DISTINCT|ALL))?(?!\s*TOP\s*\()/i',
"\\1SELECT\\2 TOP $limit", $sql);
} else {
// Only apply TOP clause if we have any limitnum (limitfrom offset is handled later)
if ($limit < 1) {