Permalink
Browse files

Merge pull request #58 from SuperMartas/lock-name-fix

Fixed problem with lock name in MySQL 5.7.5+
  • Loading branch information...
hrach committed Jan 7, 2017
2 parents c9f61e4 + 7840a1f commit 9a6d21eadee4248531ac95d4d157c3539d6992aa
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/Drivers/MySqlDriver.php
@@ -66,7 +66,7 @@ public function rollbackTransaction()
public function lock()
{
$lock = $this->dbal->escapeString(self::LOCK_NAME);
$result = (int) $this->dbal->query("SELECT GET_LOCK(CONCAT($lock, '-', DATABASE()), 3) AS `result`")[0]['result'];
$result = (int) $this->dbal->query("SELECT GET_LOCK(SHA1(CONCAT($lock, '-', DATABASE())), 3) AS `result`")[0]['result'];
if ($result !== 1) {
throw new LockException('Unable to acquire a lock.');
}
@@ -76,7 +76,7 @@ public function lock()
public function unlock()
{
$lock = $this->dbal->escapeString(self::LOCK_NAME);
$result = (int) $this->dbal->query("SELECT RELEASE_LOCK(CONCAT($lock, '-', DATABASE())) AS `result`")[0]['result'];
$result = (int) $this->dbal->query("SELECT RELEASE_LOCK(SHA1(CONCAT($lock, '-', DATABASE()))) AS `result`")[0]['result'];
if ($result !== 1) {
throw new LockException('Unable to release a lock.');
}

0 comments on commit 9a6d21e

Please sign in to comment.