diff options
author | Jens-Christian Fischer <jens-christian.fischer@switch.ch> | 2015-04-11 18:06:21 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-04-30 16:07:01 +0200 |
commit | 8d51e8eb724b8d13c23b74f26933aa3b5a6eaa49 (patch) | |
tree | 12a0e4701506e24a336eba7c06fd86dbaf3488e9 | |
parent | b453cccf51598a45d327ef40ee5298a01b233dbf (diff) | |
download | nextcloud-server-8d51e8eb724b8d13c23b74f26933aa3b5a6eaa49.tar.gz nextcloud-server-8d51e8eb724b8d13c23b74f26933aa3b5a6eaa49.zip |
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.
-rw-r--r-- | lib/private/files/cache/cache.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php index e9ed987a6ff..7ea90d0e75e 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); + } /** |