Permalink
Browse files

MDL-39024 fix MSSQL seek past the end of recordset

  • Loading branch information...
1 parent 0816f85 commit 239fb7ac418c98d12d5268adea1fca53c3defc9d @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 239fb7a

Please sign in to comment.