[Pkg-owncloud-commits] [owncloud] 39/103: don't update identical values

David Prévot taffit at moszumanska.debian.org
Sun May 31 12:32:36 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag v8.0.4RC1
in repository owncloud.

commit 8d51e8eb724b8d13c23b74f26933aa3b5a6eaa49
Author: Jens-Christian Fischer <jens-christian.fischer at switch.ch>
Date:   Sat Apr 11 18:06:21 2015 +0200

    don't update identical values
    
    The UPDATE oc_filecache statement blindly overwrites identical data.
    Databases like Postgres that create a new row on an update
    and mark the old one as dead will suffer from the previous
    behaviour, as millions of "new" rows are created in the database.
    
    This patch changes the WHERE clause to test for identical
    values and not updating if the values in the DB are identical
    to the ones being passed.
---
 lib/private/files/cache/cache.php | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index e9ed987..7ea90d0 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -285,10 +285,16 @@ class Cache {
 		}
 
 		list($queryParts, $params) = $this->buildParts($data);
+
+		$params = array_merge($params, $params);
 		$params[] = $id;
 
-		$sql = 'UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=? WHERE `fileid` = ?';
+		// don't update if the data we try to set is the same as the one in the record
+		// some databases (Postgres) don't like superfluous updates
+		$sql = 'UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=? ' .
+			'WHERE (' . implode(' <> ? OR ', $queryParts) . ' <> ? ) AND `fileid` = ? ';
 		\OC_DB::executeAudited($sql, $params);
+
 	}
 
 	/**

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list