Skip to content

Commit

Permalink
Fixed problem with lock name in MySQL 5.7.5+
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperMartas committed Jan 7, 2017
1 parent c9f61e4 commit 7840a1f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Drivers/MySqlDriver.php
Expand Up @@ -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.');
}
Expand All @@ -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.');
}
Expand Down

0 comments on commit 7840a1f

Please sign in to comment.