Skip to content
Extraits de code Groupes Projets
Valider e1a7acaf rédigé par mattab's avatar mattab
Parcourir les fichiers

Thanks for the report. Could you apply this patch and confirm it is working for you?

Fixes #4156 Adding ORDER BY clause when DELETING so that it works with replication
https://dev.mysql.com/doc/refman/5.1/en/replication-features-limit.html
(cherry picked from commit ce6254e3)
parent 6c825342
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -156,11 +156,15 @@ class Db ...@@ -156,11 +156,15 @@ class Db
* @param string $where The where clause of the query. Must include the WHERE keyword. * @param string $where The where clause of the query. Must include the WHERE keyword.
* @param int $maxRowsPerQuery The maximum number of rows to delete per DELETE query. * @param int $maxRowsPerQuery The maximum number of rows to delete per DELETE query.
* @param array $parameters Parameters to bind in the query. * @param array $parameters Parameters to bind in the query.
* @param string $primaryKey Name of primary key to sort by.
* @return int The total number of rows deleted. * @return int The total number of rows deleted.
*/ */
static public function deleteAllRows($table, $where, $maxRowsPerQuery = 100000, $parameters = array()) static public function deleteAllRows($table, $where, $orderBy, $maxRowsPerQuery = 100000, $parameters = array())
{ {
$sql = "DELETE FROM $table $where LIMIT " . (int)$maxRowsPerQuery; $sql = "DELETE FROM $table
$where
ORDER BY $orderBy ASC
LIMIT " . (int)$maxRowsPerQuery;
// delete rows w/ a limit // delete rows w/ a limit
$totalRowsDeleted = 0; $totalRowsDeleted = 0;
......
...@@ -207,7 +207,7 @@ class API ...@@ -207,7 +207,7 @@ class API
WHERE idsite = ? WHERE idsite = ?
AND idgoal = ?", AND idgoal = ?",
array($idSite, $idGoal)); array($idSite, $idGoal));
Db::deleteAllRows(Common::prefixTable("log_conversion"), "WHERE idgoal = ?", 100000, array($idGoal)); Db::deleteAllRows(Common::prefixTable("log_conversion"), "WHERE idgoal = ?", "idvisit", 100000, array($idGoal));
Cache::regenerateCacheWebsiteAttributes($idSite); Cache::regenerateCacheWebsiteAttributes($idSite);
} }
......
...@@ -76,7 +76,7 @@ class LogDataPurger ...@@ -76,7 +76,7 @@ class LogDataPurger
foreach ($logTables as $logTable) { foreach ($logTables as $logTable) {
// deleting from log_action must be handled differently, so we do it later // deleting from log_action must be handled differently, so we do it later
if ($logTable != Common::prefixTable('log_action')) { if ($logTable != Common::prefixTable('log_action')) {
Db::deleteAllRows($logTable, $where, $this->maxRowsToDeletePerQuery, array($maxIdVisit)); Db::deleteAllRows($logTable, $where, "idvisit", $this->maxRowsToDeletePerQuery, array($maxIdVisit));
} }
} }
......
...@@ -118,7 +118,7 @@ class ReportsPurger ...@@ -118,7 +118,7 @@ class ReportsPurger
if (!empty($where)) { if (!empty($where)) {
$where = "WHERE $where"; $where = "WHERE $where";
} }
Db::deleteAllRows($table, $where, $this->maxRowsToDeletePerQuery); Db::deleteAllRows($table, $where, "idarchive", $this->maxRowsToDeletePerQuery);
} }
if ($optimize) { if ($optimize) {
...@@ -133,7 +133,7 @@ class ReportsPurger ...@@ -133,7 +133,7 @@ class ReportsPurger
if ($this->keepBasicMetrics == 1 && !empty($this->metricsToKeep)) { if ($this->keepBasicMetrics == 1 && !empty($this->metricsToKeep)) {
$where = "WHERE name NOT IN ('" . implode("','", $this->metricsToKeep) . "') AND name NOT LIKE 'done%'"; $where = "WHERE name NOT IN ('" . implode("','", $this->metricsToKeep) . "') AND name NOT LIKE 'done%'";
foreach ($oldNumericTables as $table) { foreach ($oldNumericTables as $table) {
Db::deleteAllRows($table, $where, $this->maxRowsToDeletePerQuery); Db::deleteAllRows($table, $where, "idarchive", $this->maxRowsToDeletePerQuery);
} }
if ($optimize) { if ($optimize) {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter