MDL-26844 ugly workaround for PHP int size limitation in query limits

It looks like the pg driver or database is internally overflowing at least on my 64bit test setup, I think we can safely return all results when from + num is over our max PHP integer.
This commit is contained in:
Petr Skoda
2011-03-16 16:15:43 +01:00
parent 3d24c50144
commit 4335aa296e
+6
View File
@@ -623,6 +623,9 @@ class pgsql_native_moodle_database extends moodle_database {
if ($limitfrom or $limitnum) {
if ($limitnum < 1) {
$limitnum = "ALL";
} else if (PHP_INT_MAX - $limitnum < $limitfrom) {
// this is a workaround for weird max int problem
$limitnum = "ALL";
}
$sql .= " LIMIT $limitnum OFFSET $limitfrom";
}
@@ -662,6 +665,9 @@ class pgsql_native_moodle_database extends moodle_database {
if ($limitfrom or $limitnum) {
if ($limitnum < 1) {
$limitnum = "ALL";
} else if (PHP_INT_MAX - $limitnum < $limitfrom) {
// this is a workaround for weird max int problem
$limitnum = "ALL";
}
$sql .= " LIMIT $limitnum OFFSET $limitfrom";
}