Permalink
Browse files

Merge branch 'MDL-30026_sqlsrv' of git://github.com/stronk7/moodle

  • Loading branch information...
2 parents 9d06eb1 + f8cd596 commit c32e3a0a0afa3a25d5a023ae6bfad8b447dc0703 @nebgor nebgor committed Nov 23, 2011
Showing with 12 additions and 1 deletion.
  1. +12 −1 lib/dml/sqlsrv_native_moodle_database.php
@@ -1301,7 +1301,18 @@ public function get_session_lock($rowid, $timeout) {
$timeoutmilli = $timeout * 1000;
$fullname = $this->dbname.'-'.$this->prefix.'-session-'.$rowid;
- $sql = "sp_getapplock '$fullname', 'Exclusive', 'Session', $timeoutmilli";
+ // While this may work using proper {call sp_...} calls + binding +
+ // executing + consuming recordsets, the solution used for the mssql
+ // driver is working perfectly, so 100% mimic-ing that code.
+ // $sql = "sp_getapplock '$fullname', 'Exclusive', 'Session', $timeoutmilli";
+ $sql = "BEGIN
+ DECLARE @result INT
+ EXECUTE @result = sp_getapplock @Resource='$fullname',
+ @LockMode='Exclusive',
+ @LockOwner='Session',
+ @LockTimeout='$timeoutmilli'
+ SELECT @result
+ END";
$this->query_start($sql, null, SQL_QUERY_AUX);
$result = sqlsrv_query($this->sqlsrv, $sql);
$this->query_end($result);

0 comments on commit c32e3a0

Please sign in to comment.