Fixed anomalous bug of temporary existance table collision in case of any update/delete issue by dropping temp table, no matter what's the result of other executes.
This commit is contained in:
parent
738bfd8082
commit
f54f8f8a95
@ -108,12 +108,20 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
|
||||
// Create temporary id table
|
||||
$conn->executeUpdate($this->_createTempTableSql);
|
||||
|
||||
// Insert identifiers
|
||||
$numDeleted = $conn->executeUpdate($this->_insertSql, $params, $types);
|
||||
try {
|
||||
// Insert identifiers
|
||||
$numDeleted = $conn->executeUpdate($this->_insertSql, $params, $types);
|
||||
|
||||
// Execute DELETE statements
|
||||
foreach ($this->_sqlStatements as $sql) {
|
||||
$conn->executeUpdate($sql);
|
||||
// Execute DELETE statements
|
||||
foreach ($this->_sqlStatements as $sql) {
|
||||
$conn->executeUpdate($sql);
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
// FAILURE! Drop temporary table to avoid possible collisions
|
||||
$conn->executeUpdate($this->_dropTempTableSql);
|
||||
|
||||
// Re-throw exception
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
// Drop temporary table
|
||||
|
@ -150,24 +150,32 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
|
||||
// Create temporary id table
|
||||
$conn->executeUpdate($this->_createTempTableSql);
|
||||
|
||||
// Insert identifiers. Parameters from the update clause are cut off.
|
||||
$numUpdated = $conn->executeUpdate(
|
||||
$this->_insertSql,
|
||||
array_slice($params, $this->_numParametersInUpdateClause),
|
||||
array_slice($types, $this->_numParametersInUpdateClause)
|
||||
);
|
||||
try {
|
||||
// Insert identifiers. Parameters from the update clause are cut off.
|
||||
$numUpdated = $conn->executeUpdate(
|
||||
$this->_insertSql,
|
||||
array_slice($params, $this->_numParametersInUpdateClause),
|
||||
array_slice($types, $this->_numParametersInUpdateClause)
|
||||
);
|
||||
|
||||
// Execute UPDATE statements
|
||||
for ($i=0, $count=count($this->_sqlStatements); $i<$count; ++$i) {
|
||||
$parameters = array();
|
||||
$types = array();
|
||||
// Execute UPDATE statements
|
||||
for ($i=0, $count=count($this->_sqlStatements); $i<$count; ++$i) {
|
||||
$parameters = array();
|
||||
$types = array();
|
||||
|
||||
if (isset($this->_sqlParameters[$i])) {
|
||||
$parameters = isset($this->_sqlParameters[$i]['parameters']) ? $this->_sqlParameters[$i]['parameters'] : array();
|
||||
$types = isset($this->_sqlParameters[$i]['types']) ? $this->_sqlParameters[$i]['types'] : array();
|
||||
if (isset($this->_sqlParameters[$i])) {
|
||||
$parameters = isset($this->_sqlParameters[$i]['parameters']) ? $this->_sqlParameters[$i]['parameters'] : array();
|
||||
$types = isset($this->_sqlParameters[$i]['types']) ? $this->_sqlParameters[$i]['types'] : array();
|
||||
}
|
||||
|
||||
$conn->executeUpdate($this->_sqlStatements[$i], $parameters, $types);
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
// FAILURE! Drop temporary table to avoid possible collisions
|
||||
$conn->executeUpdate($this->_dropTempTableSql);
|
||||
|
||||
$conn->executeUpdate($this->_sqlStatements[$i], $parameters, $types);
|
||||
// Re-throw exception
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
// Drop temporary table
|
||||
|
Loading…
Reference in New Issue
Block a user