Permalink
Browse files

MDL-39024 fix MSSQL seek past the end of recordset

  • Loading branch information...
1 parent 7cfccbb commit 0992cee1de9000bd07e0310e83de6d8981d64ac7 @skodak skodak committed with stronk7 Apr 8, 2013
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/dml/mssql_native_moodle_database.php
@@ -713,7 +713,11 @@ public function get_recordset_sql($sql, array $params=null, $limitfrom=0, $limit
$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);

0 comments on commit 0992cee

Please sign in to comment.