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:
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user