-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Bug 6160: Deadlock removed #12315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug 6160: Deadlock removed #12315
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,46 +90,46 @@ public function unlockTable() { | |
| * @throws \Doctrine\DBAL\DBALException | ||
| */ | ||
| public function insertIfNotExist($table, $input, array $compare = null) { | ||
| if (empty($compare)) { | ||
| $compare = array_keys($input); | ||
| }; | ||
|
|
||
| //Search for given compare-fields | ||
| $query_select = 'SELECT * FROM `' . $table . '` WHERE 1=1'; | ||
| foreach($compare as $key) { | ||
| $query_select .= ' AND `' . $key . '`'; | ||
| if (is_null($input[$key])) { | ||
| $query_select .= ' IS NULL'; | ||
| } else { | ||
| $query_select .= ' = "' . $input[$key] .'"'; | ||
| }; | ||
| }; | ||
| $result = $this->conn->executeQuery($query_select); | ||
| $data = $result->fetch(); | ||
| //took this from cache.php: | ||
| //FIXME hide this HACK in the next database layer, or just use doctrine and get rid of MDB2 and PDO | ||
| //PDO returns false, MDB2 returns null, oracle always uses MDB2, so convert null to false | ||
| if ($data === null) { | ||
| $data = false; | ||
| } | ||
| if ($data) { | ||
| return 0; //Data already there, only empty result returned | ||
| }; | ||
| if (empty($compare)) { | ||
| $compare = array_keys($input); | ||
| } | ||
|
|
||
| //Do update | ||
| $inserts = array_values($input); | ||
| $query_insert = 'INSERT INTO `' .$table . '` (`' | ||
| . implode('`,`', array_keys($input)) | ||
| . '`) VALUES (' | ||
| . str_repeat('?,', count($input)-1).'? ' // Is there a prettier alternative? | ||
| . ')'; | ||
| return $this->conn->executeUpdate($query_insert, $inserts); | ||
| //Search for given compare-fields | ||
| $query_select = 'SELECT * FROM `' . $table . '` WHERE 1=1'; | ||
| foreach($compare as $key) { | ||
| $query_select .= ' AND `' . $key . '`'; | ||
| if (is_null($input[$key])) { | ||
| $query_select .= ' IS NULL'; | ||
| } else { | ||
| $query_select .= ' = "' . $input[$key] .'"'; | ||
| }; | ||
| }; | ||
| $result = $this->conn->executeQuery($query_select); | ||
| $data = $result->fetch(); | ||
| //took this from cache.php: | ||
| //FIXME hide this HACK in the next database layer, or just use doctrine and get rid of MDB2 and PDO | ||
| //PDO returns false, MDB2 returns null, oracle always uses MDB2, so convert null to false | ||
| if ($data === null) { | ||
| $data = false; | ||
| } | ||
| if ($data) { | ||
| return 0; //Data already there, only empty result returned | ||
| }; | ||
|
|
||
| /* $query = 'INSERT INTO `' .$table . '` (`' | ||
| //Do update | ||
| $inserts = array_values($input); | ||
| $query = 'INSERT INTO `' .$table . '` (`' | ||
| . implode('`,`', array_keys($input)) | ||
| . '`) VALUES (' | ||
| . str_repeat('?,', count($input)-1).'? ' // Is there a prettier alternative? | ||
| . ')'; | ||
| /* This coding caused Deadlocks with some DB-Setups an was replaced | ||
| $query = 'INSERT INTO `' .$table . '` (`' | ||
| . implode('`,`', array_keys($input)) . '`) SELECT ' | ||
| . str_repeat('?,', count($input)-1).'? ' // Is there a prettier alternative? | ||
| . 'FROM `' . $table . '` WHERE '; | ||
|
|
||
| $inserts = array_values($input); | ||
| foreach($compare as $key) { | ||
| $query .= '`' . $key . '`'; | ||
| if (is_null($input[$key])) { | ||
|
|
@@ -141,7 +141,7 @@ public function insertIfNotExist($table, $input, array $compare = null) { | |
| } | ||
| $query = substr($query, 0, -5); | ||
| $query .= ' HAVING COUNT(*) = 0'; | ||
| return $this->conn->executeUpdate($query, $inserts); | ||
| */ | ||
|
||
| } | ||
| return $this->conn->executeUpdate($query, $inserts); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.