From 4c97487728312f90205f6ab8527ed4d1a7b1fe82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Mon, 8 Apr 2013 10:36:37 +0200 Subject: [PATCH] MDL-39024 fix MSSQL seek past the end of recordset --- lib/dml/mssql_native_moodle_database.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/dml/mssql_native_moodle_database.php b/lib/dml/mssql_native_moodle_database.php index 11045181596..6fe792980db 100644 --- a/lib/dml/mssql_native_moodle_database.php +++ b/lib/dml/mssql_native_moodle_database.php @@ -713,7 +713,11 @@ class mssql_native_moodle_database extends moodle_database { $this->query_end($result); if ($limitfrom) { // Skip $limitfrom records - mssql_data_seek($result, $limitfrom); + if (!@mssql_data_seek($result, $limitfrom)) { + // Nothing, most probably seek past the end. + mssql_free_result($result); + $result = null; + } } return $this->create_recordset($result);